Open zhang-qiang-github opened 1 year ago
I think this is indeed some problem from upstream vtk, I remember this showed up already in some other context.. although i'm not getting the error with this:
from vedo import *
tube = Tube([[0,0,0], [10,0,0]], r=4, res=50).triangulate().alpha(0.3)
tri = Mesh([[(0,0,0), (10,0,0), (10,10,0)], [(0,1,2)]]).c('r5')
contour = tube.intersect_with(tri).lw(10).c('k')
show(tube, tri, contour, axes=1)
in
vedo 2022.4.1.dev7 | vtk 9.2.2 | python 3.9
Finally, I can repeat the bug:
vtkSmartPointer<vtkLineSource> lineSource = vtkSmartPointer<vtkLineSource>::New();
lineSource->SetPoint1(0, 0, 0);
lineSource->SetPoint2(10, 0, 0);
vtkSmartPointer<vtkTubeFilter> tubeFilter = vtkSmartPointer<vtkTubeFilter>::New();
tubeFilter->SetInputConnection(lineSource->GetOutputPort());
tubeFilter->SetRadius(4);
/////////////////////////////////////////////////////////////////////////////
tubeFilter->SetNumberOfSides(50); // key code
/////////////////////////////////////////////////////////////////////////////
tubeFilter->SetCapping(1);
tubeFilter->Update();
vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPoints> vps = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
polygon->GetPointIds()->SetNumberOfIds(3);
vps->InsertNextPoint(0, 0, 0);
polygon->GetPointIds()->SetId(0, 0);
vps->InsertNextPoint(10, 0, 0);
polygon->GetPointIds()->SetId(1, 1);
vps->InsertNextPoint(10, 10, 0);
polygon->GetPointIds()->SetId(2, 2);
vtkSmartPointer<vtkCellArray> polygons = vtkSmartPointer<vtkCellArray>::New();
polygons->InsertNextCell(polygon);
polydata->SetPoints(vps);
polydata->SetPolys(polygons);
vtkSmartPointer<vtkTriangleFilter> tri1 = vtkSmartPointer<vtkTriangleFilter>::New();
tri1->SetInputData(tubeFilter->GetOutput());
tri1->Update();
vtkSmartPointer<vtkTriangleFilter> tri2 = vtkSmartPointer<vtkTriangleFilter>::New();
tri2->SetInputData(polydata);
tri2->Update();
vtkSmartPointer<vtkIntersectionPolyDataFilter> intersection = vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();
intersection->SetInputData(0, tri1->GetOutput());
intersection->SetInputData(1, tri2->GetOutput());
intersection->Update();
It is caused by vtk.
I don't know whether it is a bug. Or there is something wrong with my bug.
Could you please have a look at this code?
Hi @zhang-qiang-github thanks for reporting this, I would suggest to submit this report to the vtk experts (on discourse website) as there is not much to do in the downstream vedo...
The code to reproduce my problem is:
When I run it, a bug is reported:
But, if I modify
tube = Tube([[0, 0, 0], [10, 0, 0]], r=4, res=50).triangulate().alpha(0.3)
totube = Tube([[0, 0, 0], [10, 0, 0]], r=4, res=49).triangulate().alpha(0.3)
, everything is OK:Only
res
is modified.I think this bug may be caused by vtk.
Could you please have a look at it?