CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
BBox.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
25#ifndef _SpBBox_h_Included_
26#define _SpBBox_h_Included_
27
28#include "Si/SiSpatialIndex.h"
29#include "Ge/GeBoundBlock3d.h"
30
35namespace OdSi
36{
42 class BBox : public OdGeBoundBlock3d, public OdSiShape
43 {
44 public:
46 {
48 k3dExtents = 1
49 };
50
72 static ExtentsType explodeExtent(OdGePoint3d* points, const OdGeExtents3d& extents)
73 {
74 points[0] = extents.minPoint();
75 points[1].set( extents.minPoint().x, extents.maxPoint().y, extents.minPoint().z );
76 points[2].set( extents.maxPoint().x, extents.maxPoint().y, extents.minPoint().z );
77 points[3].set( extents.maxPoint().x, extents.minPoint().y, extents.minPoint().z );
78
79 if(points->z == extents.maxPoint().z)
80 return k2dExtents;
81
82 points[4].set( extents.minPoint().x, extents.minPoint().y, extents.maxPoint().z );
83 points[5].set( extents.minPoint().x, extents.maxPoint().y, extents.maxPoint().z );
84 points[6] = extents.maxPoint();
85 points[7].set( extents.maxPoint().x, extents.minPoint().y, extents.maxPoint().z );
86
87 return k3dExtents;
88 }
89
112 {
113 OdGeVector3d side1, side2, side3;
114 extents.get(points[0], side1, side2, side3);
115
116 points[1] = points[0] + side1;
117 points[2] = points[0] + side1 + side2;
118 points[3] = points[0] + side2;
119
120 if(OdZero(side3.length()))
121 return k2dExtents;
122
123 points[4] = points[0] + side3;
124 points[5] = points[1] + side3;
125 points[6] = points[2] + side3;
126 points[7] = points[3] + side3;
127
128 return k3dExtents;
129 }
130
131 virtual bool contains( const OdGeExtents3d& extents, bool planar = false, const OdGeTol& tol = OdGeContext::gTol ) const
132 {
133 ODA_ASSERT( planar == false );
134
135 if ( !OdGeBoundBlock3d::contains( extents.minPoint(), tol ) )
136 return false;
137 if ( !OdGeBoundBlock3d::contains( extents.maxPoint(), tol ) )
138 return false;
140 extents.maxPoint().y, extents.minPoint().z ), tol ) )
141 return false;
143 extents.minPoint().y, extents.minPoint().z ), tol ) )
144 return false;
145 if(OdEqual(extents.maxPoint().z, extents.minPoint().z, tol.equalPoint()))
146 return true;
148 extents.maxPoint().y, extents.maxPoint().z ), tol ) )
149 return false;
151 extents.minPoint().y, extents.maxPoint().z ), tol ) )
152 return false;
153
154 return true;
155 }
156
157 virtual bool intersects( const OdGeExtents3d& extents, bool planar = false, const OdGeTol& tol = OdGeContext::gTol) const
158 {
159 ODA_ASSERT( planar == false );
160 if (isBox())
161 {
162 OdGePoint3d minPt, maxPt;
163 getMinMaxPoints(minPt, maxPt);
164 return !OdGeExtents3d(minPt, maxPt).isDisjoint(extents, tol);
165 }
166 else
167 return !OdGeBoundBlock3d( extents.minPoint(), extents.maxPoint() ).isDisjoint( *this, tol );
168 }
169
170 virtual OdSiShape* clone() const
171 {
172 return new BBox(*this);
173 }
174
175 virtual void transform(const OdGeMatrix3d& mtx)
176 {
177 setToBox(false);
178 transformBy(mtx);
180 }
181
195 BBox() {}
197 BBox( const OdGePoint3d& base, const OdGeVector3d& side1,
198 const OdGeVector3d& side2, const OdGeVector3d& side3 )
199 : OdGeBoundBlock3d( base, side1, side2, side3 )
200 {
201 setToBoxOrtho(side1, side2, side3);
202 }
203 BBox( const OdGePoint3d& p1, const OdGePoint3d& p2 )
204 : OdGeBoundBlock3d( p1, p2 ){}
205 };
206}
207
208#endif
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
tol
Definition: DimVarDefs.h:2287
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 contains(const OdGePoint3d &point, const OdGeTol &tol=OdGeContext::gTol) const
bool isBox() const
OdGeBoundBlock3d & setToBox(bool toBox)
void get(OdGePoint3d &base, OdGeVector3d &side1, OdGeVector3d &side2, OdGeVector3d &side3) const
void getMinMaxPoints(OdGePoint3d &p1, OdGePoint3d &p2) const
OdGeEntity3d & transformBy(const OdGeMatrix3d &xfm)
bool isDisjoint(const OdGeExtents3d &extents, const OdGeTol &tol=OdGeContext::gTol) const
Definition: GeExtents3d.h:545
const OdGePoint3d & maxPoint() const
Definition: GeExtents3d.h:443
const OdGePoint3d & minPoint() const
Definition: GeExtents3d.h:438
double z
Definition: GePoint3d.h:497
double y
Definition: GePoint3d.h:496
double x
Definition: GePoint3d.h:495
OdGePoint3d & set(double xx, double yy, double zz)
Definition: GePoint3d.h:455
Definition: GeTol.h:49
double length() const
static ExtentsType explodeExtent(OdGePoint3d *points, const OdGeBoundBlock3d &extents)
Definition: BBox.h:111
BBox(const BBox &source)
Definition: BBox.h:196
ExtentsType
Definition: BBox.h:46
@ k2dExtents
Definition: BBox.h:47
@ k3dExtents
Definition: BBox.h:48
virtual OdSiShape * clone() const
Definition: BBox.h:170
virtual bool intersects(const OdGeExtents3d &extents, bool planar=false, const OdGeTol &tol=OdGeContext::gTol) const
Definition: BBox.h:157
BBox(const OdGePoint3d &p1, const OdGePoint3d &p2)
Definition: BBox.h:203
virtual bool contains(const OdGeExtents3d &extents, bool planar=false, const OdGeTol &tol=OdGeContext::gTol) const
Definition: BBox.h:131
BBox()
Definition: BBox.h:195
BBox(const OdGePoint3d &base, const OdGeVector3d &side1, const OdGeVector3d &side2, const OdGeVector3d &side3)
Definition: BBox.h:197
static ExtentsType explodeExtent(OdGePoint3d *points, const OdGeExtents3d &extents)
Definition: BBox.h:72
virtual void transform(const OdGeMatrix3d &mtx)
Definition: BBox.h:175
GLsizei GLsizei GLchar * source
Definition: gles2_ext.h:282
Definition: SiVolume.h:34
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65