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 }
virtual BOOL putBytes(const U8 *bytes, U32 num_bytes)=0
int BOOL
Definition: mydefs.hpp:57
#define FALSE
Definition: mydefs.hpp:133
unsigned int U32
Definition: mydefs.hpp:39
unsigned char U8
Definition: mydefs.hpp:41
#define LAS_SPATIAL_QUAD_TREE
Definition: lasspatial.hpp:40
BOOL write(const LASspatial *spatial, ByteStreamOut *stream) const
Definition: lasspatial.cpp:76
virtual void getBytes(U8 *bytes, const U32 num_bytes)=0
virtual BOOL read(ByteStreamIn *stream)=0
virtual BOOL put32bitsLE(const U8 *bytes)=0
LASspatial * read(ByteStreamIn *stream) const
Definition: lasspatial.cpp:38
virtual BOOL write(ByteStreamOut *stream) const =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 Mon Feb 28 2022 22:46:07