Skip to content

Commit 2f5acf0

Browse files
committed
fix maxthreads limit, GUI: fix crash if no import/export format selected, remove % from json percentage value, remove default export format (need to select or assign it with args), #BUILD beta
1 parent 23b2a6c commit 2f5acf0

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

MainWindow.xaml.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace PointCloudConverter
2525
{
2626
public partial class MainWindow : Window
2727
{
28-
static readonly string version = "09.09.2024";
28+
static readonly string version = "10.09.2024";
2929
static readonly string appname = "PointCloud Converter - " + version;
3030
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
3131

@@ -88,6 +88,10 @@ private async void Main()
8888
//var testwriter = PointCloudConverter.Plugins.PluginLoader.LoadWriter("plugins/GLTFWriter.dll");
8989
//testwriter.Close();
9090

91+
// for debug: print config file location in appdata local here directly
92+
// string configFilePath = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
93+
// Log.WriteLine("Config file: " + configFilePath);
94+
9195
// using from commandline
9296
if (args.Length > 1)
9397
{
@@ -168,10 +172,7 @@ private async void Main()
168172
LoadSettings();
169173
}
170174

171-
172-
173175
// main processing loop
174-
175176
private static async Task ProcessAllFiles(object workerParamsObject)
176177
{
177178
var workerParams = (WorkerParams)workerParamsObject;
@@ -293,6 +294,7 @@ private static async Task ProcessAllFiles(object workerParamsObject)
293294
//// hack to fix progress bar not updating on last file
294295
//progressFile++;
295296

297+
// clamp to maxfiles
296298
int maxThreads = Math.Min(importSettings.maxThreads, importSettings.maxFiles);
297299
// clamp to min 1
298300
maxThreads = Math.Max(maxThreads, 1);
@@ -301,7 +303,7 @@ private static async Task ProcessAllFiles(object workerParamsObject)
301303
// init pool
302304
importSettings.InitWriterPool(maxThreads, importSettings.exportFormat);
303305

304-
var semaphore = new SemaphoreSlim(importSettings.maxThreads);
306+
var semaphore = new SemaphoreSlim(maxThreads);
305307

306308
var tasks = new List<Task>();
307309

@@ -325,18 +327,17 @@ private static async Task ProcessAllFiles(object workerParamsObject)
325327
}
326328
finally
327329
{
328-
// Ensure the semaphore is released, if needed
329-
if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire
330-
{
331-
semaphore.Release();
332-
}
330+
//// Ensure the semaphore is released, if needed
331+
//if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire
332+
//{
333+
// semaphore.Release();
334+
//}
333335
}
334336
//int? taskId = Task.CurrentId; // Get the current task ID
335337

336338
//progressFile = i;
337339
Interlocked.Increment(ref progressFile);
338340

339-
340341
//bool isLastTask = (i == len - 1); // Check if this is the last task
341342

342343
int index = i; // Capture the current file index in the loop
@@ -582,7 +583,7 @@ static void ProgressTick(object sender, EventArgs e)
582583
"\"thread\": " + index + "," +
583584
"\"currentPoint\": " + currentValue + "," +
584585
"\"totalPoints\": " + maxValue + "," +
585-
"\"percentage\": " + (int)((currentValue / (float)maxValue) * 100) + "%," +
586+
"\"percentage\": " + (int)((currentValue / (float)maxValue) * 100) + "," +
586587
"\"file\": " + System.Text.Json.JsonSerializer.Serialize(progressInfo.FilePath) +
587588
"}";
588589
Log.WriteLine(jsonString, LogEvent.Progress);
@@ -698,7 +699,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
698699
}
699700
else
700701
{
701-
Log.WriteLine("Points: " + pointCount);
702+
Log.WriteLine("Points: " + pointCount + " (" + importSettings.inputFiles[fileIndex] + ")");
702703
}
703704

704705
// NOTE only works with formats that have bounds defined in header, otherwise need to loop whole file to get bounds?
@@ -967,7 +968,7 @@ void StartProcess(bool doProcess = true)
967968
args.Add("-rgb=" + (bool)chkImportRGB.IsChecked);
968969
args.Add("-intensity=" + (bool)chkImportIntensity.IsChecked);
969970

970-
if (cmbExportFormat.SelectedItem.ToString().ToUpper().Contains("PCROOT")) args.Add("-gridsize=" + txtGridSize.Text);
971+
if (cmbExportFormat.SelectedItem?.ToString()?.ToUpper()?.Contains("PCROOT") == true) args.Add("-gridsize=" + txtGridSize.Text);
971972

972973
if ((bool)chkUseMinPointCount.IsChecked) args.Add("-minpoints=" + txtMinPointCount.Text);
973974
if ((bool)chkUseScale.IsChecked) args.Add("-scale=" + txtScale.Text);
@@ -1415,10 +1416,10 @@ private void cmbExportFormat_SelectionChanged(object sender, SelectionChangedEve
14151416
// if PCROOT then filename is required, use default output.pcroot then
14161417
if (cmbExportFormat.SelectedValue.ToString().ToUpper().Contains("PCROOT"))
14171418
{
1418-
string sourceName= Path.GetFileNameWithoutExtension(txtInputFile.Text);
1419+
string sourceName = Path.GetFileNameWithoutExtension(txtInputFile.Text);
14191420
if (string.IsNullOrEmpty(sourceName)) sourceName = "output";
14201421

1421-
txtOutput.Text = Path.Combine(currentOutput, sourceName +".pcroot");
1422+
txtOutput.Text = Path.Combine(currentOutput, sourceName + ".pcroot");
14221423
}
14231424
return;
14241425
}

Structs/ImportSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public void ReleaseReader(int? taskId)
237237
[JsonConverter(typeof(JsonStringEnumConverter))]
238238
public ImportFormat importFormat { get; set; } = ImportFormat.LAS; //default to las for now
239239
[JsonConverter(typeof(JsonStringEnumConverter))]
240-
public ExportFormat exportFormat { get; set; } = ExportFormat.PCROOT; // defaults to PCROOT (v3) now
240+
public ExportFormat exportFormat { get; set; }// = ExportFormat.PCROOT; // defaults to PCROOT (v3) now
241241

242242
public List<string> inputFiles { get; set; } = new List<string>();
243243
public string outputFile { get; set; } = null;

Tools/ArgParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ public static ImportSettings Parse(string[] args, string rootFolder)
798798
// check required settings
799799
if (importSettings.exportFormat == ExportFormat.Unknown)
800800
{
801-
importSettings.errors.Add("No export format defined (Example: -exportformat" + argValueSeparator + "UCPC)");
801+
importSettings.errors.Add("No export format defined (Example: -exportformat" + argValueSeparator + "PCROOT)");
802802
}
803803

804804
// cannot have both rgb & intensity

0 commit comments

Comments
 (0)