Skip to content

Commit 60d40da

Browse files
committed
Upgrade laszip.net (fixes# 9), fix Int packed negative values issue for batch processing (now min Y/Z bound is used to keep all points above 0), #BUILD
1 parent 4a23fb6 commit 60d40da

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

MainWindow.xaml.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace PointCloudConverter
2626
{
2727
public partial class MainWindow : Window
2828
{
29-
static readonly string version = "11.02.2024";
29+
static readonly string version = "24.02.2024";
3030
static readonly string appname = "PointCloud Converter - " + version;
3131
static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
3232

@@ -271,6 +271,10 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
271271
// offset cloud to be near 0,0,0
272272
importSettings.offsetX = bounds.minX;
273273
importSettings.offsetY = bounds.minY;
274+
}
275+
// NOW smallest Y offset and largest X,Z is used (to fix INT packing negative value issue)
276+
if (bounds.minZ < importSettings.offsetZ)
277+
{
274278
importSettings.offsetZ = bounds.minZ;
275279
}
276280
}
@@ -280,14 +284,13 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
280284
importSettings.offsetY = importSettings.manualOffsetY;
281285
importSettings.offsetZ = importSettings.manualOffsetZ;
282286
}
283-
else
287+
else // neither
284288
{
285289
importSettings.offsetX = 0;
286290
importSettings.offsetY = 0;
287291
importSettings.offsetZ = 0;
288292
}
289293

290-
291294
var writerRes = importSettings.writer.InitWriter(importSettings, pointCount);
292295
if (writerRes == false)
293296
{

Readers/LAZ.cs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,55 @@
88
// (c) of C# port 2014-2017 by Shinta [email protected]
99

1010
using PointCloudConverter.Structs;
11-
using laszip.net;
1211
using System;
12+
using LASzip.Net;
1313

1414
namespace PointCloudConverter.Readers
1515
{
1616
public class LAZ : IReader
1717
{
18-
laszip_dll lazReader = new laszip_dll();
19-
bool compressed = false;
20-
bool importRGB = true;
21-
bool importIntensity = false;
18+
//laszip_dll lazReader = new laszip_dll();
19+
laszip lazReader = new laszip();
20+
21+
bool compressedLAZ = false;
22+
//bool importRGB = true;
23+
//bool importIntensity = false;
2224
bool customIntensityRange = false;
2325

2426
bool IReader.InitReader(ImportSettings importSettings, int fileIndex)
2527
{
2628
// TODO check errors
2729
var file = importSettings.inputFiles[fileIndex];
28-
importRGB = importSettings.importRGB;
29-
importIntensity = importSettings.importIntensity;
30+
//importRGB = importSettings.importRGB;
31+
//importIntensity = importSettings.importIntensity;
3032
customIntensityRange = importSettings.useCustomIntensityRange;
31-
lazReader.laszip_open_reader(file, ref compressed);
33+
lazReader.open_reader(file, out compressedLAZ);
3234
return true;
3335
}
3436

3537
Bounds IReader.GetBounds()
3638
{
3739
var b = new Bounds();
38-
3940
// get original bounds from file
4041
b.minX = (float)lazReader.header.min_x;
4142
b.maxX = (float)lazReader.header.max_x;
4243
b.minY = (float)lazReader.header.min_y;
4344
b.maxY = (float)lazReader.header.max_y;
4445
b.minZ = (float)lazReader.header.min_z;
4546
b.maxZ = (float)lazReader.header.max_z;
46-
4747
return b;
4848
}
4949

5050
int IReader.GetPointCount()
5151
{
52-
return (int)lazReader.header.number_of_point_records;
52+
long count = 0;
53+
lazReader.get_point_count(out count);
54+
// check alternative point counts
55+
if (count == 0) count = (int)lazReader.header.extended_number_of_point_records;
56+
if (count == 0) count = lazReader.header.number_of_point_records;
57+
return (int)count;
5358
}
5459

55-
5660
Color IReader.GetRGB()
5761
{
5862
var c = new Color();
@@ -105,22 +109,22 @@ Float3 IReader.GetXYZ()
105109
f.hasError = false;
106110

107111
// Read point
108-
lazReader.laszip_read_point();
112+
lazReader.read_point();
109113

110114
// check for received errors
111-
var err = lazReader.laszip_get_error();
112-
if (err != null)
115+
var err = lazReader.get_error();
116+
if (err == null)
113117
{
114118
Console.ForegroundColor = ConsoleColor.Red;
115-
Console.WriteLine("Failed to read until end of file, partial data is kept.");
119+
Console.WriteLine("Failed to read until end of file?");
116120
Console.WriteLine("ErrorCode: " + err);
117121
Console.ForegroundColor = ConsoleColor.White;
118122
f.hasError = true;
119123
}
120124

121125
// Get precision coordinates
122126
var coordArray = new double[3];
123-
lazReader.laszip_get_coordinates(coordArray);
127+
lazReader.get_coordinates(coordArray);
124128
f.x = coordArray[0];
125129
f.y = coordArray[1];
126130
f.z = coordArray[2];
@@ -130,7 +134,7 @@ Float3 IReader.GetXYZ()
130134

131135
void IReader.Close()
132136
{
133-
lazReader.laszip_close_reader();
137+
lazReader.close_reader();
134138
}
135139
} // class
136140
} // namespace

Writers/PCROOT.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ bool IWriter.InitWriter(ImportSettings _importSettings, int _pointCount)
4848
nodeR.Clear();
4949
nodeG.Clear();
5050
nodeB.Clear();
51+
nodeIntensity.Clear();
5152

5253
bsPoints = null;
5354
writerPoints = null;

libs/laszip.net.dll

125 KB
Binary file not shown.

0 commit comments

Comments
 (0)