7 #include "imstkTetraToPointSetCD.h" 8 #include "imstkCollisionData.h" 9 #include "imstkParallelUtils.h" 10 #include "imstkTetrahedralMesh.h" 14 TetraToPointSetCD::TetraToPointSetCD()
16 setRequiredInputType<TetrahedralMesh>(0);
17 setRequiredInputType<PointSet>(1);
22 std::shared_ptr<Geometry> geomA,
23 std::shared_ptr<Geometry> geomB,
24 std::vector<CollisionElement>& elementsA,
25 std::vector<CollisionElement>& elementsB)
27 std::shared_ptr<TetrahedralMesh> tetMesh = std::dynamic_pointer_cast<
TetrahedralMesh>(geomA);
28 std::shared_ptr<PointSet> pointSet = std::dynamic_pointer_cast<
PointSet>(geomB);
33 constexpr
const double eps = IMSTK_DOUBLE_EPS;
36 std::shared_ptr<VecDataArray<double, 3>> verticesMeshBPtr = pointSet->getVertexPositions();
41 ParallelUtils::parallelFor(tetMesh->getNumCells(),
46 tetMesh->computeTetrahedronBoundingBox(tetIdA, min, max);
50 for (
size_t vertexIdB : meshBVertexIds)
52 Vec3d vPos = verticesMeshB[vertexIdB];
55 const Vec4d bCoord = tetMesh->computeBarycentricWeights(tetIdA, vPos);
62 elemA.ids[0] = tetIdA;
64 elemA.cellType = IMSTK_TETRAHEDRON;
67 elemB.ids[0] =
static_cast<int>(vertexIdB);
69 elemB.cellType = IMSTK_VERTEX;
72 elementsA.push_back(elemA);
73 elementsB.push_back(elemB);
void unlock()
End a thread-safe region.
Base class for all geometries represented by discrete points and elements The pointsets follow a pipe...
void clear()
Clears the table.
void insertPoints(const VecDataArray< double, 3 > &points)
Insert an array of points.
SpatialHashTableSeparateChaining m_hashTableB
Spatial hash table.
std::vector< size_t > getPointsInAABB(const Vec3d &corner1, const Vec3d &corner2)
Finds IDs of all points in an AABB.
Represents a set of tetrahedrons & vertices via an array of Vec3d double vertices & Vec4i integer ind...
void lock()
Start a thread-safe region, where only one thread can execute at a time until a call to the unlock fu...
Represents a cell by a single cell id OR by N vertex ids. Which case can be determined by the idCount...
void computeCollisionDataAB(std::shared_ptr< Geometry > geomA, std::shared_ptr< Geometry > geomB, std::vector< CollisionElement > &elementsA, std::vector< CollisionElement > &elementsB) override
Compute collision data for both sides simultaneously.