zippy84 / vtkbool

A new boolean operations filter for VTK
Apache License 2.0
166 stars 40 forks source link

Disconnected faces after connected components #41

Closed zandarina closed 2 years ago

zandarina commented 3 years ago

Hello, I found a weird behaviour after applying a subtraction using your library.

I am trying to subtract two polydatas and if i do not apply connected components, the result looks ok, but if I apply the connected components filter to get the largest region, the result is a small subset of faces of what it should be the whole component. I show this issue in images

Result of the boolean subtraction without connected components is ok rhino_guide

Result of the boolean subtraction with connected components fails resultAfterconnectedComponent

The code seems ok to me. So I wonder if it is a bug in the way to connect faces. I wonder if there is a way to solve this issue.

     vtkSmartPointer<vtkTriangleFilter> tri1 =
        vtkSmartPointer<vtkTriangleFilter>::New();
    tri1->SetInputData(splint);
    vtkSmartPointer<vtkCleanPolyData> clean1 =
        vtkSmartPointer<vtkCleanPolyData>::New();
    clean1->SetInputConnection(tri1->GetOutputPort());
    clean1->Update();
    vtkSmartPointer<vtkStripper> strip1 =
        vtkSmartPointer<vtkStripper>::New();
    strip1->SetInputConnection(clean1->GetOutputPort());
    strip1->Update();
    vtkNew<vtkPolyDataNormals> normal1;
    normal1->SetInputData(strip1->GetOutput());
    normal1->ComputePointNormalsOn();
    normal1->ComputeCellNormalsOff();
    normal1->Update();
    auto input1 = normal1->GetOutput();

    vtkSmartPointer<vtkTriangleFilter> tri2 =
        vtkSmartPointer<vtkTriangleFilter>::New();
    tri2->SetInputData(polydataToSubstractToSplint);
    tri2->Update();
    vtkSmartPointer<vtkCleanPolyData> clean2 =
        vtkSmartPointer<vtkCleanPolyData>::New();
    clean2->SetInputConnection(tri2->GetOutputPort());
    clean2->Update();
    vtkSmartPointer<vtkStripper> strip2 =
        vtkSmartPointer<vtkStripper>::New();
    strip2->SetInputConnection(clean2->GetOutputPort());
    strip2->Update();
    vtkNew<vtkPolyDataNormals> normal2;
    normal2->SetInputData(strip2->GetOutput());
    normal2->ComputePointNormalsOn();
    normal2->ComputeCellNormalsOff();
    normal2->Update();
    auto input2 = normal2->GetOutput();
    vtkPolyDataBooleanFilter *bf2 = vtkPolyDataBooleanFilter::New();
    bf2->SetInputData(0, input1);
    bf2->SetInputData(1, input2);
    bf2->SetOperModeToDifference();
    try {
        bf2->Update();
    }

I attach some polydatas for testing in case this issue is unknown.

https://we.tl/t-STIpdaCFNQ

Thanks

zandarina commented 3 years ago

Any idea? Is it a problem of the library?

zippy84 commented 2 years ago

My answer is very late, but do you still need help on this? Otherwise I would close the issue.