8
8
// (c) of C# port 2014-2017 by Shinta [email protected]
9
9
10
10
using PointCloudConverter . Structs ;
11
- using laszip . net ;
12
11
using System ;
12
+ using LASzip . Net ;
13
13
14
14
namespace PointCloudConverter . Readers
15
15
{
16
16
public class LAZ : IReader
17
17
{
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;
22
24
bool customIntensityRange = false ;
23
25
24
26
bool IReader . InitReader ( ImportSettings importSettings , int fileIndex )
25
27
{
26
28
// TODO check errors
27
29
var file = importSettings . inputFiles [ fileIndex ] ;
28
- importRGB = importSettings . importRGB ;
29
- importIntensity = importSettings . importIntensity ;
30
+ // importRGB = importSettings.importRGB;
31
+ // importIntensity = importSettings.importIntensity;
30
32
customIntensityRange = importSettings . useCustomIntensityRange ;
31
- lazReader . laszip_open_reader ( file , ref compressed ) ;
33
+ lazReader . open_reader ( file , out compressedLAZ ) ;
32
34
return true ;
33
35
}
34
36
35
37
Bounds IReader . GetBounds ( )
36
38
{
37
39
var b = new Bounds ( ) ;
38
-
39
40
// get original bounds from file
40
41
b . minX = ( float ) lazReader . header . min_x ;
41
42
b . maxX = ( float ) lazReader . header . max_x ;
42
43
b . minY = ( float ) lazReader . header . min_y ;
43
44
b . maxY = ( float ) lazReader . header . max_y ;
44
45
b . minZ = ( float ) lazReader . header . min_z ;
45
46
b . maxZ = ( float ) lazReader . header . max_z ;
46
-
47
47
return b ;
48
48
}
49
49
50
50
int IReader . GetPointCount ( )
51
51
{
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 ;
53
58
}
54
59
55
-
56
60
Color IReader . GetRGB ( )
57
61
{
58
62
var c = new Color ( ) ;
@@ -105,22 +109,22 @@ Float3 IReader.GetXYZ()
105
109
f . hasError = false ;
106
110
107
111
// Read point
108
- lazReader . laszip_read_point ( ) ;
112
+ lazReader . read_point ( ) ;
109
113
110
114
// 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 )
113
117
{
114
118
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? " ) ;
116
120
Console . WriteLine ( "ErrorCode: " + err ) ;
117
121
Console . ForegroundColor = ConsoleColor . White ;
118
122
f . hasError = true ;
119
123
}
120
124
121
125
// Get precision coordinates
122
126
var coordArray = new double [ 3 ] ;
123
- lazReader . laszip_get_coordinates ( coordArray ) ;
127
+ lazReader . get_coordinates ( coordArray ) ;
124
128
f . x = coordArray [ 0 ] ;
125
129
f . y = coordArray [ 1 ] ;
126
130
f . z = coordArray [ 2 ] ;
@@ -130,7 +134,7 @@ Float3 IReader.GetXYZ()
130
134
131
135
void IReader . Close ( )
132
136
{
133
- lazReader . laszip_close_reader ( ) ;
137
+ lazReader . close_reader ( ) ;
134
138
}
135
139
} // class
136
140
} // namespace
0 commit comments