|
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/collisionAlgorithm/operations/NeedleOperations.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> |
@@ -247,38 +248,11 @@ class InsertionAlgorithm : public BaseAlgorithm |
247 | 248 | } |
248 | 249 | else // Don't bother with removing the point that was just added |
249 | 250 | { |
250 | | - // 2.2. Check whether coupling point should be removed |
| 251 | + // Remove coupling points that are ahead of the tip in the insertion direction |
251 | 252 | ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2); |
252 | | - auto createShaftProximity = |
253 | | - Operations::CreateCenterProximity::Operation::get(itShaft->getTypeInfo()); |
254 | | - const BaseProximity::SPtr shaftProx = createShaftProximity(itShaft->element()); |
255 | | - if (shaftProx) |
256 | | - { |
257 | | - const EdgeProximity::SPtr edgeProx = |
258 | | - dynamic_pointer_cast<EdgeProximity>(shaftProx); |
259 | | - if (edgeProx) |
260 | | - { |
261 | | - const type::Vec3 normal = (edgeProx->element()->getP1()->getPosition() - |
262 | | - edgeProx->element()->getP0()->getPosition()) |
263 | | - .normalized(); |
264 | | - // If the (last) coupling point lies ahead of the tip (positive dot product), |
265 | | - // the needle is retreating. Thus, that point is removed. |
266 | | - if (dot(tip2Pt, normal) > 0_sreal) |
267 | | - { |
268 | | - m_couplingPts.pop_back(); |
269 | | - } |
270 | | - } |
271 | | - else |
272 | | - { |
273 | | - msg_warning() << "shaftGeom: " << l_shaftGeom->getName() |
274 | | - << " is not an EdgeGeometry. Point removal is disabled"; |
275 | | - } |
276 | | - } |
277 | | - else |
278 | | - { |
279 | | - msg_warning() << "Cannot create proximity from shaftGeom: " |
280 | | - << l_shaftGeom->getName() << " - point removal is disabled"; |
281 | | - } |
| 253 | + auto prunePointsAheadOfTip = |
| 254 | + Operations::Needle::PrunePointsAheadOfTip::get(itShaft->getTypeInfo()); |
| 255 | + prunePointsAheadOfTip(m_couplingPts, itShaft->element()); |
282 | 256 | } |
283 | 257 | } |
284 | 258 |
|
|
0 commit comments