Skip to content

Commit 94abacd

Browse files
authored
[algorithm] Enable collision detection between the needle shaft and the surface (#54)
1 parent 746b1b3 commit 94abacd

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
@@ -174,6 +174,34 @@ class InsertionAlgorithm : public BaseAlgorithm
174174
collisionOutput.add(tipProx, surfProx);
175175
}
176176
}
177+
178+
// 1.3 Collision with the shaft geometry
179+
if (collisionOutput.size())
180+
{
181+
auto createShaftProximity =
182+
Operations::CreateCenterProximity::Operation::get(l_shaftGeom->getTypeInfo());
183+
auto projectOnShaft = Operations::Project::Operation::get(l_shaftGeom);
184+
for (const auto& itShaft : *l_shaftGeom)
185+
{
186+
BaseProximity::SPtr shaftProx = createShaftProximity(itShaft.element());
187+
if (!shaftProx) continue;
188+
const BaseProximity::SPtr surfProx = findClosestProxOnSurf(
189+
shaftProx, l_surfGeom.get(), projectOnSurf, getFilterFunc());
190+
if (surfProx)
191+
{
192+
surfProx->normalize();
193+
194+
// 1.2 If not, create a proximity pair for the tip-surface collision
195+
if (d_projective.getValue())
196+
{
197+
shaftProx = projectOnShaft(surfProx->getPosition(), itShaft.element()).prox;
198+
if (!shaftProx) continue;
199+
shaftProx->normalize();
200+
}
201+
collisionOutput.add(shaftProx, surfProx);
202+
}
203+
}
204+
}
177205
}
178206
else
179207
{

0 commit comments

Comments
 (0)