SAGA API v9.10
Loading...
Searching...
No Matches
tin.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// tin.h //
15// //
16// Copyright (C) 2005 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 Goettingen //
44// Goldschmidtstr. 5 //
45// 37077 Goettingen //
46// Germany //
47// //
48// e-mail: oconrad@saga-gis.org //
49// //
51
52//---------------------------------------------------------
53#ifndef HEADER_INCLUDED__SAGA_API__tin_H
54#define HEADER_INCLUDED__SAGA_API__tin_H
55
56
58// //
59// //
60// //
62
63//---------------------------------------------------------
73
74
76// //
77// //
78// //
80
81//---------------------------------------------------------
82#include "shapes.h"
83
84
86// //
87// //
88// //
90
91//---------------------------------------------------------
92class SAGA_API_DLL_EXPORT CSG_TIN_Node : public CSG_Table_Record
93{
94 friend class CSG_TIN;
95
96public:
97
98 int Get_ID (void) { return( m_ID ); }
99
100 const TSG_Point & Get_Point (void) { return( m_Point ); }
101 double Get_X (void) { return( m_Point.x ); }
102 double Get_Y (void) { return( m_Point.y ); }
103
104 int Get_Neighbor_Count (void) { return( m_nNeighbors ); }
105 CSG_TIN_Node * Get_Neighbor (int iNeighbor) { return( iNeighbor >= 0 && iNeighbor < m_nNeighbors ? m_Neighbors[iNeighbor] : NULL ); }
106 double Get_Gradient (int iNeighbor, int iField);
107
108 int Get_Triangle_Count (void) { return( m_nTriangles ); }
109 class CSG_TIN_Triangle * Get_Triangle (int iTriangle) { return( iTriangle >= 0 && iTriangle < m_nTriangles ? m_Triangles[iTriangle] : NULL ); }
110
111 bool Get_Polygon (CSG_Points &Points);
112 double Get_Polygon_Area (void);
113
114
115private:
116
117 CSG_TIN_Node(CSG_TIN *pOwner, sLong Index);
118 virtual ~CSG_TIN_Node(void);
119
120
121 int m_ID, m_nNeighbors, m_nTriangles;
122
123 TSG_Point m_Point;
124
125 CSG_TIN_Node **m_Neighbors;
126
127 class CSG_TIN_Triangle **m_Triangles;
128
129
130 bool _Add_Neighbor (CSG_TIN_Node *pNeighbor);
131 bool _Add_Triangle (class CSG_TIN_Triangle *pTriangle);
132
133 bool _Del_Relations (void);
134
135};
136
137
139// //
140// //
141// //
143
144//---------------------------------------------------------
145class SAGA_API_DLL_EXPORT CSG_TIN_Edge
146{
147 friend class CSG_TIN;
148
149public:
150
151 CSG_TIN_Node * Get_Node (int iNode) { return( m_Nodes[iNode % 2] ); }
152
153
154private:
155
157 virtual ~CSG_TIN_Edge(void);
158
159
160 CSG_TIN_Node *m_Nodes[2];
161
162};
163
164
166// //
167// //
168// //
170
171//---------------------------------------------------------
172class SAGA_API_DLL_EXPORT CSG_TIN_Triangle
173{
174 friend class CSG_TIN;
175
176public:
177
178 CSG_TIN_Node * Get_Node (int iNode) { return( m_Nodes[iNode % 3] ); }
179
180 const CSG_Rect & Get_Extent (void) { return( m_Extent ); }
181
182 double Get_Area (void) { return( m_Area ); }
183
184 bool is_Containing (const TSG_Point &p);
185 bool is_Containing (double x, double y);
186
187 bool Get_Value (int zField, const TSG_Point &p, double &z);
188 bool Get_Value (int zField, double x, double y, double &z);
189
190 bool Get_Gradient (int zField, double &Decline, double &Azimuth);
191
192 void Get_CircumCircle (TSG_Point &Point, double &Radius) { Point = m_Center; Radius = m_Radius; }
193 double Get_CircumCircle_Radius (void) { return( m_Radius ); }
194 TSG_Point Get_CircumCircle_Point (void) { return( m_Center ); }
195
196
197private:
198
200 virtual ~CSG_TIN_Triangle(void);
201
202
203 double m_Area, m_Radius;
204
205 TSG_Point m_Center;
206
207 CSG_Rect m_Extent;
208
209 CSG_TIN_Node *m_Nodes[3];
210
211};
212
213
215// //
216// //
217// //
219
220//---------------------------------------------------------
222{
223public:
224
225 CSG_TIN(void);
226
227 CSG_TIN (const CSG_TIN &TIN);
228 bool Create (const CSG_TIN &TIN);
229
230 CSG_TIN (CSG_Shapes *pShapes);
231 bool Create (CSG_Shapes *pShapes);
232
233 CSG_TIN (const CSG_String &File);
234 bool Create (const CSG_String &File);
235 CSG_TIN (const char *File);
236 bool Create (const char *File);
237 CSG_TIN (const wchar_t *File);
238 bool Create (const wchar_t *File);
239
240 virtual ~CSG_TIN(void);
241
242 virtual bool Destroy (void);
243
245
246 virtual bool Save (const CSG_String &File, int Format = 0);
247 virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
248 virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
249
250 virtual bool Assign (CSG_Data_Object *pObject, bool bProgress = false);
251
252 virtual bool is_Valid (void) const { return( Get_Count() >= 3 ); }
253
254 const CSG_Rect & Get_Extent (void) { Update(); return( m_Extent ); }
255
256 bool Triangulate (bool bOn = true, bool bUpdate = false);
257
258 //-----------------------------------------------------
259 CSG_TIN_Node * Add_Node (const TSG_Point &Point, CSG_Table_Record *pRecord = NULL, bool bUpdateNow = false);
260 bool Del_Node (sLong Index, bool bUpdateNow);
261
262 sLong Get_Node_Count (void) const { return( Get_Count() ); }
263 CSG_TIN_Node * Get_Node (sLong Index) const { return( (CSG_TIN_Node *)Get_Record(Index) ); }
264
265 sLong Get_Edge_Count (void) const { return( m_nEdges ); }
266 CSG_TIN_Edge * Get_Edge (sLong Index) const { return( Index >= 0 && Index < m_nEdges ? m_Edges[Index] : NULL ); }
267
268 sLong Get_Triangle_Count (void) const { return( m_nTriangles ); }
269 CSG_TIN_Triangle * Get_Triangle (sLong Index) const { return( Index >= 0 && Index < m_nTriangles ? m_Triangles[Index] : NULL ); }
270 CSG_TIN_Triangle * Add_Triangle (CSG_TIN_Node *p0, CSG_TIN_Node *p1, CSG_TIN_Node *p2);
271 CSG_TIN_Triangle * Add_Triangle (CSG_TIN_Node *p[3]);
272
273
274protected:
275
276 typedef struct
277 {
278 int p1, p2;
279 }
280 TTIN_Edge;
281
282 typedef struct
283 {
284 int p1, p2, p3;
285 }
287
288
289protected:
290
291 bool m_bTriangulate{true};
292
294
296
298
300
301
302 virtual bool On_Update (void);
303 virtual bool On_Reload (void);
304 virtual bool On_Delete (void);
305
306 void _On_Construction (void);
307
308 virtual CSG_Table_Record * _Get_New_Record (sLong Index);
309
310 bool _Destroy_Nodes (void);
311 bool _Destroy_Edges (void);
312 bool _Destroy_Triangles (void);
313
316
317 bool _Triangulate (void);
318 bool _Triangulate (CSG_TIN_Node **Nodes, int nNodes, TTIN_Triangle *Triangles, int &nTriangles);
319 int _CircumCircle (double xp, double yp, double x1, double y1, double x2, double y2, double x3, double y3, double *xc, double *yc, double *r);
320
321};
322
323
325// //
326// //
327// //
329
330//---------------------------------------------------------
333
336
339
341SAGA_API_DLL_EXPORT CSG_TIN * SG_Create_TIN (const char *File);
343SAGA_API_DLL_EXPORT CSG_TIN * SG_Create_TIN (const wchar_t *File);
346
347
349// //
350// //
351// //
353
354//---------------------------------------------------------
355#endif // #ifndef HEADER_INCLUDED__SAGA_API__tin_H
signed long long sLong
Definition api_core.h:158
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
bool Update(bool bForce=false)
friend class CSG_TIN
Definition tin.h:147
CSG_TIN_Node * Get_Node(int iNode)
Definition tin.h:151
class CSG_TIN_Triangle * Get_Triangle(int iTriangle)
Definition tin.h:109
int Get_Neighbor_Count(void)
Definition tin.h:104
CSG_TIN_Node * Get_Neighbor(int iNeighbor)
Definition tin.h:105
double Get_Y(void)
Definition tin.h:102
const TSG_Point & Get_Point(void)
Definition tin.h:100
friend class CSG_TIN
Definition tin.h:94
double Get_X(void)
Definition tin.h:101
int Get_ID(void)
Definition tin.h:98
int Get_Triangle_Count(void)
Definition tin.h:108
CSG_TIN_Node * Get_Node(int iNode)
Definition tin.h:178
double Get_Area(void)
Definition tin.h:182
friend class CSG_TIN
Definition tin.h:174
TSG_Point Get_CircumCircle_Point(void)
Definition tin.h:194
const CSG_Rect & Get_Extent(void)
Definition tin.h:180
void Get_CircumCircle(TSG_Point &Point, double &Radius)
Definition tin.h:192
double Get_CircumCircle_Radius(void)
Definition tin.h:193
Definition tin.h:222
CSG_TIN_Edge * Get_Edge(sLong Index) const
Definition tin.h:266
void _On_Construction(void)
Definition tin.cpp:138
virtual bool On_Reload(void)
Definition tin.cpp:549
CSG_TIN_Triangle * Get_Triangle(sLong Index) const
Definition tin.h:269
CSG_TIN_Triangle * _Add_Triangle(CSG_TIN_Node *a, CSG_TIN_Node *b, CSG_TIN_Node *c)
Definition tin.cpp:481
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 tin.h:244
CSG_TIN_Triangle ** m_Triangles
Definition tin.h:299
sLong Get_Edge_Count(void) const
Definition tin.h:265
CSG_Rect m_Extent
Definition tin.h:295
sLong Get_Node_Count(void) const
Definition tin.h:262
virtual bool Save(const char *File, int Format=0)
Definition tin.h:247
virtual bool is_Valid(void) const
Definition tin.h:252
CSG_TIN_Node * Get_Node(sLong Index) const
Definition tin.h:263
CSG_TIN_Edge * _Add_Edge(CSG_TIN_Node *a, CSG_TIN_Node *b)
Definition tin.cpp:470
CSG_TIN_Edge ** m_Edges
Definition tin.h:297
virtual bool On_Update(void)
Definition tin.cpp:519
bool _Destroy_Edges(void)
Definition tin.cpp:258
virtual CSG_Table_Record * _Get_New_Record(sLong Index)
Definition tin.cpp:409
bool _Destroy_Triangles(void)
Definition tin.cpp:274
virtual bool Save(const wchar_t *File, int Format=0)
Definition tin.h:248
int _CircumCircle(double xp, double yp, double x1, double y1, double x2, double y2, double x3, double y3, double *xc, double *yc, double *r)
bool _Triangulate(void)
CSG_TIN(void)
Definition tin.cpp:103
sLong m_nTriangles
Definition tin.h:293
virtual bool Destroy(void)
Definition tin.cpp:235
virtual bool On_Delete(void)
Definition tin.cpp:555
bool Create(const CSG_TIN &TIN)
Definition tin.cpp:152
sLong m_nEdges
Definition tin.h:293
bool _Destroy_Nodes(void)
Definition tin.cpp:252
bool m_bTriangulate
Definition tin.h:291
sLong Get_Triangle_Count(void) const
Definition tin.h:268
const CSG_Rect & Get_Extent(void)
Definition tin.h:254
CSG_Table_Record(class CSG_Table *pTable, sLong Index)
virtual bool Assign(CSG_Table_Record *pRecord)
CSG_Table_Value * Get_Value(int Field)
Definition table.h:239
sLong Get_Count(void) const
Definition table.h:400
CSG_Table(void)
Definition table.cpp:147
friend class CSG_Table_Record
Definition table.h:286
virtual CSG_Table_Record * Get_Record(sLong Index) const
Definition table.h:402
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_TIN
Definition dataobject.h:122
struct SSG_Point TSG_Point
SAGA_API_DLL_EXPORT CSG_TIN * SG_Create_TIN(void)
Definition tin.cpp:63