Skip to content

Commit e469103

Browse files
committed
fix autooffset value bug, fixed crash for cancel process with 1 thread, import/export settings, now properly sets all fields, tilerows: dont replace comma in filenames, rename GLTF plugin to GLB, #BUILD beta
1 parent 0b3ddc6 commit e469103

File tree

5 files changed

+62
-18
lines changed

5 files changed

+62
-18
lines changed

MainWindow.xaml.cs

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
using PointCloudConverter.Writers;
2424
using System.Reflection;
2525
using System.Globalization;
26+
using System.Windows.Media;
2627

2728
namespace PointCloudConverter
2829
{
2930
public partial class MainWindow : Window
3031
{
31-
static readonly string version = "23.09.2024";
32+
static readonly string version = "24.09.2024";
3233
static readonly string appname = "PointCloud Converter - " + version;
3334
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
3435

@@ -310,7 +311,7 @@ private static async Task ProcessAllFiles(object workerParamsObject)
310311
if (boundsListTemp[iii].z < lowestZ) lowestZ = (float)boundsListTemp[iii].z;
311312
}
312313

313-
//Console.WriteLine("Lowest bounds: " + lowestX + " " + lowestY + " " + lowestZ);
314+
//Log.Write("Lowest bounds: " + lowestX + " " + lowestY + " " + lowestZ);
314315
// TODO could take center for XZ, and lowest for Y?
315316
importSettings.offsetX = lowestX;
316317
importSettings.offsetY = lowestY;
@@ -382,11 +383,18 @@ private static async Task ProcessAllFiles(object workerParamsObject)
382383
}
383384
finally
384385
{
385-
//// Ensure the semaphore is released, if needed
386-
//if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire
387-
//{
388-
// semaphore.Release();
389-
//}
386+
// Ensure the semaphore is released safely
387+
if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire
388+
{
389+
try
390+
{
391+
semaphore.Release();
392+
}
393+
catch (SemaphoreFullException ex)
394+
{
395+
//Log.Write($"Semaphore was already fully released. Exception: {ex.Message}");
396+
}
397+
}
390398
}
391399
//int? taskId = Task.CurrentId; // Get the current task ID
392400

@@ -768,13 +776,18 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
768776
importSettings.offsetY = importSettings.manualOffsetY;
769777
importSettings.offsetZ = importSettings.manualOffsetZ;
770778
}
771-
else // neither
779+
else // no autooffset either
772780
{
773-
importSettings.offsetX = 0;
774-
importSettings.offsetY = 0;
775-
importSettings.offsetZ = 0;
781+
if (importSettings.useAutoOffset == false)
782+
{
783+
importSettings.offsetX = 0;
784+
importSettings.offsetY = 0;
785+
importSettings.offsetZ = 0;
786+
}
776787
}
777788

789+
//Log.Write("************** Offsets: " + importSettings.offsetX + " " + importSettings.offsetY + " " + importSettings.offsetZ);
790+
778791
var taskWriter = importSettings.GetOrCreateWriter(taskId);
779792

780793
// for saving pcroot header, we need this writer
@@ -1020,7 +1033,8 @@ void StartProcess(bool doProcess = true)
10201033
args.Add("-output=" + txtOutput.Text);
10211034

10221035
// check if using autooffset
1023-
if ((bool)chkAutoOffset.IsChecked && !(bool)chkManualOffset.IsChecked)
1036+
//if ((bool)chkAutoOffset.IsChecked && !(bool)chkManualOffset.IsChecked)
1037+
if (!(bool)chkManualOffset.IsChecked)
10241038
{
10251039
args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
10261040
}
@@ -1123,6 +1137,9 @@ void ImportArgs(string rawArgs)
11231137
bool isFirstArgExe = args[0].EndsWith(".exe", StringComparison.OrdinalIgnoreCase);
11241138
int startIndex = isFirstArgExe ? 1 : 0;
11251139

1140+
// reset all checkboxes to false
1141+
UncheckAllCheckboxes(this);
1142+
11261143
for (int i = startIndex; i < args.Length; i++)
11271144
{
11281145
string arg = args[i];
@@ -1246,6 +1263,27 @@ void ImportArgs(string rawArgs)
12461263
} // for all args
12471264
} // ImportArgs()
12481265

1266+
private void UncheckAllCheckboxes(DependencyObject parent)
1267+
{
1268+
// Loop through all the child elements
1269+
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
1270+
{
1271+
var child = VisualTreeHelper.GetChild(parent, i);
1272+
1273+
// If the child is a CheckBox, set it to unchecked
1274+
if (child is CheckBox checkBox)
1275+
{
1276+
checkBox.IsChecked = false;
1277+
}
1278+
1279+
// If the child is a container, recursively call the function to check its children
1280+
if (VisualTreeHelper.GetChildrenCount(child) > 0)
1281+
{
1282+
UncheckAllCheckboxes(child);
1283+
}
1284+
}
1285+
}
1286+
12491287
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
12501288
{
12511289
SaveSettings();

Tools/ArgParser.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,12 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
867867

868868
if (importSettings.batch == true && importSettings.exportFormat == ExportFormat.UCPC && Path.GetExtension(importSettings.outputFile).ToLower() == ".ucpc")
869869
{
870-
importSettings.errors.Add("With UCPC batching, do not set output filename - set ONLY output folder (each ucpc file will be saved separately)");
870+
importSettings.errors.Add("With batch processing whole input folder, do not set output filename - Set output folder (each .UCPP file will be saved separately)");
871+
}
872+
873+
if (importSettings.batch == true && importSettings.exportFormat == ExportFormat.External && Path.GetExtension(importSettings.outputFile).ToLower() == ".glb")
874+
{
875+
importSettings.errors.Add("With batch processing whole input folder, do not set output filename - Set output folder (each .GLB file will be saved separately)");
871876
}
872877

873878
if (importSettings.skipPoints == true && importSettings.keepPoints == true)
@@ -885,7 +890,7 @@ public static ImportSettings Parse(string[] args, string rootFolder, ILogger log
885890
if (importSettings.exportFormat == ExportFormat.PCROOT && importSettings.useGrid == false)
886891
{
887892
//importSettings.errors.Add("V3 pcroot export format requires -usegrid=true to use grid");
888-
Log.Write("V3 pcroot export format requires -usegrid=true to use grid, enabling it..");
893+
Log.Write("V3 pcroot export format requires -usegrid=true to use grid, enabling it now.");
889894
importSettings.useGrid = true;
890895
}
891896

Tools/PluginLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static IWriter LoadWriter(string pluginName)
3030
var pluginAssembly = Assembly.LoadFrom(pluginPath);
3131

3232
// Find the specific type 'PointCloudConverter.Writers.GLTF'
33-
var writerType = pluginAssembly.GetType("PointCloudConverter.Writers.GLTF");
33+
var writerType = pluginAssembly.GetType("PointCloudConverter.Writers.GLB");
3434

3535
if (writerType == null)
3636
throw new InvalidOperationException($"No valid implementation of IWriter found in {pluginPath}");

Tools/Tools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public static void PrintHelpAndExit(char argSeparator, bool waitEnter = false)
289289
// TODO Console.WriteLine("-decimate" + separator + "50\t\t\tRemoves 50% of the points (by skipping every x point)\tDefault is off");
290290
//Console.WriteLine("-version" + argSeparator + "2\t\t2=v2 .ucpc, 3=v3 .pcroot tiles\tDefault is 2");
291291
Console.WriteLine("-randomize" + argSeparator + "true\t\tRandomize point indexes, to use Dynamic resolution\tDefault is true (Always enabled for v3)");
292-
Console.WriteLine("-seed" + argSeparator + "42\t\tSet random seed\tDefault is random value");
292+
Console.WriteLine("-seed" + argSeparator + "42\t\tSet random seed\tDefault is some random value");
293293
Console.WriteLine("-json" + argSeparator + "false\t\tOutput console log in JSON format\tDefault is false");
294294
Console.WriteLine("-customintensityrange" + argSeparator + "false\t\tCustom intensity range (0-65535)\tDefault is false");
295295
Console.WriteLine("-metadata" + argSeparator + "false\t\tRead metadata from header, outputs into json file\tDefault is false");

Writers/PCROOT.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ void IWriter.Close()
230230
// add to tileroot list
231231
for (int i = 0, len = nodeBounds.Count; i < len; i++)
232232
{
233-
var tilerow = nodeBounds[i].fileName + sep + nodeBounds[i].totalPoints + sep + nodeBounds[i].minX + sep + nodeBounds[i].minY + sep + nodeBounds[i].minZ + sep + nodeBounds[i].maxX + sep + nodeBounds[i].maxY + sep + nodeBounds[i].maxZ + sep + nodeBounds[i].cellX + sep + nodeBounds[i].cellY + sep + nodeBounds[i].cellZ + sep + nodeBounds[i].averageTimeStamp + sep + nodeBounds[i].overlapRatio;
234-
// force dot as decimal separator
233+
var tilerow = nodeBounds[i].totalPoints + sep + nodeBounds[i].minX + sep + nodeBounds[i].minY + sep + nodeBounds[i].minZ + sep + nodeBounds[i].maxX + sep + nodeBounds[i].maxY + sep + nodeBounds[i].maxZ + sep + nodeBounds[i].cellX + sep + nodeBounds[i].cellY + sep + nodeBounds[i].cellZ + sep + nodeBounds[i].averageTimeStamp + sep + nodeBounds[i].overlapRatio;
234+
// force dot as decimal separator for values
235235
tilerow = tilerow.Replace(",", ".");
236+
tilerow = nodeBounds[i].fileName + sep + tilerow;
236237
tilerootdata.Add(tilerow);
237238
totalPointCount += nodeBounds[i].totalPoints;
238239
}

0 commit comments

Comments
 (0)