Skip to content

Commit ecfe5e8

Browse files
committed
fix config last used folder, fix skipping points for pcroot, add -offsetmode: min= all cloud min bounds, legacy= first cloud min bounds, #BUILD beta
1 parent e469103 commit ecfe5e8

File tree

9 files changed

+112
-70
lines changed

9 files changed

+112
-70
lines changed

App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@
151151
<setting name="lastUsedConfigFolder" serializeAs="String">
152152
<value />
153153
</setting>
154+
<setting name="offsetMode" serializeAs="String">
155+
<value>min</value>
156+
</setting>
154157
</PointCloudConverter.Properties.Settings>
155158
</userSettings>
156159
<runtime>

MainWindow.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
<CheckBox x:Name="chkImportRGB" Content="Read RGB" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Reads RGB color values" Checked="chkImportRGB_Checked" Unchecked="chkImportRGB_Unchecked"/>
4242
<CheckBox x:Name="chkImportIntensity" Content="Read Intensity" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="False" ToolTip="Reads Intensity as Color value" Checked="chkImportIntensity_Checked" Unchecked="chkImportIntensity_Unchecked"/>
4343
</StackPanel>
44-
<CheckBox x:Name="chkAutoOffset" Content="Auto-Offset" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Auto-offsets cloud near 0,0,0 by using bounds min. as offset" Checked="chkAutoOffset_Checked"/>
44+
<StackPanel Orientation="Horizontal">
45+
<CheckBox x:Name="chkAutoOffset" Content="Auto-Offset, mode:" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Auto-offsets cloud near 0,0,0 by using bounds min. as offset" Checked="chkAutoOffset_Checked"/>
46+
<TextBox x:Name="txtOffsetMode" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top" Width="45" Text="min" MaxLines="1" ToolTip="Legacy=first cloud min bounds, Min=All clouds min bounds" />
47+
</StackPanel>
4548
<StackPanel Orientation="Vertical">
4649
<CheckBox x:Name="chkManualOffset" Content="Manual Offset" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Add offset to all points (After Auto-Offset and Flip, if those are enabled)" Checked="chkManualOffset_Checked"/>
4750
<StackPanel Orientation="Horizontal" Margin="18,0,0,0">

MainWindow.xaml.cs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ private static async Task ProcessAllFiles(object workerParamsObject)
262262
// get all file bounds, if in batch mode and RGB+INT+PACK
263263
// TODO: check what happens if its too high? over 128/256?
264264
//if (importSettings.useAutoOffset == true && importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false)
265-
266265
//Log.Write(importSettings.useAutoOffset + " && " + importSettings.importMetadataOnly + " || (" + importSettings.importIntensity + " && " + importSettings.importRGB + " && " + importSettings.packColors + " && " + importSettings.importMetadataOnly + ")");
267266
//bool istrue1 = (importSettings.useAutoOffset == true && importSettings.importMetadataOnly == false);
268267
//bool istrue2 = (importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false);
@@ -271,7 +270,9 @@ private static async Task ProcessAllFiles(object workerParamsObject)
271270

272271
if ((importSettings.useAutoOffset == true && importSettings.importMetadataOnly == false) || (importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true && importSettings.importMetadataOnly == false))
273272
{
274-
for (int i = 0, len = importSettings.maxFiles; i < len; i++)
273+
int iterations = importSettings.offsetMode == "min" ? importSettings.maxFiles : 1; // 1 for legacy mode
274+
275+
for (int i = 0, len = iterations; i < len; i++)
275276
{
276277
if (cancellationToken.IsCancellationRequested)
277278
{
@@ -768,6 +769,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
768769
// dont use these bounds, in this case
769770
if (importSettings.useAutoOffset == true || (importSettings.importIntensity == true && importSettings.importRGB == true && importSettings.packColors == true))
770771
{
772+
// TODO add manual offset here still?
771773
// we use global bounds or Y offset to fix negative Y
772774
}
773775
else if (importSettings.useManualOffset == true)
@@ -847,13 +849,21 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
847849
Float3 point = taskReader.GetXYZ();
848850
if (point.hasError == true) break; // TODO display errors
849851

852+
// get point color
853+
Color rgb = (default);
854+
855+
if (importSettings.importRGB == true)
856+
{
857+
rgb = taskReader.GetRGB();
858+
}
859+
860+
850861
// skip points
851862
if (importSettings.skipPoints == true && (i % importSettings.skipEveryN == 0)) continue;
852863

853864
// keep points
854865
if (importSettings.keepPoints == true && (i % importSettings.keepEveryN != 0)) continue;
855866

856-
857867
// add offsets (its 0 if not used)
858868
point.x -= importSettings.offsetX;
859869
point.y -= importSettings.offsetY;
@@ -887,16 +897,10 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
887897
point.x = -point.x;
888898
}
889899

890-
// get point color
891-
Color rgb = (default);
900+
892901
Color intensity = (default);
893902
double time = 0;
894903

895-
if (importSettings.importRGB == true)
896-
{
897-
rgb = taskReader.GetRGB();
898-
}
899-
900904
// TODO get intensity as separate value, TODO is this float or rgb?
901905
if (importSettings.importIntensity == true)
902906
{
@@ -1039,6 +1043,8 @@ void StartProcess(bool doProcess = true)
10391043
args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
10401044
}
10411045

1046+
args.Add("-offsetmode=" + txtOffsetMode.Text.ToLower());
1047+
10421048
// or manual offset, TODO later should allow using both (first autooffset, then add manual)
10431049
if ((bool)chkManualOffset.IsChecked) args.Add("-offset=" + txtOffsetX.Text + "," + txtOffsetY.Text + "," + txtOffsetZ.Text);
10441050

@@ -1460,6 +1466,7 @@ private void LoadSettings()
14601466
chkCalculateOverlappingTiles.IsChecked = Properties.Settings.Default.calculateOverlappingTiles;
14611467
txtMaxThreads.Text = Properties.Settings.Default.maxThreads;
14621468
chkUseGrid.IsChecked = Properties.Settings.Default.useGrid;
1469+
txtOffsetMode.Text = Properties.Settings.Default.offsetMode;
14631470
isInitialiazing = false;
14641471
}
14651472

@@ -1510,6 +1517,7 @@ void SaveSettings()
15101517
Properties.Settings.Default.calculateOverlappingTiles = (bool)chkCalculateOverlappingTiles.IsChecked;
15111518
Properties.Settings.Default.maxThreads = txtMaxThreads.Text;
15121519
Properties.Settings.Default.useGrid = (bool)chkUseGrid.IsChecked;
1520+
Properties.Settings.Default.offsetMode = txtOffsetMode.Text;
15131521
Properties.Settings.Default.Save();
15141522
}
15151523

@@ -1691,13 +1699,13 @@ private void btnImportSettings_Click(object sender, RoutedEventArgs e)
16911699
dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
16921700

16931701
// if have previously used config dir use that, if not, use local config dir if exists, if neither, use default..
1694-
if (string.IsNullOrEmpty(Properties.Settings.Default.lastImportFolder) == false)
1702+
if (string.IsNullOrEmpty(Properties.Settings.Default.lastUsedConfigFolder) == false)
16951703
{
1696-
dialog.InitialDirectory = Properties.Settings.Default.lastImportFolder;
1704+
dialog.InitialDirectory = Properties.Settings.Default.lastUsedConfigFolder;
16971705
}
1698-
else if (Directory.Exists("configs/"))
1706+
else if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "configs")))
16991707
{
1700-
dialog.InitialDirectory = "configs/";
1708+
dialog.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "configs");
17011709
}
17021710

17031711
if (dialog.ShowDialog() == true)
@@ -1706,7 +1714,7 @@ private void btnImportSettings_Click(object sender, RoutedEventArgs e)
17061714
{
17071715
var contents = File.ReadAllText(dialog.FileName);
17081716
ImportArgs(contents);
1709-
Properties.Settings.Default.lastImportFolder = Path.GetDirectoryName(dialog.FileName);
1717+
Properties.Settings.Default.lastUsedConfigFolder = Path.GetDirectoryName(dialog.FileName);
17101718
}
17111719
}
17121720
}
@@ -1717,20 +1725,20 @@ private void btnExportSettings_Click(object sender, RoutedEventArgs e)
17171725
dialog.Title = "Save settings file";
17181726
dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
17191727

1720-
if (string.IsNullOrEmpty(Properties.Settings.Default.lastImportFolder) == false)
1728+
if (string.IsNullOrEmpty(Properties.Settings.Default.lastUsedConfigFolder) == false)
17211729
{
1722-
dialog.InitialDirectory = Properties.Settings.Default.lastImportFolder;
1730+
dialog.InitialDirectory = Properties.Settings.Default.lastUsedConfigFolder;
17231731
}
1724-
else if (Directory.Exists("configs/"))
1732+
else if (Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "configs")))
17251733
{
1726-
dialog.InitialDirectory = "configs/";
1734+
dialog.InitialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "configs");
17271735
}
17281736

17291737
if (dialog.ShowDialog() == true)
17301738
{
17311739
StartProcess(false);
17321740
File.WriteAllText(dialog.FileName, txtConsole.Text);
1733-
Properties.Settings.Default.lastImportFolder = Path.GetDirectoryName(dialog.FileName);
1741+
Properties.Settings.Default.lastUsedConfigFolder = Path.GetDirectoryName(dialog.FileName);
17341742
}
17351743
}
17361744

Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,8 @@
143143
<Setting Name="lastUsedConfigFolder" Type="System.String" Scope="User">
144144
<Value Profile="(Default)" />
145145
</Setting>
146+
<Setting Name="offsetMode" Type="System.String" Scope="User">
147+
<Value Profile="(Default)">min</Value>
148+
</Setting>
146149
</Settings>
147150
</SettingsFile>

Structs/ImportSettings.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,13 @@ public void ReleaseReader(int? taskId)
203203
public int seed { get; set; } = -1; // random seed for shuffling
204204
public int maxThreads { get; set; }
205205

206-
public bool useJSONLog = false;
207-
public bool importMetadata = false;
208-
public bool importMetadataOnly = false;
209-
public bool averageTimestamp = false; // calculate average timestamp for all points for this tile
210-
public bool checkoverlap = false; // check if tile overlaps with other tiles (save into pcroot)
211-
public bool useGrid = true; // required for PCROOT format
206+
public bool useJSONLog { get; set; } = false;
207+
public bool importMetadata { get; set; } = false;
208+
public bool importMetadataOnly { get; set; } = false;
209+
public bool averageTimestamp { get; set; } = false; // calculate average timestamp for all points for this tile
210+
public bool checkoverlap { get; set; } = false; // check if tile overlaps with other tiles (save into pcroot)
211+
public bool useGrid { get; set; } = true; // required for PCROOT format
212+
public string offsetMode { get; set; } = "min"; // TODO use enum: "min" or "legacy" now (legacy is first bounds min only)
212213

213214
public override string ToString()
214215
{
@@ -251,6 +252,8 @@ public override string ToString()
251252
t += "\n importMetadataOnly=" + importMetadataOnly;
252253
t += "\n averageTimestamp=" + averageTimestamp;
253254
t += "\n checkoverlap=" + checkoverlap;
255+
t += "\n useGrid=" + useGrid;
256+
t += "\n offsetMode=" + offsetMode;
254257
return t;
255258
}
256259

Tools/ArgParser.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,19 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
727727
importSettings.importIntensity = (param == "true");
728728
}
729729
break;
730+
731+
case "-offsetmode":
732+
Log.Write("offsetmode = " + param);
733+
734+
if (param != "legacy" && param != "min")
735+
{
736+
importSettings.errors.Add("Invalid offsetmode parameter: " + param);
737+
}
738+
else
739+
{
740+
importSettings.offsetMode = param;
741+
}
742+
break;
730743

731744
// TODO load whole commandline args list from text file
732745
case "-config":

Tools/Tools.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ public static void PrintHelpAndExit(char argSeparator, bool waitEnter = false)
296296
Console.WriteLine("-metadataonly" + argSeparator + "false\t\tRead metadata only (dont process points)\tDefault is false");
297297
Console.WriteLine("-averagetimestamp" + argSeparator + "false\t\tGet Average timestamp per Tile\tDefault is false");
298298
Console.WriteLine("-checkoverlap" + argSeparator + "false\t\tCalculate overlapping tiles\tDefault is false");
299+
Console.WriteLine("-offsetmode" + argSeparator + "min\t\tGet auto-offset bounds, min=min from all bounds, legacy= first cloud min bounds\tDefault is min");
299300
Console.WriteLine("");
300301
Console.WriteLine("? /? -? help -help /help");
301302
Console.ForegroundColor = ConsoleColor.White;

0 commit comments

Comments
 (0)