lasspatial.cpp
Go to the documentation of this file.
1 /*
2 ===============================================================================
3 
4  FILE: lasspatial.cpp
5 
6  CONTENTS:
7 
8  see corresponding header file
9 
10  PROGRAMMERS:
11 
12  martin.isenburg@gmail.com
13 
14  COPYRIGHT:
15 
16  (c) 2011, Martin Isenburg, LASSO - tools to catch reality
17 
18  This software is distributed WITHOUT ANY WARRANTY and without even the
19  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 
21  CHANGE HISTORY:
22 
23  see corresponding header file
24 
25 ===============================================================================
26 */
27 #include "lasspatial.hpp"
28 
29 #include "bytestreamin.hpp"
30 #include "bytestreamout.hpp"
31 
32 #include "lasquadtree.hpp"
33 
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 
39 {
40  char signature[4];
41  try { stream->getBytes((U8*)signature, 4); } catch(...)
42  {
43  fprintf(stderr,"ERROR (LASspatialReadWrite): reading signature\n");
44  return FALSE;
45  }
46  if (strncmp(signature, "LASS", 4) != 0)
47  {
48  fprintf(stderr,"ERROR (LASspatialReadWrite): wrong signature %4s instead of 'LASS'\n", signature);
49  return FALSE;
50  }
51  U32 type;
52  try { stream->getBytes((U8*)&type, 4); } catch(...)
53  {
54  fprintf(stderr,"ERROR (LASspatialReadWrite): reading type\n");
55  return 0;
56  }
57  LASspatial* spatial;
58  if (type == LAS_SPATIAL_QUAD_TREE)
59  {
60  spatial = new LASquadtree;
61  if (!spatial->read(stream))
62  {
63  delete spatial;
64  return 0;
65  }
66  return spatial;
67  }
68  else
69  {
70  fprintf(stderr,"ERROR (LASspatialReadWrite): unknown type %u\n", type);
71  return 0;
72  }
73  return spatial;
74 }
75 
77 {
78  if (!stream->putBytes((U8*)"LASS", 4))
79  {
80  fprintf(stderr,"ERROR (LASspatialReadWrite): writing signature\n");
81  return FALSE;
82  }
84  if (!stream->put32bitsLE((U8*)&type))
85  {
86  fprintf(stderr,"ERROR (LASspatialReadWrite): writing type %u\n", type);
87  return FALSE;
88  }
89  return spatial->write(stream);
90 }
LASquadtree
Definition: lasquadtree.hpp:39
LASspatial::write
virtual BOOL write(ByteStreamOut *stream) const =0
LAS_SPATIAL_QUAD_TREE
#define LAS_SPATIAL_QUAD_TREE
Definition: lasspatial.hpp:40
ByteStreamOut::put32bitsLE
virtual BOOL put32bitsLE(const U8 *bytes)=0
LASspatial
Definition: lasspatial.hpp:42
ByteStreamOut
Definition: bytestreamout.hpp:36
bytestreamin.hpp
bytestreamout.hpp
LASspatialReadWrite::write
BOOL write(const LASspatial *spatial, ByteStreamOut *stream) const
Definition: lasspatial.cpp:76
ByteStreamIn
Definition: bytestreamin.hpp:36
lasquadtree.hpp
U8
unsigned char U8
Definition: mydefs.hpp:41
BOOL
int BOOL
Definition: mydefs.hpp:57
LASspatial::read
virtual BOOL read(ByteStreamIn *stream)=0
FALSE
#define FALSE
Definition: mydefs.hpp:133
lasspatial.hpp
U32
unsigned int U32
Definition: mydefs.hpp:39
LASspatialReadWrite::read
LASspatial * read(ByteStreamIn *stream) const
Definition: lasspatial.cpp:38
ByteStreamIn::getBytes
virtual void getBytes(U8 *bytes, const U32 num_bytes)=0
ByteStreamOut::putBytes
virtual BOOL putBytes(const U8 *bytes, U32 num_bytes)=0


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23