Skip to content

Commit e63677b

Browse files
committed
[algorithm] Enable collision detection between the needle shaft and the surface
1 parent aba6c42 commit e63677b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,34 @@ class InsertionAlgorithm : public BaseAlgorithm
170170
collisionOutput.add(tipProx, surfProx);
171171
}
172172
}
173+
174+
// 1.3 Collision with the shaft geometry
175+
if (collisionOutput.size())
176+
{
177+
auto createShaftProximity =
178+
Operations::CreateCenterProximity::Operation::get(l_shaftGeom->getTypeInfo());
179+
auto projectOnShaft = Operations::Project::Operation::get(l_shaftGeom);
180+
for (const auto& itShaft : *l_shaftGeom)
181+
{
182+
BaseProximity::SPtr shaftProx = createShaftProximity(itShaft.element());
183+
if (!shaftProx) continue;
184+
const BaseProximity::SPtr surfProx = findClosestProxOnSurf(
185+
shaftProx, l_surfGeom.get(), projectOnSurf, getFilterFunc());
186+
if (surfProx)
187+
{
188+
surfProx->normalize();
189+
190+
// 1.2 If not, create a proximity pair for the tip-surface collision
191+
if (d_projective.getValue())
192+
{
193+
shaftProx = projectOnShaft(surfProx->getPosition(), itShaft.element()).prox;
194+
if (!shaftProx) continue;
195+
shaftProx->normalize();
196+
}
197+
collisionOutput.add(shaftProx, surfProx);
198+
}
199+
}
200+
}
173201
}
174202
else
175203
{

0 commit comments

Comments
 (0)