SAGA API v9.10
Loading...
Searching...
No Matches
shape.cpp
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// shape.cpp //
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#include "shapes.h"
54
55
57// //
58// //
59// //
61
62//---------------------------------------------------------
64 : CSG_Table_Record(pOwner, Index)
65{}
66
67//---------------------------------------------------------
69{
70 Destroy();
71}
72
73
75// //
77
78//---------------------------------------------------------
80{}
81
82
84// //
86
87//---------------------------------------------------------
89{
90 return( ((CSG_Shapes *)m_pTable)->Get_Type() );
91}
92
93//---------------------------------------------------------
98
99
101// //
103
104//---------------------------------------------------------
105inline void CSG_Shape::_Invalidate(void)
106{
107 ((CSG_Shapes *)m_pTable)->Set_Update_Flag();
108
109 Set_Modified();
110}
111
112
114// //
116
117//---------------------------------------------------------
119{
120 if( !pShape || !Intersects(pShape->Get_Extent()) )
121 {
122 return( INTERSECTION_None );
123 }
124
125 //-----------------------------------------------------
126 if( Get_Extent().is_Equal(pShape->Get_Extent()) && Get_Part_Count() == pShape->Get_Part_Count() && Get_Point_Count() == pShape->Get_Point_Count() )
127 {
128 bool bIdentical = true;
129
130 for(int iPart=0; iPart<Get_Part_Count() && bIdentical; iPart++)
131 {
132 if( Get_Point_Count(iPart) != pShape->Get_Point_Count(iPart) )
133 {
134 bIdentical = false;
135 }
136 else for(int iPoint=0; iPoint<Get_Point_Count(iPart) && bIdentical; iPoint++)
137 {
138 CSG_Point Point(Get_Point(iPoint, iPart));
139
140 if( !Point.is_Equal(pShape->Get_Point(iPoint, iPart)) )
141 {
142 bIdentical = false;
143 }
144 }
145 }
146
147 if( bIdentical )
148 {
149 return( INTERSECTION_Identical );
150 }
151 }
152
153 //-----------------------------------------------------
154 TSG_Intersection Intersection;
155
156 if( Get_Type() >= pShape->Get_Type() && (Intersection = On_Intersects(pShape)) != INTERSECTION_None )
157 {
158 return( Intersection );
159 }
160
161 Intersection = pShape->On_Intersects(this);
162
163 if( Intersection == INTERSECTION_Contained )
164 {
165 return( INTERSECTION_Contains );
166 }
167
168 if( Intersection == INTERSECTION_Contains )
169 {
170 return( INTERSECTION_Contained );
171 }
172
173 return( Intersection );
174}
175
176//---------------------------------------------------------
178{
179 TSG_Intersection Intersection = Get_Extent().Intersects(Region);
180
181 switch( Intersection )
182 {
183 default : return( Intersection );
185 case INTERSECTION_Overlaps: return( On_Intersects(Region) );
186 }
187}
188
189
191// //
193
194//---------------------------------------------------------
196{
197 return( Assign(pRecord, SHAPE_COPY) );
198}
199
200bool CSG_Shape::Assign(CSG_Table_Record *pRecord, bool bAssign_Attributes)
201{
202 return( Assign(pRecord, bAssign_Attributes ? SHAPE_COPY : SHAPE_COPY_GEOM) );
203}
204
206{
207 if( pRecord )
208 {
209 if( (mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_GEOM) && pRecord->Get_Table()->Get_ObjectType() == SG_DATAOBJECT_TYPE_Shapes )
210 {
211 CSG_Shape *pShape = (CSG_Shape *)pRecord;
212
213 if( Get_Type() == pShape->Get_Type() )
214 {
215 On_Assign(pShape);
216 }
217 }
218
219 if( (mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_ATTR) )
220 {
221 return( CSG_Table_Record::Assign(pRecord) );
222 }
223
224 return( true );
225 }
226
227 return( false );
228}
229
230
232// //
233// //
234// //
236
237//---------------------------------------------------------
signed long long sLong
Definition api_core.h:158
virtual bool is_Equal(const CSG_Point &Point, double epsilon=0.) const
Definition geo_tools.h:175
TSG_Intersection Intersects(const CSG_Rect &Rect) const
virtual int Get_Point_Count(void) const =0
TSG_Intersection Intersects(CSG_Shape *pShape)
Definition shape.cpp:118
friend class CSG_Shapes
Definition shapes.h:142
virtual bool On_Assign(CSG_Shape *pShape)=0
TSG_Shape_Type Get_Type(void) const
Definition shape.cpp:88
CSG_Shape(class CSG_Shapes *pOwner, sLong Index)
Definition shape.cpp:63
virtual int Get_Part_Count(void) const =0
virtual TSG_Point Get_Point(int iPoint=0) const =0
virtual void _Invalidate(void)
Definition shape.cpp:105
virtual bool Assign(CSG_Table_Record *pRecord)
Definition shape.cpp:195
virtual ~CSG_Shape(void)
Definition shape.cpp:68
virtual const CSG_Rect & Get_Extent(void)=0
virtual TSG_Intersection On_Intersects(CSG_Shape *pShape)=0
virtual void Destroy(void)
Definition shape.cpp:79
TSG_Vertex_Type Get_Vertex_Type(void) const
Definition shape.cpp:94
void Set_Modified(bool bOn=true)
CSG_Table_Record(class CSG_Table *pTable, sLong Index)
class CSG_Table * m_pTable
Definition table.h:260
class CSG_Table * Get_Table(void)
Definition table.h:135
virtual bool Assign(CSG_Table_Record *pRecord)
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 table.h:318
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
TSG_Intersection
Definition geo_tools.h:101
@ INTERSECTION_Overlaps
Definition geo_tools.h:104
@ INTERSECTION_None
Definition geo_tools.h:102
@ INTERSECTION_Contains
Definition geo_tools.h:106
@ INTERSECTION_Identical
Definition geo_tools.h:103
@ INTERSECTION_Contained
Definition geo_tools.h:105
struct SSG_Rect TSG_Rect
TSG_Vertex_Type
Definition shapes.h:91
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
TSG_Shape_Type
Definition shapes.h:100