CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GiIntersectionsCalculator.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 __ODGIINTERSECTIONSCALCULATOR__
25#define __ODGIINTERSECTIONSCALCULATOR__
26
27#include "TD_PackPush.h"
28#include "Ge/GeExtents3d.h"
30
36{
40
41 // unique ID of the object
42 //IMPORTANT: the user is responsible for the uniqueness of the ID
43 OdUInt64 ID;
44
45 // extents of the triangle
46 OdGeExtents3d m_extents;
47
48 // parameters of the triangle's plane
49 OdGeVector3d planeNorm;
50 double planeD;
51 bool m_bIsPlaneCalculated;
52
53public:
54 //three vertices
56
57 // default constructor
59
60 //constructor
62
68 void setData( const OdGePoint3d* points, bool bCalcExtents = true );
73 void rewriteExtents( const OdGeExtents3d& extents );
74
75 // retrieve the plane's normal
77
78 //retrieve the D
79 inline double getPlaneD();
80
81 //**********************************************************************//
82 //********************METHODS FOR USING IN SPACE TREE*******************//
83 //**********************************************************************//
84 //set/get ID
85 OdUInt64 getID() {return ID;}
86 void setID(OdUInt64 uniqueID){ID = uniqueID;}
87
88 // check that the triangle is in extents
89 inline bool isInExtents(OdGeExtents3d& extents) const;
90
91 // not need for this class
92 bool isInExtents(OdGeExtents2d& extents) const {return false;}
93
94 // check that objects are equal
96 {
97 return false;
98 }
99
100private:
101
102 // calculate the parameters of the plane
103 inline void calculatePlaneParameters();
104};
105
109
116{
117 public:
118 //means that this edge is an edge of touching of two triangles
120
122 {
123 m_bIsTouchingEdge = false;
124 }
125};
126
144class OdGiIntersectionsCalculator : public OdGiExtentsSpaceTreeCallback<OdGeExtents3d, OdGiTriangleForIntersectTest>
145{
146 protected:
147 // tolerance for the intersection calculation
149
150 // cach data for the controlling already intersected triangles with the given triangle
153
154 // data for controlling the objects with which will be intersected the given object
156
157 // following parameter need for the callback method' notifyObjectPlacedAtNode'
159
160 // cach data for storing the triangles from all objects
162
163 // extents trees for the triangles and vertices
166
167 // arrays for storing the intersecting vertices and edges (this arrays will have the same size as 'm_vectToBeTestedObjects')
170
171 // list for the storing final pathes for polyout
174
175 // method for the callback from the tree
177
178 // calculate intersections of the triangles
179 void intersectTriangles(OdUInt64 idObjA, OdUInt64 trIdA, OdUInt64 idObjB, OdUInt64 trIdB, OdUInt64 idObjTested, const OdGeTol& tol);
180
181 //Public API
182 public:
184
191 OdInt64 addTriangleToContainer( OdInt64 containerID, const OdGePoint3d *pTriangle );
197 void computeIntersections( OdInt64 containerID, const OdGeExtents3d &extents );
198 // initialize calculations
199 virtual void initializeCalculations(OdGeExtents3d& ext, OdInt64 nObjects);
200 // finalize calculations
201 virtual void finalizeCalculations();
202 // intermediate finalize calculations
204
205 //process triangles into tree
206 void processTrianglesIntoSpaceTree(OdInt64 objID, bool bOtherObjectsProcessed);
207 //process path calculation
213 const OdGeTol& tolerance() const { return m_tol; }
218 void setTolerance( const OdGeTol& tol ) { m_tol = tol; }
219
220 public:
221 //Data accessors
222 bool& facesActive() { return m_b3dFacesActive; }
223
225
227
229
230 void removeEdgeInfo( OdInt64 objID );
231
235};
236
238{
239public:
242
243protected:
244 // method for the callback from the tree
246
247protected: //Hide OdGiIntersectionsCalculator methods
248 void computeIntersections( OdInt64 containerID, const OdGeExtents3d &extents ) { OdGiIntersectionsCalculator::computeIntersections( containerID, extents ); }
254
255public:
256 void detectCollisions( OdInt64 containerID, const OdGeExtents3d &extents );
258
267 bool getCollisionDistance( OdInt64 collisionIndex, double& result ) const;
268
269 // finalize calculations
270 virtual void finalizeCalculations();
271
273
279
286
291 void setClearance( double cl )
292 {
294 m_dClearance = cl;
295 }
296
302 bool isClearance() const { return GETBIT( m_options, kOption_Clearance ); }
303
307 double getClearance() const { return m_dClearance; }
308
314
321
326 void setCheckAll( bool b ) { SETBIT( m_options, kOption_CheckAll, b ); }
327
333 bool getCheckAll() const { return GETBIT( m_options, kOption_CheckAll ); }
334
335protected:
337 {
339 double dDistance;
342 operator bool() const { return bDetected; }
343 DetectedCollision& operator=( bool b ) { bDetected = b; return *this; }
344 };
346 //Performance
350
351 bool collideTriangles( OdUInt64 idObjA, OdUInt64 trIdA, OdUInt64 idObjB, OdUInt64 trIdB, OdUInt64 idObjTested, const OdGeTol& tol );
352
353 //check that points of one triangle are placed on opposite siedes of the second triangle plane
354 OdUInt32 checkPointsPlacement( const OdGeVector3d* pPlaneNormalA, double D_A, const OdGePoint3d* pPointsTriangleB, const OdGeTol& tol );
355
357 {
362 };
364
366};
367
368//Collision detector that detect only intersections (no touching)
369//It is separate class because additional checks in OdGiCollisionDetector::collideTriangles will slow down it
370/*class OdGiCollisionDetectorIntersectionsOnly : public OdGiCollisionDetector
371{
372public:
373 OdGiCollisionDetectorIntersectionsOnly() : OdGiCollisionDetector()
374 {};
375 virtual ~OdGiCollisionDetectorIntersectionsOnly()
376 {};
377protected:
378 // method for the callback from the tree
379 virtual bool notifyObjectPlacedAtNode(OdGiTriangleForIntersectTest* pTriang, int objectType, OdGiExtents3dSpaceNode_Gi* pNode);
380
381 bool collideTriangles(OdUInt64 idObjA, OdUInt64 trIdA, OdUInt64 idObjB, OdUInt64 trIdB, OdUInt64 idObjTested, const OdGeTol& tol);
382
383 //check that points of one triangle are placed on opposite siedes of the second triangle plane
384 OdUInt32 checkPointsPlacement(const OdGeVector3d* pPlaneNormalA, double D_A, const OdGePoint3d* pPointsTriangleB, const OdGeTol& tol);
385};*/
386
387
388#include "TD_PackPop.h"
389
390#endif //#ifndef __ODGIINTERSECTIONSCALCULATOR__
tol
Definition: DimVarDefs.h:2287
false
Definition: DimVarDefs.h:165
OdGiExtentsSpaceTree< 3, 5, 20, OdGeExtents3d, OdGePoint3d, OdGiTriangleForIntersectTest > OdGiExtents3dSpaceTree_Gi
OdVector< OdGiTriangleForIntersectTest, OdMemoryAllocator< OdGiTriangleForIntersectTest > > OdGiIntersectTrianglesVector
OdGiExtentsSpaceNode< OdGeExtents3d, OdGiTriangleForIntersectTest > OdGiExtents3dSpaceNode_Gi
unsigned int OdUInt32
unsigned char OdUInt8
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:516
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
Definition: GeTol.h:49
virtual void finalizeCalculations()
OdArray< OdGiEdgeForIntersectTest * > * intersectionEdges()
OdList< OdGiExtents3dSpaceChainPolyline * > & finalIntersectionPathes()
bool collideTriangles(OdUInt64 idObjA, OdUInt64 trIdA, OdUInt64 idObjB, OdUInt64 trIdB, OdUInt64 idObjTested, const OdGeTol &tol)
void clearContainersToBeTested()
OdUInt32 checkPointsPlacement(const OdGeVector3d *pPlaneNormalA, double D_A, const OdGePoint3d *pPointsTriangleB, const OdGeTol &tol)
virtual bool notifyObjectPlacedAtNode(OdGiTriangleForIntersectTest *pTriang, int objectType, OdGiExtents3dSpaceNode_Gi *pNode)
void processPathCalculation(OdUInt64 idObjTested)
void computeIntersections(OdInt64 containerID, const OdGeExtents3d &extents)
void removeEdgeInfo(OdInt64 objID)
bool getCollisionDistance(OdInt64 collisionIndex, double &result) const
OdVector< DetectedCollision, OdMemoryAllocator< DetectedCollision > > m_vectCollidedContainers
void detectCollisions(OdInt64 containerID, const OdGeExtents3d &extents)
DetectedCollision * m_vectCollidedContainersAsPtr
OdArray< OdGiExtents3dSpacePoint * > * intersectionVertices()
void getCollisions(OdList< OdInt64 > &result)
OdGiEdgeForIntersectTest(OdGiExtents3dSpacePoint &pt1, OdGiExtents3dSpacePoint &pt2, OdInt64 uniqueID)
OdList< OdGiExtents3dSpaceChainPolyline * > m_finalIntersectPathes
void intersectTriangles(OdUInt64 idObjA, OdUInt64 trIdA, OdUInt64 idObjB, OdUInt64 trIdB, OdUInt64 idObjTested, const OdGeTol &tol)
OdArray< OdGiExtents3dSpacePoint * > * m_intersectVertices
virtual bool notifyObjectPlacedAtNode(OdGiTriangleForIntersectTest *pTriang, int objectType, OdGiExtents3dSpaceNode_Gi *pNode)
void removeEdgeInfo(OdInt64 objID)
OdInt64 addTriangleToContainer(OdInt64 containerID, const OdGePoint3d *pTriangle)
OdGiExtents3dSpaceTree_Gi m_spaceTriangTree
OdArray< OdGiEdgeForIntersectTest * > * m_intersectEdges
OdVector< bool, OdMemoryAllocator< bool > > m_vectTestedTriangles
bool getSpaceTreeRootExtents(OdGeExtents3d &ext)
OdGiExtents3dSpaceTree m_spaceVertexTree
OdInt64 addContainerToBeTested(OdInt64 containerID)
virtual void finalizeCalculations()
OdArray< OdGiEdgeForIntersectTest * > * intersectionEdges()
OdArray< OdGiExtents3dSpacePoint * > * intersectionVertices()
void computeIntersections(OdInt64 containerID, const OdGeExtents3d &extents)
OdInt64 appendTriangleContainer(OdGiIntersectTrianglesVector *pContainer)
OdList< OdGiExtents3dSpaceChainPolyline * > & finalIntersectionPathes()
void setTolerance(const OdGeTol &tol)
void processTrianglesIntoSpaceTree(OdInt64 objID, bool bOtherObjectsProcessed)
OdVector< OdGiIntersectTrianglesVector * > m_containerTriangles
virtual void initializeCalculations(OdGeExtents3d &ext, OdInt64 nObjects)
void processPathCalculation(OdUInt64 idObjTested)
bool isEqual(OdGiTriangleForIntersectTest *pObject, const OdGeTol &tol=OdGeContext::gTol) const
bool isInExtents(OdGeExtents2d &extents) const
void rewriteExtents(const OdGeExtents3d &extents)
OdGiTriangleForIntersectTest(const OdGePoint3d *points, OdUInt64 uniqueID)
bool isInExtents(OdGeExtents3d &extents) const
void setData(const OdGePoint3d *points, bool bCalcExtents=true)
const OdGeVector3d * getTrianglePlaneNorm()
Definition: Int64.h:43
Definition: OdList.h:50
size_type size() const
Definition: OdVector.h:1204
static GE_STATIC_EXPORT OdGeTol gTol
Definition: GeGbl.h:65