[vtkusers] Bug in vtkStripper on a very simple case ? (confirmed)
pof
jd379252 at gmail.com
Mon Dec 10 17:04:14 EST 2012
Dear vtk'ers,
I confirm that I found a bug in vtkStripper, which in some cases does not produce the expected result.
In this simple example (polydata0.vtk file), 5 segments are defined, and they do define unambiguously a single polyline:
///////
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 6 float
1.7 0.5 0 2 0 0 1.7 -0.5 0
1.6 -1 0 1.8 -0.2 0 1.6 1 0
LINES 5 15
2 0 1
2 2 3
2 4 2
2 1 4
2 5 0
///////
When this polydata is processed through the vtkStripper, the first four segments are merged, but the last segment remains unmerged (see the last section of the polydata1.vtk file below) :
LINES 2 9
5 0 1 4 2 3
2 5 0
Strangely, if the polydata is modified by defining the segment (2 5 0) as the first segment, then vtkStripper succeed to merge the 5 segments (see the last section below) :
LINES 1 7
6 5 0 1 4 2 3
Herebelow is the code used to reproduce this data and the described bug.
Any idea why vtkStripper does not behave correctly in this case?
Thanks
JD
--------------------------------------
#include <vtkPolyData.h>
#include <vtkPolyDataWriter.h>
#include <vtkSmartPointer.h>
#include <vtkCellArray.h>
#include <vtkStripper.h>
int main(int argc, char *argv[])
{
vtkSmartPointer<vtkPoints> Points = vtkSmartPointer<vtkPoints>::New();
// Create 6 points
Points->InsertNextPoint(1.7, 0.5, 0);
Points->InsertNextPoint(2.0, 0, 0);
Points->InsertNextPoint(1.7, -0.5, 0);
Points->InsertNextPoint(1.6, -1, 0);
Points->InsertNextPoint(1.8, -0.2, 0);
Points->InsertNextPoint(1.6, 1, 0);
vtkSmartPointer<vtkCellArray> Segments =
vtkSmartPointer<vtkCellArray>::New();
// Create line segment #0
Segments->InsertNextCell(2);
Segments->InsertCellPoint(0);
Segments->InsertCellPoint(1);
// Create line segment #1
Segments->InsertNextCell(2);
Segments->InsertCellPoint(2);
Segments->InsertCellPoint(3);
// Create line segment #2
Segments->InsertNextCell(2);
Segments->InsertCellPoint(4);
Segments->InsertCellPoint(2);
// Create line segment #3
Segments->InsertNextCell(2);
Segments->InsertCellPoint(1);
Segments->InsertCellPoint(4);
// Create line segment #4
Segments->InsertNextCell(2);
Segments->InsertCellPoint(5);
Segments->InsertCellPoint(0);
// Create the polydata from points and faces
vtkSmartPointer<vtkPolyData> SegPD = vtkSmartPointer<vtkPolyData>::New();
SegPD->SetPoints(Points);
SegPD->SetLines(Segments);
SegPD->Update();
// Try to get the polyline (there should be 1) from the segments
vtkSmartPointer<vtkStripper> stripper =
vtkSmartPointer<vtkStripper>::New();
stripper->SetInputConnection(SegPD->GetProducerPort());
stripper->Update();
vtkSmartPointer<vtkPolyDataWriter> wr =
vtkSmartPointer<vtkPolyDataWriter>::New();
// Save the original polydata on a vtk file
wr->SetFileName("D:\\polylines0.vtk");
wr->SetInputConnection(SegPD->GetProducerPort());
wr->Write();
// Save the filtered polydata on a vtk file
wr->SetFileName("D:\\polylines1.vtk");
wr->SetInputConnection(stripper->GetOutputPort());
wr->Write();
return EXIT_SUCCESS;
}
--------------------------------------
More information about the vtkusers
mailing list