CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
SiSpatialIndex.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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};
77
84{
92 virtual bool extents(OdGeExtents3d& extents) const = 0;
93};
94
101{
106 virtual void visit( OdSiEntity* entity, bool completelyInside ) = 0;
107};
108
114
120class ODSI_API OdSiSpatialIndex : public OdRxObject
121{
122public:
124
129 {
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
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
220 virtual void setTolerance(const OdGeTol& tol) = 0;
221
227 virtual bool isInitialized() const = 0;
228};
229
230namespace OdSi
231{
233}
234
241{
242 virtual void update(const OdGeExtents3d& we) const = 0;
243};
244
247
255{
259
264
266 {
267 clear();
268 }
269
271 {
272 return m_shapes;
273 }
274
276 {
277 clear();
278 m_shapes.reserve(shapes.size());
279 for(OdSiShapeConstPtrArray::const_iterator it = shapes.begin(); it != shapes.end(); it++)
280 m_shapes.push_back((*it)->clone());
281 }
282
283 void clear()
284 {
285 for(OdSiShapePtrArray::iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
286 delete *it;
287 m_shapes.clear();
288 }
289 virtual bool contains(const OdGeExtents3d& extents, bool planar, const OdGeTol& tol = OdGeContext::gTol) const
290 {
291 for(OdSiShapePtrArray::const_iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
292 {
293 if(!(*it)->contains(extents, planar, tol))
294 return false;
295 }
296 return true;
297 }
298
299 virtual bool intersects( const OdGeExtents3d& extents, bool planar, const OdGeTol& tol = OdGeContext::gTol ) const
300 {
301 for(OdSiShapePtrArray::const_iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
302 {
303 if(!(*it)->intersects(extents, planar, tol))
304 return false;
305 }
306 return true;
307 }
308
309 virtual OdSiShape* clone() const
310 {
312 ar.reserve(m_shapes.size());
313 for(OdSiShapePtrArray::const_iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
314 ar.push_back(*it);
315 return new OdSiShapesIntersection(ar);
316 }
317
318 virtual void transform(const OdGeMatrix3d& tf)
319 {
320 for(OdSiShapePtrArray::iterator it = m_shapes.begin(); it != m_shapes.end(); it++)
321 (*it)->transform(tf);
322 }
323
324private:
325 OdSiShapePtrArray m_shapes;
326};
327
328#include "TD_PackPop.h"
329
330#endif
tol
OdArray< const OdSiShape *, OdMemoryAllocator< const OdSiShape * > > OdSiShapeConstPtrArray
Definition GsViewImpl.h:54
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
void push_back(const T &value)
Definition OdArray.h:1422
void reserve(size_type reserveLength)
Definition OdArray.h:1288
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 bool isInitialized() const =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
bool ODSI_API properExtents(const OdGeExtents3d &ext)
static GE_STATIC_EXPORT OdGeTol gTol
Definition GeGbl.h:67
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