CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
BBox.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 _SpBBox_h_Included_
25#define _SpBBox_h_Included_
26
27#include "Si/SiSpatialIndex.h"
28#define _CORE_18621
29#ifdef _CORE_18621
30#include "Gs/SiBBlock.h"
31#else
32#include "Ge/GeBoundBlock3d.h"
33#endif
34
39namespace OdSi
40{
46#ifdef _CORE_18621
47 class BBox : public OdSiBoundBlock3d, public OdSiShape
48#else
49 class BBox : public OdGeBoundBlock3d, public OdSiShape
50#endif
51 {
52 public:
54 {
57 };
58
81 {
82 points[0] = extents.minPoint();
83 points[1].set( extents.minPoint().x, extents.maxPoint().y, extents.minPoint().z );
84 points[2].set( extents.maxPoint().x, extents.maxPoint().y, extents.minPoint().z );
85 points[3].set( extents.maxPoint().x, extents.minPoint().y, extents.minPoint().z );
86
87 if(points->z == extents.maxPoint().z)
88 return k2dExtents;
89
90 points[4].set( extents.minPoint().x, extents.minPoint().y, extents.maxPoint().z );
91 points[5].set( extents.minPoint().x, extents.maxPoint().y, extents.maxPoint().z );
92 points[6] = extents.maxPoint();
93 points[7].set( extents.maxPoint().x, extents.minPoint().y, extents.maxPoint().z );
94
95 return k3dExtents;
96 }
97
122 static ExtentsType explodeExtent(OdGePoint3d* points, const OdGePoint3d &origin, const OdGeVector3d &xAxis, const OdGeVector3d &yAxis, const OdGeVector3d &zAxis)
123 {
124 points[0] = origin;
125 points[1] = points[0] + xAxis;
126 points[2] = points[0] + xAxis + yAxis;
127 points[3] = points[0] + yAxis;
128
129 if(OdZero(zAxis.length()))
130 return k2dExtents;
131
132 points[4] = points[0] + zAxis;
133 points[5] = points[1] + zAxis;
134 points[6] = points[2] + zAxis;
135 points[7] = points[3] + zAxis;
136
137 return k3dExtents;
138 }
139
140 virtual bool contains( const OdGeExtents3d& extents, bool planar = false, const OdGeTol& tol = OdGeContext::gTol ) const
141 {
142 ODA_ASSERT( planar == false );
143
144#ifdef _CORE_18621
146#else
147 if ( !OdGeBoundBlock3d::contains( extents.minPoint(), tol ) )
148 return false;
149 if ( !OdGeBoundBlock3d::contains( extents.maxPoint(), tol ) )
150 return false;
151 if ( !OdGeBoundBlock3d::contains( OdGePoint3d( extents.minPoint().x,
152 extents.maxPoint().y, extents.minPoint().z ), tol ) )
153 return false;
154 if ( !OdGeBoundBlock3d::contains( OdGePoint3d( extents.maxPoint().x,
155 extents.minPoint().y, extents.minPoint().z ), tol ) )
156 return false;
157 if(OdEqual(extents.maxPoint().z, extents.minPoint().z, tol.equalPoint()))
158 return true;
159 if ( !OdGeBoundBlock3d::contains( OdGePoint3d( extents.minPoint().x,
160 extents.maxPoint().y, extents.maxPoint().z ), tol ) )
161 return false;
162 if ( !OdGeBoundBlock3d::contains( OdGePoint3d( extents.maxPoint().x,
163 extents.minPoint().y, extents.maxPoint().z ), tol ) )
164 return false;
165
166 return true;
167#endif
168 }
169
170 virtual bool intersects( const OdGeExtents3d& extents, bool planar = false, const OdGeTol& tol = OdGeContext::gTol) const
171 {
172 ODA_ASSERT( planar == false );
173#ifdef _CORE_18621
175#else
176 if (isBox())
177 {
178 OdGePoint3d minPt, maxPt;
179 getMinMaxPoints(minPt, maxPt);
180 return !OdGeExtents3d(minPt, maxPt).isDisjoint(extents, tol);
181 }
182 else
183 return !OdGeBoundBlock3d( extents.minPoint(), extents.maxPoint() ).isDisjoint( *this, tol );
184#endif
185 }
186
187 virtual OdSiShape* clone() const
188 {
189 return new BBox(*this);
190 }
191
192 virtual void transform(const OdGeMatrix3d& mtx)
193 {
194#ifdef _CORE_18621
196#else
197 setToBox(false);
198 transformBy(mtx);
199 setToBoxOrtho();
200#endif
201 }
202
216 BBox() {}
217#ifdef _CORE_18621
219 BBox( const OdGePoint3d& base, const OdGeVector3d& side1,
220 const OdGeVector3d& side2, const OdGeVector3d& side3 )
221 : OdSiBoundBlock3d( base, side1, side2, side3 ) { }
222 BBox( const OdGePoint3d& p1, const OdGePoint3d& p2 )
223 : OdSiBoundBlock3d( p1, p2 ) { }
224#else
225 BBox( const BBox& source ) : OdGeBoundBlock3d( source ) {}
226 BBox( const OdGePoint3d& base, const OdGeVector3d& side1,
227 const OdGeVector3d& side2, const OdGeVector3d& side3 )
228 : OdGeBoundBlock3d( base, side1, side2, side3 )
229 {
230 setToBoxOrtho(side1, side2, side3);
231 }
232 BBox( const OdGePoint3d& p1, const OdGePoint3d& p2 )
233 : OdGeBoundBlock3d( p1, p2 ){}
234#endif
235 };
236}
237
238#endif
#define ODA_ASSERT(exp)
Definition DebugStuff.h:57
tol
bool OdEqual(double x, double y, double tol=1.e-10)
Definition OdaDefs.h:542
bool OdZero(double x, double tol=1.e-10)
Definition OdaDefs.h:532
bool isDisjoint(const OdGeBoundBlock3d &block, const OdGeTol &tol=OdGeContext::gTol) const
bool contains(const OdGePoint3d &point, const OdGeTol &tol=OdGeContext::gTol) const
bool isDisjoint(const OdGeExtents3d &extents, const OdGeTol &tol=OdGeContext::gTol) const
OdGePoint3d & set(double xx, double yy, double zz)
Definition GePoint3d.h:476
double length() const
BBox(const BBox &source)
Definition BBox.h:218
static ExtentsType explodeExtent(OdGePoint3d *points, const OdGePoint3d &origin, const OdGeVector3d &xAxis, const OdGeVector3d &yAxis, const OdGeVector3d &zAxis)
Definition BBox.h:122
ExtentsType
Definition BBox.h:54
@ k2dExtents
Definition BBox.h:55
@ k3dExtents
Definition BBox.h:56
virtual OdSiShape * clone() const
Definition BBox.h:187
virtual bool intersects(const OdGeExtents3d &extents, bool planar=false, const OdGeTol &tol=OdGeContext::gTol) const
Definition BBox.h:170
BBox(const OdGePoint3d &p1, const OdGePoint3d &p2)
Definition BBox.h:222
virtual bool contains(const OdGeExtents3d &extents, bool planar=false, const OdGeTol &tol=OdGeContext::gTol) const
Definition BBox.h:140
BBox(const OdGePoint3d &base, const OdGeVector3d &side1, const OdGeVector3d &side2, const OdGeVector3d &side3)
Definition BBox.h:219
static ExtentsType explodeExtent(OdGePoint3d *points, const OdGeExtents3d &extents)
Definition BBox.h:80
virtual void transform(const OdGeMatrix3d &mtx)
Definition BBox.h:192
bool isDisjoint(const OdGeExtents3d &exts, const OdGeTol &tolerance=OdGeContext::gTol) const
Definition SiBBlock.h:342
void getMinMaxPoints(OdGePoint3d &p1, OdGePoint3d &p2) const
Definition SiBBlock.h:283
void transformBy(const OdGeMatrix3d &tm)
Definition SiBBlock.h:213
bool contains(const OdGeExtents3d &exts, const OdGeTol &tolerance=OdGeContext::gTol) const
Definition SiBBlock.h:398
void extents(OdGeExtents3d &exts) const
Definition SiBBlock.h:290
bool isBox() const
Definition SiBBlock.h:292
GLsizei GLsizei GLchar * source
Definition gles2_ext.h:282
static GE_STATIC_EXPORT OdGeTol gTol
Definition GeGbl.h:67