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