vtkbool: sometimes it does not work when connect some tubes
Hello developer. I get an error when I use vtkPolyDataBooleanFilter
to connect some tubes.
array<double, 3> point1{0.001,10.122,100.000};
array<double, 3> point2{-0.000,-10.128,100.000};
array<double, 3> point3{10.125,-0.003,99.995};
array<double, 3> point4{-10.124,-0.002,100.005};
array<double, 3> point5{7.160,7.157,100.000};
array<double, 3> point6{-7.159,-7.162,100.000};
auto line1 = vtkSmartPointer<vtkLineSource>::New();
line1->SetPoint1(point1.data());
line1->SetPoint2(point2.data());
auto line2 = vtkSmartPointer<vtkLineSource>::New();
line2->SetPoint1(point3.data());
line2->SetPoint2(point4.data());
auto line3 = vtkSmartPointer<vtkLineSource>::New();
line3->SetPoint1(point5.data());
line3->SetPoint2(point6.data());
auto tube1 = vtkSmartPointer<vtkTubeFilter>::New();
tube1->SetRadius(3);
tube1->SetNumberOfSides(30);
tube1->SetInputConnection(line1->GetOutputPort());
auto tube2 = vtkSmartPointer<vtkTubeFilter>::New();
tube2->SetRadius(3);
tube2->SetNumberOfSides(30);
tube2->SetInputConnection(line2->GetOutputPort());
auto tube3 = vtkSmartPointer<vtkTubeFilter>::New();
tube3->SetRadius(3);
tube3->SetNumberOfSides(30);
tube3->SetInputConnection(line3->GetOutputPort());
auto booleanFilter1 = vtkSmartPointer<vtkPolyDataBooleanFilter>::New();
booleanFilter1->SetInputConnection(0,tube1->GetOutputPort());
booleanFilter1->SetInputConnection(1, tube2->GetOutputPort());
booleanFilter1->SetOperModeToUnion();
auto booleanFilter2 = vtkSmartPointer<vtkPolyDataBooleanFilter>::New();
booleanFilter2->SetInputConnection(0,booleanFilter1->GetOutputPort());
booleanFilter2->SetInputConnection(1, tube3->GetOutputPort());
booleanFilter2->SetOperModeToUnion();
booleanFilter2->Update();
These three tubes clearly have a common intersection at the origin and do not overlap, but the program does not give the expected result. It output
tube_connect_test: /home/wzx/CLionProjects/tube_connect/vtkbool-2.5.2/vtkPolyDataBooleanFilter.cxx:1997: void vtkPolyDataBooleanFilter::MergePoints(vtkPolyData*, PolyStripsType&): Assertion `numPts > 0' failed.
The strange thing is When I remove the last digit of the decimal, It works
array<double, 3> point1{0.00,10.12,100.00};
array<double, 3> point2{-0.00,-10.128,100.00};
array<double, 3> point3{10.12,-0.00,99.99};
array<double, 3> point4{-10.12,-0.00,100.00};
array<double, 3> point5{7.16,7.15,100.00};
array<double, 3> point6{-7.15,-7.16,100.00};
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 29 (18 by maintainers)
After some hours of debugging, I found a solution for the problem. The result looks like this:
The patch will follow today or tomorrow.
That is very cool. 😆