83 if (stream == 0)
return FALSE;
84 if (this->file) this->file =
file;
92 fprintf(stderr,
"ERROR: file name pointer is zero\n");
96 file = fopen(file_name,
"wb");
100 fprintf(stderr,
"ERROR: cannot open file '%s'\n", file_name);
104 if (setvbuf(
file,
NULL, _IOFBF, io_buffer_size) != 0)
106 fprintf(stderr,
"WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size);
115 return open(out, header, version);
122 fprintf(stderr,
"ERROR: file pointer is zero\n");
129 if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 )
131 fprintf(stderr,
"ERROR: cannot set stdout to binary (untranslated) mode\n");
142 return open(out, header, version);
149 fprintf(stderr,
"ERROR: ByteStreamOut pointer is zero\n");
152 this->stream = stream;
156 fprintf(stderr,
"ERROR: LASheader pointer is zero\n");
160 if (strstr(version,
"ts16"))
162 this->version = 20020715;
166 this->version = 20010712;
171 tsheader.
version = this->version;
178 units = tsheader.
units = (
I32)(1.0 / scale);
201 if (version == 20020715)
213 if (!stream->putBytes((
U8*)&tspoint,
sizeof(
TSpoint)))
return FALSE;
224 if (!stream->putBytes((
U8*)&tsrow,
sizeof(
TSrow)))
return FALSE;
230 if (!stream->putBytes((
U8*)&time,
sizeof(
U32)))
return FALSE;
235 rgba[0] = point->
rgb[0]/256;
236 rgba[1] = point->
rgb[1]/256;
237 rgba[2] = point->
rgb[2]/256;
239 if (!stream->putBytes((
U8*)&rgba,
sizeof(
U32)))
return FALSE;
256 if (update_header && p_count != npoints)
258 if (!stream->isSeekable())
261 fprintf(stderr,
"ERROR: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count);
263 fprintf(stderr,
"ERROR: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count);
269 stream->put32bitsLE((
U8*)&p_count);
273 bytes = stream->tell();
virtual BOOL putBytes(const U8 *bytes, U32 num_bytes)=0
I64 close(BOOL update_npoints=true)
BOOL open(const char *file_name, const LASheader *header, const char *version, U32 io_buffer_size=65536)
BOOL write_point(const LASpoint *point)
BOOL update_header(const LASheader *header, BOOL use_inventory=TRUE, BOOL update_extra_bytes=FALSE)
std::shared_ptr< HighFive::File > open(const std::string &filename)
U8 number_of_returns_of_given_pulse