[vtkusers] Wrong BoundaryEdge output from vtkFeatureEdges
Anuwat Dechvijankit
anuwat_boy at yahoo.com
Sat Aug 2 01:16:16 EDT 2014
Hi all vtkusers,
First post here.
I have wrong output result from vtkFeatureEdges filtering BoundaryEdge only.
(on vtk 6.1 x64 windows 8.1)
here is sample code:
#include <vtkSmartPointer.h>
#include <vtkPlaneSource.h>
#include <vtkFeatureEdges.h>
#include <vtkCellArray.h>
#include <vtkLine.h>
#include <ostream>
int _tmain(int argc, _TCHAR* argv[])
{
vtkSmartPointer<vtkPlaneSource> planeSource = vtkSmartPointer<vtkPlaneSource>::New();
planeSource->SetXResolution(4);
planeSource->SetYResolution(4);
planeSource->SetCenter(0,0,0);
planeSource->SetNormal(0.0, 0.0, 1.0);
planeSource->Update();
vtkSmartPointer<vtkPolyData> polydata = planeSource->GetOutput();
std::cout << "Total points:" << polydata->GetNumberOfPoints() << endl;
for (int i = 0; i < polydata->GetNumberOfPoints(); i++)
{
double pt[3];
polydata->GetPoint(i , pt);
std::cout << "Point:" << i << " \t(" <<pt[0]<<"," << pt[1] <<"," <<pt[2]<< ")" << endl;
}
vtkSmartPointer<vtkFeatureEdges> borderEdges = vtkSmartPointer<vtkFeatureEdges>::New();
borderEdges->SetInputConnection(planeSource->GetOutputPort());
borderEdges->FeatureEdgesOff();
borderEdges->ManifoldEdgesOff();
borderEdges->NonManifoldEdgesOff();
borderEdges->ColoringOff();
borderEdges->BoundaryEdgesOn();
borderEdges->Update();
vtkSmartPointer<vtkCellArray> lines= borderEdges->GetOutput()->GetLines();
int numBorderEdges = lines->GetNumberOfCells();
std::cout << "Total border edges:" << numBorderEdges << endl;
for(vtkIdType i = 0; i < numBorderEdges; i++)
{
vtkLine* line = vtkLine::SafeDownCast(borderEdges->GetOutput()->GetCell(i));
int numID = line->GetPointIds()->GetNumberOfIds();
int id0 = line->GetPointIds()->GetId(0);
int id1 = line->GetPointIds()->GetId(1);
std::cout << "B-edge:" << i <<"\t"<< numID <<"(" <<id0<<"," <<id1<<")"<< endl;
}
getchar();
return 0;
}
report result is:
Total points:25
Point:0 (-0.5,-0.5,0)
Point:1 (-0.25,-0.5,0)
Point:2 (0,-0.5,0)
Point:3 (0.25,-0.5,0)
Point:4 (0.5,-0.5,0)
Point:5 (-0.5,-0.25,0)
Point:6 (-0.25,-0.25,0)
Point:7 (0,-0.25,0)
Point:8 (0.25,-0.25,0)
Point:9 (0.5,-0.25,0)
Point:10 (-0.5,0,0)
Point:11 (-0.25,0,0)
Point:12 (0,0,0)
Point:13 (0.25,0,0)
Point:14 (0.5,0,0)
Point:15 (-0.5,0.25,0)
Point:16 (-0.25,0.25,0)
Point:17 (0,0.25,0)
Point:18 (0.25,0.25,0)
Point:19 (0.5,0.25,0)
Point:20 (-0.5,0.5,0)
Point:21 (-0.25,0.5,0)
Point:22 (0,0.5,0)
Point:23 (0.25,0.5,0)
Point:24 (0.5,0.5,0)
Total border edges:16
B-edge:0 2(0,1)
B-edge:1 2(2,0)
B-edge:2 2(1,3)
B-edge:3 2(3,4)
B-edge:4 2(4,5)
B-edge:5 2(5,6)
B-edge:6 2(7,2)
B-edge:7 2(6,8)
B-edge:8 2(9,7)
B-edge:9 2(8,10)
B-edge:10 2(11,12)
B-edge:11 2(12,9)
B-edge:12 2(13,11)
B-edge:13 2(14,13)
B-edge:14 2(10,15)
B-edge:15 2(15,14)
as you see b-edges#2,#3 report wrong id pairs.
#4 reports wrong too.
Is it library bug ? or I have wrong coding?
best regards,
Anuwat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140801/b1e3cdd3/attachment.html>
More information about the vtkusers
mailing list