CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GiIntersectionsCalculator.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 __ODGIINTERSECTIONSCALCULATOR__
25#define __ODGIINTERSECTIONSCALCULATOR__
26
27#include "TD_PackPush.h"
28#include "Ge/GeExtents3d.h"
30#include "GiExport.h"
31
37{
41
42 // unique ID of the object
43 //IMPORTANT: the user is responsible for the uniqueness of the ID
44 OdUInt32 ID;
45
46 // extents of the triangle
47 OdGeExtents3d m_extents;
48
49 // parameters of the triangle's plane
50 OdGeVector3d planeNorm;
51 double planeD;
52 bool m_bIsPlaneCalculated;
53
54public:
55 //three vertices
57
58 // default constructor
60
61 //constructor
63
69 void setData( const OdGePoint3d* points, bool bCalcExtents = true );
74 void rewriteExtents( const OdGeExtents3d& extents );
75
76 // retrieve the plane's normal
78
79 //retrieve the D
80 inline double getPlaneD();
81
82 //**********************************************************************//
83 //********************METHODS FOR USING IN SPACE TREE*******************//
84 //**********************************************************************//
85 //set/get ID
86 OdUInt32 getID() {return ID;}
87 void setID(OdUInt32 uniqueID){ID = uniqueID;}
88
89 // check that the triangle is in extents
90 inline bool isInExtents(OdGeExtents3d& extents) const;
91
92 // not need for this class
93 bool isInExtents(OdGeExtents2d& extents) const {return false;}
94
95 // check that objects are equal
97 {
98 return false;
99 }
100
101private:
102
103 // calculate the parameters of the plane
104 inline void calculatePlaneParameters();
105};
106
113
120{
121 public:
122 //means that this edge is an edge of touching of two triangles
124
129};
130
148class /*FELIX_CHANGE*/ ODGI_EXPORT OdGiIntersectionsCalculator : public OdGiExtentsSpaceTreeCallback<OdGeExtents3d, OdGiTriangleForIntersectTest>
149{
150 protected:
151 // tolerance for the intersection calculation
153
154 // cach data for the controlling already intersected triangles with the given triangle
157
158 // data for controlling the objects with which will be intersected the given object
160
161 // following parameter need for the callback method' notifyObjectPlacedAtNode'
163
164 // cach data for storing the triangles from all objects
166
167 // extents trees for the triangles and vertices
170
171 // arrays for storing the intersecting vertices and edges (this arrays will have the same size as 'm_vectToBeTestedObjects')
174
175 // list for the storing final pathes for polyout
178
179 // method for the callback from the tree
181
182 // calculate intersections of the triangles
183 void intersectTriangles(OdUInt32 idObjA, OdUInt32 trIdA, OdUInt32 idObjB, OdUInt32 trIdB, OdUInt32 idObjTested, const OdGeTol& tol);
184
185 //Public API
186 public:
187
192
202 OdInt32 addTriangleToContainer( OdInt32 containerID, const OdGePoint3d *pTriangle );
208 void computeIntersections( OdInt32 containerID, OdGeExtents3d &extents );
209 // initialize calculations
210 virtual void initializeCalculations(OdGeExtents3d& ext, OdInt32 nObjects);
211 // finalize calculations
212 virtual void finalizeCalculations();
213 // intermediate finalize calculations
215
216 //process triangles into tree
217 void processTrianglesIntoSpaceTree(OdUInt32 objID, bool bOtherObjectsProcessed);
218 //process path calculation
224 const OdGeTol& tolerance() const { return m_tol; }
229 void setTolerance( const OdGeTol& tol ) { m_tol = tol; }
230
231 public:
232 //Data accessors
233 bool& facesActive() { return m_b3dFacesActive; }
234
236
238
240
241 void removeEdgeInfo( OdInt32 objID );
242
246};
247
256{
257public:
262
267
268protected:
269 // method for the callback from the tree
271
272protected: //Hide OdGiIntersectionsCalculator methods
273 void computeIntersections( OdInt32 containerID, OdGeExtents3d &extents ) { OdGiIntersectionsCalculator::computeIntersections( containerID, extents ); }
279
280public:
286 void detectCollisions( OdInt32 containerID, const OdGeExtents3d &extents );
287
293
302 bool getCollisionDistance( OdUInt32 collisionIndex, double& result ) const;
303
307 virtual void finalizeCalculations();
308
313
319
326
331 void setClearance( double cl )
332 {
334 m_dClearance = cl;
335 }
336
342 bool isClearance() const { return GETBIT( m_options, kOption_Clearance ); }
343
347 double getClearance() const { return m_dClearance; }
348
354
361
366 void setCheckAll( bool b ) { SETBIT( m_options, kOption_CheckAll, b ); }
367
373 bool getCheckAll() const { return GETBIT( m_options, kOption_CheckAll ); }
374
375protected:
376 //DOM-IGNORE-BEGIN
377
379 {
381 double dDistance;
383 operator bool() const { return bDetected; }
384 DetectedCollision& operator=( bool b ) { bDetected = b; return *this; }
385 };
387 //Performance
391
392 bool collideTriangles( OdUInt32 idObjA, OdUInt32 trIdA, OdUInt32 idObjB, OdUInt32 trIdB, OdUInt32 idObjTested, const OdGeTol& tol );
393
394 //check that points of one triangle are placed on opposite siedes of the second triangle plane
395 OdUInt32 checkPointsPlacement( const OdGeVector3d* pPlaneNormalA, double D_A, const OdGePoint3d* pPointsTriangleB, const OdGeTol& tol );
396
405
407
408 //DOM-IGNORE-END
409};
410
411//Collision detector that detect only intersections (no touching)
412//It is separate class because additional checks in OdGiCollisionDetector::collideTriangles will slow down it
413/*class OdGiCollisionDetectorIntersectionsOnly : public OdGiCollisionDetector
414{
415public:
416 OdGiCollisionDetectorIntersectionsOnly() : OdGiCollisionDetector()
417 {};
418 virtual ~OdGiCollisionDetectorIntersectionsOnly()
419 {};
420protected:
421 // method for the callback from the tree
422 virtual bool notifyObjectPlacedAtNode(OdGiTriangleForIntersectTest* pTriang, int objectType, OdGiExtents3dSpaceNode_Gi* pNode);
423
424 bool collideTriangles(OdUInt64 idObjA, OdUInt64 trIdA, OdUInt64 idObjB, OdUInt64 trIdB, OdUInt64 idObjTested, const OdGeTol& tol);
425
426 //check that points of one triangle are placed on opposite siedes of the second triangle plane
427 OdUInt32 checkPointsPlacement(const OdGeVector3d* pPlaneNormalA, double D_A, const OdGePoint3d* pPointsTriangleB, const OdGeTol& tol);
428};*/
429
430
431#include "TD_PackPop.h"
432
433#endif //#ifndef __ODGIINTERSECTIONSCALCULATOR__
tol
false
Definition DimVarDefs.h:165
#define ODGI_EXPORT
Definition GiExport.h:35
OdGiExtentsSpaceTree< 3, 5, 20, OdGeExtents3d, OdGePoint3d, OdGiExtentsSpaceObject > OdGiExtents3dSpaceTree
OdGiExtentsSpaceTree< 3, 5, 20, OdGeExtents3d, OdGePoint3d, OdGiTriangleForIntersectTest > OdGiExtents3dSpaceTree_Gi
OdVector< OdGiTriangleForIntersectTest, OdMemoryAllocator< OdGiTriangleForIntersectTest > > OdGiIntersectTrianglesVector
OdGiExtentsSpaceNode< OdGeExtents3d, OdGiTriangleForIntersectTest > OdGiExtents3dSpaceNode_Gi
unsigned int OdUInt32
int OdInt32
unsigned char OdUInt8
OdVector< OdUInt32, OdMemoryAllocator< OdUInt32 > > OdUInt32Vector
Definition OdVector.h:1713
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
void computeIntersections(OdInt32 containerID, OdGeExtents3d &extents)
virtual void finalizeCalculations()
OdArray< OdGiEdgeForIntersectTest * > * intersectionEdges()
OdList< OdGiExtents3dSpaceChainPolyline * > & finalIntersectionPathes()
void clearContainersToBeTested()
void getCollisions(OdList< OdInt32 > &result)
OdUInt32 checkPointsPlacement(const OdGeVector3d *pPlaneNormalA, double D_A, const OdGePoint3d *pPointsTriangleB, const OdGeTol &tol)
virtual bool notifyObjectPlacedAtNode(OdGiTriangleForIntersectTest *pTriang, int objectType, OdGiExtents3dSpaceNode_Gi *pNode)
bool collideTriangles(OdUInt32 idObjA, OdUInt32 trIdA, OdUInt32 idObjB, OdUInt32 trIdB, OdUInt32 idObjTested, const OdGeTol &tol)
OdVector< DetectedCollision, OdMemoryAllocator< DetectedCollision > > m_vectCollidedContainers
void processPathCalculation(OdUInt32 idObjTested)
bool getCollisionDistance(OdUInt32 collisionIndex, double &result) const
DetectedCollision * m_vectCollidedContainersAsPtr
void detectCollisions(OdInt32 containerID, const OdGeExtents3d &extents)
OdArray< OdGiExtents3dSpacePoint * > * intersectionVertices()
OdGiEdgeForIntersectTest(OdGiExtents3dSpacePoint &pt1, OdGiExtents3dSpacePoint &pt2, OdUInt32 uniqueID)
OdGiExtents3dSpaceEdge(OdGiExtents3dSpacePoint &pt1, OdGiExtents3dSpacePoint &pt2, OdUInt32 uniqueID)
void intersectTriangles(OdUInt32 idObjA, OdUInt32 trIdA, OdUInt32 idObjB, OdUInt32 trIdB, OdUInt32 idObjTested, const OdGeTol &tol)
void processTrianglesIntoSpaceTree(OdUInt32 objID, bool bOtherObjectsProcessed)
OdList< OdGiExtents3dSpaceChainPolyline * > m_finalIntersectPathes
void computeIntersections(OdInt32 containerID, OdGeExtents3d &extents)
OdArray< OdGiExtents3dSpacePoint * > * m_intersectVertices
virtual bool notifyObjectPlacedAtNode(OdGiTriangleForIntersectTest *pTriang, int objectType, OdGiExtents3dSpaceNode_Gi *pNode)
OdGiExtents3dSpaceTree_Gi m_spaceTriangTree
OdArray< OdGiEdgeForIntersectTest * > * m_intersectEdges
OdVector< bool, OdMemoryAllocator< bool > > m_vectTestedTriangles
bool getSpaceTreeRootExtents(OdGeExtents3d &ext)
OdInt32 addContainerToBeTested(OdInt32 containerID)
virtual void initializeCalculations(OdGeExtents3d &ext, OdInt32 nObjects)
virtual void finalizeCalculations()
void removeEdgeInfo(OdInt32 objID)
OdInt32 appendTriangleContainer(OdGiIntersectTrianglesVector *pContainer)
OdArray< OdGiEdgeForIntersectTest * > * intersectionEdges()
OdArray< OdGiExtents3dSpacePoint * > * intersectionVertices()
OdList< OdGiExtents3dSpaceChainPolyline * > & finalIntersectionPathes()
void setTolerance(const OdGeTol &tol)
OdInt32 addTriangleToContainer(OdInt32 containerID, const OdGePoint3d *pTriangle)
OdVector< OdGiIntersectTrianglesVector * > m_containerTriangles
void processPathCalculation(OdUInt32 idObjTested)
bool isEqual(OdGiTriangleForIntersectTest *pObject, const OdGeTol &tol=OdGeContext::gTol) const
bool isInExtents(OdGeExtents2d &extents) const
void rewriteExtents(const OdGeExtents3d &extents)
bool isInExtents(OdGeExtents3d &extents) const
void setData(const OdGePoint3d *points, bool bCalcExtents=true)
OdGiTriangleForIntersectTest(const OdGePoint3d *points, OdUInt32 uniqueID)
const OdGeVector3d * getTrianglePlaneNorm()
static GE_STATIC_EXPORT OdGeTol gTol
Definition GeGbl.h:67