SAGA API v9.10
Loading...
Searching...
No Matches
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//---------------------------------------------------------
69
70
72// //
73// //
74// //
76
77//---------------------------------------------------------
78#include "shapes.h"
79
80
82// //
83// //
84// //
86
87//---------------------------------------------------------
95
96
98// //
99// //
100// //
102
103//---------------------------------------------------------
105{
106public:
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, bool bProgress = false);
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 int Get_Field_Length (int Field, int Encoding = SG_FILE_ENCODING_UNDEFINED) const;
150 virtual bool Set_Field_Type (int Field, TSG_Data_Type Type);
151
152 //-----------------------------------------------------
153 int Get_Attribute_Count (void) const { return( m_nFields - 3 ); }
154 const SG_Char * Get_Attribute_Name (int Field) const { Field += 3; return( Field >= 3 && Field < m_nFields ? m_Field_Info[Field]->m_Name.c_str() : NULL ); }
155 TSG_Data_Type Get_Attribute_Type (int Field) const { Field += 3; return( Field >= 3 && Field < m_nFields ? m_Field_Info[Field]->m_Type : SG_DATATYPE_Undefined ); }
156 int Get_Attribute_Length(int Field, int Encoding = SG_FILE_ENCODING_UNDEFINED) const { return( Get_Field_Length(Field + 3) ); }
157
158 //-----------------------------------------------------
159 bool Add_Point (double x, double y, double z);
160 bool Add_Point (const CSG_Point_3D &Point);
161 bool Del_Point (sLong Index);
162 bool Del_Points (void);
163
164 //-----------------------------------------------------
165 bool Set_Cursor (sLong Index) { return( (m_Cursor = Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL) != NULL ); }
166 virtual bool Set_Value ( int Field, double Value) { return( _Set_Field_Value(m_Cursor, Field, Value) ); }
167 virtual double Get_Value ( int Field) const { return( _Get_Field_Value(m_Cursor, Field) ); }
168 double Get_X (void) const { return( _Get_Field_Value(m_Cursor, 0) ); }
169 double Get_Y (void) const { return( _Get_Field_Value(m_Cursor, 1) ); }
170 double Get_Z (void) const { return( _Get_Field_Value(m_Cursor, 2) ); }
171 bool Set_Attribute ( int Field, double Value) { return( Set_Value(Field + 3, Value) ); }
172 double Get_Attribute ( int Field) const { return( Get_Value(Field + 3) ); }
173 bool Set_NoData ( int Field) { return( Set_Value(Field, Get_NoData_Value()) ); }
174 bool is_NoData ( int Field) const { return( is_NoData_Value(Get_Value(Field)) ); }
175
176 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) ); }
177 virtual double Get_Value (sLong Index, int Field) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, Field) ); }
178 double Get_X (sLong Index) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, 0) ); }
179 double Get_Y (sLong Index) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, 1) ); }
180 double Get_Z (sLong Index) const { return( _Get_Field_Value(Index >= 0 && Index < m_nRecords ? m_Points[Index] : NULL, 2) ); }
181 bool Set_Attribute (sLong Index, int Field, double Value) { return( Set_Value(Index, Field + 3, Value) ); }
182 double Get_Attribute (sLong Index, int Field) const { return( Get_Value(Index, Field + 3) ); }
183 bool Set_NoData (sLong Index, int Field) { return( Set_Value(Index, Field, Get_NoData_Value()) );}
184 bool is_NoData (sLong Index, int Field) const { return( is_NoData_Value(Get_Value(Index, Field)) ); }
185
186 virtual bool Get_Value (sLong Index, int Field, double &Value) const { if( Index >= 0 && Index < m_nRecords ) { Value = _Get_Field_Value(m_Points[Index], Field); return( !is_NoData_Value(Value) ); } return( false ); }
187 virtual bool Get_Attribute (sLong Index, int Field, double &Value) const { return( Get_Value(Index, Field + 3, Value) ); }
188
189 virtual bool Set_Value ( int Field, const SG_Char *Value) { return( _Set_Field_Value(m_Cursor, Field, Value) ); }
190 virtual bool Get_Value ( int Field, CSG_String &Value) const { return( _Get_Field_Value(m_Cursor, Field, Value) ); }
191 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) ); }
192 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) ); }
193 virtual bool Set_Attribute ( int Field, const SG_Char *Value) { return( Set_Value(Field + 3, Value) ); }
194 virtual bool Get_Attribute ( int Field, CSG_String &Value) const { return( Get_Value(Field + 3, Value) ); }
195 virtual bool Set_Attribute (sLong Index, int Field, const SG_Char *Value) { return( Set_Value(Index, Field + 3, Value) ); }
196 virtual bool Get_Attribute (sLong Index, int Field, CSG_String &Value) const { return( Get_Value(Index, Field + 3, Value) ); }
197
198 sLong Get_Point (const CSG_Point &Point, double Epsilon = 0.);
199 TSG_Point_3D Get_Point (void) const;
200 TSG_Point_3D Get_Point (sLong Index) const;
201 virtual bool Set_Point ( const TSG_Point_3D &Point);
202 virtual bool Set_Point (sLong Index, const TSG_Point_3D &Point);
203
204 virtual void Set_Modified (bool bModified = true) { CSG_Data_Object::Set_Modified(bModified); }
205
206
207 //-----------------------------------------------------
208 // Overrides: CSG_Table, CSG_Shapes
209
210 virtual CSG_Table_Record * Get_Record (sLong Index) const;
211
212 virtual CSG_Shape * Get_Shape (const CSG_Point &Point, double Epsilon = 0.);
213
214 virtual bool Del_Record (sLong Index) { return( Del_Point(Index) ); }
215 virtual bool Del_Shape (sLong Index) { return( Del_Point(Index) ); }
216 virtual bool Del_Records (void) { return( Del_Points() ); }
217 virtual bool Del_Shapes (void) { return( Del_Points() ); }
218
219 virtual CSG_Table_Record * Ins_Record (sLong Index, CSG_Table_Record *pCopy = NULL);
220 virtual CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL);
221 virtual CSG_Shape * Add_Shape ( CSG_Table_Record *pCopy = NULL, TSG_ADD_Shape_Copy_Mode mCopy = SHAPE_COPY);
222 virtual bool Del_Shape (CSG_Shape *pShape) { return( false ); }
223
224 virtual bool Select (sLong Index , bool bInvert = false);
225 virtual bool Select (CSG_Table_Record *pShape = NULL, bool bInvert = false);
226 virtual bool Select (const TSG_Rect &Extent , bool bInvert = false);
227 virtual bool Select (const TSG_Point &Point , bool bInvert = false);
228
229 virtual bool is_Selected (sLong Index) const;
230
231 virtual sLong Del_Selection (void);
232 virtual sLong Inv_Selection (void);
233 virtual CSG_Table_Record * Get_Selection (sLong Index = 0) const;
234 virtual const CSG_Rect & Get_Selection_Extent(void);
235
236 virtual bool Sort (const CSG_Index &Index);
237
238
239protected:
240
241 virtual bool On_Update (void);
242 virtual bool On_Reload (void);
243 virtual bool On_Delete (void);
244
245 virtual void _On_Construction (void);
246
247 virtual bool _Stats_Update (int Field) const;
248
249
250private:
251
252 bool m_bXYZPrecDbl = true;
253
254 char **m_Points = NULL, *m_Cursor = NULL;
255
256 int m_nPointBytes = 0, *m_Field_Offset = NULL;
257
258 CSG_Array m_Array_Points;
259
260 CSG_Shapes m_Shapes;
261
262
263 bool _Load (const CSG_String &File);
264 bool _Load (CSG_File &Stream);
265 bool _Save (CSG_File &Stream);
266 CSG_MetaData _Create_Header (void) const;
267
268 bool _Add_Field (const SG_Char *Name, TSG_Data_Type Type, int Field = -1);
269 bool _Set_Field_Value (char *pPoint, int Field, double Value);
270 double _Get_Field_Value (char *pPoint, int Field ) const;
271 bool _Set_Field_Value (char *pPoint, int Field, const SG_Char *Value);
272 bool _Get_Field_Value (char *pPoint, int Field, CSG_String &Value) const;
273
274 bool _Inc_Array (void);
275 bool _Dec_Array (void);
276
277 CSG_Shape * _Shape_Get (sLong Index);
278 void _Shape_Flush (void);
279
280};
281
282
284// //
285// //
286// //
288
289//---------------------------------------------------------
292
295
302
305
307// //
308// //
309// //
311
312//---------------------------------------------------------
313#endif // #ifndef HEADER_INCLUDED__SAGA_API__pointcloud_H
signed long long sLong
Definition api_core.h:158
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
TSG_Data_Type
Definition api_core.h:997
@ SG_DATATYPE_Undefined
Definition api_core.h:1013
#define SG_Char
Definition api_core.h:536
@ SG_FILE_ENCODING_UNDEFINED
Definition api_core.h:557
bool is_NoData_Value(double Value) const
Definition dataobject.h:255
double Get_NoData_Value(bool bUpper=false) const
Definition dataobject.h:253
virtual void Set_Modified(bool bOn=true)
Definition dataobject.h:227
bool Del_Point(sLong Index)
bool Set_Attribute(int Field, double Value)
Definition pointcloud.h:171
double Get_Z(void) const
Definition pointcloud.h:170
double Get_Attribute(int Field) const
Definition pointcloud.h:172
double Get_Y(sLong Index) const
Definition pointcloud.h:179
bool Set_Cursor(sLong Index)
Definition pointcloud.h:165
virtual bool Get_Value(sLong Index, int Field, double &Value) const
Definition pointcloud.h:186
virtual bool Del_Shapes(void)
Definition pointcloud.h:217
virtual bool Get_Attribute(int Field, CSG_String &Value) const
Definition pointcloud.h:194
bool is_NoData(sLong Index, int Field) const
Definition pointcloud.h:184
double Get_X(sLong Index) const
Definition pointcloud.h:178
int Get_Attribute_Length(int Field, int Encoding=SG_FILE_ENCODING_UNDEFINED) const
Definition pointcloud.h:156
virtual bool Get_Value(int Field, CSG_String &Value) const
Definition pointcloud.h:190
const SG_Char * Get_Attribute_Name(int Field) const
Definition pointcloud.h:154
virtual void Set_Modified(bool bModified=true)
Definition pointcloud.h:204
virtual bool Del_Record(sLong Index)
Definition pointcloud.h:214
int Get_Attribute_Count(void) const
Definition pointcloud.h:153
virtual double Get_Value(int Field) const
Definition pointcloud.h:167
virtual bool Set_Attribute(int Field, const SG_Char *Value)
Definition pointcloud.h:193
virtual bool Get_Value(sLong Index, int Field, CSG_String &Value) const
Definition pointcloud.h:192
virtual bool Set_Value(int Field, const SG_Char *Value)
Definition pointcloud.h:189
bool Set_Attribute(sLong Index, int Field, double Value)
Definition pointcloud.h:181
double Get_Z(sLong Index) const
Definition pointcloud.h:180
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
TSG_Data_Type Get_Attribute_Type(int Field) const
Definition pointcloud.h:155
bool Del_Points(void)
bool Set_NoData(sLong Index, int Field)
Definition pointcloud.h:183
virtual bool Set_Attribute(sLong Index, int Field, const SG_Char *Value)
Definition pointcloud.h:195
virtual bool Set_Value(sLong Index, int Field, double Value)
Definition pointcloud.h:176
virtual bool Set_Value(int Field, double Value)
Definition pointcloud.h:166
virtual bool is_Valid(void) const
Definition pointcloud.h:141
virtual bool Save(const wchar_t *File, int Format=0)
Definition pointcloud.h:134
virtual bool Del_Shape(sLong Index)
Definition pointcloud.h:215
virtual bool Get_Attribute(sLong Index, int Field, double &Value) const
Definition pointcloud.h:187
bool is_NoData(int Field) const
Definition pointcloud.h:174
double Get_X(void) const
Definition pointcloud.h:168
virtual double Get_Value(sLong Index, int Field) const
Definition pointcloud.h:177
virtual bool Del_Shape(CSG_Shape *pShape)
Definition pointcloud.h:222
virtual bool Set_Value(sLong Index, int Field, const SG_Char *Value)
Definition pointcloud.h:191
double Get_Attribute(sLong Index, int Field) const
Definition pointcloud.h:182
virtual bool Get_Attribute(sLong Index, int Field, CSG_String &Value) const
Definition pointcloud.h:196
virtual bool Del_Records(void)
Definition pointcloud.h:216
bool Set_NoData(int Field)
Definition pointcloud.h:173
virtual bool Save(const char *File, int Format=0)
Definition pointcloud.h:133
double Get_Y(void) const
Definition pointcloud.h:169
void Set_XYZ_Precision(bool bDouble)
Definition pointcloud.h:136
virtual bool Assign(CSG_Data_Object *pObject, bool bProgress=false)
Definition shapes.cpp:351
virtual CSG_Shape * Add_Shape(CSG_Table_Record *pCopy=NULL, TSG_ADD_Shape_Copy_Mode mCopy=SHAPE_COPY)
Definition shapes.cpp:402
virtual bool On_Delete(void)
Definition shapes_io.cpp:72
virtual bool Save(const CSG_String &File, int Format=0)
CSG_Shapes(void)
Definition shapes.cpp:156
virtual CSG_Shape * Get_Shape(const CSG_Point &Point, double Epsilon=0.)
Definition shapes.cpp:483
virtual void _On_Construction(void)
Definition shapes.cpp:193
TSG_Shape_Type m_Type
Definition shapes.h:843
virtual bool Destroy(void)
Definition shapes.cpp:331
virtual const CSG_Rect & Get_Selection_Extent(void)
friend class CSG_Shape
Definition shapes.h:773
virtual bool On_Update(void)
Definition shapes.cpp:433
virtual bool Select(sLong Index, bool bInvert=false)
virtual bool On_Reload(void)
Definition shapes_io.cpp:66
bool Create(void)
Definition table.cpp:153
virtual CSG_Table_Record * Ins_Record(sLong Index, CSG_Table_Record *pCopy=NULL)
Definition table.cpp:829
virtual bool _Stats_Update(int Field) const
Definition table.cpp:1252
sLong m_nRecords
Definition table.h:489
bool is_Compatible(const CSG_Table &Table, bool bExactMatch=false) const
Definition table.cpp:413
CSG_Field_Info ** m_Field_Info
Definition table.h:485
virtual bool Get_Value(sLong Index, int Field, CSG_String &Value) const
Definition table.cpp:1185
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
Definition table.cpp:823
virtual sLong Inv_Selection(void)
virtual bool Mov_Field(int Field, int Position)
Definition table.cpp:542
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition table.h:402
virtual int Get_Field_Length(int Field, int Encoding=SG_FILE_ENCODING_UNDEFINED) const
Definition table.cpp:674
virtual CSG_Table_Record * Get_Selection(sLong Index=0) const
Definition table.h:430
bool Sort(const char *Field, bool bAscending=true)
Definition table.cpp:1352
virtual bool is_Selected(sLong Index) const
Definition table.h:432
int m_nFields
Definition table.h:487
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition table.cpp:479
virtual bool Set_Value(sLong Index, int Field, const SG_Char *Value)
Definition table.cpp:1159
virtual bool Set_Field_Type(int Field, TSG_Data_Type Type)
Definition table.cpp:610
virtual bool Del_Field(int Field)
Definition table.cpp:510
virtual sLong Del_Selection(void)
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_PointCloud
Definition dataobject.h:123
struct SSG_Point TSG_Point
struct SSG_Point_3D TSG_Point_3D
struct SSG_Rect TSG_Rect
TSG_PointCloud_File_Type
Definition pointcloud.h:89
@ POINTCLOUD_FILE_FORMAT_Compressed
Definition pointcloud.h:92
@ POINTCLOUD_FILE_FORMAT_Undefined
Definition pointcloud.h:90
@ POINTCLOUD_FILE_FORMAT_Normal
Definition pointcloud.h:91
SAGA_API_DLL_EXPORT CSG_PointCloud * SG_Create_PointCloud(void)
TSG_ADD_Shape_Copy_Mode
Definition shapes.h:124
@ SHAPE_COPY
Definition shapes.h:128