[vtkusers] closed polygon from splinewidget
Dean Inglis
dean.inglis at sympatico.ca
Sat Feb 3 10:37:28 EST 2007
Hi Michael,
vtkSplineWidget gives a shallow copy of the output (vtkPolyData)
from the widget's internal vtkParametricFunctionSource, but that
output is a polyline NOT a polygon, which vtkTriangleFilter expects.
If you know that the output is a closed planar curve, then
just triangulate without recopying.
if ( NewSpline->IsClosed() ) // is it actually geometrically closed?
{
vtkPolyData* temp = vtkPolyData::New();
NewSpline->GetPolyData(temp); // temporarily get the shallow copy
NewPoly->SetPoints(temp->GetPoints()); // trick to convert polylines to a
polygon
NewPoly->SetPolys(temp->GetLines());
triangleFilter->SetInput(NewPoly);
triangleFilter->Update();
temp->Delete();
}
else
{
// do something?
}
Dean
Hi,
I want to probe a dataset with the vtkSplineWidget. But I don't know how to
get the closed surface (inside of closed spline).
I use the vtkSplineWidget to create a closed Spline and get the
corresponding PolyData (->GetPolyData())from the spline. If I visualize it,
I can see that it is a closed Spline (->ClosedOn() was set in
vtkSplineWidget) but only as a line like a Circle or whatever you form with
it.
What I need is the complete Surface e.g. a disk
The way I tried is this:
1.) create a PolyLine (should be closed) from the PolyData.
2.) create vtkCellArray and create new polygon from PolyLine and Array
3.) Tessalate the polgon // gives ERROR
Now when I test to triangulate the new Polygon I get an error that the
vtkTriangleFilter is working on a degenerated polygon.
Here is the code snippet:
// the spline returns polydata (which can be shown once mapped, it
forms a circle)
NewSpline->GetPolyData(NewPoly);
// creating a PolyLine from the polydata (not sure if correct)
int pointCount = NewPoly->GetPoints()->GetNumberOfPoints();
aPolyLine = vtkPolyLine::New();
aPolyLine->GetPointIds()->SetNumberOfIds(pointCount);
int* pntIds = new int[pointCount];
for (unsigned int i = 0; i < (int)pointCount; i++)
{
pntIds[i] = i;
}
aPolyLine->Initialize(pointCount, pntIds, NewPoly->GetPoints());
vCA = vktCellArray::New();
vCA->InsertNextCell(aPolyLine);
// this is from Examples capCow and should create a Polygon from
closed PolyLine ( I also tried the vtkStripper to create a closed PolyLine
but didnt help)
tempPoly = vtkPolyData::New();
tempPoly->SetPoints(aPolyLine->GetPoints());
tempPoly->SetPolys(vCA);
triangleFilter->SetInput(tempPoly);
triangleFilter->Update(); // ERROR vtkPolygon (94564696): Degenerate
polygon encountered during triangulation
Can anybody help?
Thanks alot
Michael
More information about the vtkusers
mailing list