[vtkusers] pb converting other format polygons to vtkPolyData : cleaner behaves like if there was no points
Sébastien MARAUX
maraux at ondim.fr
Wed Mar 10 03:00:09 EST 2004
Hello,
I am converting from another (GIS) format to vtkPolyData.
The problem is that when I convert a polygon, everything seems fine, but
when I clean it, it clears my polygon, as if all points where not valid.
Note that it is possible that first and last point of the input polygons
could be the same, but it should not make any difference in this code.
Here is my code :
(Mp_GG is a group of geometric objects, such as Polygons. I took away
part of code for other formats. mp_External is the vtkPolyData)
Any help will be greatly appreciated.
Sebastien MARAUX
////////////////////////////////////////////////////////////////////////
///
vtkPoints *tempPoints = vtkPoints::New();
vtkIdList *tempList = vtkIdList::New();
mp_External = vtkPolyData::New();
mp_External->Allocate();
// for each geometric object, create the point id list and add them to
the
// main vtkPoints
for (int i=0;i<mp_GG->GetNumberOfGO();i++) {
tempList->Reset();
for (int j=0;j<mp_GG->GetGOById(i)->GetNumberOfPoints();j++) {
vtkIdType currentPoint =
tempPoints->InsertNextPoint(mp_GG->GetGOById(i)->GetPoint(j));
tempList->InsertNextId(currentPoint);
if (textureXId != -1) {
tCoords->InsertTuple2(
currentPoint,
OGISFloatArray::safeDownCast(mp_GG->GetGOById(i)->GetPointsDG()->GetDOBy
Id(textureXId))->GetElement(j),
OGISFloatArray::safeDownCast(mp_GG->GetGOById(i)->GetPointsDG()->GetDOBy
Id(textureYId))->GetElement(j));
}
}
// add the current points to the vtkPolyData
mp_External->SetPoints(tempPoints);
// handle each geometric object kind
switch (mp_GG->GetGOById(i)->GetType()) {
case myPolygon:
{
mp_External->InsertNextCell(VTK_POLYGON,tempList);
mp_External->Update();
// with my test, here my vtkPolyData contains a
polygon
// and 382 points : I constructed a list of
points, added // those points and constructed a cell
but this is not working.
vtkCleanPolyData *cleaner =
vtkCleanPolyData::New();
cleaner->SetInput(mp_External);
cleaner->Update();
mp_External->SetPoints(cleaner->GetOutput()->GetPoints());
mp_External->DeepCopy(cleaner->GetOutput());
// here there is no more polygons, as if points
were not valid
cleaner->Delete();
}
//...//
}
tempPoints->Delete();
tempList->Delete();
More information about the vtkusers
mailing list