Commit 71b7c26b authored by Joachim Pouderoux's avatar Joachim Pouderoux
Browse files

Add support for Polyhedron in UnstructuredGridGeometryFilter.

This cell type was not supported so far by this filter. This used
to generate an error when applying the Triangulate feature of
ParaView on a dataset or when a dataset contained Polyhedron and
non-linear cells.
parent 73fb094d
......@@ -72,6 +72,7 @@
# include "vtkPolyVertex.h"
# include "vtkLine.h"
# include "vtkPolyLine.h"
# include "vtkPolyhedron.h"
# include "vtkQuadraticEdge.h"
# include "vtkTriangle.h"
# include "vtkTriangleStrip.h"
......@@ -3521,6 +3522,101 @@ int TestUnstructuredGridGeometryFilter(int argc, char* argv[])
pointId+=55;
// 3D: polyhedron: 2 hexahedra with one common face
xOffset+=3.0;
points->InsertNextPoint(xOffset+0.0,yOffset+0.0,0.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+2.0,yOffset+0.0,0.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+2.0,yOffset+2.0,0.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.0,yOffset+2.0,0.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.1,yOffset+0.1,3.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.9,yOffset+0.1,3.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.9,yOffset+1.9,3.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.1,yOffset+1.9,3.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.0,yOffset+0.0,4.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+2.0,yOffset+0.0,4.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+2.0,yOffset+2.0,5.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
points->InsertNextPoint(xOffset+0.0,yOffset+2.0,5.0);
scalars->InsertNextValue(scalar);
scalar+=scalarStep;
vtkPolyhedron *polyhedron = vtkPolyhedron::New();
vtkIdType faces[6][4] =
{
{0, 4, 7, 3},
{1, 2, 6, 5},
{0, 1, 5, 4},
{3, 7, 6, 2},
{0, 3, 2, 1},
{4, 5, 6, 7}
};
polyhedron->GetPointIds()->SetNumberOfIds(6 * 5 + 1);
vtkIdType fptr = 0;
polyhedron->GetPointIds()->SetId(fptr++, 6);
for (int f = 0; f < 6; f++)
{
polyhedron->GetPointIds()->SetId(fptr++, 4);
for (int p = 0; p < 4; p++)
{
polyhedron->GetPointIds()->SetId(fptr++, pointId + faces[f][p]);
}
}
cellIds->InsertNextValue(cellId);
++cellId;
grid->InsertNextCell(polyhedron->GetCellType(), polyhedron->GetPointIds());
polyhedron->GetPointIds()->SetNumberOfIds(6 * 5 + 1);
fptr = 0;
polyhedron->GetPointIds()->SetId(fptr++, 6);
for (int f = 0; f < 6; f++)
{
polyhedron->GetPointIds()->SetId(fptr++, 4);
for (int p = 0; p < 4; p++)
{
polyhedron->GetPointIds()->SetId(fptr++, 4 + pointId + faces[f][p]);
}
}
cellIds->InsertNextValue(cellId);
++cellId;
grid->InsertNextCell(polyhedron->GetCellType(), polyhedron->GetPointIds());
polyhedron->Delete();
pointId+=12;
grid->SetPoints(points);
grid->GetPointData()->SetScalars(scalars);
......
......@@ -14,40 +14,40 @@
=========================================================================*/
#include "vtkUnstructuredGridGeometryFilter.h"
#include "vtkBiQuadraticQuadraticHexahedron.h"
#include "vtkBiQuadraticQuadraticWedge.h"
#include "vtkBiQuadraticTriangle.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkCellIterator.h"
#include "vtkGenericCell.h"
#include "vtkHexagonalPrism.h"
#include "vtkHexahedron.h"
#include "vtkIncrementalPointLocator.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkMergePoints.h"
#include "vtkObjectFactory.h"
#include "vtkPentagonalPrism.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkPolyhedron.h"
#include "vtkPyramid.h"
#include "vtkPentagonalPrism.h"
#include "vtkQuadraticHexahedron.h"
#include "vtkQuadraticLinearWedge.h"
#include "vtkQuadraticPyramid.h"
#include "vtkQuadraticTetra.h"
#include "vtkQuadraticWedge.h"
#include "vtkSmartPointer.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStructuredGrid.h"
#include "vtkTetra.h"
#include "vtkTriQuadraticHexahedron.h"
#include "vtkUnsignedCharArray.h"
#include "vtkUnstructuredGrid.h"
#include "vtkVoxel.h"
#include "vtkWedge.h"
#include "vtkQuadraticTetra.h"
#include "vtkQuadraticHexahedron.h"
#include "vtkQuadraticWedge.h"
#include "vtkQuadraticPyramid.h"
#include "vtkTriQuadraticHexahedron.h"
#include "vtkQuadraticLinearWedge.h"
#include "vtkBiQuadraticQuadraticWedge.h"
#include "vtkBiQuadraticQuadraticHexahedron.h"
#include "vtkBiQuadraticTriangle.h"
#include "vtkIncrementalPointLocator.h"
#include <vector>
#include <cassert>
......@@ -1388,6 +1388,18 @@ int vtkUnstructuredGridGeometryFilter::RequestData(
++face;
}
break;
case VTK_POLYHEDRON:
{
vtkIdList* faces = cellIter->GetFaces();
vtkIdType nbFaces = cellIter->GetNumberOfFaces();
for (vtkIdType f = 0, fptr = 1; f < nbFaces; f++)
{
pt = faces->GetId(fptr++);
this->HashTable->InsertFace(cellId, VTK_POLYGON, pt, faces->GetPointer(fptr));
fptr += pt;
}
break;
}
default:
vtkErrorMacro(<< "Cell type "
<< vtkCellTypes::GetClassNameFromTypeId(cellType)
......
Supports Markdown
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