CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
SiSpatialIndex.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef _SpatialIndex_h_Included_
25#define _SpatialIndex_h_Included_
26
27#include "OdPlatformSettings.h"
28
29#ifdef SPATIALINDEX_DLL_EXPORTS
30 #define ODSI_API OD_TOOLKIT_EXPORT
31 #define ODSI_API_STATIC OD_STATIC_EXPORT
32#else
33 #define ODSI_API OD_TOOLKIT_IMPORT
34 #define ODSI_API_STATIC OD_STATIC_IMPORT
35#endif
36
38
39#include "RxObject.h"
40#include "Ge/GeExtents3d.h"
41#include "Ge/GeExtents2d.h"
42
43#include "TD_PackPush.h"
44
51{
58 virtual bool contains( const OdGeExtents3d& extents, bool planar, const OdGeTol& tol = OdGeContext::gTol ) const = 0;
65 virtual bool intersects( const OdGeExtents3d& extents, bool planar, const OdGeTol& tol = OdGeContext::gTol ) const = 0;
66
67 virtual ~OdSiShape() {};
68 virtual OdSiShape* clone() const { return 0; }
69 virtual void transform(const OdGeMatrix3d&) {};
70
71 static bool isOverallSpace(const OdSiShape* ptr);
72 static bool isNoSpace(const OdSiShape* ptr);
73
76};
84{
92 virtual bool extents(OdGeExtents3d& extents) const = 0;
93};
94
101{
106 virtual void visit( OdSiEntity* entity, bool completelyInside ) = 0;
107};
108
114
121{
122public:
124
129 {
130 kSiNoFlags = 0,
131
132 kSiPlanar = (1 << 0), // Create 2D Spatial Index.
133 kSiModifyMtAware = (1 << 1), // Protect insert/remove/clear by mutex object.
134 kSiAccessMtAware = (1 << 2), // Protect query/extents/tolerance by mutex object.
135
136 kSiFullMtAware = (kSiModifyMtAware | kSiAccessMtAware)
137 };
138
151 static OdSiSpatialIndexPtr createObject( OdUInt32 flags, unsigned int initialNumEntity, unsigned int maxDepth = 30, unsigned int maxCount = 20, double eps = 1e-10 );
152
157 virtual void insert( OdSiEntity* entity ) = 0;
164 virtual bool remove( OdSiEntity* entity ) = 0;
165
170 virtual void query( const OdSiShape& shape, OdSiVisitor& visitor ) const = 0;
174 virtual void clear() = 0;
181 virtual void setMaxTreeDepth( unsigned char maxDepth ) = 0;
186 virtual void setMaxNodeSize( unsigned char maxCount ) = 0;
194 virtual bool extents(OdGeExtents3d& extents) const = 0;
195
201 virtual unsigned maxTreeDepth() const = 0;
202
206 virtual unsigned maxNodeSize() const = 0;
207
214 virtual const OdGeTol& tolerance() const = 0;
215
216 virtual void setTolerance(const OdGeTol& tol) = 0;
217};
218
219namespace OdSi
220{
222}
223
230{
231 virtual void update(const OdGeExtents3d& we) const = 0;
232};
233
236
244{
246 {
247 }
248
250 {
251 reset(shapes);
252 }
253
255 {
256 clear();
257 }
258
260 {
261 return m_shapes;
262 }
263
264 void reset(const OdSiShapeConstPtrArray& shapes)
265 {
266 clear();
267 m_shapes.reserve(shapes.size());
268 for(OdSiShapeConstPtrArray::const_iterator it = shapes.begin(); it != shapes.end(); it++)
269 m_shapes.push_back((*it)->clone());
270 }
271
272 void clear()
273 {
274 for(OdSiShapePtrArray::iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
275 delete *it;
276 m_shapes.clear();
277 }
278 virtual bool contains(const OdGeExtents3d& extents, bool planar, const OdGeTol& tol = OdGeContext::gTol) const
279 {
280 for(OdSiShapePtrArray::const_iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
281 {
282 if(!(*it)->contains(extents, planar, tol))
283 return false;
284 }
285 return true;
286 }
287
288 virtual bool intersects( const OdGeExtents3d& extents, bool planar, const OdGeTol& tol = OdGeContext::gTol ) const
289 {
290 for(OdSiShapePtrArray::const_iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
291 {
292 if(!(*it)->intersects(extents, planar, tol))
293 return false;
294 }
295 return true;
296 }
297
298 virtual OdSiShape* clone() const
299 {
301 ar.reserve(m_shapes.size());
302 for(OdSiShapePtrArray::const_iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
303 ar.push_back(*it);
304 return new OdSiShapesIntersection(ar);
305 }
306
307 virtual void transform(const OdGeMatrix3d& tf)
308 {
309 for(OdSiShapePtrArray::iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
310 (*it)->transform(tf);
311 }
312
313private:
314 OdSiShapePtrArray m_shapes;
315};
316
317#include "TD_PackPop.h"
318
319#endif
tol
Definition: DimVarDefs.h:2287
unsigned int OdUInt32
#define ODSI_API
#define ODSI_API_STATIC
OdArray< OdSiShape *, OdMemoryAllocator< OdSiShape * > > OdSiShapePtrArray
OdSmartPtr< OdSiSpatialIndex > OdSiSpatialIndexPtr
OdArray< const OdSiShape *, OdMemoryAllocator< const OdSiShape * > > OdSiShapeConstPtrArray
iterator end()
Definition: OdArray.h:1041
size_type size() const
Definition: OdArray.h:1247
void push_back(const T &value)
Definition: OdArray.h:1411
iterator begin()
Definition: OdArray.h:1017
void reserve(size_type reserveLength)
Definition: OdArray.h:1281
Definition: GeTol.h:49
virtual void clear()=0
static OdSiSpatialIndexPtr createObject(OdUInt32 flags, unsigned int initialNumEntity, unsigned int maxDepth=30, unsigned int maxCount=20, double eps=1e-10)
virtual void setTolerance(const OdGeTol &tol)=0
virtual void insert(OdSiEntity *entity)=0
virtual void setMaxNodeSize(unsigned char maxCount)=0
virtual unsigned maxNodeSize() const =0
ODRX_DECLARE_MEMBERS(OdSiSpatialIndex)
virtual unsigned maxTreeDepth() const =0
virtual void query(const OdSiShape &shape, OdSiVisitor &visitor) const =0
virtual bool remove(OdSiEntity *entity)=0
virtual const OdGeTol & tolerance() const =0
virtual bool extents(OdGeExtents3d &extents) const =0
virtual void setMaxTreeDepth(unsigned char maxDepth)=0
GLsizei maxCount
Definition: gles2_ext.h:276
Definition: SiVolume.h:34
bool ODSI_API properExtents(const OdGeExtents3d &ext)
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65
virtual void update(const OdGeExtents3d &we) const =0
virtual bool extents(OdGeExtents3d &extents) const =0
virtual ~OdSiShape()
virtual OdSiShape * clone() const
static ODSI_API_STATIC const OdSiShape & kOverallSpace
virtual bool contains(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol=OdGeContext::gTol) const =0
virtual bool intersects(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol=OdGeContext::gTol) const =0
virtual void transform(const OdGeMatrix3d &)
static bool isOverallSpace(const OdSiShape *ptr)
static ODSI_API_STATIC const OdSiShape & kNoSpace
static bool isNoSpace(const OdSiShape *ptr)
virtual OdSiShape * clone() const
void reset(const OdSiShapeConstPtrArray &shapes)
const OdSiShapePtrArray & shapes() const
virtual void transform(const OdGeMatrix3d &tf)
virtual bool intersects(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol=OdGeContext::gTol) const
virtual bool contains(const OdGeExtents3d &extents, bool planar, const OdGeTol &tol=OdGeContext::gTol) const
OdSiShapesIntersection(const OdSiShapeConstPtrArray &shapes)
virtual void visit(OdSiEntity *entity, bool completelyInside)=0