Following discussions in the VTKHDF polyhedrons thread, we would like to discuss a potential improvement to the vtkUnstructuredGrid data model that allows reusing the same faces using different orientations in different polyhedral cells.
For that, as suggested by @olesenm , we would change the FaceLocations array to handle negative values: face n is referenced as -(n+1) to signify a flipped orientation (ie points are taken in the reverse order). This way, 2 adjacent polyhedrons sharing a face will only have to define this face once, and use the flipped orientation in the FaceLocations array for one of these polygons to get correct normal vectors. This saves on both storage space when written to disk, and in memory.
Impact
The required changes are mostly internal to vtkUnstructuredGrid. For instance, face streams will be unchanged. GetPolyhedronFaceLocations will be renamed to GetOrientedPolyhedronFaceLocations that returns a cell array, referencing positive or negative face ids as points, depending on their orientation. GetPolyhedronFaceLocations will be deprecated and will implement a compatibility layer, that creates new faces so that every face id is positive, as it was before. All code using GetPolyhedronFaceLocations will need to adapt to the new GetOrientedPolyhedronFaceLocationswhich will require new code to handle the negative face ids. It should be mostly transparent for readers/writers that simply copy the array from/to disk.