Commit a3498cc3 authored by Bengt Rosenberger's avatar Bengt Rosenberger

Fixed vtkCleanPolyData adding unwanted cells

vtkCleanPolyData added degenerated cells to wrong cell array if the respective convert option was OFF
parent a8f86e37
......@@ -302,8 +302,9 @@ int vtkCleanPolyData::RequestData(
updatedPts[numNewPts++] = ptId;
}
}//for all cell points
if ( (numNewPts>1) || !this->ConvertLinesToPoints )
if (numNewPts == 2)
{
// Cell is a proper line, always add
newId = newLines->InsertNextCell(numNewPts,updatedPts);
outLineData->CopyData(inputCD, inCellID, newId);
if (lineIDcounter!=newId)
......@@ -312,8 +313,9 @@ int vtkCleanPolyData::RequestData(
}
lineIDcounter++;
}
else if ( numNewPts==1 )
else if (numNewPts == 1 && (npts == numNewPts || this->ConvertLinesToPoints))
{
// Cell was either a vertex to begin with and we didn't modify it or a degenerated line and the user wanted it included as a vertex
if (!newVerts)
{
newVerts = vtkCellArray::New();
......@@ -372,8 +374,9 @@ int vtkCleanPolyData::RequestData(
{
numNewPts--;
}
if ( (numNewPts > 2) || !this->ConvertPolysToLines )
if (numNewPts > 2)
{
// Cell is a proper polygon, always add
newId = newPolys->InsertNextCell(numNewPts,updatedPts);
outPolyData->CopyData(inputCD, inCellID, newId);
if (polyIDcounter!=newId)
......@@ -382,8 +385,9 @@ int vtkCleanPolyData::RequestData(
}
polyIDcounter++;
}
else if ( (numNewPts==2) || !this->ConvertLinesToPoints )
else if (numNewPts == 2 && (npts == numNewPts || this->ConvertPolysToLines))
{
// Cell was either a line to begin with and we didn't modify it or a degenerated poly and the user wanted it included as a line
if (!newLines)
{
newLines = vtkCellArray::New();
......@@ -399,8 +403,9 @@ int vtkCleanPolyData::RequestData(
}
lineIDcounter++;
}
else if ( numNewPts==1 )
else if (numNewPts == 1 && (npts == numNewPts || this->ConvertLinesToPoints))
{
// Cell was either a vertex to begin with and we didn't modify it or a degenerated line and the user wanted it included as a vertex
if (!newVerts)
{
newVerts = vtkCellArray::New();
......@@ -454,8 +459,9 @@ int vtkCleanPolyData::RequestData(
updatedPts[numNewPts++] = ptId;
}
}
if ( (numNewPts > 3) || !this->ConvertStripsToPolys )
if (numNewPts > 3)
{
// Cell is a proper triangle strip, always add
newId = newStrips->InsertNextCell(numNewPts,updatedPts);
outStrpData->CopyData(inputCD, inCellID, newId);
if (strpIDcounter!=newId)
......@@ -464,8 +470,9 @@ int vtkCleanPolyData::RequestData(
}
strpIDcounter++;
}
else if ( (numNewPts==3) || !this->ConvertPolysToLines )
else if (numNewPts == 3 && (npts == numNewPts || this->ConvertStripsToPolys))
{
// Cell was either a triangle to begin with and we didn't modify it or a degenerated triangle strip and the user wanted it included as a polygon
if (!newPolys)
{
newPolys = vtkCellArray::New();
......@@ -481,8 +488,9 @@ int vtkCleanPolyData::RequestData(
}
polyIDcounter++;
}
else if ( (numNewPts==2) || !this->ConvertLinesToPoints )
else if (numNewPts == 2 && (npts == numNewPts || this->ConvertPolysToLines))
{
// Cell was either a line to begin with and we didn't modify it or a degenerated triangle strip and the user wanted it included as a line
if (!newLines)
{
newLines = vtkCellArray::New();
......@@ -498,8 +506,9 @@ int vtkCleanPolyData::RequestData(
}
lineIDcounter++;
}
else if ( numNewPts==1 )
else if (numNewPts == 1 && (npts == numNewPts || this->ConvertLinesToPoints))
{
// Cell was either a vertex to begin with and we didn't modify it or a degenerated triangle strip and the user wanted it included as a vertex
if (!newVerts)
{
newVerts = vtkCellArray::New();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment