VTK Select Poly data doesn't work

Hello,
I have a curve in 3D and I’m trying to select the polydata that intersect with, the problem is I’m getting very bad output, and meshes are thrown and flying in the 3D space

image

vtkNew selectionPoints;
for (int i = 0; i < lasso3D.size(); i += 3)
{
selectionPoints->InsertPoint(i, lasso3D[i], lasso3D[i + 1], lasso3D[i+2]);
}

//curvePoly->SetPolys(triangles);

vtkSmartPointer loop = vtkSmartPointer::New();

loop->SetLoop(selectionPoints); // circleReader->GetOutput()->GetPoints() )
loop->SetInputData(mandiblePolyData);

loop->GenerateSelectionScalarsOff();
loop->GlobalWarningDisplayOn();
loop->DebugOn();
//loop->SetSelectionModeToSmallestRegion();
loop->SetEdgeSearchModeToDijkstra();
loop->SetSelectionModeToClosestPointRegion();
loop->Update();

auto* loopPd = loop->GetOutput();
cout << loopPd->GetNumberOfCells() << ", " << loopPd->GetNumberOfPoints() << endl;

Please use triple-backtick to quote code. The > character is for quoting, which does not preserve HTML tags, therefore we don’t see what class you instantiate using vtkNew.

It looks like the filter extracted some internal surface from your mesh, most likely because it was closest to the (0,0,0) position. If you set the correct closest point position (e.g., to a point in the middle of your surface patch) then most likely it will be correctly retrieved?

What is your end goal? What is the clinical need you are trying to address? Orthognatic surgery? Mandibular reconstruction using fibula flap? Lots of VTK-based dental and craniomaxillofacial have been developed over the years, so most likely you would not need to start from scratch, but you can reuse existing solutions and just customize/extend them.