88// (c) of C# port 2014-2017 by Shinta [email protected] 99
1010using PointCloudConverter . Structs ;
11- using laszip . net ;
1211using System ;
12+ using LASzip . Net ;
1313
1414namespace 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
0 commit comments