7 #include "imstkCompoundCD.h" 9 #include "imstkCollisionData.h" 10 #include "imstkCollisionUtils.h" 11 #include "imstkCompoundGeometry.h" 12 #include "imstkCDObjectFactory.h" 13 #include "imstkLogger.h" 14 #include "imstkParallelFor.h" 18 CompoundCD::CompoundCD()
20 setRequiredInputType<CompoundGeometry>(0);
21 setRequiredInputType<Geometry>(1);
24 m_collisionDataVector->clear();
31 ParallelUtils::parallelFor(m_cdAlgorithms.size(), [
this](
const int idx) { m_cdAlgorithms[idx]->update(); },
true);
40 CHECK(valid) <<
"Invalid or missing inputs in CompoundCD";
44 if (compound ==
nullptr)
52 if (m_cdAlgorithms.size() > 0)
57 for (
size_t i = 0; i < compound->count(); ++i)
59 auto geom = compound->get(i);
62 CHECK(type !=
getTypeName()) <<
"Can't stack a vector data algorithm inside of CompoundCD";
66 LOG(WARNING) <<
"CompoundCD could not find a CD Algorithm for " << geom->getTypeName() <<
" and " <<
67 other->getTypeName() <<
" skipping.";
72 algorithm->setInput(geom, 0);
73 algorithm->setInput(other, 1);
74 m_collisionDataVector->push_back(algorithm->getCollisionData());
75 m_cdAlgorithms.push_back(algorithm);
bool areInputsValid() override
Check inputs are correct (always works reversibly)
void setGenerateCD(const bool generateA, const bool generateB)
If generateA is false, CD data will not be generated for input0,A Similarly, if generateB is false...
std::shared_ptr< Geometry > getInput(size_t port=0) const
Returns input geometry given port, returns nullptr if doesn't exist.
virtual bool areInputsValid() override
Check inputs are correct (always works reversibly)
virtual const std::string getTypeName() const =0
Returns collision detection type string name.
static std::shared_ptr< CollisionDetectionAlgorithm > makeCollisionDetection(const std::string collisionTypeName)
attempts to create a new CD algorithm
void requestUpdate() override
Compute the collision data.
static std::string getCDType(const Geometry &obj1, const Geometry &obj2)
Get the CD type from the types of objects colliding.