|
6 | 6 | #include <sofa/collisionAlgorithm/operations/CreateCenterProximity.h> |
7 | 7 | #include <sofa/collisionAlgorithm/operations/FindClosestProximity.h> |
8 | 8 | #include <sofa/collisionAlgorithm/operations/Project.h> |
| 9 | +#include <sofa/colliisonAlgorithm/operations/ContainsPoint.h> |
9 | 10 | #include <sofa/collisionAlgorithm/proximity/EdgeProximity.h> |
10 | 11 | #include <sofa/collisionAlgorithm/proximity/TetrahedronProximity.h> |
11 | 12 | #include <sofa/component/constraint/lagrangian/solver/ConstraintSolverImpl.h> |
@@ -230,6 +231,8 @@ class InsertionAlgorithm : public BaseAlgorithm |
230 | 231 | auto findClosestProxOnVol = |
231 | 232 | Operations::FindClosestProximity::Operation::get(l_volGeom); |
232 | 233 | auto projectOnVol = Operations::Project::Operation::get(l_volGeom); |
| 234 | + auto containsPointInVol = |
| 235 | + Operations::ContainsPointInProximity::Operation::get(l_volGeom); |
233 | 236 |
|
234 | 237 | // Iterate over shaft segments to find which one contains the next candidate CP |
235 | 238 | for (auto itShaft = l_shaftGeom->begin(); itShaft != l_shaftGeom->end(); itShaft++) |
@@ -269,22 +272,12 @@ class InsertionAlgorithm : public BaseAlgorithm |
269 | 272 | // proximity |
270 | 273 | shaftProx = projectOnShaft(candidateCP, itShaft->element()).prox; |
271 | 274 | if (!shaftProx) continue; |
| 275 | + |
272 | 276 | const BaseProximity::SPtr volProx = findClosestProxOnVol( |
273 | 277 | shaftProx, l_volGeom.get(), projectOnVol, getFilterFunc()); |
274 | 278 | if (!volProx) continue; |
275 | 279 |
|
276 | | - TetrahedronProximity::SPtr tetProx = |
277 | | - dynamic_pointer_cast<TetrahedronProximity>(volProx); |
278 | | - if (!tetProx) continue; |
279 | | - |
280 | | - double f0(tetProx->f0()), f1(tetProx->f1()), f2(tetProx->f2()), |
281 | | - f3(tetProx->f3()); |
282 | | - bool isInTetra = toolbox::TetrahedronToolBox::isInTetra( |
283 | | - shaftProx->getPosition(), tetProx->element()->getTetrahedronInfo(), f0, |
284 | | - f1, f2, f3); |
285 | | - |
286 | | - // Ensure candidate CP lies inside tetrahedron |
287 | | - if (isInTetra) |
| 280 | + if (containsPointInVol(shaftProx->getPosition(), volProx)) |
288 | 281 | { |
289 | 282 | volProx->normalize(); |
290 | 283 | m_couplingPts.push_back(volProx); |
|
0 commit comments