Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/CollisionAlgorithm/algorithm/InsertionAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ class InsertionAlgorithm : public BaseAlgorithm
const BaseProximity::SPtr tipProx = createTipProximity(itTip->element());
if (!tipProx) return;

// Remove coupling points that are ahead of the tip in the insertion direction
ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2);
auto prunePointsAheadOfTip =
Operations::Needle::PrunePointsAheadOfTip::get(itShaft->getTypeInfo());
prunePointsAheadOfTip(m_couplingPts, itShaft->element());

if (m_couplingPts.empty()) return;

type::Vec3 lastCP = m_couplingPts.back()->getPosition();
const SReal tipDistThreshold = this->d_tipDistThreshold.getValue();

Expand Down Expand Up @@ -290,14 +298,6 @@ class InsertionAlgorithm : public BaseAlgorithm
}
}
}
else // Don't bother with removing the point that was just added
{
// Remove coupling points that are ahead of the tip in the insertion direction
ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2);
auto prunePointsAheadOfTip =
Operations::Needle::PrunePointsAheadOfTip::get(itShaft->getTypeInfo());
prunePointsAheadOfTip(m_couplingPts, itShaft->element());
}
}

if (!m_couplingPts.empty())
Expand Down
15 changes: 9 additions & 6 deletions src/CollisionAlgorithm/operations/NeedleOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
}
const type::Vec3 edgeBase(edge->getP0()->getPosition());
const type::Vec3 tip(edge->getP1()->getPosition());

const type::Vec3 edgeDirection = tip - edgeBase;

if (couplingPts.empty()) return true;
const type::Vec3 tip2Pt = couplingPts.back()->getPosition() - tip;
const int initSize = couplingPts.size();

// Positive dot product means the point is ahead of the tip
if (dot(tip2Pt, edgeDirection) > 0_sreal) couplingPts.pop_back();
while(!couplingPts.empty())
{
const type::Vec3 tip2Pt = couplingPts.back()->getPosition() - tip;

return true;
// Negative dot product means the point is behind the tip
if(dot(tip2Pt, edgeDirection) < 0_sreal) break;
couplingPts.pop_back();
}
return (initSize == couplingPts.size());
}

int register_PrunePointsAheadOfTip_Edge =
Expand Down
Loading