Skip to content

Commit 2fbd7ad

Browse files
committed
[operations] Message warning for empty element pointer or empty coupling points vector
1 parent afda3a8 commit 2fbd7ad

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/sofa/collisionAlgorithm/operations/NeedleOperations.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ namespace sofa::collisionAlgorithm::Operations::Needle
66
bool prunePointsUsingEdges(std::vector<BaseProximity::SPtr>& couplingPts,
77
const EdgeElement::SPtr& edge)
88
{
9+
if (!edge)
10+
{
11+
msg_warning("Needle::PrunePointsAheadOfTip")
12+
<< "Null element pointer in prunePointsUsingEdges; returning false";
13+
return false;
14+
}
915
const type::Vec3 edgeBase(edge->getP0()->getPosition());
1016
const type::Vec3 tip(edge->getP1()->getPosition());
1117

1218
const type::Vec3 edgeDirection = tip - edgeBase;
19+
20+
if (couplingPts.empty()) return true;
1321
const type::Vec3 tip2Pt = couplingPts.back()->getPosition() - tip;
1422

1523
// Positive dot product means the point is ahead of the tip

0 commit comments

Comments
 (0)