Skip to content

Commit b476d80

Browse files
committed
add usegrid option
1 parent df0753a commit b476d80

File tree

8 files changed

+65
-24
lines changed

8 files changed

+65
-24
lines changed

App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@
145145
<setting name="maxThreads" serializeAs="String">
146146
<value>4</value>
147147
</setting>
148+
<setting name="useGrid" serializeAs="String">
149+
<value>True</value>
150+
</setting>
148151
</PointCloudConverter.Properties.Settings>
149152
</userSettings>
150153
<runtime>

MainWindow.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@
141141
<CheckBox x:Name="chkGetAvgTileTimestamp" Content="Get Average timestamp per Tile" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="False" ToolTip="Experimental: Calculate average raw gps_time from tile points and save into pcroot"/>
142142
<CheckBox x:Name="chkCalculateOverlappingTiles" Content="Calculate overlapping tiles" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="False" ToolTip="Experimental: Save additional overlapped tile data into pcroot (if tile overlaps another tile)"/>
143143
</StackPanel>
144+
</GroupBox>
145+
146+
<!-- gltf options -->
147+
<GroupBox x:Name="groupBoxGLTF" HorizontalAlignment="Right" Header="GLTF (.glb) Options" Margin="0,365,10,0" VerticalAlignment="Top" Width="276" BorderBrush="#FF737373" BorderThickness="0.2,0.2,0.2,0.2" Foreground="White">
148+
<StackPanel Margin="0,4,0,0">
149+
<CheckBox x:Name="chkUseGrid" Content="Use grid (split to grid)" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="False" ToolTip="If disabled, 1 cloud is exported to single .glb file. If enabled: 1 tile is 1 .glb file"/>
150+
</StackPanel>
144151
</GroupBox>
145152

146153

MainWindow.xaml.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private async void Main()
130130
// Add the writer type to the dictionary for later use
131131
externalWriters.Add(writerName, writerType);
132132
Log.WriteLine($"Found writer: {writerType.FullName} in {pluginDLL}");
133-
133+
134134
// TODO take extensions from plugin? has 2: .glb and .gltf
135135
externalFileFormats += "|" + writerName + " (" + writerType.FullName + ")|*." + writerName.ToLower();
136136
}
@@ -1024,7 +1024,11 @@ void StartProcess(bool doProcess = true)
10241024
args.Add("-rgb=" + (bool)chkImportRGB.IsChecked);
10251025
args.Add("-intensity=" + (bool)chkImportIntensity.IsChecked);
10261026

1027-
if (cmbExportFormat.SelectedItem?.ToString()?.ToUpper()?.Contains("PCROOT") == true) args.Add("-gridsize=" + txtGridSize.Text);
1027+
bool isPCROOT = (cmbExportFormat.SelectedItem.ToString() == "PCROOT");
1028+
bool isGLTF = (cmbExportFormat.SelectedItem.ToString() == "GLTF");
1029+
// cmbExportFormat.SelectedItem?.ToString()?.ToUpper()?.Contains("PCROOT")
1030+
1031+
if (isPCROOT == true) args.Add("-gridsize=" + txtGridSize.Text);
10281032

10291033
if ((bool)chkUseMinPointCount.IsChecked) args.Add("-minpoints=" + txtMinPointCount.Text);
10301034
if ((bool)chkUseScale.IsChecked) args.Add("-scale=" + txtScale.Text);
@@ -1047,6 +1051,8 @@ void StartProcess(bool doProcess = true)
10471051
if ((bool)chkCalculateOverlappingTiles.IsChecked) args.Add("-checkoverlap=true");
10481052
args.Add("-maxthreads=" + txtMaxThreads.Text);
10491053

1054+
if (isGLTF == true) args.Add( ("-usegrid=" + (bool)chkUseGrid.IsChecked).ToLower() );
1055+
10501056
if (((bool)chkImportIntensity.IsChecked) && ((bool)chkCustomIntensityRange.IsChecked)) args.Add("-customintensityrange=True");
10511057

10521058
// check input files
@@ -1405,6 +1411,7 @@ private void LoadSettings()
14051411
chkGetAvgTileTimestamp.IsChecked = Properties.Settings.Default.getAvgTileTimestamp;
14061412
chkCalculateOverlappingTiles.IsChecked = Properties.Settings.Default.calculateOverlappingTiles;
14071413
txtMaxThreads.Text = Properties.Settings.Default.maxThreads;
1414+
chkUseGrid.IsChecked = Properties.Settings.Default.useGrid;
14081415
isInitialiazing = false;
14091416
}
14101417

@@ -1454,6 +1461,7 @@ void SaveSettings()
14541461
Properties.Settings.Default.getAvgTileTimestamp = (bool)chkGetAvgTileTimestamp.IsChecked;
14551462
Properties.Settings.Default.calculateOverlappingTiles = (bool)chkCalculateOverlappingTiles.IsChecked;
14561463
Properties.Settings.Default.maxThreads = txtMaxThreads.Text;
1464+
Properties.Settings.Default.useGrid = (bool)chkUseGrid.IsChecked;
14571465
Properties.Settings.Default.Save();
14581466
}
14591467

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
@@ -137,5 +137,8 @@
137137
<Setting Name="maxThreads" Type="System.String" Scope="User">
138138
<Value Profile="(Default)">4</Value>
139139
</Setting>
140+
<Setting Name="useGrid" Type="System.Boolean" Scope="User">
141+
<Value Profile="(Default)">True</Value>
142+
</Setting>
140143
</Settings>
141144
</SettingsFile>

Structs/ImportSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public void ReleaseReader(int? taskId)
289289
public bool importMetadataOnly = false;
290290
public bool averageTimestamp = false; // calculate average timestamp for all points for this tile
291291
public bool checkoverlap = false; // check if tile overlaps with other tiles (save into pcroot)
292+
public bool useGrid = true; // required for PCROOT format
292293

293294
public override string ToString()
294295
{

Tools/ArgParser.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,19 @@ public static ImportSettings Parse(string[] args, string rootFolder)
684684
}
685685
break;
686686

687+
case "-usegrid":
688+
Log.WriteLine("usegrid = " + param);
689+
690+
if (param != "false" && param != "true")
691+
{
692+
importSettings.errors.Add("Invalid usegrid parameter: " + param);
693+
}
694+
else
695+
{
696+
importSettings.useGrid = (param == "true");
697+
}
698+
break;
699+
687700
case "-rgb":
688701
Log.WriteLine("rgb = " + param);
689702

@@ -860,6 +873,14 @@ public static ImportSettings Parse(string[] args, string rootFolder)
860873
Log.WriteLine("No import format defined, using Default: " + importSettings.importFormat.ToString());
861874
}
862875

876+
if (importSettings.exportFormat == ExportFormat.PCROOT && importSettings.useGrid == false)
877+
{
878+
//importSettings.errors.Add("V3 pcroot export format requires -usegrid=true to use grid");
879+
Log.WriteLine("V3 pcroot export format requires -usegrid=true to use grid, enabling it..");
880+
importSettings.useGrid = true;
881+
}
882+
883+
863884
// disable this error, if user really wants to use it
864885
//if (importSettings.randomize == false && importSettings.exportFormat == ExportFormat.PCROOT)
865886
//{

Writers/PCROOT.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public class PCROOT : IWriter, IDisposable
1717

1818
BufferedStream bsPoints = null;
1919
BinaryWriter writerPoints = null;
20-
2120
ImportSettings importSettings;
21+
2222
static List<PointCloudTile> nodeBounds = new List<PointCloudTile>(); // for all tiles
2323
static float cloudMinX = float.PositiveInfinity;
2424
static float cloudMinY = float.PositiveInfinity;
@@ -27,22 +27,24 @@ public class PCROOT : IWriter, IDisposable
2727
static float cloudMaxY = float.NegativeInfinity;
2828
static float cloudMaxZ = float.NegativeInfinity;
2929

30+
StringBuilder keyBuilder = new StringBuilder(32);
3031
Dictionary<string, (int, int, int)> keyCache = new Dictionary<string, (int, int, int)>();
3132

3233
// our nodes (=tiles, =grid cells), string is tileID and float are X,Y,Z,R,G,B values
3334
Dictionary<string, List<float>> nodeX = new Dictionary<string, List<float>>();
3435
Dictionary<string, List<float>> nodeY = new Dictionary<string, List<float>>();
3536
Dictionary<string, List<float>> nodeZ = new Dictionary<string, List<float>>();
36-
3737
Dictionary<string, List<float>> nodeR = new Dictionary<string, List<float>>();
3838
Dictionary<string, List<float>> nodeG = new Dictionary<string, List<float>>();
3939
Dictionary<string, List<float>> nodeB = new Dictionary<string, List<float>>();
40-
4140
Dictionary<string, List<float>> nodeIntensity = new Dictionary<string, List<float>>();
4241
Dictionary<string, List<double>> nodeTime = new Dictionary<string, List<double>>();
4342

43+
//int? taskID;
4444

45-
int? taskID;
45+
static int skippedNodesCounter = 0;
46+
static int skippedPointsCounter = 0;
47+
static bool useLossyFiltering = false; //not used, for testing only
4648

4749
public void Dispose()
4850
{
@@ -52,7 +54,6 @@ public void Dispose()
5254
// GC.SuppressFinalize(this);
5355
GC.WaitForPendingFinalizers();
5456
GC.Collect();
55-
5657
//GC.Collect();
5758
//Log.WriteLine("Memory used: " + GC.GetTotalMemory(false));
5859
}
@@ -119,14 +120,12 @@ protected virtual void Dispose(bool disposing)
119120
public PCROOT(int? _taskID)
120121
{
121122
//Log.WriteLine("*** PCROOT writer created for task: " + _taskID);
122-
taskID = _taskID;
123+
//taskID = _taskID;
123124
}
124125

125126
public bool InitWriter(dynamic _importSettings, int pointCount)
126127
{
127128
//Log.WriteLine("--------------------- initwriter for taskID: " + taskID);
128-
129-
130129
var res = true;
131130

132131
// clear old nodes
@@ -343,26 +342,16 @@ void IWriter.Cleanup(int fileIndex)
343342
ClearDictionary(nodeTime);
344343

345344
keyCache.Clear();
346-
347-
348345
}
349346

350347
void IWriter.Randomize()
351348
{
352349

353350
}
354351

355-
StringBuilder keyBuilder = new StringBuilder(32);
356-
357352
void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, float b, bool hasIntensity, float i, bool hasTime, double time)
358353
{
359354
// get global all clouds bounds
360-
//if (x < cloudMinX) cloudMinX = x;
361-
//if (x > cloudMaxX) cloudMaxX = x;
362-
//if (y < cloudMinY) cloudMinY = y;
363-
//if (y > cloudMaxY) cloudMaxY = y;
364-
//if (z < cloudMinZ) cloudMinZ = z;
365-
//if (z > cloudMaxZ) cloudMaxZ = z;
366355
cloudMinX = Math.Min(cloudMinX, x);
367356
cloudMaxX = Math.Max(cloudMaxX, x);
368357
cloudMinY = Math.Min(cloudMinY, y);
@@ -421,7 +410,7 @@ void IWriter.AddPoint(int index, float x, float y, float z, float r, float g, fl
421410
if (hasIntensity == true) nodeIntensity[key] = new List<float> { i };
422411
if (hasTime == true) nodeTime[key] = new List<double> { time };
423412
}
424-
}
413+
} // addpoint()
425414

426415
[MethodImpl(MethodImplOptions.AggressiveInlining)]
427416
unsafe void FloatToBytes(float value, byte[] buffer, int offset)
@@ -441,9 +430,6 @@ unsafe void IntToBytes(int value, byte[] buffer, int offset)
441430
}
442431
}
443432

444-
static int skippedNodesCounter = 0;
445-
static int skippedPointsCounter = 0;
446-
static bool useLossyFiltering = false; //not used, for testing only
447433

448434
// returns list of saved files
449435
void IWriter.Save(int fileIndex)

0 commit comments

Comments
 (0)