Maybe it helps if I can post more detail what the software is actually doing and what is the result.
So this is a very much stripped down version of source code that is supposed to generate a hexahedron as a VTK_POLYHEDRON:
vtkSmartPointer<vtkAtgTableToSamplings> generateSampling =
vtkSmartPointer<vtkAtgTableToSamplings>::New();
generateSampling->SetInputData(inTable);
generateSampling->Update();
vtkPolyData* dataItems = generateSampling->GetOutput();
// get and prepare the output grid
vtkUnstructuredGrid* outputItemsUGrid =
vtkUnstructuredGrid::GetData(outputVector->GetInformationObject(0));
outputItemsUGrid->Allocate();
vtkSmartPointer<vtkPoints> outPoints = vtkSmartPointer<vtkPoints>::New();
outputItemsUGrid->SetPoints(outPoints);
vtkIdType pointIds[8] = {0, 1, 2, 3, 4, 5, 6, 7};
outPoints->InsertNextPoint(-1.0,-1.0,-1.0);
outPoints->InsertNextPoint( 1.0,-1.0,-1.0);
outPoints->InsertNextPoint( 1.0, 1.0,-1.0);
outPoints->InsertNextPoint(-1.0, 1.0,-1.0);
outPoints->InsertNextPoint(-1.0,-1.0, 1.0);
outPoints->InsertNextPoint( 1.0,-1.0, 1.0);
outPoints->InsertNextPoint( 1.0, 1.0, 1.0);
outPoints->InsertNextPoint(-1.0, 1.0, 1.0);
vtkIdType faces[] =
{
4, 0, 3, 2, 1,
4, 0, 4, 7, 3,
4, 4, 5, 6, 7,
4, 5, 1, 2, 6,
4, 0, 1, 5, 4,
4, 2, 3, 7, 6
};
outputItemsUGrid->InsertNextCell(VTK_POLYHEDRON, 8, pointIds, 6, faces);
The output 3D view (in ParaView) shows just NOTHING.
The “Information” panel tells me that I am having an “unstructured grid” with 1 cell and 8 points.
A “spreadsheet view” shows in “point data” the 8 point coordinates, and in “cell data” one cell of type POLYHEDRON.
Writing this “unstructured grid” of one cell to a vtu file generates the following output:
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="8" NumberOfCells="1">
<PointData>
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float64" Name="Points" NumberOfComponents="3" format="ascii" RangeMin="1.7320508075688772" RangeMax="1.7320508075688772">
-1 -1 -1 1 -1 -1
1 1 -1 -1 1 -1
-1 -1 1 1 -1 1
1 1 1 -1 1 1
<InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
<Value index="0">
1.7320508076
</Value>
<Value index="1">
1.7320508076
</Value>
</InformationKey>
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
1.7320508076
</Value>
<Value index="1">
1.7320508076
</Value>
</InformationKey>
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="7">
0 1 2 3 4 5
6 7
</DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="8" RangeMax="8">
8
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii" RangeMin="42" RangeMax="42">
42
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
Reading this same file back in results in NOTHING again.
Manually inserting the following after the last seems to fix the vtu file:
<DataArray type="Int64" Name="faces" format="ascii" RangeMin="0" RangeMax="7">
6
4 0 3 2 1
4 0 4 7 3
4 4 5 6 7
4 5 1 2 6
4 0 1 5 4
4 2 3 7 6
</DataArray>
<DataArray type="Int64" Name="faceoffsets" format="ascii" RangeMin="31" RangeMax="31">
31
</DataArray>
Note that this is exactly the same thing that I had already also written in the source code above!
Finally inserted the following data dump code after the InsertNextCell above:
vtkIdTypeArray* farr = outputItemsUGrid->GetFaces();
if(nullptr == farr)
std::cout << "- NO faces array" << std::endl;
else
{
std::cout << "- faces array";
for(vtkIdType i = 0; i < farr->GetNumberOfValues(); ++i)
std::cout << " " << farr->GetValue(i);
std::cout << std::endl;
}
vtkIdTypeArray* flarr = outputItemsUGrid->GetFaceLocations();
if(nullptr == flarr)
std::cout << "- NO faces location array" << std::endl;
else
{
std::cout << "- faces location array";
for(vtkIdType i = 0; i < flarr->GetNumberOfValues(); ++i)
std::cout << " " << flarr->GetValue(i);
std::cout << std::endl;
}
generating the following output:
- faces array 6 4 0 3 2 1 4 0 4 7 3 4 4 5 6 7 4 5 1 2 6 4 0 1 5 4 4 2 3 7 6
- faces location array 0
So it looks like “faces” and “faces location” data are also generated correctly during the InsertNextCell call!
(It looks like the “faces location array” is not exactly the same as what is expected in the “faceoffsets” - which makes even sense for me if I think about how the code should handle this kind of “streaming data”)
Now I start running out of options what else I could check…