20 #ifndef MIRTK_SurfaceCollisions_H 21 #define MIRTK_SurfaceCollisions_H 23 #include "mirtk/SurfaceFilter.h" 25 #include "mirtk/Math.h" 26 #include "mirtk/Array.h" 27 #include "mirtk/OrderedSet.h" 28 #include "mirtk/Memory.h" 29 #include "mirtk/PointSetExport.h" 31 #include "vtkSmartPointer.h" 71 MIRTK_PointSet_EXPORT
static const char *
const BOUNDING_SPHERE_CENTER;
72 MIRTK_PointSet_EXPORT
static const char *
const BOUNDING_SPHERE_RADIUS;
73 MIRTK_PointSet_EXPORT
static const char *
const COLLISION_TYPE;
89 _CellId(cellId), _Adjacent(adj)
122 _Distance(numeric_limits<double>::quiet_NaN()),
125 memset(_Point1, 0, 3 *
sizeof(
double));
126 memset(_Point2, 0, 3 *
sizeof(
double));
134 memcpy(_Point1, p1, 3 *
sizeof(
double));
135 memcpy(_Point2, p2, 3 *
sizeof(
double));
136 const double a = _Point2[0] - _Point1[0];
137 const double b = _Point2[1] - _Point1[1];
138 const double c = _Point2[2] - _Point1[2];
139 _Distance = sqrt(a * a + b * b + c * c);
148 memcpy(_Point1, p1, 3 *
sizeof(
double));
149 memcpy(_Point2, p2, 3 *
sizeof(
double));
158 memcpy(_Point1, other.
_Point1, 3 *
sizeof(
double));
159 memcpy(_Point2, other.
_Point2, 3 *
sizeof(
double));
167 memcpy(_Point1, other.
_Point1, 3 *
sizeof(
double));
168 memcpy(_Point2, other.
_Point2, 3 *
sizeof(
double));
178 typedef OrderedSet<IntersectionInfo> IntersectionsSet;
179 typedef IntersectionsSet::const_iterator IntersectionsIterator;
180 typedef Array<IntersectionsSet> IntersectionsArray;
182 typedef OrderedSet<CollisionInfo> CollisionsSet;
183 typedef CollisionsSet::const_iterator CollisionsIterator;
184 typedef Array<CollisionsSet> CollisionsArray;
191 mirtkPublicAttributeMacro(vtkSmartPointer<vtkDataArray>, Mask);
194 mirtkPublicAttributeMacro(
bool, UseInputBoundingSpheres);
198 mirtkPublicAttributeMacro(
double, MinSearchRadius);
202 mirtkPublicAttributeMacro(
double, MaxSearchRadius);
209 mirtkPublicAttributeMacro(
double, MinFrontfaceDistance);
216 mirtkPublicAttributeMacro(
double, MinBackfaceDistance);
220 mirtkPublicAttributeMacro(
double, MaxAngle);
223 mirtkPublicAttributeMacro(
bool, AdjacentIntersectionTest);
226 mirtkPublicAttributeMacro(
bool, NonAdjacentIntersectionTest);
229 mirtkPublicAttributeMacro(
bool, FrontfaceCollisionTest);
232 mirtkPublicAttributeMacro(
bool, BackfaceCollisionTest);
235 mirtkPublicAttributeMacro(
bool, FastCollisionTest);
238 mirtkPublicAttributeMacro(
bool, StoreIntersectionDetails);
241 mirtkPublicAttributeMacro(
bool, StoreCollisionDetails);
244 mirtkPublicAttributeMacro(
bool, ResetCollisionType);
248 mirtkReadOnlyAttributeMacro(IntersectionsArray,
Intersections);
252 mirtkReadOnlyAttributeMacro(CollisionsArray,
Collisions);
371 inline const SurfaceCollisions::IntersectionsSet &
374 return _Intersections[cellId];
378 inline const SurfaceCollisions::CollisionsSet &
381 return _Collisions[cellId];
393 return static_cast<int>(
Collisions(cellId).size());
399 #endif // MIRKT_SurfaceCollisions_H vtkDataArray * GetCenterArray() const
Get cell data array storing center points of bounding spheres.
Non-adjacent triangles intersect each other.
const CollisionsSet & Collisions(int) const
vtkDataArray * GetCollisionTypeArray() const
Get cell data array storing type of cell collision.
int NumberOfCollisions(int) const
static bool IsCollision(CollisionType)
Whether a given collision type indicates a near miss collision.
Adjacent triangles intersect each other.
Structure storing information about detected self-intersection.
Second triangle is within minimum distance towards the back of first triangle.
vtkDataArray * GetRadiusArray() const
Get cell data array storing radii of bounding spheres.
virtual void Initialize()
Initialize filter after input and parameters are set.
int NumberOfIntersections(int) const
double _Distance
Distance between closest points.
Unknown or mixed collision types.
int _CellId
ID of other triangle.
static bool IsIntersection(CollisionType)
Whether a given collision type indicates a self-intersection.
bool FoundCollisions() const
Whether at least one collision was found.
No collision with another triangle within search range.
bool _Adjacent
Whether triangles are adjacent.
virtual ~SurfaceCollisions()
Destructor.
Unknown or mixed intersection types.
Both collisions and self-intersections found.
bool FoundIntersections() const
Whether at least one intersection was found.
double _Point2[3]
Point in other triangle which is closest.
Structure storing information about detected collision.
int _CellId
ID of other triangle.
Second triangle is within minimum distance towards the front of first triangle.
double _Point1[3]
Point in this triangle which is closest.
const IntersectionsSet & Intersections(int) const
CollisionType _Type
Type of collision.
virtual void Execute()
Execute filter.
CollisionType GetCollisionType(int) const
Get type of cell collision.
CollisionType
Type of self-collision.
SurfaceCollisions()
Constructor.
mirtkOnOffMacro(AdjacentIntersectionTest)
Enable/disable intersection test for adjacent triangles.