CFx SDK Documentation  2022 SP0
GsCullingVolume.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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 _ODGSCULLINGVOLUME_H_INCLUDED_
25 #define _ODGSCULLINGVOLUME_H_INCLUDED_
26 
27 #include "OdaCommon.h"
28 #include "RxObject.h"
29 #include "Gs/GsExport.h"
30 #include "Ge/GeBoundBlock3d.h"
31 #include "Ge/GeExtents3d.h"
32 #include "Ge/GePoint3d.h"
33 #include "Ge/GeSphere.h"
34 #include "Ge/GeVector3d.h"
35 
36 #include "TD_PackPush.h"
37 
38 // Culling primitives:
39 // BBox (AABB - Axis Aligned Bounding Box)
40 // BSphere (Bounding Sphere)
41 // OBBox (OBB - Oriented Bounding Box)
42 
51 {
52  public:
65  {
68  kPrimOBBox
69  };
70  public:
72  {
73  }
74 
76  {
77  }
78 
90  virtual PrimitiveType primitiveType() const = 0;
91 };
92 
101 {
102  public:
105  , OdGeExtents3d()
106  {
107  }
108 
111  , OdGeExtents3d(min, max)
112  {
113  }
114 
117  , OdGeExtents3d(ext.minPoint(), ext.maxPoint())
118  {
119  }
120 
123  , OdGeExtents3d(aabb.minPoint(), aabb.maxPoint())
124  {
125  }
126 
128  {
129  }
130 
131  OdGsCullingBBox &operator =(const OdGeExtents3d &ext)
132  {
133  set(ext.minPoint(), ext.maxPoint());
134  return *this;
135  }
136 
137  OdGsCullingBBox &operator =(const OdGsCullingBBox &aabb)
138  {
139  set(aabb.minPoint(), aabb.maxPoint());
140  return *this;
141  }
142 
143  // OdGsCullingPrimitive overrides
144 
149  {
150  return kPrimBBox;
151  }
152 };
153 
161 class GS_TOOLKIT_EXPORT OdGsCullingBSphere : public OdGsCullingPrimitive, public OdGeSphere // GeSphere has many unnecessary data for culling
162 {
163  public:
166  , OdGeSphere()
167  {
168  }
169 
170  OdGsCullingBSphere(double radius, const OdGePoint3d &center)
172  , OdGeSphere(radius, center)
173  {
174  }
175 
178  , OdGeSphere(sphere)
179  {
180  }
181 
184  , OdGeSphere(bsphere)
185  {
186  }
187 
189  {
190  }
191 
192  OdGsCullingBSphere &operator =(const OdGeSphere &sphere)
193  {
194  set(sphere.radius(), sphere.center());
195  return *this;
196  }
197 
198  OdGsCullingBSphere &operator =(const OdGsCullingBSphere &bsphere)
199  {
200  set(bsphere.radius(), bsphere.center());
201  return *this;
202  }
203 
204  // OdGsCullingPrimitive overrides
205 
210  {
211  return kPrimBSphere;
212  }
213 };
214 
223 {
224  public:
227  , OdGeBoundBlock3d()
228  {
229  }
230 
231  OdGsCullingOBBox(const OdGePoint3d &base, const OdGeVector3d &xAxis, const OdGeVector3d &yAxis, const OdGeVector3d &zAxis)
233  , OdGeBoundBlock3d(base, xAxis, yAxis, zAxis)
234  {
235  }
236 
239  , OdGeBoundBlock3d(bb)
240  {
241  }
242 
245  , OdGeBoundBlock3d(obb)
246  {
247  }
248 
250  {
251  }
252 
253  OdGsCullingOBBox &operator =(const OdGeBoundBlock3d &bb)
254  {
255  OdGePoint3d base; OdGeVector3d side1, side2, side3;
256  bb.get(base, side1, side2, side3);
257  set(base, side1, side2, side3);
258  return *this;
259  }
260 
261  OdGsCullingOBBox &operator =(const OdGsCullingOBBox &obb)
262  {
263  OdGePoint3d base; OdGeVector3d side1, side2, side3;
264  obb.get(base, side1, side2, side3);
265  set(base, side1, side2, side3);
266  return *this;
267  }
268 
269  // OdGsCullingPrimitive overrides
270 
275  {
276  return kPrimOBBox;
277  }
278 };
279 
280 // Projection culling primitives:
281 // Ortho (Orthogonal culling box merged with optimization for 2d mode)
282 // Frustum (Perspective culling box without near and far culling planes)
283 
292 {
293  public:
295  {
297  kProjPerspective
298  };
300  {
301  kIntersectNot, // No intersection detected
302  kIntersectOk, // Intersects with projection boundary
303  kIntersectIn // Primitive completely inside projection boundary
304  };
305  public:
307 
318  virtual ProjectionType projectionType() const = 0;
319 
324  virtual bool intersectWithOpt(const OdGsCullingPrimitive &prim) const = 0;
340  virtual IntersectionStatus intersectWith(const OdGsCullingPrimitive &prim) const = 0;
341 
346  virtual void transformBy(const OdGeMatrix3d& xfm) = 0;
347 };
348 
353 
362 {
363  public:
365 
374  virtual void init(const OdGePoint3d &position, const OdGeVector3d &direction, const OdGeVector3d &upVector,
375  double volumeWidth, double volumeHeight) = 0;
376 };
377 
382 
391 {
392  public:
394 
406  virtual void init(const OdGePoint3d &position, const OdGeVector3d &direction, const OdGeVector3d &upVector,
407  double fovY, double aspect, OdUInt32 nPlanes = 4, double nearZ = 1.0, double farZ = 1e20) = 0;
420  virtual void init(const OdGePoint3d &position, const OdGeVector3d &direction, const OdGeVector3d &upVector,
421  double fovX, bool aspect, double fovY, OdUInt32 nPlanes = 4, double nearZ = 1.0, double farZ = 1e20) = 0;
422 };
423 
428 
429 #include "TD_PackPop.h"
430 
431 #endif // _ODGSCULLINGVOLUME_H_INCLUDED_
OdSmartPtr< OdGsOrthoCullingVolume > OdGsOrthoCullingVolumePtr
OdSmartPtr< OdGsFrustumCullingVolume > OdGsFrustumCullingVolumePtr
OdSmartPtr< OdGsCullingVolume > OdGsCullingVolumePtr
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
unsigned int OdUInt32
void get(OdGePoint3d &base, OdGeVector3d &side1, OdGeVector3d &side2, OdGeVector3d &side3) const
const OdGePoint3d & maxPoint() const
Definition: GeExtents3d.h:242
const OdGePoint3d & minPoint() const
Definition: GeExtents3d.h:237
OdGePoint3d center() const
double radius() const
OdGsCullingBBox(const OdGePoint3d &min, const OdGePoint3d &max)
OdGsCullingBBox(const OdGeExtents3d &ext)
OdGsCullingBBox(const OdGsCullingBBox &aabb)
PrimitiveType primitiveType() const
OdGsCullingBSphere(const OdGsCullingBSphere &bsphere)
OdGsCullingBSphere(double radius, const OdGePoint3d &center)
PrimitiveType primitiveType() const
OdGsCullingBSphere(const OdGeSphere &sphere)
PrimitiveType primitiveType() const
OdGsCullingOBBox(const OdGePoint3d &base, const OdGeVector3d &xAxis, const OdGeVector3d &yAxis, const OdGeVector3d &zAxis)
OdGsCullingOBBox(const OdGeBoundBlock3d &bb)
OdGsCullingOBBox(const OdGsCullingOBBox &obb)
virtual ~OdGsCullingPrimitive()
virtual PrimitiveType primitiveType() const =0
virtual void transformBy(const OdGeMatrix3d &xfm)=0
virtual bool intersectWithOpt(const OdGsCullingPrimitive &prim) const =0
virtual IntersectionStatus intersectWith(const OdGsCullingPrimitive &prim) const =0
virtual ProjectionType projectionType() const =0
ODRX_DECLARE_MEMBERS(OdGsCullingVolume)
virtual void init(const OdGePoint3d &position, const OdGeVector3d &direction, const OdGeVector3d &upVector, double fovX, bool aspect, double fovY, OdUInt32 nPlanes=4, double nearZ=1.0, double farZ=1e20)=0
ODRX_DECLARE_MEMBERS(OdGsFrustumCullingVolume)
virtual void init(const OdGePoint3d &position, const OdGeVector3d &direction, const OdGeVector3d &upVector, double fovY, double aspect, OdUInt32 nPlanes=4, double nearZ=1.0, double farZ=1e20)=0
virtual void init(const OdGePoint3d &position, const OdGeVector3d &direction, const OdGeVector3d &upVector, double volumeWidth, double volumeHeight)=0
ODRX_DECLARE_MEMBERS(OdGsOrthoCullingVolume)
const T & min(const T &x, const T &y)
const T & max(const T &x, const T &y)