SAGA API v9.10
Loading...
Searching...
No Matches
shapes.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// shapes.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__shapes_H
54#define HEADER_INCLUDED__SAGA_API__shapes_H
55
56
58// //
59// //
60// //
62
63//---------------------------------------------------------
71
72
74// //
75// //
76// //
78
79//---------------------------------------------------------
80#include "table.h"
81
82
84// //
85// //
86// //
88
89//---------------------------------------------------------
97
98//---------------------------------------------------------
108
109//---------------------------------------------------------
111
112//---------------------------------------------------------
121
122//---------------------------------------------------------
131
132
134// //
135// //
136// //
138
139//---------------------------------------------------------
141{
142 friend class CSG_Shapes;
143
144public:
145
146 virtual void Destroy (void);
147
148 virtual bool Assign (CSG_Table_Record *pRecord);
149 virtual bool Assign (CSG_Table_Record *pRecord, bool bAssign_Attributes);
150 virtual bool Assign (CSG_Table_Record *pRecord, TSG_ADD_Shape_Copy_Mode mCopy);
151
152 TSG_Shape_Type Get_Type (void) const;
153 TSG_Vertex_Type Get_Vertex_Type (void) const;
154
155 class CSG_Shape_Point * asPoint (void) const { return( Get_Type() == SHAPE_TYPE_Point ? (CSG_Shape_Point *)this : NULL ); }
156 class CSG_Shape_Points * asPoints (void) const { return( Get_Type() == SHAPE_TYPE_Points ? (CSG_Shape_Points *)this : NULL ); }
157 class CSG_Shape_Line * asLine (void) const { return( Get_Type() == SHAPE_TYPE_Line ? (CSG_Shape_Line *)this : NULL ); }
158 class CSG_Shape_Polygon * asPolygon (void) const { return( Get_Type() == SHAPE_TYPE_Polygon ? (CSG_Shape_Polygon *)this : NULL ); }
159
160 //-----------------------------------------------------
161 virtual int Get_Point_Count (void) const = 0;
162 virtual int Get_Point_Count (int iPart) const = 0;
163 virtual int Get_Part_Count (void) const = 0;
164
165 virtual int Add_Part (class CSG_Shape_Part *pPart, bool bRevert = false) { return( -1 ); }
166 virtual CSG_Shape_Part * Get_Part (int iPart) const { return( NULL ); }
167 virtual int Del_Part (int iPart) { return( -1 ); }
168 virtual int Del_Parts (void) { return( -1 ); }
169
170 virtual int Add_Point (double x, double y, int iPart = 0) = 0;
171 virtual int Add_Point (const CSG_Point &p, int iPart = 0) = 0;
172 virtual int Add_Point (const CSG_Point_3D &p, int iPart = 0) = 0;
173 virtual int Add_Point (const CSG_Point_4D &p, int iPart = 0) = 0;
174
175 virtual int Ins_Point (double x, double y, int iPoint , int iPart = 0) = 0;
176 virtual int Ins_Point (const CSG_Point &p, int iPoint , int iPart = 0) = 0;
177 virtual int Ins_Point (const CSG_Point_3D &p, int iPoint , int iPart = 0) = 0;
178 virtual int Ins_Point (const CSG_Point_4D &p, int iPoint , int iPart = 0) = 0;
179
180 virtual int Set_Point (double x, double y, int iPoint = 0, int iPart = 0) = 0;
181 virtual int Set_Point (const CSG_Point &p, int iPoint = 0, int iPart = 0) = 0;
182 virtual int Set_Point (const CSG_Point_3D &p, int iPoint = 0, int iPart = 0) = 0;
183 virtual int Set_Point (const CSG_Point_4D &p, int iPoint = 0, int iPart = 0) = 0;
184
185 virtual int Del_Point ( int iPoint , int iPart = 0) = 0;
186
187 virtual TSG_Point Get_Point (int iPoint = 0) const = 0;
188 virtual TSG_Point Get_Point (int iPoint, int iPart, bool bAscending = true) const = 0;
189
190 //-----------------------------------------------------
191 virtual void Set_Z (double z, int iPoint = 0, int iPart = 0) { }
192 virtual double Get_Z (int iPoint = 0, int iPart = 0, bool bAscending = true) const { return( 0. ); }
193 virtual double Get_ZMin (void) { return( 0. ); }
194 virtual double Get_ZMax (void) { return( 0. ); }
195 virtual TSG_Point_3D Get_Point_Z (int iPoint = 0, int iPart = 0, bool bAscending = true) const
196 {
197 TSG_Point_3D Point; TSG_Point p = Get_Point(iPoint, iPart, bAscending);
198
199 Point.x = p.x;
200 Point.y = p.y;
201 Point.z = Get_Z(iPoint, iPart, bAscending);
202
203 return( Point );
204 }
205
206 //-----------------------------------------------------
207 virtual void Set_M (double m, int iPoint = 0, int iPart = 0) { }
208 virtual double Get_M (int iPoint = 0, int iPart = 0, bool bAscending = true) const { return( 0. ); }
209 virtual double Get_MMin (void) { return( 0. ); }
210 virtual double Get_MMax (void) { return( 0. ); }
211 virtual TSG_Point_4D Get_Point_ZM (int iPoint = 0, int iPart = 0, bool bAscending = true) const
212 {
213 TSG_Point_4D Point; TSG_Point p = Get_Point(iPoint, iPart, bAscending);
214
215 Point.x = p.x;
216 Point.y = p.y;
217 Point.z = Get_Z(iPoint, iPart, bAscending);
218 Point.m = Get_M(iPoint, iPart, bAscending);
219
220 return( Point );
221 }
222
223 //-----------------------------------------------------
224 virtual const CSG_Rect & Get_Extent (void) = 0;
225 virtual const CSG_Rect & Get_Extent (int iPart) { return( Get_Extent() ); }
226
227 virtual TSG_Point Get_Centroid (void) = 0;
228
230 TSG_Intersection Intersects (const TSG_Rect &Extent);
231
232 virtual double Get_Distance (TSG_Point Point ) const = 0;
233 virtual double Get_Distance (TSG_Point Point , int iPart) const = 0;
234 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next ) const = 0;
235 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) const = 0;
236
237 virtual bool Revert_Points (int iPart) { return( true ); }
238
239
240protected:
241
242 CSG_Shape(class CSG_Shapes *pOwner, sLong Index);
243 virtual ~CSG_Shape(void);
244
245 virtual bool On_Assign (CSG_Shape *pShape) = 0;
248
249 virtual void _Invalidate (void);
250
251};
252
253
255// //
256// Point //
257// //
259
260//---------------------------------------------------------
262{
263 friend class CSG_Shapes;
264
265public:
266
267 virtual bool is_Valid (void) const { return( true ); }
268
269 virtual int Get_Point_Count (void) const { return( 1 ); }
270 virtual int Get_Point_Count (int iPart) const { return( 1 ); }
271 virtual int Get_Part_Count (void) const { return( 1 ); }
272
273 virtual int Add_Point (double x, double y, int iPart = 0) { return( Set_Point(x, y, 0) ); }
274 virtual int Add_Point (const CSG_Point &p, int iPart = 0) { return( Set_Point(p , 0) ); }
275 virtual int Add_Point (const CSG_Point_3D &p, int iPart = 0) { return( Set_Point(p , 0) ); }
276 virtual int Add_Point (const CSG_Point_4D &p, int iPart = 0) { return( Set_Point(p , 0) ); }
277
278 virtual int Ins_Point (double x, double y, int iPoint , int iPart = 0) { return( Set_Point(x, y, 0) ); }
279 virtual int Ins_Point (const CSG_Point &p, int iPoint , int iPart = 0) { return( Set_Point(p , 0) ); }
280 virtual int Ins_Point (const CSG_Point_3D &p, int iPoint , int iPart = 0) { return( Set_Point(p , 0) ); }
281 virtual int Ins_Point (const CSG_Point_4D &p, int iPoint , int iPart = 0) { return( Set_Point(p , 0) ); }
282
283 virtual int Set_Point (double x, double y, int iPoint = 0, int iPart = 0) { m_Point.x = x; m_Point.y = y; _Invalidate(); return( 1 ); }
284 virtual int Set_Point (const CSG_Point &p, int iPoint = 0, int iPart = 0) { m_Point.x = p.x; m_Point.y = p.y; _Invalidate(); return( 1 ); }
285 virtual int Set_Point (const CSG_Point_3D &p, int iPoint = 0, int iPart = 0) { m_Point.x = p.x; m_Point.y = p.y; Set_Z(p.z, 0); _Invalidate(); return( 1 ); }
286 virtual int Set_Point (const CSG_Point_4D &p, int iPoint = 0, int iPart = 0) { m_Point.x = p.x; m_Point.y = p.y; Set_Z(p.z, 0); Set_M(p.m, 0); _Invalidate(); return( 1 ); }
287
288 virtual int Del_Point ( int iPoint , int iPart = 0) { return( -1 ); }
289
290 virtual TSG_Point Get_Point (int iPoint = 0) const { return( m_Point ); }
291 virtual TSG_Point Get_Point (int iPoint, int iPart, bool bAscending = true) const { return( m_Point ); }
292
293 virtual TSG_Point Get_Centroid (void) { return( m_Point ); }
294
295 virtual const CSG_Rect & Get_Extent (void);
296
297 virtual double Get_Distance (TSG_Point Point ) const { return( SG_Get_Distance(Point, m_Point) ); }
298 virtual double Get_Distance (TSG_Point Point , int iPart) const { return( SG_Get_Distance(Point, m_Point) ); }
299 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next ) const { Next = m_Point; return( SG_Get_Distance(Point, m_Point) ); }
300 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) const { Next = m_Point; return( SG_Get_Distance(Point, m_Point) ); }
301
302
303protected:
304
305 CSG_Shape_Point(class CSG_Shapes *pOwner, sLong Index);
306 virtual ~CSG_Shape_Point(void);
307
308
310
311
312 virtual bool On_Assign (CSG_Shape *pShape);
313 virtual TSG_Intersection On_Intersects (CSG_Shape *pShape);
314 virtual TSG_Intersection On_Intersects (TSG_Rect Region);
315
316};
317
318//---------------------------------------------------------
320{
321 friend class CSG_Shapes;
322
323public:
324
325 CSG_Shape_Point_Z(class CSG_Shapes *pOwner, sLong Index) : CSG_Shape_Point(pOwner, Index) { m_Z = 0.; }
326
327 virtual void Set_Z (double z, int iPoint = 0, int iPart = 0) { m_Z = z; _Invalidate(); }
328 virtual double Get_Z (int iPoint = 0, int iPart = 0, bool bAscending = true) const { return( m_Z ); }
329 virtual double Get_ZMin (void) { return( m_Z ); }
330 virtual double Get_ZMax (void) { return( m_Z ); }
331
332
333private:
334
335 double m_Z;
336
337};
338
339//---------------------------------------------------------
341{
342 friend class CSG_Shapes;
343
344public:
345
346 CSG_Shape_Point_ZM(class CSG_Shapes *pOwner, sLong Index) : CSG_Shape_Point_Z(pOwner, Index) { m_M = 0.; }
347
348 virtual void Set_M (double m, int iPoint = 0, int iPart = 0) { m_M = m; _Invalidate(); }
349 virtual double Get_M (int iPoint = 0, int iPart = 0, bool bAscending = true) const { return( m_M ); }
350 virtual double Get_MMin (void) { return( m_M ); }
351 virtual double Get_MMax (void) { return( m_M ); }
352
353
354private:
355
356 double m_M;
357
358};
359
360
362// //
363// Points //
364// //
366
367//---------------------------------------------------------
369{
370 friend class CSG_Shape_Points;
371 friend class CSG_Shape_Line;
372 friend class CSG_Shape_Polygon;
373
374public:
375
376 class CSG_Shape_Points * Get_Owner (void) { return( m_pOwner ); }
377
378 virtual bool Destroy (void);
379 virtual bool Assign (CSG_Shape_Part *pPart);
380
381 const CSG_Rect & Get_Extent (void) { _Update_Extent(); return( m_Extent ); }
382
383 int Get_Count (void) const { return( m_nPoints ); }
384
385 TSG_Point Get_Point (int iPoint, bool bAscending = true) const
386 {
387 if( iPoint >= 0 && iPoint < m_nPoints )
388 {
389 return( m_Points[bAscending ? iPoint : m_nPoints - 1 - iPoint] );
390 }
391
392 return( (TSG_Point)CSG_Point(0., 0.) );
393 }
394
395
396 int Add_Point (double x, double y ) { return( Ins_Point(x, y, m_nPoints) ); }
397 int Add_Point (const CSG_Point &p) { return( Ins_Point(p , m_nPoints) ); }
398 int Add_Point (const CSG_Point_3D &p) { return( Ins_Point(p , m_nPoints) ); }
399 int Add_Point (const CSG_Point_4D &p) { return( Ins_Point(p , m_nPoints) ); }
400
401 int Ins_Point (double x, double y , int iPoint);
402 int Ins_Point (const CSG_Point &p, int iPoint) { return( Ins_Point(p.x, p.y, iPoint) ); }
403 int Ins_Point (const CSG_Point_3D &p, int iPoint);
404 int Ins_Point (const CSG_Point_4D &p, int iPoint);
405
406 int Set_Point (double x, double y , int iPoint);
407 int Set_Point (const CSG_Point &p, int iPoint) { return( Set_Point(p.x, p.y, iPoint) ); }
408 int Set_Point (const CSG_Point_3D &p, int iPoint);
409 int Set_Point (const CSG_Point_4D &p, int iPoint);
410
411 int Del_Point ( int iPoint);
412
413 void Set_Z (double z, int iPoint) { if ( m_Z && iPoint >= 0 && iPoint < m_nPoints ) { m_Z[iPoint] = z; _Invalidate(); } }
414 double Get_Z (int iPoint, bool bAscending = true) const { return( m_Z && iPoint >= 0 && iPoint < m_nPoints ? m_Z[bAscending ? iPoint : m_nPoints - 1 - iPoint] : 0. ); }
415 double Get_ZMin (void) { _Update_Extent(); return( m_ZMin ); }
416 double Get_ZMax (void) { _Update_Extent(); return( m_ZMax ); }
417 TSG_Point_3D Get_Point_Z (int iPoint, bool bAscending = true) const
418 {
419 TSG_Point_3D Point; TSG_Point p = Get_Point(iPoint, bAscending);
420
421 Point.x = p.x;
422 Point.y = p.y;
423 Point.z = Get_Z(iPoint, bAscending);
424
425 return( Point );
426 }
427
428 void Set_M (double m, int iPoint) { if ( m_M && iPoint >= 0 && iPoint < m_nPoints ) { m_M[iPoint] = m; _Invalidate(); } }
429 double Get_M (int iPoint, bool bAscending = true) const { return( m_M && iPoint >= 0 && iPoint < m_nPoints ? m_M[bAscending ? iPoint : m_nPoints - 1 - iPoint] : 0. ); }
430 double Get_MMin (void) { _Update_Extent(); return( m_MMin ); }
431 double Get_MMax (void) { _Update_Extent(); return( m_MMax ); }
432 TSG_Point_4D Get_Point_ZM (int iPoint, bool bAscending = true) const
433 {
434 TSG_Point_4D Point; TSG_Point p = Get_Point(iPoint, bAscending);
435
436 Point.x = p.x;
437 Point.y = p.y;
438 Point.z = Get_Z(iPoint, bAscending);
439 Point.m = Get_M(iPoint, bAscending);
440
441 return( Point );
442 }
443
444 bool Add_Points (CSG_Shape_Part *pPoints, bool bAscending = true);
445
446 bool Revert_Points (void);
447
448
449protected:
450
451 CSG_Shape_Part(class CSG_Shape_Points *pOwner);
452 virtual ~CSG_Shape_Part(void);
453
454
456
458
460
462
464
466
467
468 virtual bool _Alloc_Memory (int nPoints);
469 virtual void _Invalidate (void);
470 virtual void _Update_Extent (void);
471
472};
473
474
476// //
477// Points //
478// //
480
481//---------------------------------------------------------
483{
484 friend class CSG_Shapes;
485 friend class CSG_Shape_Part;
486
487public:
488
489 virtual void Destroy (void);
490
491 virtual bool is_Valid (void) const { return( m_nParts > 0 && m_pParts[0]->Get_Count() > 0 ); }
492
493 virtual int Get_Point_Count (void) const { return( m_nPoints ); }
494 virtual int Get_Point_Count (int iPart) const { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart]->Get_Count() : 0 ); }
495 virtual int Get_Part_Count (void) const { return( m_nParts ); }
496
497 virtual int Add_Part (class CSG_Shape_Part *pPart, bool bRevert = false);
498 virtual CSG_Shape_Part * Get_Part (int iPart) const { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart] : NULL ); }
499 virtual int Del_Part (int iPart);
500 virtual int Del_Parts (void);
501
502 virtual int Add_Point (double x, double y, int iPart = 0) { return( Ins_Point(x, y, Get_Point_Count(iPart), iPart) ); }
503 virtual int Add_Point (const CSG_Point &p, int iPart = 0) { return( Ins_Point(p , Get_Point_Count(iPart), iPart) ); }
504 virtual int Add_Point (const CSG_Point_3D &p, int iPart = 0) { return( Ins_Point(p , Get_Point_Count(iPart), iPart) ); }
505 virtual int Add_Point (const CSG_Point_4D &p, int iPart = 0) { return( Ins_Point(p , Get_Point_Count(iPart), iPart) ); }
506
507 virtual int Ins_Point (double x, double y, int iPoint , int iPart = 0);
508 virtual int Ins_Point (const CSG_Point &p, int iPoint , int iPart = 0) { return( Ins_Point(p.x, p.y, iPoint, iPart) ); }
509 virtual int Ins_Point (const CSG_Point_3D &p, int iPoint , int iPart = 0);
510 virtual int Ins_Point (const CSG_Point_4D &p, int iPoint , int iPart = 0);
511
512 virtual int Set_Point (double x, double y, int iPoint = 0, int iPart = 0);
513 virtual int Set_Point (const CSG_Point &p, int iPoint = 0, int iPart = 0) { return( Set_Point(p.x, p.y, iPoint, iPart) ); }
514 virtual int Set_Point (const CSG_Point_3D &p, int iPoint = 0, int iPart = 0);
515 virtual int Set_Point (const CSG_Point_4D &p, int iPoint = 0, int iPart = 0);
516
517 virtual int Del_Point ( int iPoint , int iPart = 0);
518
519 virtual TSG_Point Get_Point (int iPoint = 0) const;
520 virtual TSG_Point Get_Point (int iPoint, int iPart, bool bAscending = true) const
521 {
522 if( iPart >= 0 && iPart < m_nParts )
523 {
524 return( m_pParts[iPart]->Get_Point(iPoint, bAscending) );
525 }
526
527 return( (TSG_Point)CSG_Point(0., 0.) );
528 }
529
530 virtual void Set_Z (double z, int iPoint = 0, int iPart = 0) { if ( iPart >= 0 && iPart < m_nParts ) m_pParts[iPart]->Set_Z(z, iPoint); }
531 virtual double Get_Z ( int iPoint = 0, int iPart = 0, bool bAscending = true) const { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart]->Get_Z( iPoint, bAscending) : 0. ); }
532 virtual double Get_ZMin (void) { _Update_Extent(); return( m_ZMin ); }
533 virtual double Get_ZMax (void) { _Update_Extent(); return( m_ZMax ); }
534
535 virtual void Set_M (double m, int iPoint = 0, int iPart = 0) { if ( iPart >= 0 && iPart < m_nParts ) m_pParts[iPart]->Set_M(m, iPoint); }
536 virtual double Get_M ( int iPoint = 0, int iPart = 0, bool bAscending = true) const { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart]->Get_M( iPoint, bAscending) : 0. ); }
537 virtual double Get_MMin (void) { _Update_Extent(); return( m_MMin ); }
538 virtual double Get_MMax (void) { _Update_Extent(); return( m_MMax ); }
539
540 virtual const CSG_Rect & Get_Extent (void) { _Update_Extent(); return( m_Extent ); }
541
542 virtual TSG_Point Get_Centroid (void);
543
544 virtual double Get_Distance (TSG_Point Point ) const;
545 virtual double Get_Distance (TSG_Point Point , int iPart) const;
546 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next ) const;
547 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) const;
548
549 virtual bool Revert_Points (int iPart) { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart]->Revert_Points() : false ); }
550
551
552protected:
553
554 CSG_Shape_Points(class CSG_Shapes *pOwner, sLong Index);
555 virtual ~CSG_Shape_Points(void);
556
557
559
561
563
565
567
568
569 int _Add_Part (void);
570
571 virtual CSG_Shape_Part * _Get_Part (void) { return( new CSG_Shape_Part(this) ); }
572
573 virtual void _Invalidate (void)
574 {
575 if( !m_bUpdate )
576 {
577 m_bUpdate = true;
578
580 }
581 }
582
583 void _Update_Extent (void);
584
585 virtual bool On_Assign (CSG_Shape *pShape);
586 virtual TSG_Intersection On_Intersects (CSG_Shape *pShape);
587 virtual TSG_Intersection On_Intersects (TSG_Rect Region);
588
589};
590
591
593// //
594// Line //
595// //
597
598//---------------------------------------------------------
600{
601 friend class CSG_Shapes;
602
603public:
604
605 virtual bool is_Valid (void) const { return( m_nParts > 0 && m_pParts[0]->Get_Count() > 1 ); }
606
607 virtual TSG_Point Get_Centroid (void);
608
609 double Get_Length (void);
610 double Get_Length (int iPart);
611
612 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) const;
613
614
615protected:
616
617 CSG_Shape_Line(class CSG_Shapes *pOwner, sLong Index);
618 virtual ~CSG_Shape_Line(void);
619
620 virtual TSG_Intersection On_Intersects (CSG_Shape *pShape);
621 virtual TSG_Intersection On_Intersects (TSG_Rect Region);
622
623};
624
625
627// //
628// Polygon //
629// //
631
632//---------------------------------------------------------
641
642//---------------------------------------------------------
644{
645 friend class CSG_Shape_Polygon;
646
647public:
648
649 bool is_Clockwise (void) { _Update_Area(); return( m_bClockwise == 1 ); }
650
651 double Get_Perimeter (void) { _Update_Area(); return( m_Perimeter ); }
652
653 double Get_Area (void) { _Update_Area(); return( m_Area ); }
654
655 const TSG_Point & Get_Centroid (void) { _Update_Area(); return( m_Centroid ); }
656
657 TSG_Polygon_Point_Relation Get_Point_Relation (const CSG_Point &p);
658 TSG_Polygon_Point_Relation Get_Point_Relation (double x, double y);
659
660 bool is_OnEdge (const CSG_Point &p);
661 bool is_OnEdge (double x, double y);
662
663 bool Contains (const CSG_Point &p);
664 bool Contains (double x, double y);
665
666 bool is_Neighbour (CSG_Shape_Polygon_Part *pPart, bool bSimpleCheck = true);
667
668 CSG_Lines Get_Shared_Edges (CSG_Shape_Polygon_Part *pPart, bool bVertexCheck, double Epsilon = 0.);
669 double Get_Shared_Length (CSG_Shape_Polygon_Part *pPart, bool bVertexCheck, double Epsilon = 0.);
670
671 double Get_Distance (TSG_Point Point, TSG_Point &Next);
672
673
674protected:
675
677 virtual ~CSG_Shape_Polygon_Part(void);
678
679
681
683
685
686
687 virtual void _Invalidate (void);
688
689 void _Update_Area (void);
690
691 void _Add_Edge_Points (CSG_Shape_Polygon_Part *pPart, const CSG_Point &P0, const CSG_Point &P1, CSG_Points &Part, double Epsilon);
692 bool _is_OnEdge (CSG_Shape_Polygon_Part *pPart, const CSG_Point &P, bool bVertex , double Epsilon);
693
694};
695
696//---------------------------------------------------------
698{
699 friend class CSG_Shapes;
700
701public:
702
703 virtual bool is_Valid (void) const { return( m_nParts > 0 && m_pParts[0]->Get_Count() > 2 ); }
704
705
706 CSG_Shape_Polygon_Part * Get_Polygon_Part (int iPart) const { return( (CSG_Shape_Polygon_Part *)Get_Part(iPart) ); }
707
708 bool is_Lake (int iPart);
709
710 bool is_Clockwise (int iPart);
711
712 double Get_Perimeter (int iPart);
713 double Get_Perimeter (void);
714
715 double Get_Area (int iPart);
716 double Get_Area (void);
717
718 TSG_Point Get_Centroid (int iPart);
719 TSG_Point Get_Centroid (void);
720
721 TSG_Polygon_Point_Relation Get_Point_Relation (const CSG_Point &p, int iPart);
722 TSG_Polygon_Point_Relation Get_Point_Relation (double x, double y, int iPart);
723 TSG_Polygon_Point_Relation Get_Point_Relation (const CSG_Point &p);
724 TSG_Polygon_Point_Relation Get_Point_Relation (double x, double y);
725
726
727 bool is_OnEdge (const CSG_Point &p, int iPart);
728 bool is_OnEdge (double x, double y, int iPart);
729 bool is_OnEdge (const CSG_Point &p);
730 bool is_OnEdge (double x, double y);
731
732 bool Contains (const CSG_Point &p, int iPart);
733 bool Contains (double x, double y, int iPart);
734 bool Contains (const CSG_Point &p);
735 bool Contains (double x, double y);
736
737 bool is_Neighbour (CSG_Shape_Polygon *pPolygon, bool bSimpleCheck = true);
738
739 CSG_Lines Get_Shared_Edges (CSG_Shape_Polygon *pPolygon, bool bVertexCheck, double Epsilon = 0.);
740 double Get_Shared_Length (CSG_Shape_Polygon *pPolygon, bool bVertexCheck, double Epsilon = 0.);
741
742 virtual double Get_Distance (TSG_Point Point, TSG_Point &Next, int iPart) const;
743
744
745protected:
746
747 CSG_Shape_Polygon(class CSG_Shapes *pOwner, sLong Index);
748 virtual ~CSG_Shape_Polygon(void);
749
750
752
753
754 virtual CSG_Shape_Part * _Get_Part (void) { return( new CSG_Shape_Polygon_Part(this) ); }
755
756 virtual void _Invalidate (void);
757
758 virtual TSG_Intersection On_Intersects (CSG_Shape *pShape);
759 virtual TSG_Intersection On_Intersects (TSG_Rect Region);
760
761};
762
763
765// //
766// Shapes //
767// //
769
770//---------------------------------------------------------
772{
773 friend class CSG_Shape;
774
775public:
776
777 CSG_Shapes(void);
778
779 CSG_Shapes (const CSG_Shapes &Shapes);
780 bool Create (const CSG_Shapes &Shapes);
781
782 CSG_Shapes (const char *File);
783 bool Create (const char *File);
784 CSG_Shapes (const wchar_t *File);
785 bool Create (const wchar_t *File);
786 CSG_Shapes (const CSG_String &File);
787 bool Create (const CSG_String &File);
788
789 CSG_Shapes (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pTemplate = NULL, TSG_Vertex_Type Vertex_Type = SG_VERTEX_TYPE_XY);
790 bool Create (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pTemplate = NULL, TSG_Vertex_Type Vertex_Type = SG_VERTEX_TYPE_XY);
791
792 virtual ~CSG_Shapes(void);
793
794 virtual bool Destroy (void);
795
797
798 virtual bool Assign (CSG_Data_Object *pObject, bool bProgress = false);
799
800 virtual bool Save (const CSG_String &File, int Format = 0);
801 virtual bool Save (const char *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
802 virtual bool Save (const wchar_t *File, int Format = 0) { return( Save(CSG_String(File), Format) ); }
803
804 virtual bool is_Valid (void) const { return( m_Type != SHAPE_TYPE_Undefined && Get_Count() >= 0 ); }
805
806 virtual TSG_Shape_Type Get_Type (void) const { return( m_Type ); }
807
809
810 virtual const CSG_Rect & Get_Extent (void) { Update(); return( m_Extent ); }
811
812 double Get_ZMin (void) { Update(); return( m_ZMin ); }
813 double Get_ZMax (void) { Update(); return( m_ZMax ); }
814 double Get_MMin (void) { Update(); return( m_MMin ); }
815 double Get_MMax (void) { Update(); return( m_MMax ); }
816
817 //-----------------------------------------------------
818 virtual CSG_Shape * Add_Shape (CSG_Table_Record *pCopy = NULL, TSG_ADD_Shape_Copy_Mode mCopy = SHAPE_COPY);
819 virtual bool Del_Shape (sLong Index);
820 virtual bool Del_Shape (CSG_Shape *pShape);
821 virtual bool Del_Shapes (void) { return( Del_Records() ); }
822
823 virtual CSG_Shape * Get_Shape (const CSG_Point &Point, double Epsilon = 0.);
824 virtual CSG_Shape * Get_Shape (sLong Index) const { return( (CSG_Shape *)Get_Record (Index) ); }
825 virtual CSG_Shape * Get_Shape_byIndex (sLong Index) const { return( (CSG_Shape *)Get_Record_byIndex(Index) ); }
826
827 //-----------------------------------------------------
828 bool Make_Clean (void);
829
830 //-----------------------------------------------------
831 virtual const CSG_Rect & Get_Selection_Extent (void);
832
833 virtual bool Select (sLong Index , bool bInvert = false);
834 virtual bool Select (CSG_Table_Record *pShape = NULL, bool bInvert = false);
835 virtual bool Select (const TSG_Rect &Extent , bool bInvert = false);
836 virtual bool Select (const TSG_Point &Point , bool bInvert = false);
837
838
839protected:
840
842
844
846
848
849
850 virtual bool On_Update (void);
851 virtual bool On_Reload (void);
852 virtual bool On_Delete (void);
853
854 virtual void _On_Construction (void);
855
856 virtual CSG_Table_Record * _Get_New_Record (sLong Index);
857
858
859private:
860
861 bool _Load_GDAL (const CSG_String &File);
862 bool _Save_GDAL (const CSG_String &File, const CSG_String &Driver);
863
864 bool _Load_ESRI (const CSG_String &File);
865 bool _Save_ESRI (const CSG_String &File);
866
867};
868
869
871// //
872// //
873// //
875
876//---------------------------------------------------------
879
882
886SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes (const wchar_t *File);
889
891SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pTemplate = NULL, TSG_Vertex_Type Vertex_Type = SG_VERTEX_TYPE_XY);
892
895
896
897//---------------------------------------------------------
901
902
904// //
905// Point Region QuadTree //
906// //
908
909//---------------------------------------------------------
911{
912public:
913
914 virtual bool is_Leaf (void) const { return( false ); }
915 virtual bool is_Node (void) const { return( false ); }
916 virtual bool has_Statistics (void) const { return( false ); }
917
918 const CSG_Rect & Get_Extent (void) const { return( m_Extent ); }
919 double Get_xMin (void) const { return( m_Extent.xMin ); }
920 double Get_xCenter (void) const { return( m_Extent.Get_XCenter() ); }
921 double Get_xMax (void) const { return( m_Extent.xMax ); }
922 double Get_yMin (void) const { return( m_Extent.yMin ); }
923 double Get_yCenter (void) const { return( m_Extent.Get_YCenter() ); }
924 double Get_yMax (void) const { return( m_Extent.yMax ); }
925 double Get_Size (void) const { return( m_Extent.Get_XRange() ); }
926
927 bool Contains (const CSG_Point &p) const { return( m_Extent.Contains(p ) ); }
928 bool Contains (double x, double y) const { return( m_Extent.Contains(x, y) ); }
929
930 class CSG_PRQuadTree_Leaf * asLeaf (void) const { return( (class CSG_PRQuadTree_Leaf *)this ); }
931 class CSG_PRQuadTree_Node * asNode (void) const { return( (class CSG_PRQuadTree_Node *)this ); }
932
933
934protected:
935
936 CSG_PRQuadTree_Item(const CSG_Rect &Extent, int Quadrant = -1) { Set_Extent(Extent, Quadrant); }
937
938 virtual ~CSG_PRQuadTree_Item(void) {}
939
940 void Set_Extent (const CSG_Rect &Extent, int Quadrant = -1)
941 {
942 switch( Quadrant )
943 {
944 case 0: m_Extent.Assign(Extent.Get_XMin (), Extent.Get_YMin (), Extent.Get_XCenter(), Extent.Get_YCenter()); break; // bottom left
945 case 1: m_Extent.Assign(Extent.Get_XMin (), Extent.Get_YCenter(), Extent.Get_XCenter(), Extent.Get_YMax ()); break; // top left
946 case 2: m_Extent.Assign(Extent.Get_XCenter(), Extent.Get_YCenter(), Extent.Get_XMax (), Extent.Get_YMax ()); break; // top right
947 case 3: m_Extent.Assign(Extent.Get_XCenter(), Extent.Get_YMin (), Extent.Get_XMax (), Extent.Get_YCenter()); break; // bottom right
948 default: m_Extent.Assign(Extent); break;
949 }
950 }
951
952 int Get_Quadrant (const TSG_Point &p) const { return( Get_Quadrant(p.x, p.y) ); }
953
954 int Get_Quadrant (double x, double y) const
955 {
956 return( y < Get_yCenter() ? (x < Get_xCenter() ? 0 : 3) : (x < Get_xCenter() ? 1 : 2) );
957 }
958
959
961
962};
963
964//---------------------------------------------------------
966{
968
969public:
970
971 virtual bool is_Leaf (void) const { return( true ); }
972
973 const TSG_Point & Get_Point (void) const { return( m_Point ); }
974 double Get_X (void) const { return( m_Point.x ); }
975 double Get_Y (void) const { return( m_Point.y ); }
976 double Get_Z (void) const { return( m_z ); }
977
978
979protected:
980
981 CSG_PRQuadTree_Leaf(const CSG_Rect &Extent, int Quadrant, double x, double y, double z)
982 : CSG_PRQuadTree_Item(Extent, Quadrant)
983 {
984 m_Point.x = x;
985 m_Point.y = y;
986 m_z = z;
987 }
988
989 virtual ~CSG_PRQuadTree_Leaf(void) {}
990
991
992 double m_z;
993
995
996};
997
998//---------------------------------------------------------
1000{
1002
1003public:
1004
1005 virtual bool has_Statistics (void) const { return( true ); }
1006
1007 sLong Get_Count (void) { return( s_z.Get_Count () ); }
1008 double Get_Value (sLong i) { return( s_z.Get_Value (i) ); }
1009 double Get_Minimum (void) { return( s_z.Get_Minimum () ); }
1010 double Get_Maximum (void) { return( s_z.Get_Maximum () ); }
1011 double Get_Range (void) { return( s_z.Get_Range () ); }
1012 double Get_Sum (void) { return( s_z.Get_Sum () ); }
1013 double Get_Mean (void) { return( s_z.Get_Mean () ); }
1014 double Get_Variance (void) { return( s_z.Get_Variance() ); }
1015 double Get_StdDev (void) { return( s_z.Get_StdDev () ); }
1016
1017
1018protected:
1019
1020 CSG_PRQuadTree_Leaf_List(const CSG_Rect &Extent, int Quadrant, double x, double y, double z)
1021 : CSG_PRQuadTree_Leaf(Extent, Quadrant, x, y, z)
1022 {
1023 s_z.Create(true);
1024
1025 s_z.Add_Value(z);
1026 }
1027
1029
1030 void Add_Value (double z)
1031 {
1032 s_z.Add_Value(z);
1033
1034 m_z = s_z.Get_Mean();
1035 }
1036
1038
1039};
1040
1041//---------------------------------------------------------
1043{
1044 friend class CSG_PRQuadTree;
1045
1046public:
1047
1048 virtual bool is_Node (void) const { return( true ); }
1049
1050 CSG_PRQuadTree_Item * Get_Child (int Quadrant) const { return( Quadrant >= 0 && Quadrant < 4 ? m_pChildren[Quadrant] : NULL ); }
1051 CSG_PRQuadTree_Item * Get_Child (double x, double y);
1052
1053 bool Add_Point (double x, double y, double z);
1054
1055 virtual CSG_Simple_Statistics * Get_X (void) { return( NULL ); }
1056 virtual CSG_Simple_Statistics * Get_Y (void) { return( NULL ); }
1057 virtual CSG_Simple_Statistics * Get_Z (void) { return( NULL ); }
1058
1059
1060protected:
1061
1062 CSG_PRQuadTree_Node(const CSG_Rect &Extent, int Quadrant = -1);
1064 virtual ~CSG_PRQuadTree_Node(void);
1065
1066
1068
1069};
1070
1071//---------------------------------------------------------
1073{
1074 friend class CSG_PRQuadTree;
1076
1077public:
1078
1079 virtual bool has_Statistics (void) const { return( true ); }
1080
1081 virtual CSG_Simple_Statistics * Get_X (void) { return( &m_x ); }
1082 virtual CSG_Simple_Statistics * Get_Y (void) { return( &m_y ); }
1083 virtual CSG_Simple_Statistics * Get_Z (void) { return( &m_z ); }
1084
1085
1086protected:
1087
1088 CSG_PRQuadTree_Node_Statistics(const CSG_Rect &Extent, int Quadrant = -1)
1089 : CSG_PRQuadTree_Node(Extent, Quadrant)
1090 {}
1091
1095
1097
1098
1100
1101};
1102
1103//---------------------------------------------------------
1105{
1106public:
1107 CSG_PRQuadTree(void);
1108 virtual ~CSG_PRQuadTree(void);
1109
1110 CSG_PRQuadTree (const TSG_Rect &Extent, bool bStatistics = false);
1111 bool Create (const CSG_Rect &Extent, bool bStatistics = false);
1112
1113 CSG_PRQuadTree (CSG_Shapes *pShapes, int Attribute, bool bStatistics = false);
1114 bool Create (CSG_Shapes *pShapes, int Attribute, bool bStatistics = false);
1115
1116 void Destroy (void);
1117
1118 bool Add_Point (double x, double y, double z);
1119 bool Add_Point (const TSG_Point &p, double z);
1120
1121 size_t Get_Point_Count (void) const { return( m_nPoints ); }
1122
1123 const CSG_PRQuadTree_Node & Get_Root (void) const { return( *m_pRoot ); }
1124 CSG_PRQuadTree_Node * Get_Root_Pointer (void) const { return( m_pRoot ); }
1125
1126 bool is_Okay (void) const { return( m_pRoot != NULL ); }
1127
1128 bool is_Polar (void) const { return( m_bPolar ); }
1129 void Set_Polar_Search (bool bOn) { m_bPolar = bOn; }
1130
1131 CSG_PRQuadTree_Leaf * Get_Nearest_Leaf (const TSG_Point &p, double &Distance) const;
1132 CSG_PRQuadTree_Leaf * Get_Nearest_Leaf (double x, double y, double &Distance) const;
1133 bool Get_Nearest_Point (const TSG_Point &p, TSG_Point &Point, double &Value, double &Distance) const;
1134 bool Get_Nearest_Point (double x, double y, TSG_Point &Point, double &Value, double &Distance) const;
1135
1136 size_t Get_Nearest_Points (CSG_Points_3D &Points, const TSG_Point &p, size_t maxPoints, double Radius = 0., int iQuadrant = -1) const;
1137 size_t Get_Nearest_Points (CSG_Points_3D &Points, double x, double y, size_t maxPoints, double Radius = 0., int iQuadrant = -1) const;
1138
1139 size_t Select_Nearest_Points (const TSG_Point &p, size_t maxPoints, double Radius = 0., int iQuadrant = -1);
1140 size_t Select_Nearest_Points (double x, double y, size_t maxPoints, double Radius = 0., int iQuadrant = -1);
1141
1142 size_t Get_Selected_Count (void) const { return( m_Selection.Get_Size() ); }
1143 CSG_PRQuadTree_Leaf * Get_Selected_Leaf (size_t i) const { return( i >= (size_t)m_Selection.Get_Size() ? NULL : (((TLeaf *)m_Selection.Get_Array()) + i)->pLeaf ); }
1144 double Get_Selected_Z (size_t i) const { return( i >= (size_t)m_Selection.Get_Size() ? 0. : (((TLeaf *)m_Selection.Get_Array()) + i)->pLeaf->Get_Z() ); }
1145 double Get_Selected_Distance (size_t i) const { return( i >= (size_t)m_Selection.Get_Size() ? -1. : (((TLeaf *)m_Selection.Get_Array()) + i)->Distance ); }
1146 bool Get_Selected_Point (size_t i, double &x, double &y, double &z) const
1147 {
1149
1150 if( pLeaf )
1151 {
1152 x = pLeaf->Get_X();
1153 y = pLeaf->Get_Y();
1154 z = pLeaf->Get_Z();
1155
1156 return( true );
1157 }
1158
1159 return( false );
1160 }
1161
1162
1163private:
1164
1165 typedef struct SLeaf
1166 {
1167 CSG_PRQuadTree_Leaf *pLeaf;
1168
1169 double Distance;
1170 }
1171 TLeaf;
1172
1173
1174private:
1175
1176 bool m_bPolar;
1177
1178 size_t m_nPoints;
1179
1180 CSG_Array m_Selection;
1181
1182 CSG_PRQuadTree_Node *m_pRoot;
1183
1184 bool _Check_Root (double x, double y);
1185
1186 bool _Quadrant_Contains (double x, double y, int iQuadrant, const TSG_Point &p) const;
1187 bool _Radius_Contains (double x, double y, double r, const TSG_Point &p) const;
1188 bool _Radius_Contains (double x, double y, double r, int iQuadrant, const TSG_Point &p) const;
1189 bool _Quadrant_Intersects (double x, double y, int iQuadrant, CSG_PRQuadTree_Item *pItem) const;
1190 bool _Radius_Intersects (double x, double y, double r, CSG_PRQuadTree_Item *pItem) const;
1191 bool _Radius_Intersects (double x, double y, double r, int iQuadrant, CSG_PRQuadTree_Item *pItem) const;
1192
1193 CSG_PRQuadTree_Leaf * _Get_Nearest_Point (CSG_PRQuadTree_Item *pItem, double x, double y, double &Distance) const;
1194
1195 TLeaf * _Get_Selected (const CSG_Array &Selection, size_t i) const;
1196 bool _Add_Selected ( CSG_Array &Selection , CSG_PRQuadTree_Leaf *pLeaf, double Distance) const;
1197 bool _Set_Selected ( CSG_Array &Selection, size_t i, CSG_PRQuadTree_Leaf *pLeaf, double Distance) const;
1198 void _Select_Nearest_Points ( CSG_Array &Selection, CSG_PRQuadTree_Item *pItem, double x, double y, double &Distance, double Radius, size_t maxPoints, int iQuadrant) const;
1199 size_t _Select_Nearest_Points ( CSG_Array &Selection, double x, double y, size_t maxPoints, double Radius, int iQuadrant) const;
1200
1201};
1202
1203
1205// //
1206// Point Search Engine //
1207// //
1209
1210//---------------------------------------------------------
1212{
1213public:
1214 CSG_KDTree(void);
1215 virtual ~CSG_KDTree(void);
1216
1217 static const char * Get_Version (void);
1218
1219 virtual bool Destroy (void);
1220
1221 bool is_Okay (void) const { return( m_pKDTree != NULL ); }
1222
1223 size_t Get_Match_Count (void ) const { return( m_Indices.Get_Size() ); }
1224 size_t Get_Match_Index (size_t i) const { return( m_Indices [i] ); }
1225 double Get_Match_Distance (size_t i) const { return( m_Distances[i] ); }
1226 CSG_Shape * Get_Match_Shape (size_t i) const;
1227
1228 int Get_Point_Count (void) const { return( m_Points.Get_NY() ); }
1229 double * Get_Point (int i) const { return( m_Points[i] ); }
1230 double * Get_Point (size_t i) const { return( m_Points[i] ); }
1231 double * operator [] (int i) const { return( m_Points[i] ); }
1232 double * operator [] (size_t i) const { return( m_Points[i] ); }
1233 virtual double Get_Point_Value (int i) const { return( Get_Point_Value((size_t)i) ); }
1234 virtual double Get_Point_Value (size_t i) const = 0;
1235
1236
1237protected:
1238
1239 class CSG_KDTree_Adaptor *m_pAdaptor;
1240
1242
1244
1246
1248
1249
1250 void _On_Construction (void);
1251
1252};
1253
1254
1256// //
1258
1259//---------------------------------------------------------
1261{
1262public:
1263 CSG_KDTree_2D(void);
1264 virtual ~CSG_KDTree_2D(void);
1265
1266 CSG_KDTree_2D (CSG_Shapes *pPoints, int Field = -1);
1267 bool Create (CSG_Shapes *pPoints, int Field = -1);
1268
1269 CSG_KDTree_2D (CSG_PointCloud *pPoints);
1270 bool Create (CSG_PointCloud *pPoints);
1271
1272 CSG_KDTree_2D (const CSG_Matrix &Points);
1273 bool Create (const CSG_Matrix &Points);
1274
1275 CSG_KDTree_2D (const double **Points, size_t nPoints);
1276 bool Create (const double **Points, size_t nPoints);
1277
1278 virtual bool Destroy (void);
1279
1280 virtual double Get_Point_Value (size_t i) const { return( m_Points[i][2] ); }
1281
1282 virtual size_t Get_Nearest_Points (double Coordinate[2], size_t Count, double Radius);
1283 virtual size_t Get_Nearest_Points (double Coordinate[2], size_t Count, double Radius, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1284 virtual size_t Get_Nearest_Points (double Coordinate[2], size_t Count, size_t *Indices, double *Distances);
1285 virtual bool Get_Nearest_Point (double Coordinate[2], size_t &Index, double &Distance);
1286 virtual bool Get_Nearest_Point (double Coordinate[2], size_t &Index);
1287 virtual bool Get_Nearest_Value (double Coordinate[2], double &Value);
1288 virtual CSG_Shape * Get_Nearest_Shape (double Coordinate[2]);
1289 virtual size_t Get_Duplicates (double Coordinate[2], CSG_Array_sLong &Indices, CSG_Vector &Distances);
1290 virtual size_t Get_Duplicates (double Coordinate[2]);
1291
1292 virtual size_t Get_Nearest_Points (double x, double y, size_t Count, double Radius);
1293 virtual size_t Get_Nearest_Points (double x, double y, size_t Count, double Radius, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1294 virtual size_t Get_Nearest_Points (double x, double y, size_t Count, size_t *Indices, double *Distances);
1295 virtual bool Get_Nearest_Point (double x, double y, size_t &Index, double &Distance);
1296 virtual bool Get_Nearest_Point (double x, double y, size_t &Index);
1297 virtual bool Get_Nearest_Value (double x, double y, double &Value);
1298 virtual CSG_Shape * Get_Nearest_Shape (double x, double y);
1299 virtual size_t Get_Duplicates (double x, double y, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1300 virtual size_t Get_Duplicates (double x, double y);
1301
1302};
1303
1304
1306// //
1308
1309//---------------------------------------------------------
1311{
1312public:
1313 CSG_KDTree_3D(void);
1314 virtual ~CSG_KDTree_3D(void);
1315
1316 CSG_KDTree_3D (CSG_Shapes *pPoints, int Field = -1, int zField = -1, double zScale = 1.);
1317 bool Create (CSG_Shapes *pPoints, int Field = -1, int zField = -1, double zScale = 1.);
1318
1319 CSG_KDTree_3D (CSG_PointCloud *pPoints);
1320 bool Create (CSG_PointCloud *pPoints);
1321
1322 CSG_KDTree_3D (const CSG_Matrix &Points);
1323 bool Create (const CSG_Matrix &Points);
1324
1325 CSG_KDTree_3D (const double **Points, size_t nPoints);
1326 bool Create (const double **Points, size_t nPoints);
1327
1328 virtual bool Destroy (void);
1329
1330 virtual double Get_Point_Value (size_t i) const { return( m_Points[i][3] ); }
1331
1332 virtual size_t Get_Nearest_Points (double Coordinate[3], size_t Count, double Radius);
1333
1334 virtual size_t Get_Nearest_Points (double Coordinate[3], size_t Count, size_t *Indices, double *Distances);
1335 virtual size_t Get_Nearest_Points (double Coordinate[3], size_t Count, double Radius, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1336 virtual bool Get_Nearest_Point (double Coordinate[3], size_t &Index, double &Distance);
1337 virtual bool Get_Nearest_Point (double Coordinate[3], size_t &Index);
1338 virtual bool Get_Nearest_Value (double Coordinate[3], double &Value);
1339 virtual CSG_Shape * Get_Nearest_Shape (double Coordinate[3]);
1340 virtual size_t Get_Duplicates (double Coordinate[3], CSG_Array_sLong &Indices, CSG_Vector &Distances);
1341 virtual size_t Get_Duplicates (double Coordinate[3]);
1342
1343 virtual size_t Get_Nearest_Points (double x, double y, double z, size_t Count, double Radius);
1344 virtual size_t Get_Nearest_Points (double x, double y, double z, size_t Count, double Radius, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1345 virtual size_t Get_Nearest_Points (double x, double y, double z, size_t Count, size_t *Indices, double *Distances);
1346 virtual bool Get_Nearest_Point (double x, double y, double z, size_t &Index, double &Distance);
1347 virtual bool Get_Nearest_Point (double x, double y, double z, size_t &Index);
1348 virtual bool Get_Nearest_Value (double x, double y, double z, double &Value);
1349 virtual CSG_Shape * Get_Nearest_Shape (double x, double y, double z);
1350 virtual size_t Get_Duplicates (double x, double y, double z, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1351 virtual size_t Get_Duplicates (double x, double y, double z);
1352
1353};
1354
1355
1357// //
1359
1360//---------------------------------------------------------
1362{
1363public:
1366
1367 virtual bool Create (class CSG_Parameters *pParameters, const CSG_String &Parent = "", size_t minPoints = 0);
1368
1369 virtual bool On_Parameter_Changed (class CSG_Parameters *pParameters, class CSG_Parameter *pParameter);
1370 virtual bool On_Parameters_Enable (class CSG_Parameters *pParameters, class CSG_Parameter *pParameter);
1371
1372 bool Do_Use_All (void) const { return( m_maxPoints == 0 && m_Radius <= 0. ); }
1373 bool Do_Use_All (bool bUpdate);
1374
1375 size_t Get_Min_Points (void) const { return( m_minPoints ); }
1376 size_t Get_Max_Points (void) const { return( m_maxPoints ); }
1377 double Get_Radius (void) const { return( m_Radius ); }
1378
1379
1380protected:
1381
1382 bool Update (void);
1383
1384
1386
1387 double m_Radius;
1388
1390
1391};
1392
1393//---------------------------------------------------------
1395{
1396public:
1399
1400 bool Initialize (CSG_Shapes *pPoints, int zField = -1);
1401 bool Finalize (void);
1402
1403 sLong Set_Location (double x, double y);
1404 sLong Set_Location (const CSG_Point &p);
1405
1406 sLong Get_Count (void) const { return( m_pPoints ? m_pPoints->Get_Count() : m_Search.Get_Match_Count() ); }
1407 bool Get_Point (sLong Index, double &x, double &y, double &z);
1408
1409 bool Get_Points (double x, double y, CSG_Points_3D &Points);
1410 bool Get_Points (const CSG_Point &p, CSG_Points_3D &Points);
1411
1412 bool Get_Points (double x, double y, CSG_Array_sLong &Indices);
1413 bool Get_Points (const CSG_Point &p, CSG_Array_sLong &Indices);
1414
1415 bool Get_Points (double x, double y, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1416 bool Get_Points (const CSG_Point &p, CSG_Array_sLong &Indices, CSG_Vector &Distances);
1417
1418
1419private:
1420
1421 int m_zField;
1422
1423 CSG_Shapes *m_pPoints;
1424
1425 CSG_KDTree_2D m_Search;
1426
1427};
1428
1429
1431// //
1432// Polygon Tools //
1433// //
1435
1436//---------------------------------------------------------
1437SAGA_API_DLL_EXPORT bool SG_Shape_Get_Intersection (CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution = NULL);
1438SAGA_API_DLL_EXPORT bool SG_Shape_Get_Difference (CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution = NULL);
1439SAGA_API_DLL_EXPORT bool SG_Shape_Get_ExclusiveOr (CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution = NULL);
1440SAGA_API_DLL_EXPORT bool SG_Shape_Get_Union (CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution = NULL);
1441SAGA_API_DLL_EXPORT bool SG_Shape_Get_Dissolve (CSG_Shape *pSubject , CSG_Shape *pSolution = NULL);
1442#ifdef CLIPPER_ONE
1443SAGA_API_DLL_EXPORT bool SG_Shape_Get_Offset (CSG_Shape *pSubject, double Size, double dArc, CSG_Shape *pSolution = NULL);
1444#else
1445//---------------------------------------------------------
1454
1455//---------------------------------------------------------
1465;
1466
1468#endif // CLIPPER_ONE
1469
1471
1472
1474// //
1475// OpenGIS //
1476// //
1478
1479//---------------------------------------------------------
1481{
1482 SG_OGIS_BYTEORDER_XDR = 0, // Big Endian
1483 SG_OGIS_BYTEORDER_NDR = 1 // Little Endian
1484};
1485
1486//---------------------------------------------------------
1487typedef enum
1488{
1490
1501
1512
1523
1534}
1536
1537
1539// //
1541
1542//---------------------------------------------------------
1544{
1545public:
1547
1548 static bool from_WKText (const CSG_String &Text, CSG_Shape *pShape);
1549 static bool to_WKText (CSG_Shape *pShape, CSG_String &Text);
1550
1551 static bool from_WKBinary (CSG_Bytes &Bytes, CSG_Shape *pShape);
1552 static bool to_WKBinary (CSG_Shape *pShape, CSG_Bytes &Bytes);
1553
1554 static bool from_ShapeType ( CSG_String &Type, TSG_Shape_Type Shape, TSG_Vertex_Type Vertex = SG_VERTEX_TYPE_XY);
1555 static CSG_String from_ShapeType ( TSG_Shape_Type Shape, TSG_Vertex_Type Vertex = SG_VERTEX_TYPE_XY);
1556 static bool to_ShapeType (const CSG_String &Type, TSG_Shape_Type &Shape, TSG_Vertex_Type &Vertex);
1557 static TSG_Shape_Type to_ShapeType (const CSG_String &Type);
1558 static TSG_Vertex_Type to_VertexType (const CSG_String &Type);
1559
1560 static bool from_ShapeType (DWORD &Type, TSG_Shape_Type Shape, TSG_Vertex_Type Vertex = SG_VERTEX_TYPE_XY);
1561 static bool to_ShapeType (DWORD Type, TSG_Shape_Type &Shape, TSG_Vertex_Type &Vertex);
1562 static TSG_Shape_Type to_ShapeType (DWORD Type);
1563 static TSG_Vertex_Type to_VertexType (DWORD Type);
1564
1565 static CSG_String Type_asWKText (DWORD Type);
1566 static DWORD Type_asWKBinary (const CSG_String &Type);
1567
1568
1569private:
1570
1571 static bool _WKT_Read_Point (const CSG_String &Text, CSG_Shape *pShape, int iPart);
1572 static bool _WKT_Read_Points (const CSG_String &Text, CSG_Shape *pShape);
1573 static bool _WKT_Read_Parts (const CSG_String &Text, CSG_Shape *pShape);
1574 static bool _WKT_Read_Polygon (const CSG_String &Text, CSG_Shape *pShape);
1575
1576 static bool _WKT_Write_Point (CSG_String &Text, CSG_Shape *pShape, int iPoint, int iPart);
1577 static bool _WKT_Write_Points (CSG_String &Text, CSG_Shape *pShape, int iPart);
1578 static bool _WKT_Write_Parts (CSG_String &Text, CSG_Shape *pShape);
1579 static bool _WKT_Write_Polygon (CSG_String &Text, CSG_Shape *pShape);
1580
1581 static bool _WKB_Read_Point (CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape, int iPart);
1582 static bool _WKB_Read_Points (CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape);
1583 static bool _WKB_Read_Polygon (CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape);
1584 static bool _WKB_Read_MultiPoint (CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape);
1585 static bool _WKB_Read_MultiLine (CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape);
1586 static bool _WKB_Read_MultiPolygon (CSG_Bytes &Bytes, bool bSwapBytes, TSG_Vertex_Type Vertex, CSG_Shape *pShape);
1587
1588 static bool _WKB_Write_Point (CSG_Bytes &Bytes, CSG_Shape *pShape, int iPoint, int iPart);
1589 static bool _WKB_Write_Points (CSG_Bytes &Bytes, CSG_Shape *pShape, int iPart);
1590 static bool _WKB_Write_MultiPoint (CSG_Bytes &Bytes, CSG_Shape *pShape);
1591 static bool _WKB_Write_MultiLine (CSG_Bytes &Bytes, CSG_Shape *pShape);
1592 static bool _WKB_Write_MultiPolygon (CSG_Bytes &Bytes, CSG_Shape *pShape);
1593
1594};
1595
1596
1598// //
1600
1601//---------------------------------------------------------
1603{
1604public:
1606
1607 static bool from_WKBinary (CSG_Bytes &Bytes, class CSG_Grid *pGrid);
1608 static bool to_WKBinary (CSG_Bytes &Bytes, class CSG_Grid *pGrid, int SRID = -1);
1609
1610};
1611
1612
1614// //
1615// //
1616// //
1618
1619//---------------------------------------------------------
1620#endif // #ifndef HEADER_INCLUDED__SAGA_API__shapes_H
signed long long sLong
Definition api_core.h:158
#define SAGA_API_DLL_EXPORT
Definition api_core.h:94
#define SG_Char
Definition api_core.h:536
bool Update(bool bForce=false)
virtual bool Destroy(void)
Definition kdtree.cpp:482
bool Create(CSG_Shapes *pPoints, int Field=-1)
Definition kdtree.cpp:343
virtual double Get_Point_Value(size_t i) const
Definition shapes.h:1280
CSG_KDTree_2D(void)
Definition kdtree.cpp:318
virtual bool Destroy(void)
Definition kdtree.cpp:863
virtual double Get_Point_Value(size_t i) const
Definition shapes.h:1330
bool Create(CSG_Shapes *pPoints, int Field=-1, int zField=-1, double zScale=1.)
Definition kdtree.cpp:727
CSG_KDTree_3D(void)
Definition kdtree.cpp:699
CSG_KDTree(void)
Definition kdtree.cpp:250
CSG_Array_sLong m_Indices
Definition shapes.h:1243
virtual double Get_Point_Value(int i) const
Definition shapes.h:1233
size_t Get_Match_Count(void) const
Definition shapes.h:1223
CSG_Matrix m_Points
Definition shapes.h:1247
virtual double Get_Point_Value(size_t i) const =0
void _On_Construction(void)
Definition kdtree.cpp:260
double * Get_Point(size_t i) const
Definition shapes.h:1230
void * m_pKDTree
Definition shapes.h:1241
int Get_Point_Count(void) const
Definition shapes.h:1228
class CSG_KDTree_Adaptor * m_pAdaptor
Definition shapes.h:1239
double * Get_Point(int i) const
Definition shapes.h:1229
CSG_Vector m_Distances
Definition shapes.h:1245
virtual bool Destroy(void)
Definition kdtree.cpp:279
double Get_Match_Distance(size_t i) const
Definition shapes.h:1225
bool is_Okay(void) const
Definition shapes.h:1221
size_t Get_Match_Index(size_t i) const
Definition shapes.h:1224
static const char * Get_Version(void)
Definition kdtree.cpp:267
CSG_Rect m_Extent
Definition shapes.h:960
virtual bool is_Leaf(void) const
Definition shapes.h:914
double Get_xMax(void) const
Definition shapes.h:921
double Get_yMin(void) const
Definition shapes.h:922
const CSG_Rect & Get_Extent(void) const
Definition shapes.h:918
class CSG_PRQuadTree_Leaf * asLeaf(void) const
Definition shapes.h:930
double Get_yMax(void) const
Definition shapes.h:924
double Get_Size(void) const
Definition shapes.h:925
virtual bool is_Node(void) const
Definition shapes.h:915
CSG_PRQuadTree_Item(const CSG_Rect &Extent, int Quadrant=-1)
Definition shapes.h:936
void Set_Extent(const CSG_Rect &Extent, int Quadrant=-1)
Definition shapes.h:940
virtual bool has_Statistics(void) const
Definition shapes.h:916
double Get_xMin(void) const
Definition shapes.h:919
bool Contains(const CSG_Point &p) const
Definition shapes.h:927
bool Contains(double x, double y) const
Definition shapes.h:928
virtual ~CSG_PRQuadTree_Item(void)
Definition shapes.h:938
int Get_Quadrant(double x, double y) const
Definition shapes.h:954
double Get_xCenter(void) const
Definition shapes.h:920
double Get_yCenter(void) const
Definition shapes.h:923
int Get_Quadrant(const TSG_Point &p) const
Definition shapes.h:952
class CSG_PRQuadTree_Node * asNode(void) const
Definition shapes.h:931
double Get_Mean(void)
Definition shapes.h:1013
void Add_Value(double z)
Definition shapes.h:1030
double Get_Variance(void)
Definition shapes.h:1014
double Get_StdDev(void)
Definition shapes.h:1015
sLong Get_Count(void)
Definition shapes.h:1007
double Get_Range(void)
Definition shapes.h:1011
friend class CSG_PRQuadTree_Node
Definition shapes.h:1001
CSG_Simple_Statistics s_z
Definition shapes.h:1037
virtual ~CSG_PRQuadTree_Leaf_List(void)
Definition shapes.h:1028
double Get_Sum(void)
Definition shapes.h:1012
CSG_PRQuadTree_Leaf_List(const CSG_Rect &Extent, int Quadrant, double x, double y, double z)
Definition shapes.h:1020
double Get_Maximum(void)
Definition shapes.h:1010
virtual bool has_Statistics(void) const
Definition shapes.h:1005
double Get_Minimum(void)
Definition shapes.h:1009
double Get_Value(sLong i)
Definition shapes.h:1008
double Get_Z(void) const
Definition shapes.h:976
CSG_PRQuadTree_Leaf(const CSG_Rect &Extent, int Quadrant, double x, double y, double z)
Definition shapes.h:981
virtual bool is_Leaf(void) const
Definition shapes.h:971
virtual ~CSG_PRQuadTree_Leaf(void)
Definition shapes.h:989
const TSG_Point & Get_Point(void) const
Definition shapes.h:973
TSG_Point m_Point
Definition shapes.h:994
double Get_X(void) const
Definition shapes.h:974
friend class CSG_PRQuadTree_Node
Definition shapes.h:967
double Get_Y(void) const
Definition shapes.h:975
CSG_PRQuadTree_Node_Statistics(CSG_PRQuadTree_Leaf *pLeaf)
Definition shapes.h:1092
virtual CSG_Simple_Statistics * Get_Z(void)
Definition shapes.h:1083
virtual ~CSG_PRQuadTree_Node_Statistics(void)
Definition shapes.h:1096
friend class CSG_PRQuadTree_Node
Definition shapes.h:1075
CSG_PRQuadTree_Node_Statistics(const CSG_Rect &Extent, int Quadrant=-1)
Definition shapes.h:1088
virtual bool has_Statistics(void) const
Definition shapes.h:1079
CSG_Simple_Statistics m_z
Definition shapes.h:1099
CSG_Simple_Statistics m_x
Definition shapes.h:1099
virtual CSG_Simple_Statistics * Get_X(void)
Definition shapes.h:1081
virtual CSG_Simple_Statistics * Get_Y(void)
Definition shapes.h:1082
CSG_Simple_Statistics m_y
Definition shapes.h:1099
CSG_PRQuadTree_Item * Get_Child(int Quadrant) const
Definition shapes.h:1050
CSG_PRQuadTree_Item * m_pChildren[4]
Definition shapes.h:1067
virtual CSG_Simple_Statistics * Get_Z(void)
Definition shapes.h:1057
virtual CSG_Simple_Statistics * Get_X(void)
Definition shapes.h:1055
CSG_PRQuadTree_Node(const CSG_Rect &Extent, int Quadrant=-1)
Definition quadtree.cpp:61
virtual CSG_Simple_Statistics * Get_Y(void)
Definition shapes.h:1056
virtual bool is_Node(void) const
Definition shapes.h:1048
friend class CSG_PRQuadTree
Definition shapes.h:1044
size_t Get_Point_Count(void) const
Definition shapes.h:1121
bool Get_Selected_Point(size_t i, double &x, double &y, double &z) const
Definition shapes.h:1146
size_t Get_Selected_Count(void) const
Definition shapes.h:1142
CSG_PRQuadTree(void)
Definition quadtree.cpp:183
bool Create(const CSG_Rect &Extent, bool bStatistics=false)
Definition quadtree.cpp:217
double Get_Selected_Distance(size_t i) const
Definition shapes.h:1145
CSG_PRQuadTree_Node * Get_Root_Pointer(void) const
Definition shapes.h:1124
bool Add_Point(double x, double y, double z)
Definition quadtree.cpp:297
CSG_PRQuadTree_Leaf * Get_Selected_Leaf(size_t i) const
Definition shapes.h:1143
void Set_Polar_Search(bool bOn)
Definition shapes.h:1129
double Get_Selected_Z(size_t i) const
Definition shapes.h:1144
void Destroy(void)
Definition quadtree.cpp:277
bool is_Okay(void) const
Definition shapes.h:1126
bool is_Polar(void) const
Definition shapes.h:1128
const CSG_PRQuadTree_Node & Get_Root(void) const
Definition shapes.h:1123
virtual ~CSG_Parameters_Point_Search_KDTree_2D(void)
Definition shapes.h:1398
bool Do_Use_All(void) const
Definition shapes.h:1372
size_t Get_Min_Points(void) const
Definition shapes.h:1375
size_t Get_Max_Points(void) const
Definition shapes.h:1376
virtual ~CSG_Parameters_Point_Search(void)
Definition shapes.h:1365
double Get_Radius(void) const
Definition shapes.h:1377
class CSG_Parameters * m_pParameters
Definition shapes.h:1389
double Get_YCenter(void) const
Definition geo_tools.h:521
double Get_XMax(void) const
Definition geo_tools.h:506
double Get_XMin(void) const
Definition geo_tools.h:505
double Get_YMin(void) const
Definition geo_tools.h:507
double Get_XCenter(void) const
Definition geo_tools.h:520
double Get_YMax(void) const
Definition geo_tools.h:508
friend class CSG_Shapes
Definition shapes.h:601
virtual bool is_Valid(void) const
Definition shapes.h:605
CSG_Shape_Line(class CSG_Shapes *pOwner, sLong Index)
friend class CSG_Shape_Line
Definition shapes.h:371
int Add_Point(double x, double y)
Definition shapes.h:396
int Ins_Point(double x, double y, int iPoint)
class CSG_Shape_Points * Get_Owner(void)
Definition shapes.h:376
int Add_Point(const CSG_Point_4D &p)
Definition shapes.h:399
double m_ZMin
Definition shapes.h:459
CSG_Rect m_Extent
Definition shapes.h:463
bool m_bUpdate
Definition shapes.h:455
friend class CSG_Shape_Points
Definition shapes.h:370
double m_MMax
Definition shapes.h:459
int Add_Point(const CSG_Point_3D &p)
Definition shapes.h:398
TSG_Point_3D Get_Point_Z(int iPoint, bool bAscending=true) const
Definition shapes.h:417
double Get_M(int iPoint, bool bAscending=true) const
Definition shapes.h:429
double Get_Z(int iPoint, bool bAscending=true) const
Definition shapes.h:414
double m_MMin
Definition shapes.h:459
double Get_ZMax(void)
Definition shapes.h:416
friend class CSG_Shape_Polygon
Definition shapes.h:372
double Get_MMin(void)
Definition shapes.h:430
const CSG_Rect & Get_Extent(void)
Definition shapes.h:381
virtual void _Update_Extent(void)
int Ins_Point(const CSG_Point &p, int iPoint)
Definition shapes.h:402
class CSG_Shape_Points * m_pOwner
Definition shapes.h:465
TSG_Point Get_Point(int iPoint, bool bAscending=true) const
Definition shapes.h:385
TSG_Point * m_Points
Definition shapes.h:461
void Set_Z(double z, int iPoint)
Definition shapes.h:413
CSG_Shape_Part(class CSG_Shape_Points *pOwner)
int Set_Point(const CSG_Point &p, int iPoint)
Definition shapes.h:407
double Get_MMax(void)
Definition shapes.h:431
double m_ZMax
Definition shapes.h:459
void Set_M(double m, int iPoint)
Definition shapes.h:428
int Get_Count(void) const
Definition shapes.h:383
virtual void _Invalidate(void)
double Get_ZMin(void)
Definition shapes.h:415
int Add_Point(const CSG_Point &p)
Definition shapes.h:397
virtual bool _Alloc_Memory(int nPoints)
double * m_M
Definition shapes.h:459
TSG_Point_4D Get_Point_ZM(int iPoint, bool bAscending=true) const
Definition shapes.h:432
double * m_Z
Definition shapes.h:459
CSG_Shape_Point_Z(class CSG_Shapes *pOwner, sLong Index)
Definition shapes.h:325
friend class CSG_Shapes
Definition shapes.h:321
virtual double Get_ZMax(void)
Definition shapes.h:330
virtual double Get_ZMin(void)
Definition shapes.h:329
virtual void Set_Z(double z, int iPoint=0, int iPart=0)
Definition shapes.h:327
virtual double Get_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:328
friend class CSG_Shapes
Definition shapes.h:342
virtual double Get_MMax(void)
Definition shapes.h:351
virtual double Get_MMin(void)
Definition shapes.h:350
CSG_Shape_Point_ZM(class CSG_Shapes *pOwner, sLong Index)
Definition shapes.h:346
virtual void Set_M(double m, int iPoint=0, int iPart=0)
Definition shapes.h:348
virtual double Get_M(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:349
virtual double Get_Distance(TSG_Point Point, int iPart) const
Definition shapes.h:298
friend class CSG_Shapes
Definition shapes.h:263
virtual bool On_Assign(CSG_Shape *pShape)
virtual int Add_Point(const CSG_Point_3D &p, int iPart=0)
Definition shapes.h:275
virtual bool is_Valid(void) const
Definition shapes.h:267
virtual int Get_Point_Count(void) const
Definition shapes.h:269
virtual int Set_Point(const CSG_Point &p, int iPoint=0, int iPart=0)
Definition shapes.h:284
virtual double Get_Distance(TSG_Point Point, TSG_Point &Next, int iPart) const
Definition shapes.h:300
virtual int Ins_Point(const CSG_Point_4D &p, int iPoint, int iPart=0)
Definition shapes.h:281
virtual int Set_Point(const CSG_Point_3D &p, int iPoint=0, int iPart=0)
Definition shapes.h:285
virtual int Add_Point(double x, double y, int iPart=0)
Definition shapes.h:273
virtual double Get_Distance(TSG_Point Point) const
Definition shapes.h:297
virtual int Add_Point(const CSG_Point &p, int iPart=0)
Definition shapes.h:274
TSG_Point m_Point
Definition shapes.h:309
virtual int Set_Point(double x, double y, int iPoint=0, int iPart=0)
Definition shapes.h:283
virtual double Get_Distance(TSG_Point Point, TSG_Point &Next) const
Definition shapes.h:299
virtual int Get_Point_Count(int iPart) const
Definition shapes.h:270
virtual int Del_Point(int iPoint, int iPart=0)
Definition shapes.h:288
virtual TSG_Intersection On_Intersects(CSG_Shape *pShape)
CSG_Shape_Point(class CSG_Shapes *pOwner, sLong Index)
virtual TSG_Point Get_Point(int iPoint=0) const
Definition shapes.h:290
virtual int Get_Part_Count(void) const
Definition shapes.h:271
virtual TSG_Point Get_Centroid(void)
Definition shapes.h:293
virtual int Ins_Point(const CSG_Point_3D &p, int iPoint, int iPart=0)
Definition shapes.h:280
virtual TSG_Point Get_Point(int iPoint, int iPart, bool bAscending=true) const
Definition shapes.h:291
virtual int Add_Point(const CSG_Point_4D &p, int iPart=0)
Definition shapes.h:276
virtual int Ins_Point(const CSG_Point &p, int iPoint, int iPart=0)
Definition shapes.h:279
virtual int Ins_Point(double x, double y, int iPoint, int iPart=0)
Definition shapes.h:278
virtual int Set_Point(const CSG_Point_4D &p, int iPoint=0, int iPart=0)
Definition shapes.h:286
virtual int Add_Point(double x, double y, int iPart=0)
Definition shapes.h:502
CSG_Shape_Points(class CSG_Shapes *pOwner, sLong Index)
virtual void _Invalidate(void)
Definition shapes.h:573
double m_ZMax
Definition shapes.h:562
friend class CSG_Shapes
Definition shapes.h:484
virtual void Set_M(double m, int iPoint=0, int iPart=0)
Definition shapes.h:535
friend class CSG_Shape_Part
Definition shapes.h:485
virtual TSG_Point Get_Point(int iPoint=0) const
virtual bool Revert_Points(int iPart)
Definition shapes.h:549
virtual void Set_Z(double z, int iPoint=0, int iPart=0)
Definition shapes.h:530
virtual double Get_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:531
CSG_Shape_Part ** m_pParts
Definition shapes.h:566
CSG_Rect m_Extent
Definition shapes.h:564
virtual TSG_Point Get_Point(int iPoint, int iPart, bool bAscending=true) const
Definition shapes.h:520
virtual CSG_Shape_Part * Get_Part(int iPart) const
Definition shapes.h:498
virtual int Ins_Point(const CSG_Point &p, int iPoint, int iPart=0)
Definition shapes.h:508
virtual int Get_Point_Count(int iPart) const
Definition shapes.h:494
virtual int Get_Part_Count(void) const
Definition shapes.h:495
virtual int Get_Point_Count(void) const
Definition shapes.h:493
virtual double Get_ZMin(void)
Definition shapes.h:532
virtual bool is_Valid(void) const
Definition shapes.h:491
virtual int Add_Point(const CSG_Point &p, int iPart=0)
Definition shapes.h:503
double m_MMax
Definition shapes.h:562
virtual int Ins_Point(double x, double y, int iPoint, int iPart=0)
virtual CSG_Shape_Part * _Get_Part(void)
Definition shapes.h:571
virtual int Add_Point(const CSG_Point_4D &p, int iPart=0)
Definition shapes.h:505
virtual double Get_M(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:536
virtual void Destroy(void)
void _Update_Extent(void)
virtual double Get_ZMax(void)
Definition shapes.h:533
double m_ZMin
Definition shapes.h:562
virtual int Add_Point(const CSG_Point_3D &p, int iPart=0)
Definition shapes.h:504
virtual double Get_MMin(void)
Definition shapes.h:537
virtual const CSG_Rect & Get_Extent(void)
Definition shapes.h:540
virtual int Set_Point(const CSG_Point &p, int iPoint=0, int iPart=0)
Definition shapes.h:513
double m_MMin
Definition shapes.h:562
virtual double Get_MMax(void)
Definition shapes.h:538
virtual void _Invalidate(void)
double Get_Perimeter(void)
Definition shapes.h:651
friend class CSG_Shape_Polygon
Definition shapes.h:645
double Get_Area(void)
Definition shapes.h:653
TSG_Point m_Centroid
Definition shapes.h:684
bool _is_OnEdge(CSG_Shape_Polygon_Part *pPart, const CSG_Point &P, bool bVertex, double Epsilon)
const TSG_Point & Get_Centroid(void)
Definition shapes.h:655
bool is_Clockwise(void)
Definition shapes.h:649
void _Add_Edge_Points(CSG_Shape_Polygon_Part *pPart, const CSG_Point &P0, const CSG_Point &P1, CSG_Points &Part, double Epsilon)
CSG_Shape_Polygon_Part(class CSG_Shape_Points *pOwner)
friend class CSG_Shapes
Definition shapes.h:699
virtual bool is_Valid(void) const
Definition shapes.h:703
CSG_Shape_Polygon_Part * Get_Polygon_Part(int iPart) const
Definition shapes.h:706
virtual CSG_Shape_Part * _Get_Part(void)
Definition shapes.h:754
CSG_Shape_Polygon(class CSG_Shapes *pOwner, sLong Index)
virtual int Get_Point_Count(void) const =0
TSG_Intersection Intersects(CSG_Shape *pShape)
Definition shape.cpp:118
virtual const CSG_Rect & Get_Extent(int iPart)
Definition shapes.h:225
virtual void Set_M(double m, int iPoint=0, int iPart=0)
Definition shapes.h:207
virtual int Get_Point_Count(int iPart) const =0
friend class CSG_Shapes
Definition shapes.h:142
virtual double Get_MMax(void)
Definition shapes.h:210
virtual TSG_Point_4D Get_Point_ZM(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:211
virtual int Add_Point(const CSG_Point_4D &p, int iPart=0)=0
class CSG_Shape_Polygon * asPolygon(void) const
Definition shapes.h:158
virtual bool Revert_Points(int iPart)
Definition shapes.h:237
virtual bool On_Assign(CSG_Shape *pShape)=0
virtual double Get_Distance(TSG_Point Point) const =0
virtual int Add_Part(class CSG_Shape_Part *pPart, bool bRevert=false)
Definition shapes.h:165
virtual int Add_Point(const CSG_Point_3D &p, int iPart=0)=0
TSG_Shape_Type Get_Type(void) const
Definition shape.cpp:88
virtual double Get_Distance(TSG_Point Point, TSG_Point &Next, int iPart) const =0
CSG_Shape(class CSG_Shapes *pOwner, sLong Index)
Definition shape.cpp:63
virtual int Add_Point(double x, double y, int iPart=0)=0
virtual double Get_MMin(void)
Definition shapes.h:209
virtual TSG_Intersection On_Intersects(TSG_Rect Extent)=0
virtual int Get_Part_Count(void) const =0
virtual TSG_Point Get_Point(int iPoint=0) const =0
virtual TSG_Point_3D Get_Point_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:195
virtual int Set_Point(const CSG_Point &p, int iPoint=0, int iPart=0)=0
virtual CSG_Shape_Part * Get_Part(int iPart) const
Definition shapes.h:166
class CSG_Shape_Line * asLine(void) const
Definition shapes.h:157
virtual double Get_ZMax(void)
Definition shapes.h:194
virtual double Get_Distance(TSG_Point Point, TSG_Point &Next) const =0
virtual void _Invalidate(void)
Definition shape.cpp:105
virtual int Ins_Point(const CSG_Point_3D &p, int iPoint, int iPart=0)=0
virtual int Del_Parts(void)
Definition shapes.h:168
virtual double Get_ZMin(void)
Definition shapes.h:193
virtual TSG_Point Get_Point(int iPoint, int iPart, bool bAscending=true) const =0
class CSG_Shape_Point * asPoint(void) const
Definition shapes.h:155
virtual int Set_Point(double x, double y, int iPoint=0, int iPart=0)=0
virtual int Del_Point(int iPoint, int iPart=0)=0
virtual int Ins_Point(const CSG_Point &p, int iPoint, int iPart=0)=0
class CSG_Shape_Points * asPoints(void) const
Definition shapes.h:156
virtual const CSG_Rect & Get_Extent(void)=0
virtual double Get_Distance(TSG_Point Point, int iPart) const =0
virtual double Get_Z(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:192
virtual TSG_Intersection On_Intersects(CSG_Shape *pShape)=0
virtual int Add_Point(const CSG_Point &p, int iPart=0)=0
virtual TSG_Point Get_Centroid(void)=0
virtual void Destroy(void)
Definition shape.cpp:79
virtual int Ins_Point(const CSG_Point_4D &p, int iPoint, int iPart=0)=0
TSG_Vertex_Type Get_Vertex_Type(void) const
Definition shape.cpp:94
virtual int Set_Point(const CSG_Point_3D &p, int iPoint=0, int iPart=0)=0
virtual double Get_M(int iPoint=0, int iPart=0, bool bAscending=true) const
Definition shapes.h:208
virtual void Set_Z(double z, int iPoint=0, int iPart=0)
Definition shapes.h:191
virtual int Set_Point(const CSG_Point_4D &p, int iPoint=0, int iPart=0)=0
virtual int Del_Part(int iPart)
Definition shapes.h:167
virtual int Ins_Point(double x, double y, int iPoint, int iPart=0)=0
virtual bool is_Valid(void) const
Definition shapes.h:804
double m_MMax
Definition shapes.h:841
virtual bool Save(const wchar_t *File, int Format=0)
Definition shapes.h:802
virtual const CSG_Rect & Get_Extent(void)
Definition shapes.h:810
double Get_MMin(void)
Definition shapes.h:814
virtual bool Del_Shapes(void)
Definition shapes.h:821
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 shapes.h:796
virtual CSG_Table_Record * _Get_New_Record(sLong Index)
Definition shapes.cpp:380
double Get_ZMax(void)
Definition shapes.h:813
bool Create(const CSG_Shapes &Shapes)
Definition shapes.cpp:209
virtual bool On_Delete(void)
Definition shapes_io.cpp:72
CSG_Shapes(void)
Definition shapes.cpp:156
double m_ZMax
Definition shapes.h:841
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
double m_MMin
Definition shapes.h:841
TSG_Vertex_Type Get_Vertex_Type(void) const
Definition shapes.h:808
virtual TSG_Shape_Type Get_Type(void) const
Definition shapes.h:806
virtual bool Save(const char *File, int Format=0)
Definition shapes.h:801
double m_ZMin
Definition shapes.h:841
TSG_Vertex_Type m_Vertex_Type
Definition shapes.h:845
friend class CSG_Shape
Definition shapes.h:773
virtual bool On_Update(void)
Definition shapes.cpp:433
virtual bool On_Reload(void)
Definition shapes_io.cpp:66
double Get_ZMin(void)
Definition shapes.h:812
virtual CSG_Shape * Get_Shape_byIndex(sLong Index) const
Definition shapes.h:825
virtual CSG_Shape * Get_Shape(sLong Index) const
Definition shapes.h:824
CSG_Rect m_Extent_Selected
Definition shapes.h:847
double Get_MMax(void)
Definition shapes.h:815
CSG_Table_Value & operator[](int Field) const
Definition table.h:240
CSG_Table_Record(class CSG_Table *pTable, sLong Index)
virtual bool Assign(CSG_Table_Record *pRecord)
sLong Get_Count(void) const
Definition table.h:400
virtual bool Del_Records(void)
Definition table.cpp:936
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
CSG_Rect m_Extent
Definition table.h:493
CSG_Table_Record * Get_Record_byIndex(sLong Index) const
Definition table.h:407
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
double SG_Get_Distance(double ax, double ay, double bx, double by, bool bPolar)
struct SSG_Point TSG_Point
struct SSG_Point_3D TSG_Point_3D
struct SSG_Point_4D TSG_Point_4D
TSG_Intersection
Definition geo_tools.h:101
struct SSG_Rect TSG_Rect
SAGA_API_DLL_EXPORT bool SG_Shape_Get_Offset(CSG_Shape *pSubject, double Size, double dArc, CSG_Shape *pSolution=NULL, TSG_Line_JoinType JoinType=TSG_Line_JoinType::SG_LINE_JOINTYPE_Round, TSG_Line_EndType EndType=TSG_Line_EndType::SG_LINE_ENDTYPE_Round)
ESG_OGIS_ByteOrder
Definition shapes.h:1481
@ SG_OGIS_BYTEORDER_NDR
Definition shapes.h:1483
@ SG_OGIS_BYTEORDER_XDR
Definition shapes.h:1482
SAGA_API_DLL_EXPORT bool SG_Shape_Get_ExclusiveOr(CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution=NULL)
TSG_Polygon_Point_Relation
Definition shapes.h:634
@ SG_POLYGON_POINT_Vertex
Definition shapes.h:636
@ SG_POLYGON_POINT_Edge
Definition shapes.h:637
@ SG_POLYGON_POINT_Outside
Definition shapes.h:635
@ SG_POLYGON_POINT_Interior
Definition shapes.h:638
SAGA_API_DLL_EXPORT TSG_Shape_File_Format SG_Shapes_Get_File_Format_Default(void)
SAGA_API_DLL_EXPORT bool SG_Shapes_Set_File_Format_Default(int Format)
TSG_Line_JoinType
Definition shapes.h:1447
@ SG_LINE_JOINTYPE_Miter
Definition shapes.h:1451
@ SG_LINE_JOINTYPE_Square
Definition shapes.h:1448
@ SG_LINE_JOINTYPE_Bevel
Definition shapes.h:1449
@ SG_LINE_JOINTYPE_Round
Definition shapes.h:1450
SAGA_API_DLL_EXPORT bool SG_Shape_Get_Intersection(CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution=NULL)
TSG_Shape_File_Format
Definition shapes.h:114
@ SHAPE_FILE_FORMAT_Undefined
Definition shapes.h:115
@ SHAPE_FILE_FORMAT_GeoPackage
Definition shapes.h:117
@ SHAPE_FILE_FORMAT_ESRI
Definition shapes.h:116
@ SHAPE_FILE_FORMAT_GeoJSON
Definition shapes.h:118
SAGA_API_DLL_EXPORT CSG_String SG_Get_ShapeType_Name(TSG_Shape_Type Type)
Definition shapes.cpp:65
TSG_Vertex_Type
Definition shapes.h:91
@ SG_VERTEX_TYPE_XYZM
Definition shapes.h:94
@ SG_VERTEX_TYPE_XY
Definition shapes.h:92
@ SG_VERTEX_TYPE_XYZ
Definition shapes.h:93
TSG_ADD_Shape_Copy_Mode
Definition shapes.h:124
@ SHAPE_COPY
Definition shapes.h:128
@ SHAPE_COPY_GEOM
Definition shapes.h:126
@ SHAPE_COPY_ATTR
Definition shapes.h:127
@ SHAPE_NO_COPY
Definition shapes.h:125
SAGA_API_DLL_EXPORT const char * SG_Clipper_Get_Version(void)
TSG_Shape_Type
Definition shapes.h:100
@ SHAPE_TYPE_Polygon
Definition shapes.h:105
@ SHAPE_TYPE_Line
Definition shapes.h:104
@ SHAPE_TYPE_Points
Definition shapes.h:103
@ SHAPE_TYPE_Point
Definition shapes.h:102
@ SHAPE_TYPE_Undefined
Definition shapes.h:101
SAGA_API_DLL_EXPORT bool SG_Shape_Get_Union(CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution=NULL)
TSG_OGIS_Type_Geometry
Definition shapes.h:1488
@ SG_OGIS_TYPE_PolyhedralSurfaceZ
Definition shapes.h:1509
@ SG_OGIS_TYPE_MultiPolygon
Definition shapes.h:1496
@ SG_OGIS_TYPE_TriangleM
Definition shapes.h:1522
@ SG_OGIS_TYPE_GeometryCollectionM
Definition shapes.h:1519
@ SG_OGIS_TYPE_PolygonZM
Definition shapes.h:1526
@ SG_OGIS_TYPE_MultiPolygonZM
Definition shapes.h:1529
@ SG_OGIS_TYPE_MultiPoint
Definition shapes.h:1494
@ SG_OGIS_TYPE_MultiPolygonZ
Definition shapes.h:1507
@ SG_OGIS_TYPE_GeometryCollectionZM
Definition shapes.h:1530
@ SG_OGIS_TYPE_LineStringZ
Definition shapes.h:1503
@ SG_OGIS_TYPE_GeometryCollectionZ
Definition shapes.h:1508
@ SG_OGIS_TYPE_MultiLineStringM
Definition shapes.h:1517
@ SG_OGIS_TYPE_TriangleZM
Definition shapes.h:1533
@ SG_OGIS_TYPE_TINZ
Definition shapes.h:1510
@ SG_OGIS_TYPE_PolyhedralSurfaceM
Definition shapes.h:1520
@ SG_OGIS_TYPE_TIN
Definition shapes.h:1499
@ SG_OGIS_TYPE_TINZM
Definition shapes.h:1532
@ SG_OGIS_TYPE_Undefined
Definition shapes.h:1489
@ SG_OGIS_TYPE_PolyhedralSurface
Definition shapes.h:1498
@ SG_OGIS_TYPE_TINM
Definition shapes.h:1521
@ SG_OGIS_TYPE_Polygon
Definition shapes.h:1493
@ SG_OGIS_TYPE_Point
Definition shapes.h:1491
@ SG_OGIS_TYPE_LineString
Definition shapes.h:1492
@ SG_OGIS_TYPE_PolyhedralSurfaceZM
Definition shapes.h:1531
@ SG_OGIS_TYPE_LineStringZM
Definition shapes.h:1525
@ SG_OGIS_TYPE_PolygonM
Definition shapes.h:1515
@ SG_OGIS_TYPE_MultiLineStringZ
Definition shapes.h:1506
@ SG_OGIS_TYPE_MultiPointM
Definition shapes.h:1516
@ SG_OGIS_TYPE_PointZM
Definition shapes.h:1524
@ SG_OGIS_TYPE_Triangle
Definition shapes.h:1500
@ SG_OGIS_TYPE_MultiPointZM
Definition shapes.h:1527
@ SG_OGIS_TYPE_MultiLineStringZM
Definition shapes.h:1528
@ SG_OGIS_TYPE_MultiPolygonM
Definition shapes.h:1518
@ SG_OGIS_TYPE_MultiPointZ
Definition shapes.h:1505
@ SG_OGIS_TYPE_MultiLineString
Definition shapes.h:1495
@ SG_OGIS_TYPE_LineStringM
Definition shapes.h:1514
@ SG_OGIS_TYPE_PolygonZ
Definition shapes.h:1504
@ SG_OGIS_TYPE_PointM
Definition shapes.h:1513
@ SG_OGIS_TYPE_TriangleZ
Definition shapes.h:1511
@ SG_OGIS_TYPE_PointZ
Definition shapes.h:1502
@ SG_OGIS_TYPE_GeometryCollection
Definition shapes.h:1497
SAGA_API_DLL_EXPORT CSG_String SG_Shapes_Get_File_Extension_Default(void)
SAGA_API_DLL_EXPORT bool SG_Shape_Get_Difference(CSG_Shape *pSubject, CSG_Shape_Polygon *pClip, CSG_Shape *pSolution=NULL)
SAGA_API_DLL_EXPORT bool SG_Shape_Get_Dissolve(CSG_Shape *pSubject, CSG_Shape *pSolution=NULL)
SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes(void)
Definition shapes.cpp:85
TSG_Line_EndType
Definition shapes.h:1457
@ SG_LINE_ENDTYPE_Square
Definition shapes.h:1461
@ SG_LINE_ENDTYPE_Butt
Definition shapes.h:1460
@ SG_LINE_ENDTYPE_Round
Definition shapes.h:1462
@ SG_LINE_ENDTYPE_Joined
Definition shapes.h:1459
@ SG_LINE_ENDTYPE_Polygon
Definition shapes.h:1458
double x
Definition geo_tools.h:129
double y
Definition geo_tools.h:129