Skip to content

Commit 33995a6

Browse files
committed
[algorithm] check whether the tip is inside tetra before adding the detected tetrahedron
to the insertionOutput
1 parent 5b468ea commit 33995a6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <sofa/collisionAlgorithm/operations/FindClosestProximity.h>
88
#include <sofa/collisionAlgorithm/operations/Project.h>
99
#include <sofa/collisionAlgorithm/proximity/EdgeProximity.h>
10+
#include <sofa/collisionAlgorithm/proximity/TetrahedronProximity.h>
1011
#include <sofa/component/constraint/lagrangian/solver/ConstraintSolverImpl.h>
1112
#include <sofa/component/statecontainer/MechanicalObject.h>
1213

@@ -222,8 +223,18 @@ class InsertionAlgorithm : public BaseAlgorithm
222223
findClosestProxOnVol(tipProx, l_volGeom.get(), projectOnVol, getFilterFunc());
223224
if (volProx)
224225
{
225-
volProx->normalize();
226-
m_couplingPts.push_back(volProx);
226+
TetrahedronProximity::SPtr tetProx =
227+
dynamic_pointer_cast<TetrahedronProximity>(volProx);
228+
double f0(tetProx->f0()), f1(tetProx->f1()), f2(tetProx->f2()),
229+
f3(tetProx->f3());
230+
bool isInTetra = toolbox::TetrahedronToolBox::isInTetra(
231+
tipProx->getPosition(), tetProx->element()->getTetrahedronInfo(), f0, f1,
232+
f2, f3);
233+
if(isInTetra)
234+
{
235+
volProx->normalize();
236+
m_couplingPts.push_back(volProx);
237+
}
227238
}
228239
}
229240
else // Don't bother with removing the point that was just added

0 commit comments

Comments
 (0)