diff --git a/Common/vtkSurfaceBase.cxx b/Common/vtkSurfaceBase.cxx index f226789..4895aa8 100644 --- a/Common/vtkSurfaceBase.cxx +++ b/Common/vtkSurfaceBase.cxx @@ -1413,6 +1413,21 @@ void vtkSurfaceBase::CreateFromPolyData(vtkPolyData *input) // just copy the polydata in input this->ShallowCopy(input); + #if ( (VTK_MAJOR_VERSION >= 9)) + // GetFaceVertices() hands out raw pointers into the polygon connectivity and + // therefore requires 64-bit AOS cell storage. The input may carry another + // layout (32-bit or fixed-size, e.g. from vtkSurfaceNets3D), so copy its + // polygons into 64-bit storage instead of converting the shared array in place. + if (!this->GetPolys()->IsStorage64Bit()) + { + vtkCellArray *Polys64 = vtkCellArray::New(); + Polys64->DeepCopy(this->GetPolys()); + Polys64->ConvertTo64BitStorage(); + this->SetPolys(Polys64); + Polys64->Delete(); + } + #endif + // Delete the cells that are not polygons vtkCellArray *VerticesCells=this->GetVerts(); vtkCellArray *LinesCells=this->GetLines();