diff --git a/Filters/Geometry/vtkGeometryFilter.cxx b/Filters/Geometry/vtkGeometryFilter.cxx index 921b1258..07071265 100644 --- a/Filters/Geometry/vtkGeometryFilter.cxx +++ b/Filters/Geometry/vtkGeometryFilter.cxx @@ -2392,18 +2392,19 @@ struct CompositeCells }; // CompositeCells // Composite threads to produce originating cell ids -template +// fvtk: templated on TOutId so the same scatter drives int32 or int64 storage. +template struct CompositeCellIds { ExtractCellBoundaries* Extractor; ::CompositeCells* CompositeCells; ThreadOutputType* Threads; - vtkIdType* OrigIds; + TOutId* OrigIds; vtkGeometryFilter* Filter; CompositeCellIds(ExtractCellBoundaries* extract, ::CompositeCells* compositeCells, - ThreadOutputType* threads, vtkIdType* origIds, vtkGeometryFilter* filter) + ThreadOutputType* threads, TOutId* origIds, vtkGeometryFilter* filter) : Extractor(extract) , CompositeCells(compositeCells) , Threads(threads) @@ -2419,7 +2420,7 @@ struct CompositeCellIds for (vtkIdType cellId = 0; cellId < numCells; ++cellId) { - this->OrigIds[globalCellId++] = cat->OrigCellIds[cellId]; + this->OrigIds[globalCellId++] = static_cast(cat->OrigCellIds[cellId]); } } @@ -2866,17 +2867,42 @@ void PassCellIds(const char* name, ExtractCellBoundaries* extract, ThreadOutputType* threads, vtkCellData* outCD, vtkGeometryFilter* filter) { vtkIdType numOutputCells = extract->NumCells; - vtkNew origCellIds; - origCellIds->SetName(name); - origCellIds->SetNumberOfComponents(1); - origCellIds->SetNumberOfTuples(numOutputCells); - outCD->AddArray(origCellIds); - vtkIdType* origIds = origCellIds->GetPointer(0); - - // Now populate the original cell ids - CompositeCellIds compIds( - extract, compositeCells, threads, origIds, filter); - vtkSMPTools::For(0, static_cast(threads->size()), compIds); + + // fvtk: width-relaxed storage. The values are input cell ids (sacred); the + // CONTAINER is int32 when every id fits in 0x7FFFFFFF, else int64. The input + // id type TInputIdType is selected by dispatch to vtkTypeInt32 only when the + // input cell (and point) count is <= VTK_TYPE_INT32_MAX, so when it is int32 + // every stored input cell id provably fits int32. The bitexact gate width- + // normalizes integer arrays, and the render hardware-selection path reads this + // passthrough array width-agnostically (vtkOpenGL*PolyDataMapper). + if (sizeof(TInputIdType) <= sizeof(vtkTypeInt32)) + { + vtkNew origCellIds; + origCellIds->SetName(name); + origCellIds->SetNumberOfComponents(1); + origCellIds->SetNumberOfTuples(numOutputCells); + outCD->AddArray(origCellIds); + vtkTypeInt32* origIds = origCellIds->GetPointer(0); + + // Now populate the original cell ids + CompositeCellIds compIds( + extract, compositeCells, threads, origIds, filter); + vtkSMPTools::For(0, static_cast(threads->size()), compIds); + } + else + { + vtkNew origCellIds; + origCellIds->SetName(name); + origCellIds->SetNumberOfComponents(1); + origCellIds->SetNumberOfTuples(numOutputCells); + outCD->AddArray(origCellIds); + vtkIdType* origIds = origCellIds->GetPointer(0); + + // Now populate the original cell ids + CompositeCellIds compIds( + extract, compositeCells, threads, origIds, filter); + vtkSMPTools::For(0, static_cast(threads->size()), compIds); + } } } // anonymous diff --git a/tests/bitexact/ops.py b/tests/bitexact/ops.py index f13ee53e..bf1a886b 100644 --- a/tests/bitexact/ops.py +++ b/tests/bitexact/ops.py @@ -1195,10 +1195,11 @@ def op_triangle(dtype, size): def op_geometry(dtype, size): g = vtkGeometryFilter() g.SetInputData(make_volume(size, dtype)) - # fvtk: emit vtkOriginalPointIds so the width-relaxed int32 id-array storage - # (vtkGeometryFilter::PassPointIds) is validated against stock (values match, - # int32 vs int64 container normalized by the compare gate). + # fvtk: emit vtkOriginalPointIds/CellIds so the width-relaxed int32 id-array + # storage (vtkGeometryFilter::PassPointIds / PassCellIds) is validated against + # stock (values match, int32 vs int64 container normalized by the compare gate). g.PassThroughPointIdsOn() + g.PassThroughCellIdsOn() g.Update() return g.GetOutput() @@ -1669,6 +1670,7 @@ def op_geometry_ugrid(dtype, size): g = vtkGeometryFilter() g.SetInputData(make_hex_ugrid(size, dtype)) g.PassThroughPointIdsOn() # fvtk: validate int32 vtkOriginalPointIds storage + g.PassThroughCellIdsOn() # fvtk: validate int32 vtkOriginalCellIds storage g.Update() return g.GetOutput() @@ -1684,6 +1686,7 @@ def op_geometry_ugrid_mixed(dtype, size): g = vtkGeometryFilter() g.SetInputData(make_mixed_ugrid(size, dtype)) g.PassThroughPointIdsOn() # fvtk: validate int32 vtkOriginalPointIds storage + g.PassThroughCellIdsOn() # fvtk: validate int32 vtkOriginalCellIds storage g.Update() return g.GetOutput()