SAGA API  v9.5
pointcloud.h
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // pointcloud.h //
15 // //
16 // Copyright (C) 2009 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Hamburg //
44 // Germany //
45 // //
46 // e-mail: oconrad@saga-gis.org //
47 // //
49 
50 //---------------------------------------------------------
51 #ifndef HEADER_INCLUDED__SAGA_API__pointcloud_H
52 #define HEADER_INCLUDED__SAGA_API__pointcloud_H
53 
54 
56 // //
57 // //
58 // //
60 
61 //---------------------------------------------------------
71 // //
73 // //
74 // //
76 
77 //---------------------------------------------------------
78 #include "shapes.h"
79 
80 
82 // //
83 // //
84 // //
86 
87 //---------------------------------------------------------
88 typedef enum
89 {
93 }
95 
96 
98 // //
99 // //
100 // //
102 
103 //---------------------------------------------------------
105 {
106 public:
107 
108  CSG_PointCloud (void);
109  bool Create (void);
110 
111  CSG_PointCloud (const CSG_PointCloud &PointCloud);
112  bool Create (const CSG_PointCloud &PointCloud);
113 
114  CSG_PointCloud (const CSG_String &File);
115  bool Create (const CSG_String &File);
116  CSG_PointCloud (const char *File);
117  bool Create (const char *File);
118  CSG_PointCloud (const wchar_t *File);
119  bool Create (const wchar_t *File);
120 
121  CSG_PointCloud (CSG_PointCloud *pTemplate);
122  bool Create (CSG_PointCloud *pTemplate);
123 
124  virtual ~CSG_PointCloud(void);
125 
126  virtual bool Destroy (void);
127 
129 
130  virtual bool Assign (CSG_Data_Object *pSource);
131 
132  virtual bool Save (const CSG_String &File, int Format = 0);
133  virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
134  virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
135 
136  void Set_XYZ_Precision (bool bDouble) { m_bXYZPrecDbl = bDouble; }
137 
138  static bool Get_Header_Content (const CSG_String &FileName, CSG_MetaData &Header);
139 
140  //-----------------------------------------------------
141  virtual bool is_Valid (void) const { return( m_nFields > 0 ); }
142  bool is_Compatible (CSG_PointCloud *pPointCloud) const;
143 
144  //-----------------------------------------------------
145  virtual bool Add_Field (const CSG_String &Name, TSG_Data_Type Type, int Field = -1);
146  virtual bool Del_Field (int Field);
147  virtual bool Mov_Field (int Field, int Position);
148 
149  virtual bool Set_Field_Type (int Field, TSG_Data_Type Type);
150 
151  //-----------------------------------------------------
152  int Get_Attribute_Count (void) const { return( m_nFields - 3 ); }
153  const SG_Char * Get_Attribute_Name (int Field) const { Field += 3; return( Field >= 3 && Field < m_nFields ? m_Field_Name[Field]->c_str() : NULL ); }
154  TSG_Data_Type Get_Attribute_Type (int Field) const { Field += 3; return( Field >= 3 && Field < m_nFields ? m_Field_Type[Field] : SG_DATATYPE_Undefined ); }
155 
156  //-----------------------------------------------------
157  bool Add_Point (double x, double y, double z);
158  bool Add_Point (const CSG_Point_3D &Point);
159  bool Del_Point (sLong Index);
160  bool Del_Points (void);
161 
162  //-----------------------------------------------------
163  bool Set_Cursor (sLong Index) { return( (m_Cursor = Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL) != NULL ); }
164  virtual bool Set_Value ( int Field, double Value) { return( _Set_Field_Value(m_Cursor, Field, Value) ); }
165  virtual double Get_Value ( int Field) const { return( _Get_Field_Value(m_Cursor, Field) ); }
166  double Get_X (void) const { return( _Get_Field_Value(m_Cursor, 0) ); }
167  double Get_Y (void) const { return( _Get_Field_Value(m_Cursor, 1) ); }
168  double Get_Z (void) const { return( _Get_Field_Value(m_Cursor, 2) ); }
169  bool Set_Attribute ( int Field, double Value) { return( Set_Value(Field + 3, Value) ); }
170  double Get_Attribute ( int Field) const { return( Get_Value(Field + 3) ); }
171  bool Set_NoData ( int Field) { return( Set_Value(Field, Get_NoData_Value()) ); }
172  bool is_NoData ( int Field) const { return( is_NoData_Value(Get_Value(Field)) ); }
173 
174  virtual bool Set_Value (sLong Index, int Field, double Value) { return( _Set_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, Field, Value) ); }
175  virtual double Get_Value (sLong Index, int Field) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, Field) ); }
176  double Get_X (sLong Index) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, 0) ); }
177  double Get_Y (sLong Index) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, 1) ); }
178  double Get_Z (sLong Index) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, 2) ); }
179  bool Set_Attribute (sLong Index, int Field, double Value) { return( Set_Value(Index, Field + 3, Value) ); }
180  double Get_Attribute (sLong Index, int Field) const { return( Get_Value(Index, Field + 3) ); }
181  bool Set_NoData (sLong Index, int Field) { return( Set_Value(Index, Field, Get_NoData_Value()) );}
182  bool is_NoData (sLong Index, int Field) const { return( is_NoData_Value(Get_Value(Index, Field)) ); }
183 
184  virtual bool Set_Value ( int Field, const SG_Char *Value) { return( _Set_Field_Value(m_Cursor, Field, Value) ); }
185  virtual bool Get_Value ( int Field, CSG_String &Value) const { return( _Get_Field_Value(m_Cursor, Field, Value) ); }
186  virtual bool Set_Value (sLong Index, int Field, const SG_Char *Value) { return( _Set_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, Field, Value) ); }
187  virtual bool Get_Value (sLong Index, int Field, CSG_String &Value) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, Field, Value) ); }
188  virtual bool Set_Attribute ( int Field, const SG_Char *Value) { return( Set_Value(Field + 3, Value) ); }
189  virtual bool Get_Attribute ( int Field, CSG_String &Value) const { return( Get_Value(Field + 3, Value) ); }
190  virtual bool Set_Attribute (sLong Index, int Field, const SG_Char *Value) { return( Set_Value(Index, Field + 3, Value) ); }
191  virtual bool Get_Attribute (sLong Index, int Field, CSG_String &Value) const { return( Get_Value(Index, Field + 3, Value) ); }
192 
193  TSG_Point_3D Get_Point (void) const;
194  TSG_Point_3D Get_Point (sLong Index) const;
195  virtual bool Set_Point ( const TSG_Point_3D &Point);
196  virtual bool Set_Point (sLong Index, const TSG_Point_3D &Point);
197 
198  virtual void Set_Modified (bool bModified = true) { CSG_Data_Object::Set_Modified(bModified); }
199 
200 
201  //-----------------------------------------------------
202  // Overrides: CSG_Table, CSG_Shapes
203 
204  virtual CSG_Table_Record * Get_Record (sLong Index) const;
205 
206  virtual CSG_Shape * Get_Shape (const CSG_Point &Point, double Epsilon = 0.);
207 
208  virtual bool Del_Record (sLong Index) { return( Del_Point(Index) ); }
209  virtual bool Del_Shape (sLong Index) { return( Del_Point(Index) ); }
210  virtual bool Del_Records (void) { return( Del_Points() ); }
211  virtual bool Del_Shapes (void) { return( Del_Points() ); }
212 
213  virtual CSG_Table_Record * Ins_Record (sLong Index, CSG_Table_Record *pCopy = NULL);
214  virtual CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL);
215  virtual CSG_Shape * Add_Shape ( CSG_Table_Record *pCopy = NULL, TSG_ADD_Shape_Copy_Mode mCopy = SHAPE_COPY);
216  virtual bool Del_Shape (CSG_Shape *pShape) { return( false ); }
217 
218  virtual bool Select (sLong Index , bool bInvert = false);
219  virtual bool Select (CSG_Table_Record *pShape = NULL, bool bInvert = false);
220  virtual bool Select (const TSG_Rect &Extent , bool bInvert = false);
221  virtual bool Select (const TSG_Point &Point , bool bInvert = false);
222 
223  virtual bool is_Selected (sLong Index) const;
224 
225  virtual sLong Del_Selection (void);
226  virtual sLong Inv_Selection (void);
227  virtual CSG_Shape * Get_Selection (sLong Index = 0);
228  virtual const CSG_Rect & Get_Selection_Extent(void);
229 
230 
231 protected:
232 
233  virtual bool On_Update (void);
234  virtual bool On_Reload (void);
235  virtual bool On_Delete (void);
236 
237  virtual void _On_Construction (void);
238 
239  virtual bool _Stats_Update (int Field) const;
240 
241 
242 private:
243 
244  bool m_bXYZPrecDbl;
245 
246  char **m_Points, *m_Cursor;
247 
248  int m_nPointBytes, *m_Field_Offset;
249 
250  CSG_Array m_Array_Points;
251 
252  CSG_Shapes m_Shapes;
253 
254 
255  bool _Load (const CSG_String &File);
256  bool _Load (CSG_File &Stream);
257  bool _Save (CSG_File &Stream);
258  CSG_MetaData _Create_Header (void) const;
259 
260  bool _Add_Field (const SG_Char *Name, TSG_Data_Type Type, int Field = -1);
261  bool _Set_Field_Value (char *pPoint, int Field, double Value);
262  double _Get_Field_Value (char *pPoint, int Field ) const;
263  bool _Set_Field_Value (char *pPoint, int Field, const SG_Char *Value);
264  bool _Get_Field_Value (char *pPoint, int Field, CSG_String &Value) const;
265 
266  bool _Inc_Array (void);
267  bool _Dec_Array (void);
268 
269  CSG_Shape * _Shape_Get (sLong Index);
270  void _Shape_Flush (void);
271 
272 };
273 
274 
276 // //
277 // //
278 // //
280 
281 //---------------------------------------------------------
284 
287 
294 
297 
299 // //
300 // //
301 // //
303 
304 //---------------------------------------------------------
305 #endif // #ifndef HEADER_INCLUDED__SAGA_API__pointcloud_H
CSG_Rect
Definition: geo_tools.h:471
CSG_Shapes::Assign
virtual bool Assign(CSG_Data_Object *pObject)
Definition: shapes.cpp:367
CSG_PointCloud::Get_X
double Get_X(sLong Index) const
Definition: pointcloud.h:176
CSG_PointCloud::Get_Y
double Get_Y(void) const
Definition: pointcloud.h:167
CSG_PointCloud::Get_X
double Get_X(void) const
Definition: pointcloud.h:166
CSG_Shapes::On_Delete
virtual bool On_Delete(void)
Definition: shapes_io.cpp:72
SG_DATATYPE_Undefined
@ SG_DATATYPE_Undefined
Definition: api_core.h:1009
CSG_PointCloud::Set_Value
virtual bool Set_Value(sLong Index, int Field, double Value)
Definition: pointcloud.h:174
TSG_PointCloud_File_Type
TSG_PointCloud_File_Type
Definition: pointcloud.h:89
CSG_PointCloud::Del_Shapes
virtual bool Del_Shapes(void)
Definition: pointcloud.h:211
CSG_PointCloud::Set_Attribute
bool Set_Attribute(sLong Index, int Field, double Value)
Definition: pointcloud.h:179
POINTCLOUD_FILE_FORMAT_Normal
@ POINTCLOUD_FILE_FORMAT_Normal
Definition: pointcloud.h:91
CSG_PointCloud::Get_Z
double Get_Z(sLong Index) const
Definition: pointcloud.h:178
CSG_Shapes::Get_Shape
virtual CSG_Shape * Get_Shape(const CSG_Point &Point, double Epsilon=0.)
Definition: shapes.cpp:499
CSG_Shapes::Get_Selection
virtual CSG_Shape * Get_Selection(sLong Index=0)
Definition: shapes.h:835
CSG_Shapes::On_Reload
virtual bool On_Reload(void)
Definition: shapes_io.cpp:66
CSG_Table_Record
Definition: table.h:130
CSG_Table::_Stats_Update
virtual bool _Stats_Update(int iField) const
Definition: table.cpp:1224
CSG_Data_Object::Get_NoData_Value
double Get_NoData_Value(bool bUpper=false) const
Definition: dataobject.h:253
CSG_PointCloud::Del_Shape
virtual bool Del_Shape(CSG_Shape *pShape)
Definition: pointcloud.h:216
CSG_Table::Inv_Selection
virtual sLong Inv_Selection(void)
Definition: table_selection.cpp:203
TSG_ADD_Shape_Copy_Mode
TSG_ADD_Shape_Copy_Mode
Definition: shapes.h:124
SG_Create_PointCloud
SAGA_API_DLL_EXPORT CSG_PointCloud * SG_Create_PointCloud(void)
Definition: pointcloud.cpp:76
CSG_PointCloud::Get_Attribute_Type
TSG_Data_Type Get_Attribute_Type(int Field) const
Definition: pointcloud.h:154
CSG_Table::Get_Value
virtual bool Get_Value(sLong Index, int iField, CSG_String &Value) const
Definition: table.cpp:1157
CSG_PointCloud::Get_Attribute
double Get_Attribute(int Field) const
Definition: pointcloud.h:170
CSG_Table::is_Selected
virtual bool is_Selected(sLong Index) const
Definition: table.h:424
CSG_Table::Del_Field
virtual bool Del_Field(int iField)
Definition: table.cpp:520
CSG_Table::Get_Record
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition: table.h:394
CSG_PointCloud::Get_Value
virtual double Get_Value(sLong Index, int Field) const
Definition: pointcloud.h:175
CSG_PointCloud::Set_XYZ_Precision
void Set_XYZ_Precision(bool bDouble)
Definition: pointcloud.h:136
SSG_Point_3D
Definition: geo_tools.h:264
CSG_PointCloud::Set_Value
virtual bool Set_Value(int Field, const SG_Char *Value)
Definition: pointcloud.h:184
CSG_Data_Object::is_NoData_Value
bool is_NoData_Value(double Value) const
Definition: dataobject.h:255
CSG_PointCloud::Get_Value
virtual bool Get_Value(sLong Index, int Field, CSG_String &Value) const
Definition: pointcloud.h:187
CSG_Shapes::_On_Construction
virtual void _On_Construction(void)
Definition: shapes.cpp:188
SHAPE_COPY
@ SHAPE_COPY
Definition: shapes.h:128
CSG_PointCloud::Get_Value
virtual bool Get_Value(int Field, CSG_String &Value) const
Definition: pointcloud.h:185
SSG_Point
Definition: geo_tools.h:128
CSG_File
Definition: api_core.h:1124
CSG_PointCloud::Get_Attribute_Count
int Get_Attribute_Count(void) const
Definition: pointcloud.h:152
CSG_PointCloud::Set_Attribute
virtual bool Set_Attribute(int Field, const SG_Char *Value)
Definition: pointcloud.h:188
SSG_Rect
Definition: geo_tools.h:464
CSG_PointCloud::Set_Value
virtual bool Set_Value(int Field, double Value)
Definition: pointcloud.h:164
CSG_Shapes::Add_Shape
virtual CSG_Shape * Add_Shape(CSG_Table_Record *pCopy=NULL, TSG_ADD_Shape_Copy_Mode mCopy=SHAPE_COPY)
Definition: shapes.cpp:418
CSG_Table::is_Compatible
bool is_Compatible(const CSG_Table &Table, bool bExactMatch=false) const
Definition: table.cpp:430
CSG_Data_Object
Definition: dataobject.h:180
CSG_Point
Definition: geo_tools.h:135
CSG_Shapes::Get_Selection_Extent
virtual const CSG_Rect & Get_Selection_Extent(void)
Definition: shapes_selection.cpp:118
CSG_PointCloud::Get_Attribute
virtual bool Get_Attribute(int Field, CSG_String &Value) const
Definition: pointcloud.h:189
CSG_Shapes::Save
virtual bool Save(const CSG_String &File, int Format=0)
Definition: shapes_io.cpp:141
CSG_PointCloud::Get_Value
virtual double Get_Value(int Field) const
Definition: pointcloud.h:165
CSG_Point_3D
Definition: geo_tools.h:271
CSG_PointCloud::Get_ObjectType
virtual TSG_Data_Object_Type Get_ObjectType(void) const
Returns the object type as defined by TSG_Data_Object_Type. Used for run time type checking.
Definition: pointcloud.h:128
sLong
signed long long sLong
Definition: api_core.h:158
CSG_PointCloud::Get_Z
double Get_Z(void) const
Definition: pointcloud.h:168
CSG_PointCloud::Get_Attribute
double Get_Attribute(sLong Index, int Field) const
Definition: pointcloud.h:180
CSG_PointCloud::Save
virtual bool Save(const char *File, int Format=0)
Definition: pointcloud.h:133
CSG_Table::Mov_Field
virtual bool Mov_Field(int iField, int Position)
Definition: table.cpp:558
CSG_PointCloud::Save
virtual bool Save(const wchar_t *File, int Format=0)
Definition: pointcloud.h:134
SAGA_API_DLL_EXPORT
#define SAGA_API_DLL_EXPORT
Definition: api_core.h:94
CSG_Data_Object::Set_Modified
virtual void Set_Modified(bool bOn=true)
Definition: dataobject.h:227
CSG_Table::Set_Value
virtual bool Set_Value(sLong Index, int iField, const SG_Char *Value)
Definition: table.cpp:1131
CSG_PointCloud::Set_Modified
virtual void Set_Modified(bool bModified=true)
Definition: pointcloud.h:198
CSG_PointCloud::Set_Attribute
virtual bool Set_Attribute(sLong Index, int Field, const SG_Char *Value)
Definition: pointcloud.h:190
CSG_PointCloud::is_Valid
virtual bool is_Valid(void) const
Definition: pointcloud.h:141
CSG_PointCloud::Set_NoData
bool Set_NoData(int Field)
Definition: pointcloud.h:171
CSG_PointCloud::Set_Cursor
bool Set_Cursor(sLong Index)
Definition: pointcloud.h:163
CSG_PointCloud::Del_Records
virtual bool Del_Records(void)
Definition: pointcloud.h:210
CSG_Table::Add_Field
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition: table.cpp:481
CSG_PointCloud::Set_Attribute
bool Set_Attribute(int Field, double Value)
Definition: pointcloud.h:169
CSG_PointCloud::is_NoData
bool is_NoData(int Field) const
Definition: pointcloud.h:172
CSG_PointCloud::is_NoData
bool is_NoData(sLong Index, int Field) const
Definition: pointcloud.h:182
SG_Char
#define SG_Char
Definition: api_core.h:536
TSG_Data_Object_Type
TSG_Data_Object_Type
Definition: dataobject.h:117
CSG_Array
Definition: api_core.h:308
shapes.h
CSG_String
Definition: api_core.h:563
CSG_MetaData
Definition: metadata.h:88
CSG_PointCloud::Set_Value
virtual bool Set_Value(sLong Index, int Field, const SG_Char *Value)
Definition: pointcloud.h:186
POINTCLOUD_FILE_FORMAT_Compressed
@ POINTCLOUD_FILE_FORMAT_Compressed
Definition: pointcloud.h:92
CSG_Shapes::Destroy
virtual bool Destroy(void)
Definition: shapes.cpp:347
POINTCLOUD_FILE_FORMAT_Undefined
@ POINTCLOUD_FILE_FORMAT_Undefined
Definition: pointcloud.h:90
CSG_PointCloud::Get_Y
double Get_Y(sLong Index) const
Definition: pointcloud.h:177
CSG_Table::Ins_Record
virtual CSG_Table_Record * Ins_Record(sLong Index, CSG_Table_Record *pCopy=NULL)
Definition: table.cpp:801
CSG_Table::Create
bool Create(void)
Definition: table.cpp:139
CSG_Shapes
Definition: shapes.h:775
CSG_PointCloud
Definition: pointcloud.h:105
TSG_Data_Type
TSG_Data_Type
Definition: api_core.h:993
CSG_PointCloud::Get_Attribute_Name
const SG_Char * Get_Attribute_Name(int Field) const
Definition: pointcloud.h:153
CSG_Shapes::On_Update
virtual bool On_Update(void)
Definition: shapes.cpp:449
CSG_Table::Add_Record
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
Definition: table.cpp:795
CSG_PointCloud::Set_NoData
bool Set_NoData(sLong Index, int Field)
Definition: pointcloud.h:181
CSG_Table::Del_Selection
virtual sLong Del_Selection(void)
Definition: table_selection.cpp:178
CSG_PointCloud::Del_Shape
virtual bool Del_Shape(sLong Index)
Definition: pointcloud.h:209
CSG_Shape
Definition: shapes.h:141
CSG_Shapes::Select
virtual bool Select(sLong Index, bool bInvert=false)
Definition: shapes_selection.cpp:63
CSG_Table::Set_Field_Type
virtual bool Set_Field_Type(int iField, TSG_Data_Type Type)
Definition: table.cpp:626
SG_DATAOBJECT_TYPE_PointCloud
@ SG_DATAOBJECT_TYPE_PointCloud
Definition: dataobject.h:123
CSG_PointCloud::Get_Attribute
virtual bool Get_Attribute(sLong Index, int Field, CSG_String &Value) const
Definition: pointcloud.h:191
CSG_PointCloud::Del_Record
virtual bool Del_Record(sLong Index)
Definition: pointcloud.h:208