85 fprintf(stderr,
"ERROR: fine name pointer is zero\n");
91 file = fopen(file_name,
"rb");
94 fprintf(stderr,
"ERROR: cannot open file '%s'\n", file_name);
113 WIN32_FILE_ATTRIBUTE_DATA attr;
115 GetFileAttributesEx(file_name, GetFileExInfoStandard, &attr);
116 FileTimeToSystemTime(&attr.ftCreationTime, &creation);
117 int startday[13] = {-1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
118 header.file_creation_day = startday[creation.wMonth] + creation.wDay;
119 header.file_creation_year = creation.wYear;
121 if ((((creation.wYear)%4) == 0) && (creation.wMonth > 2)) header.file_creation_day++;
123 header.file_creation_day = 333;
124 header.file_creation_year = 2011;
136 fprintf(stderr,
"ERROR: ByteStreamIn* pointer is zero\n");
140 this->stream = stream;
147 fprintf(stderr,
"ERROR: reading terrasolid header\n");
155 fprintf(stderr,
"ERROR: corrupt terrasolid header. size != 56.\n");
161 fprintf(stderr,
"ERROR: corrupt terrasolid header. recog_val != 979401.\n");
165 if (strncmp(tsheader.
recog_str,
"CXYZ", 4) != 0)
167 fprintf(stderr,
"ERROR: corrupt terrasolid header. recog_str != CXYZ.\n");
175 for (i = 0; i < 32; i++)
177 header.system_identifier[i] =
'\0';
178 header.generating_software[i] =
'\0';
180 sprintf(header.system_identifier,
"LAStools (c) by Martin Isenburg");
187 header.point_data_format = 3;
188 header.point_data_record_length = 34;
192 header.point_data_format = 1;
193 header.point_data_record_length = 28;
200 header.point_data_format = 2;
201 header.point_data_record_length = 26;
205 header.point_data_format = 0;
206 header.point_data_record_length = 20;
210 header.number_of_point_records = tsheader.
npoints;
214 header.x_scale_factor = scale;
215 header.y_scale_factor = scale;
216 header.z_scale_factor = scale;
217 header.x_offset = -tsheader.
origin_x*scale;
218 header.y_offset = -tsheader.
origin_y*scale;
219 header.z_offset = -tsheader.
origin_z*scale;
223 point.init(&header, header.point_data_format, header.point_data_record_length);
231 if (!read_point())
return FALSE;
233 header.min_x = header.max_x = point.get_x();
234 header.min_y = header.max_y = point.get_y();
235 header.min_z = header.max_z = point.get_z();
239 if (!seek(i))
return FALSE;
240 if (!read_point())
return FALSE;
243 header.number_of_points_by_return[0] = 0;
244 header.number_of_points_by_return[1] = 0;
251 if (p_index < npoints)
254 if (version == 20020715)
257 pos += (
sizeof(
TSrow)*(
U32)p_index);
258 if (point.have_gps_time)
259 pos += (
sizeof(
U32)*(
U32)p_index);
261 pos += (
sizeof(
U32)*(
U32)p_index);
263 return stream->seek(pos);
270 if (p_count < npoints)
273 if (version == 20020715)
276 try { stream->getBytes((
U8*)&tspoint,
sizeof(
TSpoint)); }
catch(...)
278 fprintf(stderr,
"ERROR: reading terrasolid point after %u of %u\n", (
U32)p_count, (
U32)npoints);
285 point.classification = tspoint.
code;
286 point.point_source_ID = tspoint.
line;
292 try { stream->getBytes((
U8*)&tsrow,
sizeof(
TSrow)); }
catch(...)
294 fprintf(stderr,
"ERROR: reading terrasolid row after %u of %u\n", (
U32)p_count, (
U32)npoints);
301 point.classification = tsrow.
code;
302 point.point_source_ID = tsrow.
line;
306 if (header.min_x > point.get_x()) header.min_x = point.get_x();
307 else if (header.max_x < point.get_x()) header.max_x = point.get_x();
308 if (header.min_y > point.get_y()) header.min_y = point.get_y();
309 else if (header.max_y < point.get_y()) header.max_y = point.get_y();
310 if (header.min_z > point.get_z()) header.min_z = point.get_z();
311 else if (header.max_z < point.get_z()) header.max_z = point.get_z();
315 point.number_of_returns_of_given_pulse = 1;
316 point.return_number = 1;
317 header.number_of_points_by_return[0]++;
321 point.number_of_returns_of_given_pulse = 2;
322 point.return_number = 1;
323 header.number_of_points_by_return[0]++;
327 point.number_of_returns_of_given_pulse = 2;
328 point.return_number = 2;
329 header.number_of_points_by_return[1]++;
333 point.number_of_returns_of_given_pulse = 3;
334 point.return_number = 2;
335 header.number_of_points_by_return[1]++;
338 if (point.have_gps_time)
341 try { stream->getBytes((
U8*)&time,
sizeof(
U32)); }
catch(...)
343 fprintf(stderr,
"ERROR: reading terrasolid time\n");
346 point.gps_time = 0.0002*time;
352 try { stream->getBytes((
U8*)rgba,
sizeof(
U8)*4); }
catch(...)
354 fprintf(stderr,
"ERROR: reading terrasolid color\n");
357 point.rgb[0] = 256*rgba[0];
358 point.rgb[1] = 256*rgba[1];
359 point.rgb[2] = 256*rgba[2];
428 this->
offset[0] = x_offset;
429 this->
offset[1] = y_offset;
430 this->
offset[2] = z_offset;
452 LASreaderBINrescalereoffset::LASreaderBINrescalereoffset(
F64 x_scale_factor,
F64 y_scale_factor,
F64 z_scale_factor,
F64 x_offset,
F64 y_offset,
F64 z_offset) :
LASreaderBINrescale(x_scale_factor, y_scale_factor, z_scale_factor),
LASreaderBINreoffset(x_offset, y_offset, z_offset)
LASreaderBINrescalereoffset(F64 x_scale_factor, F64 y_scale_factor, F64 z_scale_factor, F64 x_offset, F64 y_offset, F64 z_offset)
BOOL open(const char *file_name)
virtual BOOL open(ByteStreamIn *stream)
LASreaderBINreoffset(F64 x_offset, F64 y_offset, F64 z_offset)
ByteStreamIn * get_stream() const
BOOL seek(const I64 p_index)
virtual void getBytes(U8 *bytes, const U32 num_bytes)=0
virtual BOOL open(ByteStreamIn *stream)
void close(BOOL close_stream=TRUE)
BOOL read_point_default()
LASreaderBINrescale(F64 x_scale_factor, F64 y_scale_factor, F64 z_scale_factor)
#define LAS_TOOLS_VERSION
BOOL open(ByteStreamIn *stream)
std::shared_ptr< HighFive::File > open(const std::string &filename)