7 #include "imstkPointSetToOrientedBoxCD.h" 8 #include "imstkCollisionData.h" 9 #include "imstkCollisionUtils.h" 10 #include "imstkOrientedBox.h" 11 #include "imstkParallelUtils.h" 12 #include "imstkPointSet.h" 13 #include "imstkVecDataArray.h" 17 PointSetToOrientedBoxCD::PointSetToOrientedBoxCD()
19 setRequiredInputType<PointSet>(0);
20 setRequiredInputType<OrientedBox>(1);
25 std::shared_ptr<Geometry> geomA,
26 std::shared_ptr<Geometry> geomB,
27 std::vector<CollisionElement>& elementsA,
28 std::vector<CollisionElement>& elementsB)
30 std::shared_ptr<PointSet> pointSet = std::dynamic_pointer_cast<
PointSet>(geomA);
31 std::shared_ptr<OrientedBox> box = std::dynamic_pointer_cast<
OrientedBox>(geomB);
33 std::shared_ptr<VecDataArray<double, 3>> vertexData = pointSet->getVertexPositions();
36 const Vec3d boxPos = box->getPosition();
37 const Mat3d cubeRot = box->getOrientation().toRotationMatrix();
38 const Vec3d cubeExtents = box->getExtents();
40 ParallelUtils::parallelFor(vertices.size(),
44 Vec3d pointContactNormal;
46 if (CollisionUtils::testOBBToPoint(
47 boxPos, cubeRot, cubeExtents,
49 pointContactNormal, cubeContactPt, depth))
52 elemA.dir = pointContactNormal;
54 elemA.penetrationDepth = depth;
57 elemB.dir = -pointContactNormal;
58 elemB.pt = cubeContactPt;
59 elemB.penetrationDepth = depth;
62 elementsA.push_back(elemA);
63 elementsB.push_back(elemB);
66 }, vertices.size() > 100);
71 std::shared_ptr<Geometry> geomA,
72 std::shared_ptr<Geometry> geomB,
73 std::vector<CollisionElement>& elementsA)
75 std::shared_ptr<PointSet> pointSet = std::dynamic_pointer_cast<
PointSet>(geomA);
76 std::shared_ptr<OrientedBox> box = std::dynamic_pointer_cast<
OrientedBox>(geomB);
78 std::shared_ptr<VecDataArray<double, 3>> vertexData = pointSet->getVertexPositions();
81 const Vec3d boxPos = box->getPosition();
82 const Mat3d cubeRot = box->getOrientation().toRotationMatrix();
83 const Vec3d cubeExtents = box->getExtents();
85 ParallelUtils::parallelFor(vertices.size(),
89 Vec3d pointContactNormal;
91 if (CollisionUtils::testOBBToPoint(
92 boxPos, cubeRot, cubeExtents,
94 pointContactNormal, cubeContactPt, depth))
97 elemA.dir = pointContactNormal;
99 elemA.penetrationDepth = depth;
102 elementsA.push_back(elemA);
105 }, vertices.size() > 100);
110 std::shared_ptr<Geometry> geomA,
111 std::shared_ptr<Geometry> geomB,
112 std::vector<CollisionElement>& elementsB)
114 std::shared_ptr<PointSet> pointSet = std::dynamic_pointer_cast<
PointSet>(geomA);
115 std::shared_ptr<OrientedBox> box = std::dynamic_pointer_cast<
OrientedBox>(geomB);
117 std::shared_ptr<VecDataArray<double, 3>> vertexData = pointSet->getVertexPositions();
120 const Vec3d boxPos = box->getPosition();
121 const Mat3d cubeRot = box->getOrientation().toRotationMatrix();
122 const Vec3d cubeExtents = box->getExtents();
124 ParallelUtils::parallelFor(vertices.size(),
128 Vec3d pointContactNormal;
130 if (CollisionUtils::testOBBToPoint(
131 boxPos, cubeRot, cubeExtents,
133 pointContactNormal, cubeContactPt, depth))
136 elemB.dir = -pointContactNormal;
137 elemB.pt = cubeContactPt;
138 elemB.penetrationDepth = depth;
141 elementsB.push_back(elemB);
144 }, vertices.size() > 100);
OrientedBox geometry, specified with extents (half lengths)
void unlock()
End a thread-safe region.
Base class for all geometries represented by discrete points and elements The pointsets follow a pipe...
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 AB simultaneously.
void lock()
Start a thread-safe region, where only one thread can execute at a time until a call to the unlock fu...
void computeCollisionDataA(std::shared_ptr< Geometry > geomA, std::shared_ptr< Geometry > geomB, std::vector< CollisionElement > &elementsA) override
Compute collision data for side A.
void computeCollisionDataB(std::shared_ptr< Geometry > geomA, std::shared_ptr< Geometry > geomB, std::vector< CollisionElement > &elementsB) override
Compute collision data for side B.
Direclty gives a point-direction contact as its collision data, point given by index.
Direclty gives a point-direction contact as its collision data.