Skip to content

Commit 162f144

Browse files
committed
add option for 0-65535 intensity range (and -customintensityrange argument), upgrade to vs2022, fix NaN bread in progressbar, use date in title instead of manual version number, #BUILD
1 parent c416a4c commit 162f144

File tree

8 files changed

+65
-19
lines changed

8 files changed

+65
-19
lines changed

App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
<setting name="invertX" serializeAs="String">
104104
<value>False</value>
105105
</setting>
106+
<setting name="customintensityrange" serializeAs="String">
107+
<value>False</value>
108+
</setting>
106109
</PointCloudConverter.Properties.Settings>
107110
</userSettings>
108111
</configuration>

MainWindow.xaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@
7272
<Label x:Name="label_Copy5" Content="Generated commandline parameters:" HorizontalAlignment="Left" Margin="5,503,0,0" VerticalAlignment="Top" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" FontWeight="Bold"/>
7373
<Button x:Name="btnGetParams" Content="Get Commandline params" HorizontalAlignment="Left" Margin="10,440,0,0" VerticalAlignment="Top" Width="214" Height="58" Click="btnGetParams_Click"/>
7474
<StackPanel HorizontalAlignment="Left" Height="149" Margin="320,198,0,0" VerticalAlignment="Top" Width="234">
75-
<Label x:Name="label_Copy3" Content="(none)" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}"/>
75+
<CheckBox x:Name="chkPackColors" Content="Pack Colors" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Packs color values, improves performance in viewer (but can cause lower precision positions and colors). Requires using special packed material&amp;shader in viewer"/>
76+
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">
77+
<CheckBox x:Name="chkUsePackMagic" Content="PackMagic:" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Optional packing adjustment MagicInteger. Increase this value is you have large tiles and notice precision or color issues with packed data"/>
78+
<TextBox x:Name="txtPackMagic" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top" Width="40" Text="64"/>
79+
</StackPanel>
80+
<CheckBox x:Name="chkCustomIntensityRange" Content="Custom intensity range (0-65535)" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Expected default range is 0-255, but often it can be 0-65535"/>
7681
</StackPanel>
77-
<Label x:Name="label_Copy9" Content="V2 (ucpc) Options" HorizontalAlignment="Left" Margin="318,167,0,0" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" FontWeight="Bold"/>
78-
<Label x:Name="label_Copy10" Content="V3 (pcroot) Options" HorizontalAlignment="Left" Margin="623,167,0,0" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" FontWeight="Bold"/>
82+
<Label x:Name="label_Copy9" Content="V2 (.ucpc) &amp; V3 (.pcroot) Options" HorizontalAlignment="Left" Margin="318,167,0,0" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" FontWeight="Bold"/>
83+
<Label x:Name="label_Copy10" Content="V3 (.pcroot) Options" HorizontalAlignment="Left" Margin="623,167,0,0" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" FontWeight="Bold"/>
7984
<StackPanel HorizontalAlignment="Left" Height="238" Margin="624,198,-111,0" VerticalAlignment="Top" Width="277">
8085
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">
8186
<Label x:Name="label_Copy11" Content="Grid size:" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" Foreground="{DynamicResource MainText}"/>
@@ -87,11 +92,6 @@
8792
<TextBox x:Name="txtMinPointCount" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top" Width="40" Text="1000"/>
8893
</StackPanel>
8994
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
90-
<CheckBox x:Name="chkPackColors" Content="Pack Colors" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Packs color values, improves performance in viewer (but can cause lower precision positions and colors). Requires using special packed material&amp;shader in viewer"/>
91-
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">
92-
<CheckBox x:Name="chkUsePackMagic" Content="PackMagic:" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Optional packing adjustment MagicInteger. Increase this value is you have large tiles and notice precision or color issues with packed data"/>
93-
<TextBox x:Name="txtPackMagic" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top" Width="40" Text="64"/>
94-
</StackPanel>
9595
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
9696
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal"/>
9797
</StackPanel>

MainWindow.xaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace PointCloudConverter
1818
{
1919
public partial class MainWindow : Window
2020
{
21-
static string appname = "PointCloud Converter v1.76";
21+
static string appname = "PointCloud Converter - 25.09.2023";
2222
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
2323

2424
// allow console output from WPF application https://stackoverflow.com/a/7559336/5452781
@@ -104,6 +104,7 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
104104
// loop input files
105105
progressFile = 0;
106106
progressTotalFiles = importSettings.maxFiles - 1;
107+
if (progressTotalFiles < 0) progressTotalFiles = 0;
107108
for (int i = 0, len = importSettings.maxFiles; i < len; i++)
108109
{
109110
progressFile = i;
@@ -164,7 +165,7 @@ static void ProgressTick(object sender, EventArgs e)
164165
{
165166
if (progressTotalPoints > 0)
166167
{
167-
mainWindowStatic.progressBarFiles.Value = progressFile / (float)progressTotalFiles;
168+
mainWindowStatic.progressBarFiles.Value = progressFile / (float)(progressTotalFiles + 1);
168169
mainWindowStatic.progressBarPoints.Value = progressPoint / (float)progressTotalPoints;
169170
mainWindowStatic.lblStatus.Content = lastStatusMessage;
170171
}
@@ -355,6 +356,7 @@ void StartProcess(bool doProcess = true)
355356
if ((bool)chkUseMaxFileCount.IsChecked) args.Add("-maxfiles=" + txtMaxFileCount.Text);
356357
args.Add("-randomize=" + (bool)chkRandomize.IsChecked);
357358

359+
if (((bool)chkImportIntensity.IsChecked) && ((bool)chkCustomIntensityRange.IsChecked)) args.Add("-customintensityrange=True");
358360

359361
// check input files
360362
var importSettings = ArgParser.Parse(args.ToArray(), rootFolder);
@@ -536,6 +538,7 @@ private void LoadSettings()
536538
chkUseMaxFileCount.IsChecked = Properties.Settings.Default.useMaxFileCount;
537539
txtMaxFileCount.Text = Properties.Settings.Default.maxFileCount.ToString();
538540
chkRandomize.IsChecked = Properties.Settings.Default.randomize;
541+
chkCustomIntensityRange.IsChecked = Properties.Settings.Default.customintensityrange;
539542

540543
isInitialiazing = false;
541544
}
@@ -567,6 +570,7 @@ void SaveSettings()
567570
Properties.Settings.Default.useMaxFileCount = (bool)chkUseMaxFileCount.IsChecked;
568571
Properties.Settings.Default.maxFileCount = Tools.ParseInt(txtMaxFileCount.Text);
569572
Properties.Settings.Default.randomize = (bool)chkRandomize.IsChecked;
573+
Properties.Settings.Default.customintensityrange = (bool)chkCustomIntensityRange.IsChecked;
570574
Properties.Settings.Default.Save();
571575
}
572576

Properties/Settings.Designer.cs

Lines changed: 13 additions & 1 deletion
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
@@ -95,5 +95,8 @@
9595
<Setting Name="invertX" Type="System.Boolean" Scope="User">
9696
<Value Profile="(Default)">False</Value>
9797
</Setting>
98+
<Setting Name="customintensityrange" Type="System.Boolean" Scope="User">
99+
<Value Profile="(Default)">False</Value>
100+
</Setting>
98101
</Settings>
99102
</SettingsFile>

Readers/LAZ.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ public class LAZ : IReader
1818
laszip_dll lazReader = new laszip_dll();
1919
bool compressed = false;
2020
bool importRGB = true;
21-
//bool importIntensity = false;
21+
bool customIntensityRange = false;
2222

2323
bool IReader.InitReader(ImportSettings importSettings, int fileIndex)
2424
{
2525
// TODO check errors
2626
var file = importSettings.inputFiles[fileIndex];
2727
importRGB = importSettings.importRGB;
2828
//importIntensity = importSettings.readIntensity;
29+
customIntensityRange = importSettings.useCustomIntensityRange;
2930
lazReader.laszip_open_reader(file, ref compressed);
3031
return true;
3132
}
@@ -76,7 +77,15 @@ Color IReader.GetRGB()
7677
}
7778
else // use intensity
7879
{
79-
float i = Tools.LUT255[(byte)(p.intensity)];
80+
float i = 0;
81+
if (customIntensityRange) // NOTE now only supports 65535 as custom range
82+
{
83+
i = Tools.LUT255[(byte)(p.intensity / 255f)];
84+
}
85+
else
86+
{
87+
i = Tools.LUT255[(byte)(p.intensity)];
88+
}
8089
c.r = i;
8190
c.g = i;
8291
c.b = i;

Structs/ImportSettings.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public class ImportSettings
2929
// FIXME default values will be used unless otherwise specified.. randomize = true
3030
// TODO these should be export settings..
3131

32-
public bool swapYZ = true;
33-
public bool invertX = false;
34-
public bool invertZ = false;
3532
public bool importRGB = true; // this or intensity must be on
3633
public bool importIntensity = false;
3734
public bool useAutoOffset = true;
35+
public bool swapYZ = true;
36+
public bool invertX = false;
37+
public bool invertZ = false;
3838
public float offsetX = 0;
3939
public float offsetY = 0;
4040
public float offsetZ = 0;
@@ -55,6 +55,7 @@ public class ImportSettings
5555
public float manualOffsetX = 0;
5656
public float manualOffsetY = 0;
5757
public float manualOffsetZ = 0;
58+
public bool useCustomIntensityRange = false; // if false, 0-255 range is used, if ture: 0-65535
5859

5960
public override string ToString()
6061
{
@@ -89,6 +90,7 @@ public override string ToString()
8990
t += "\n manualOffsetX=" + manualOffsetX;
9091
t += "\n manualOffsetX=" + manualOffsetX;
9192
t += "\n manualOffsetX=" + manualOffsetX;
93+
t += "\n useCustomIntensityRange=" + useCustomIntensityRange;
9294
return t;
9395
}
9496
}

Tools/ArgParser.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ public static ImportSettings Parse(string[] args, string rootFolder)
332332
}
333333
break;
334334

335+
case "-customintensityrange":
336+
Console.WriteLine("customintensityrange = " + param);
337+
338+
if (param != "true" && param != "false")
339+
{
340+
errors.Add("Invalid useCustomIntensityRange parameter: " + param);
341+
}
342+
else
343+
{
344+
importSettings.useCustomIntensityRange = param == "true";
345+
}
346+
break;
347+
335348
case "-invertx":
336349
Console.WriteLine("invertx = " + param);
337350

@@ -519,8 +532,8 @@ public static ImportSettings Parse(string[] args, string rootFolder)
519532
{
520533
importSettings.randomize = (param == "true");
521534
}
522-
break;
523-
535+
break;
536+
524537
case "-rgb":
525538
Console.WriteLine("rgb = " + param);
526539

@@ -533,7 +546,7 @@ public static ImportSettings Parse(string[] args, string rootFolder)
533546
importSettings.importRGB = (param == "true");
534547
}
535548
break;
536-
549+
537550
case "-intensity":
538551
Console.WriteLine("intensity = " + param);
539552

0 commit comments

Comments
 (0)