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