Skip to content

Commit c840611

Browse files
committed
use currently selected input format in file browser
1 parent fa50c2e commit c840611

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

MainWindow.xaml.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ private static async Task ProcessAllFiles(object workerParamsObject)
448448
}
449449
else
450450
{
451-
Log.Write("files"+importSettings.inputFiles.Count+" i:"+i);
451+
Log.Write("files" + importSettings.inputFiles.Count + " i:" + i);
452452
Log.Write("Error> Failed to parse file: " + importSettings.inputFiles[i], LogEvent.Error);
453453
}
454454
}
@@ -946,7 +946,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
946946
// if no rgb, then replace RGB with intensity
947947
if (importSettings.importRGB == false)
948948
{
949-
rgb.r = intensity/255f;
949+
rgb.r = intensity / 255f;
950950
rgb.g = rgb.r;
951951
rgb.b = rgb.r;
952952
}
@@ -976,7 +976,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
976976
// if no rgb, then replace RGB with intensity
977977
if (importSettings.importRGB == false)
978978
{
979-
rgb.r = classification/255f;
979+
rgb.r = classification / 255f;
980980
rgb.g = rgb.r;
981981
rgb.b = rgb.r;
982982
}
@@ -1388,7 +1388,27 @@ private void btnBrowseInput_Click(object sender, RoutedEventArgs e)
13881388
// select single file
13891389
var dialog = new OpenFileDialog();
13901390
dialog.Title = "Select file to import";
1391-
dialog.Filter = "Point Cloud Files|*.las;*.laz;*.ply|LAS Files|*.las;*.laz|PLY Files|*.ply|All Files|*.*";
1391+
1392+
if (cmbImportFormat.SelectedItem != null)
1393+
{
1394+
var format = cmbImportFormat.SelectedItem.ToString();
1395+
if (format == "LAS" || format == "LAZ")
1396+
{
1397+
dialog.Filter = "LAS Files|*.las;*.laz|All Files|*.*";
1398+
}
1399+
else if (format == "PLY")
1400+
{
1401+
dialog.Filter = "PLY Files|*.ply|All Files|*.*";
1402+
}
1403+
else
1404+
{
1405+
dialog.Filter = "All Files|*.*";
1406+
}
1407+
}
1408+
else
1409+
{
1410+
dialog.Filter = "Point Cloud Files|*.las;*.laz;*.ply|LAS Files|*.las;*.laz|PLY Files|*.ply|All Files|*.*";
1411+
}
13921412

13931413
// take folder from field
13941414
if (string.IsNullOrEmpty(txtInputFile.Text) == false)

Writers/PCROOT.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ void IWriter.Save(int fileIndex)
550550
Tools.Shuffle(ref nodeTempR);
551551
Tools.Shuffle(ref nodeTempG);
552552
Tools.Shuffle(ref nodeTempB);
553-
554553
}
555554

556555
if (importSettings.importIntensity == true) Tools.Shuffle(ref nodeTempIntensity);
@@ -692,7 +691,7 @@ void IWriter.Save(int fileIndex)
692691
py -= (cellY * importSettings.gridSize);
693692
pz -= (cellZ * importSettings.gridSize);
694693

695-
// pack G, PY and INTensity
694+
// pack G, Py and INTensity
696695
if (importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == false)
697696
{
698697
float c = py;
@@ -701,7 +700,7 @@ void IWriter.Save(int fileIndex)
701700
byte bg = (byte)(nodeTempG[i] * 255);
702701
byte bi = nodeTempIntensity[i];
703702
packedY = (bg << 24) | (bi << 16) | (cIntegral << 8) | cFractional;
704-
}
703+
} // pack G, Py, CLASSification
705704
else if (importSettings.importRGB == true && importSettings.importIntensity == false && importSettings.importClassification == true)
706705
{
707706
float c = py;
@@ -710,7 +709,7 @@ void IWriter.Save(int fileIndex)
710709
byte bg = (byte)(nodeTempG[i] * 255);
711710
byte bc = nodeTempClassification[i];
712711
packedY = (bg << 24) | (bc << 16) | (cIntegral << 8) | cFractional;
713-
}
712+
} // pack G, Py, INTensity, CLASSification
714713
else if (importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == true)
715714
{
716715
float c = py;
@@ -720,13 +719,13 @@ void IWriter.Save(int fileIndex)
720719
byte bi = nodeTempIntensity[i];
721720
packedY = (bg << 24) | (bi << 16) | (cIntegral << 8) | cFractional;
722721
}
723-
else
722+
else // pack G and Py
724723
{
725724
// pack green and y (note this is lossy, especially with *0.98)
726725
py = Tools.SuperPacker(nodeTempG[i] * 0.98f, py, importSettings.gridSize * importSettings.packMagicValue);
727726
}
728727

729-
// pack red, x and classification (since intensity is already in green)
728+
// pack Red, Px, CLASSification (since intensity is already in green)
730729
if (importSettings.importRGB == true && importSettings.importIntensity == true && importSettings.importClassification == true)
731730
{
732731
float c = px;
@@ -736,9 +735,8 @@ void IWriter.Save(int fileIndex)
736735
byte bc = nodeTempClassification[i];
737736
packedX = (br << 24) | (bc << 16) | (cIntegral << 8) | cFractional;
738737
}
739-
else
738+
else // pack Red and Px
740739
{
741-
// pack red and x
742740
px = Tools.SuperPacker(nodeTempR[i] * 0.98f, px, importSettings.gridSize * importSettings.packMagicValue);
743741
}
744742

@@ -849,20 +847,19 @@ void IWriter.Save(int fileIndex)
849847
{
850848
IntToBytes(packedX, pointBuffer, 0); // Convert int to bytes manually
851849
}
852-
else
850+
else // x, red
853851
{
854-
// x, red
855852
FloatToBytes(px, pointBuffer, 0);
856853
}
857854

855+
// packed: y, green, intensity AND/OR classification
858856
if (importSettings.packColors == true && importSettings.importRGB == true && (importSettings.importIntensity == true || importSettings.importClassification == true))
859857
{
860858
// y, int, classification for now
861859
IntToBytes(packedY, pointBuffer, 4);
862860
}
863-
else
861+
else // y
864862
{
865-
// y
866863
FloatToBytes(py, pointBuffer, 4);
867864
}
868865

0 commit comments

Comments
 (0)