From ed82597f2b41dc57eb761ac6def817b8ca624a8d Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Thu, 19 Dec 2024 16:54:29 -0700 Subject: [PATCH] Contour Polygons with Marching Cubes Previously, the Marching Cubes contouring algorithm only had case tables for 3D polyhedra. This means that if you attempted to contour or slice surfaces or lines, you would not get any output. However, there are many valid use cases for contouring this type of data. This change adds case tables for triangles, quadrilaterals, and lines. It also adds some special cases for general polygons and poly-lines. These special cases do not use tables. Rather, there is a special routine that iterates over the points since these cells types can have any number of points. Note that to preserve the speed of the operation, contours for cells of a single dimension type are done at one time. By default, the contour filter will try 3D cells, then 2D cells, then 1D cells. It is also possible to select a particular cell dimension or to append results from all cell types together. In this latest case, the output cells will be of type `CellSetExplicit` instead of `CellSetSingleType`. --- data/baseline/filter/contour-poly.png | 3 + data/data/unstructured/mixed-cell-shapes.vtk | 3 + data/data/unstructured/poly_contour_cases.vtk | 3 + docs/changelog/contour-polys.md | 18 + docs/users-guide/provided-filters.rst | 17 +- vtkm/filter/contour/AbstractContour.h | 65 +- vtkm/filter/contour/CMakeLists.txt | 1 + vtkm/filter/contour/Contour.cxx | 1 + vtkm/filter/contour/ContourDimension.h | 42 + vtkm/filter/contour/ContourMarchingCells.cxx | 73 +- vtkm/filter/contour/ContourMarchingCells.h | 6 +- .../testing/RenderTestContourFilter.cxx | 24 + .../contour/testing/UnitTestContourFilter.cxx | 66 +- .../testing/UnitTestContourFilterNormals.cxx | 6 +- .../contour/worklet/ContourMarchingCells.h | 140 +- .../worklet/contour/MarchingCellTables.h | 1252 ++++++++++------- .../worklet/contour/MarchingCellTables.h.in | 341 ++++- .../contour/worklet/contour/MarchingCells.h | 400 +++++- 18 files changed, 1752 insertions(+), 709 deletions(-) create mode 100644 data/baseline/filter/contour-poly.png create mode 100644 data/data/unstructured/mixed-cell-shapes.vtk create mode 100644 data/data/unstructured/poly_contour_cases.vtk create mode 100644 docs/changelog/contour-polys.md create mode 100644 vtkm/filter/contour/ContourDimension.h diff --git a/data/baseline/filter/contour-poly.png b/data/baseline/filter/contour-poly.png new file mode 100644 index 0000000000..b2d1e86af7 --- /dev/null +++ b/data/baseline/filter/contour-poly.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cc54950e4a59077715dc85afa76db9f7bc503e3458dc6a1cdaa07a0ecfa2dae +size 44574 diff --git a/data/data/unstructured/mixed-cell-shapes.vtk b/data/data/unstructured/mixed-cell-shapes.vtk new file mode 100644 index 0000000000..3da0212071 --- /dev/null +++ b/data/data/unstructured/mixed-cell-shapes.vtk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:303a29e437be8a08cc4e33ad26128a81ff2c6aae449339ab66dbfc00939eefec +size 1126 diff --git a/data/data/unstructured/poly_contour_cases.vtk b/data/data/unstructured/poly_contour_cases.vtk new file mode 100644 index 0000000000..5876e7f421 --- /dev/null +++ b/data/data/unstructured/poly_contour_cases.vtk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8044a2d5cad64d1e5b3b3d972eb69806c8ccb27a30dacfc4056e8ba73be8484 +size 659 diff --git a/docs/changelog/contour-polys.md b/docs/changelog/contour-polys.md new file mode 100644 index 0000000000..0a0d0b4bec --- /dev/null +++ b/docs/changelog/contour-polys.md @@ -0,0 +1,18 @@ +## Contour Polygons with Marching Cubes + +Previously, the Marching Cubes contouring algorithm only had case tables for 3D +polyhedra. This means that if you attempted to contour or slice surfaces or +lines, you would not get any output. However, there are many valid use cases for +contouring this type of data. + +This change adds case tables for triangles, quadrilaterals, and lines. It also +adds some special cases for general polygons and poly-lines. These special cases +do not use tables. Rather, there is a special routine that iterates over the +points since these cells types can have any number of points. + +Note that to preserve the speed of the operation, contours for cells of a single +dimension type are done at one time. By default, the contour filter will try 3D +cells, then 2D cells, then 1D cells. It is also possible to select a particular +cell dimension or to append results from all cell types together. In this latest +case, the output cells will be of type `CellSetExplicit` instead of +`CellSetSingleType`. diff --git a/docs/users-guide/provided-filters.rst b/docs/users-guide/provided-filters.rst index cd0c9bd221..95dad99a2e 100644 --- a/docs/users-guide/provided-filters.rst +++ b/docs/users-guide/provided-filters.rst @@ -180,29 +180,32 @@ The contouring/isosurface algorithm is implemented by :class:`vtkm::filter::cont :class:`vtkm::filter::contour::Contour` also inherits the following methods. .. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetIsoValue(vtkm::Float64) - .. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetIsoValue(vtkm::Id, vtkm::Float64) - .. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetIsoValues - .. doxygenfunction:: vtkm::filter::contour::AbstractContour::GetIsoValue .. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetGenerateNormals - .. doxygenfunction:: vtkm::filter::contour::AbstractContour::GetGenerateNormals .. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetComputeFastNormals - .. doxygenfunction:: vtkm::filter::contour::AbstractContour::GetComputeFastNormals .. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetNormalArrayName - .. doxygenfunction:: vtkm::filter::contour::AbstractContour::GetNormalArrayName -.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetMergeDuplicatePoints +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetInputCellDimension +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::GetInputCellDimension +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetInputCellDimensionToAuto +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetInputCellDimensionToAll +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetInputCellDimensionToPolyhedra +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetInputCellDimensionToPolygons +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetInputCellDimensionToLines +.. doxygenfunction:: vtkm::filter::contour::AbstractContour::SetMergeDuplicatePoints .. doxygenfunction:: vtkm::filter::contour::AbstractContour::GetMergeDuplicatePoints +.. doxygenenum:: vtkm::filter::contour::ContourDimension + .. load-example:: Contour :file: GuideExampleProvidedFilters.cxx :caption: Using :class:`vtkm::filter::contour::Contour`. diff --git a/vtkm/filter/contour/AbstractContour.h b/vtkm/filter/contour/AbstractContour.h index 5181f0ba59..a1a1bda997 100644 --- a/vtkm/filter/contour/AbstractContour.h +++ b/vtkm/filter/contour/AbstractContour.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -127,6 +128,65 @@ public: VTKM_CONT const std::string& GetNormalArrayName() const { return this->NormalArrayName; } + /// @brief Specify the dimension of cells on which to operate the contour. + /// + /// The contour filters operate on cells of a particular dimension + /// (i.e., polyhedra, polygons, or lines) and generate simplicies + /// of one less dimension (i.e., triangles, lines, or vertices). + /// The default is `vtkm::filter::contour::ContourDimension::Auto`. + VTKM_CONT void SetInputCellDimension(vtkm::filter::contour::ContourDimension dimension) + { + this->InputCellDimension = dimension; + } + + /// @copydoc SetInputCellDimension + VTKM_CONT vtkm::filter::contour::ContourDimension GetInputCellDimension() const + { + return this->InputCellDimension; + } + + /// @brief Specifies an automatic selection of the input cell dimension. + /// + /// This option first tries to contour polyhedra. If any polyhedra have the + /// contour, that is used. Otherwise, it tries to contour polygons. + /// If that fails, lines are contoured. + VTKM_CONT void SetInputCellDimensionToAuto() + { + this->SetInputCellDimension(vtkm::filter::contour::ContourDimension::Auto); + } + + /// @brief Specifies a combination of all possible contours. + /// + /// This option runs contour on all possible dimension types and then merges all contours together. + VTKM_CONT void SetInputCellDimensionToAll() + { + this->SetInputCellDimension(vtkm::filter::contour::ContourDimension::All); + } + + /// @brief Specifies running contours on polyhedra. + /// + /// This option runs contour on polyhedra, generating triangles. + VTKM_CONT void SetInputCellDimensionToPolyhedra() + { + this->SetInputCellDimension(vtkm::filter::contour::ContourDimension::Polyhedra); + } + + /// @brief Specifies running contours on polygons. + /// + /// This option runs contour on polygons, generating lines. + VTKM_CONT void SetInputCellDimensionToPolygons() + { + this->SetInputCellDimension(vtkm::filter::contour::ContourDimension::Polygons); + } + + /// @brief Specifies running contours on lines. + /// + /// This option runs contour on lines, generating vertices. + VTKM_CONT void SetInputCellDimensionToLines() + { + this->SetInputCellDimension(vtkm::filter::contour::ContourDimension::Lines); + } + /// Set whether the points generated should be unique for every triangle /// or will duplicate points be merged together. Duplicate points are identified /// by the unique edge it was generated from. @@ -144,7 +204,7 @@ public: /// Get whether the points generated should be unique for every triangle /// or will duplicate points be merged together. VTKM_CONT - bool GetMergeDuplicatePoints() { return this->MergeDuplicatedPoints; } + bool GetMergeDuplicatePoints() const { return this->MergeDuplicatedPoints; } protected: /// \brief Map a given field to the output \c DataSet , depending on its type. @@ -223,6 +283,9 @@ protected: bool GenerateNormals = true; bool ComputeFastNormals = false; + vtkm::filter::contour::ContourDimension InputCellDimension = + vtkm::filter::contour::ContourDimension::Auto; + bool AddInterpolationEdgeIds = false; bool MergeDuplicatedPoints = true; std::string NormalArrayName = "normals"; diff --git a/vtkm/filter/contour/CMakeLists.txt b/vtkm/filter/contour/CMakeLists.txt index c7a4105b88..ac885f386a 100644 --- a/vtkm/filter/contour/CMakeLists.txt +++ b/vtkm/filter/contour/CMakeLists.txt @@ -13,6 +13,7 @@ set(contour_headers ClipWithField.h ClipWithImplicitFunction.h Contour.h + ContourDimension.h ContourFlyingEdges.h ContourMarchingCells.h MIRFilter.h diff --git a/vtkm/filter/contour/Contour.cxx b/vtkm/filter/contour/Contour.cxx index 466a3657d2..e59dd72702 100644 --- a/vtkm/filter/contour/Contour.cxx +++ b/vtkm/filter/contour/Contour.cxx @@ -52,6 +52,7 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& inDataSet) implementation->SetGenerateNormals(this->GetGenerateNormals()); implementation->SetAddInterpolationEdgeIds(this->GetAddInterpolationEdgeIds()); implementation->SetNormalArrayName(this->GetNormalArrayName()); + implementation->SetInputCellDimension(this->GetInputCellDimension()); implementation->SetActiveField(this->GetActiveFieldName()); implementation->SetFieldsToPass(this->GetFieldsToPass()); implementation->SetNumberOfIsoValues(this->GetNumberOfIsoValues()); diff --git a/vtkm/filter/contour/ContourDimension.h b/vtkm/filter/contour/ContourDimension.h new file mode 100644 index 0000000000..033cb82963 --- /dev/null +++ b/vtkm/filter/contour/ContourDimension.h @@ -0,0 +1,42 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//============================================================================ +#ifndef vtk_m_filter_contour_ContourDimension_h +#define vtk_m_filter_contour_ContourDimension_h + +namespace vtkm +{ +namespace filter +{ +namespace contour +{ + +/// @brief Identifies what type cells will be contoured. +/// +/// The `ContourDimension` enum is used by the contour filters to specify which +/// dimension of cell to contour by. +enum struct ContourDimension +{ + /// @copydoc vtkm::filter::contour::AbstractContour::SetInputCellDimensionToAuto + Auto, + /// @copydoc vtkm::filter::contour::AbstractContour::SetInputCellDimensionToAll + All, + /// @copydoc vtkm::filter::contour::AbstractContour::SetInputCellDimensionToPolyhedra + Polyhedra, + /// @copydoc vtkm::filter::contour::AbstractContour::SetInputCellDimensionToPolygons + Polygons, + /// @copydoc vtkm::filter::contour::AbstractContour::SetInputCellDimensionToLines + Lines +}; + +} +} +} // namespace vtkm::filter::contour + +#endif // vtk_m_filter_contour_ContourDimension_h diff --git a/vtkm/filter/contour/ContourMarchingCells.cxx b/vtkm/filter/contour/ContourMarchingCells.cxx index 38a3ca5005..bf6a4ffd46 100644 --- a/vtkm/filter/contour/ContourMarchingCells.cxx +++ b/vtkm/filter/contour/ContourMarchingCells.cxx @@ -13,7 +13,7 @@ #include #include - +#include namespace vtkm { @@ -23,6 +23,70 @@ namespace contour { //----------------------------------------------------------------------------- vtkm::cont::DataSet ContourMarchingCells::DoExecute(const vtkm::cont::DataSet& inDataSet) +{ + switch (this->GetInputCellDimension()) + { + case vtkm::filter::contour::ContourDimension::Auto: + { + vtkm::cont::DataSet output = this->DoExecuteDimension<3>(inDataSet); + if (output.GetNumberOfCells() > 0) + { + return output; + } + output = this->DoExecuteDimension<2>(inDataSet); + if (output.GetNumberOfCells() > 0) + { + return output; + } + output = this->DoExecuteDimension<1>(inDataSet); + return output; + } + case vtkm::filter::contour::ContourDimension::All: + { + vtkm::cont::PartitionedDataSet allData; + vtkm::cont::DataSet output = this->DoExecuteDimension<3>(inDataSet); + if (output.GetNumberOfCells() > 0) + { + allData.AppendPartition(output); + } + output = this->DoExecuteDimension<2>(inDataSet); + if (output.GetNumberOfCells() > 0) + { + allData.AppendPartition(output); + } + output = this->DoExecuteDimension<1>(inDataSet); + if (output.GetNumberOfCells() > 0) + { + allData.AppendPartition(output); + } + if (allData.GetNumberOfPartitions() > 1) + { + vtkm::filter::multi_block::MergeDataSets merge; + return merge.Execute(allData).GetPartition(0); + } + else if (allData.GetNumberOfPartitions() == 1) + { + return allData.GetPartition(0); + } + else + { + return output; + } + } + case vtkm::filter::contour::ContourDimension::Polyhedra: + return this->DoExecuteDimension<3>(inDataSet); + case vtkm::filter::contour::ContourDimension::Polygons: + return this->DoExecuteDimension<2>(inDataSet); + case vtkm::filter::contour::ContourDimension::Lines: + return this->DoExecuteDimension<1>(inDataSet); + default: + throw vtkm::cont::ErrorBadValue("Invalid value for ContourDimension."); + } +} + + +template +vtkm::cont::DataSet ContourMarchingCells::DoExecuteDimension(const vtkm::cont::DataSet& inDataSet) { vtkm::worklet::ContourMarchingCells worklet; worklet.SetMergeDuplicatePoints(this->GetMergeDuplicatePoints()); @@ -59,11 +123,12 @@ vtkm::cont::DataSet ContourMarchingCells::DoExecute(const vtkm::cont::DataSet& i if (this->GenerateNormals && !this->GetComputeFastNormals()) { - outputCells = worklet.Run(ivalues, inputCells, inputCoords, concrete, vertices, normals); + outputCells = + worklet.Run(ivalues, inputCells, inputCoords, concrete, vertices, normals); } else { - outputCells = worklet.Run(ivalues, inputCells, inputCoords, concrete, vertices); + outputCells = worklet.Run(ivalues, inputCells, inputCoords, concrete, vertices); } }; @@ -76,9 +141,9 @@ vtkm::cont::DataSet ContourMarchingCells::DoExecute(const vtkm::cont::DataSet& i this->ExecuteGenerateNormals(output, normals); this->ExecuteAddInterpolationEdgeIds(output, worklet); - return output; } + } // namespace contour } // namespace filter } // namespace vtkm diff --git a/vtkm/filter/contour/ContourMarchingCells.h b/vtkm/filter/contour/ContourMarchingCells.h index 653a1eaadf..218e4c8cd1 100644 --- a/vtkm/filter/contour/ContourMarchingCells.h +++ b/vtkm/filter/contour/ContourMarchingCells.h @@ -33,8 +33,10 @@ class VTKM_FILTER_CONTOUR_EXPORT ContourMarchingCells : public vtkm::filter::contour::AbstractContour { protected: - VTKM_CONT - vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& result) override; + VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& result) override; + + template + VTKM_CONT vtkm::cont::DataSet DoExecuteDimension(const vtkm::cont::DataSet& result); }; } // namespace contour } // namespace filter diff --git a/vtkm/filter/contour/testing/RenderTestContourFilter.cxx b/vtkm/filter/contour/testing/RenderTestContourFilter.cxx index 607abbd6f4..e813d0229d 100644 --- a/vtkm/filter/contour/testing/RenderTestContourFilter.cxx +++ b/vtkm/filter/contour/testing/RenderTestContourFilter.cxx @@ -160,12 +160,36 @@ void TestContourFilterTangle() vtkm::rendering::testing::RenderTest(result, "tangle", "filter/contour-tangle.png", testOptions); } +void TestContourFilterPoly() +{ + std::cout << "Generate Image for Contour filter on polygons" << std::endl; + + auto pathname = vtkm::cont::testing::Testing::DataPath("unstructured/poly_contour_cases.vtk"); + vtkm::io::VTKDataSetReader reader(pathname); + vtkm::cont::DataSet dataSet = reader.ReadDataSet(); + + vtkm::filter::contour::Contour contour; + contour.SetIsoValues({ -0.20, -0.12, -0.04, 0.04, 0.12, 0.20 }); + contour.SetActiveField("PerlinNoise"); + contour.SetMergeDuplicatePoints(true); + auto result = contour.Execute(dataSet); + + result.PrintSummary(std::cout); + + vtkm::rendering::testing::RenderTestOptions testOptions; + testOptions.Mapper = vtkm::rendering::testing::MapperType::Cylinder; + testOptions.Radius = 0.01f; + vtkm::rendering::testing::RenderTest( + result, "PerlinNoise", "filter/contour-poly.png", testOptions); +} + void TestContourFilter() { TestContourFilterUniform(); TestContourFilterUniformBoundaries(); TestContourFilterTangle(); TestContourFilterWedge(); + TestContourFilterPoly(); } } // namespace diff --git a/vtkm/filter/contour/testing/UnitTestContourFilter.cxx b/vtkm/filter/contour/testing/UnitTestContourFilter.cxx index 61ccdc97b0..51e9b32bee 100644 --- a/vtkm/filter/contour/testing/UnitTestContourFilter.cxx +++ b/vtkm/filter/contour/testing/UnitTestContourFilter.cxx @@ -92,9 +92,7 @@ public: } vtkm::cont::CoordinateSystem coords = result.GetCoordinateSystem(); - vtkm::cont::UnknownCellSet dcells = result.GetCellSet(); - using CellSetType = vtkm::cont::CellSetSingleType<>; - const CellSetType& cells = dcells.AsCellSet(); + vtkm::cont::UnknownCellSet cells = result.GetCellSet(); //verify that the number of points is correct (72) //verify that the number of cells is correct (160) @@ -113,10 +111,7 @@ public: "Shouldn't have less coordinates than the unmerged version"); //verify that the number of cells is correct (160) - vtkm::cont::UnknownCellSet dcells = result.GetCellSet(); - - using CellSetType = vtkm::cont::CellSetSingleType<>; - const CellSetType& cells = dcells.AsCellSet(); + vtkm::cont::UnknownCellSet cells = result.GetCellSet(); VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, ""); } } @@ -158,9 +153,6 @@ public: vtkm::cont::DataSet dataSet = reader.ReadDataSet(); - vtkm::cont::CellSetSingleType<> cellSet; - dataSet.GetCellSet().AsCellSet(cellSet); - vtkm::cont::ArrayHandle fieldArray; dataSet.GetPointField("gyroid").GetData().AsArrayHandle(fieldArray); @@ -245,6 +237,58 @@ public: "Wrong number of cells in rectilinear contour"); } + void TestMixedShapes() const + { + auto pathname = vtkm::cont::testing::Testing::DataPath("unstructured/mixed-cell-shapes.vtk"); + vtkm::io::VTKDataSetReader reader(pathname); + vtkm::cont::DataSet input = reader.ReadDataSet(); + + // Single-cell contour + vtkm::filter::contour::Contour filter; + filter.SetActiveField("scalars"); + filter.SetMergeDuplicatePoints(true); + filter.SetIsoValues({ 5.5, 9.5, 11.5, 14.5, 17.5, 20.5, 25.5 }); + + { + filter.SetInputCellDimensionToAuto(); + vtkm::cont::DataSet output = filter.Execute(input); + VTKM_TEST_ASSERT(output.GetNumberOfPoints() == 18); + VTKM_TEST_ASSERT(output.GetNumberOfCells() == 10); + VTKM_TEST_ASSERT(output.GetCellSet().GetCellShape(0) == vtkm::CELL_SHAPE_TRIANGLE); + } + + { + filter.SetInputCellDimensionToPolyhedra(); + vtkm::cont::DataSet output = filter.Execute(input); + VTKM_TEST_ASSERT(output.GetNumberOfPoints() == 18); + VTKM_TEST_ASSERT(output.GetNumberOfCells() == 10); + VTKM_TEST_ASSERT(output.GetCellSet().GetCellShape(0) == vtkm::CELL_SHAPE_TRIANGLE); + } + + { + filter.SetInputCellDimensionToPolygons(); + vtkm::cont::DataSet output = filter.Execute(input); + VTKM_TEST_ASSERT(output.GetNumberOfPoints() == 16); + VTKM_TEST_ASSERT(output.GetNumberOfCells() == 8); + VTKM_TEST_ASSERT(output.GetCellSet().GetCellShape(0) == vtkm::CELL_SHAPE_LINE); + } + + { + filter.SetInputCellDimensionToLines(); + vtkm::cont::DataSet output = filter.Execute(input); + VTKM_TEST_ASSERT(output.GetNumberOfPoints() == 2); + VTKM_TEST_ASSERT(output.GetNumberOfCells() == 2); + VTKM_TEST_ASSERT(output.GetCellSet().GetCellShape(0) == vtkm::CELL_SHAPE_VERTEX); + } + + { + filter.SetInputCellDimensionToAll(); + vtkm::cont::DataSet output = filter.Execute(input); + VTKM_TEST_ASSERT(output.GetNumberOfPoints() == 36); + VTKM_TEST_ASSERT(output.GetNumberOfCells() == 20); + } + } + void operator()() const { this->TestContourUniformGrid(72); @@ -265,6 +309,8 @@ public: this->TestNonUniformStructured(); this->TestUnsupportedFlyingEdges(); + + this->TestMixedShapes(); } }; // class TestContourFilter diff --git a/vtkm/filter/contour/testing/UnitTestContourFilterNormals.cxx b/vtkm/filter/contour/testing/UnitTestContourFilterNormals.cxx index e149bcbea4..16fd69ea00 100644 --- a/vtkm/filter/contour/testing/UnitTestContourFilterNormals.cxx +++ b/vtkm/filter/contour/testing/UnitTestContourFilterNormals.cxx @@ -48,8 +48,7 @@ vtkm::cont::DataSet MakeNormalsTestDataSet() // Verify that the direction of the normals is consistent with the triangle winding. void CheckWinding(const vtkm::cont::DataSet& contour) { - vtkm::cont::CellSetSingleType<> cellSet; - contour.GetCellSet().AsCellSet(cellSet); + vtkm::cont::UnknownCellSet cellSet = contour.GetCellSet(); vtkm::cont::ArrayHandle coords; contour.GetCoordinateSystem().GetData().AsArrayHandle(coords); @@ -61,8 +60,9 @@ void CheckWinding(const vtkm::cont::DataSet& contour) for (vtkm::Id triId = 0; triId < cellSet.GetNumberOfCells(); ++triId) { + VTKM_TEST_ASSERT(cellSet.GetNumberOfPointsInCell(triId) == 3); vtkm::Id3 pointIds; - cellSet.GetIndices(triId, pointIds); + cellSet.GetCellPointIds(triId, &pointIds[0]); vtkm::Vec3f facetNormal = vtkm::TriangleNormal( coordsPortal.Get(pointIds[0]), coordsPortal.Get(pointIds[1]), coordsPortal.Get(pointIds[2])); diff --git a/vtkm/filter/contour/worklet/ContourMarchingCells.h b/vtkm/filter/contour/worklet/ContourMarchingCells.h index 9ecdde5692..079c9e30df 100644 --- a/vtkm/filter/contour/worklet/ContourMarchingCells.h +++ b/vtkm/filter/contour/worklet/ContourMarchingCells.h @@ -32,6 +32,7 @@ namespace worklet namespace contour { +template struct DeduceCoordType { template @@ -40,10 +41,11 @@ struct DeduceCoordType vtkm::cont::CellSetSingleType<>& result, Args&&... args) const { - result = marching_cells::execute(cells, coords, std::forward(args)...); + result = marching_cells::execute(cells, coords, std::forward(args)...); } }; +template struct DeduceCellType { template @@ -58,18 +60,20 @@ struct DeduceCellType }; // Declared outside of class, non-inline so that instantiations can be exported correctly. +template template -void DeduceCellType::operator()(const CellSetType& cells, - const vtkm::cont::CoordinateSystem& coordinateSystem, - vtkm::cont::CellSetSingleType<>& outputCells, - const std::vector& isovalues, - const vtkm::cont::ArrayHandle& input, - vtkm::cont::ArrayHandle& vertices, - vtkm::cont::ArrayHandle& normals, - vtkm::worklet::contour::CommonState& sharedState) const +void DeduceCellType::operator()( + const CellSetType& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const { vtkm::cont::CastAndCall(coordinateSystem, - contour::DeduceCoordType{}, + contour::DeduceCoordType{}, cells, outputCells, isovalues, @@ -125,7 +129,7 @@ public: public: // Filter called without normals generation - template + template VTKM_CONT vtkm::cont::CellSetSingleType<> Run( const std::vector& isovalues, const vtkm::cont::UnknownCellSet& cells, @@ -138,7 +142,7 @@ public: vtkm::cont::CellSetSingleType<> outputCells; vtkm::cont::CastAndCall(cells, - contour::DeduceCellType{}, + contour::DeduceCellType{}, coordinateSystem, outputCells, isovalues, @@ -150,7 +154,7 @@ public: } // Filter called with normals generation - template + template VTKM_CONT vtkm::cont::CellSetSingleType<> Run( const std::vector& isovalues, const vtkm::cont::UnknownCellSet& cells, @@ -163,7 +167,7 @@ public: vtkm::cont::CellSetSingleType<> outputCells; vtkm::cont::CastAndCall(cells, - contour::DeduceCellType{}, + contour::DeduceCellType{}, coordinateSystem, outputCells, isovalues, @@ -183,7 +187,7 @@ private: } // namespace vtkm::worklet VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<2>::operator()( const vtkm::cont::CellSetStructured<2>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -194,7 +198,7 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( vtkm::worklet::contour::CommonState& sharedState) const; VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<2>::operator()( const vtkm::cont::CellSetStructured<2>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -206,7 +210,7 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<3>::operator()( const vtkm::cont::CellSetStructured<3>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -217,7 +221,7 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( vtkm::worklet::contour::CommonState& sharedState) const; VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<3>::operator()( const vtkm::cont::CellSetStructured<3>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -229,7 +233,99 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<3>::operator()( + const vtkm::cont::CellSetExplicit<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<3>::operator()( + const vtkm::cont::CellSetExplicit<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END + +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<3>::operator()( + const vtkm::cont::CellSetSingleType<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<3>::operator()( + const vtkm::cont::CellSetSingleType<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END + +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<2>::operator()( + const vtkm::cont::CellSetExplicit<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<2>::operator()( + const vtkm::cont::CellSetExplicit<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END + +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<2>::operator()( + const vtkm::cont::CellSetSingleType<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<2>::operator()( + const vtkm::cont::CellSetSingleType<>& cells, + const vtkm::cont::CoordinateSystem& coordinateSystem, + vtkm::cont::CellSetSingleType<>& outputCells, + const std::vector& isovalues, + const vtkm::cont::ArrayHandle& input, + vtkm::cont::ArrayHandle& vertices, + vtkm::cont::ArrayHandle& normals, + vtkm::worklet::contour::CommonState& sharedState) const; +VTKM_INSTANTIATION_END + +VTKM_INSTANTIATION_BEGIN +extern template void vtkm::worklet::contour::DeduceCellType<1>::operator()( const vtkm::cont::CellSetExplicit<>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -240,7 +336,7 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( vtkm::worklet::contour::CommonState& sharedState) const; VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<1>::operator()( const vtkm::cont::CellSetExplicit<>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -252,7 +348,7 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<1>::operator()( const vtkm::cont::CellSetSingleType<>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, @@ -263,7 +359,7 @@ extern template void vtkm::worklet::contour::DeduceCellType::operator()( vtkm::worklet::contour::CommonState& sharedState) const; VTKM_INSTANTIATION_END VTKM_INSTANTIATION_BEGIN -extern template void vtkm::worklet::contour::DeduceCellType::operator()( +extern template void vtkm::worklet::contour::DeduceCellType<1>::operator()( const vtkm::cont::CellSetSingleType<>& cells, const vtkm::cont::CoordinateSystem& coordinateSystem, vtkm::cont::CellSetSingleType<>& outputCells, diff --git a/vtkm/filter/contour/worklet/contour/MarchingCellTables.h b/vtkm/filter/contour/worklet/contour/MarchingCellTables.h index 56dc9e8d9d..446b81d3cf 100644 --- a/vtkm/filter/contour/worklet/contour/MarchingCellTables.h +++ b/vtkm/filter/contour/worklet/contour/MarchingCellTables.h @@ -42,551 +42,735 @@ VTKM_STATIC_ASSERT(vtkm::CELL_SHAPE_HEXAHEDRON == 12); VTKM_STATIC_ASSERT(vtkm::CELL_SHAPE_WEDGE == 13); VTKM_STATIC_ASSERT(vtkm::CELL_SHAPE_PYRAMID == 14); -VTKM_EXEC inline vtkm::IdComponent GetNumTrianglesOffset(vtkm::UInt8 cellType) +template +class MarchingCellTables; + +template <> +class MarchingCellTables<3> { - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent offsets[] = { - 0, // CELL_SHAPE_EMPTY - 0, // CELL_SHAPE_VERTEX - 0, // CELL_SHAPE_POLY_VERTEX - 0, // CELL_SHAPE_LINE - 0, // CELL_SHAPE_POLY_LINE - 0, // CELL_SHAPE_TRIANGLE - 0, // CELL_SHAPE_TRIANGLE_STRIP - 0, // CELL_SHAPE_POLYGON - 0, // CELL_SHAPE_PIXEL - 0, // CELL_SHAPE_QUAD - 0, // CELL_SHAPE_TETRA - 16, // CELL_SHAPE_VOXEL - 16, // CELL_SHAPE_HEXAHEDRON - 272, // CELL_SHAPE_WEDGE - 336, // CELL_SHAPE_PYRAMID - 0 // dummy - }; - // clang-format on + VTKM_EXEC static inline vtkm::IdComponent GetNumOutCellsOffset(vtkm::UInt8 inCellType) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent offsets[] = { + 0, // CELL_SHAPE_EMPTY + 0, // CELL_SHAPE_VERTEX + 0, // CELL_SHAPE_POLY_VERTEX + 0, // CELL_SHAPE_LINE + 0, // CELL_SHAPE_POLY_LINE + 0, // CELL_SHAPE_TRIANGLE + 0, // CELL_SHAPE_TRIANGLE_STRIP + 0, // CELL_SHAPE_POLYGON + 0, // CELL_SHAPE_PIXEL + 0, // CELL_SHAPE_QUAD + 0, // CELL_SHAPE_TETRA + 16, // CELL_SHAPE_VOXEL + 16, // CELL_SHAPE_HEXAHEDRON + 272, // CELL_SHAPE_WEDGE + 336, // CELL_SHAPE_PYRAMID + 368 // table size + }; + // clang-format on - return offsets[cellType]; -} + return offsets[inCellType]; + } -VTKM_EXEC inline vtkm::UInt8 GetNumTriangles(vtkm::UInt8 cellType, vtkm::UInt8 caseNumber) -{ - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 numTriangles[] = { - // CELL_SHAPE_EMPTY - // CELL_SHAPE_VERTEX - // CELL_SHAPE_POLY_VERTEX - // CELL_SHAPE_LINE - // CELL_SHAPE_POLY_LINE - // CELL_SHAPE_TRIANGLE - // CELL_SHAPE_TRIANGLE_STRIP - // CELL_SHAPE_POLYGON - // CELL_SHAPE_PIXEL - // CELL_SHAPE_QUAD - // CELL_SHAPE_TETRA - 0, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0, // cases 0 - 15 - // CELL_SHAPE_VOXEL - // CELL_SHAPE_HEXAHEDRON - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2, // cases 0 - 15 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 16 - 31 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 32 - 47 - 2, 3, 3, 2, 3, 4, 4, 3, 3, 4, 4, 3, 4, 5, 5, 2, // cases 48 - 63 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 64 - 79 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 4, // cases 80 - 95 - 2, 3, 3, 4, 3, 4, 2, 3, 3, 4, 4, 5, 4, 5, 3, 2, // cases 96 - 111 - 3, 4, 4, 3, 4, 5, 3, 2, 4, 5, 5, 4, 5, 2, 4, 1, // cases 112 - 127 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 128 - 143 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 2, 4, 3, 4, 3, 5, 2, // cases 144 - 159 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 4, // cases 160 - 175 - 3, 4, 4, 3, 4, 5, 5, 4, 4, 3, 5, 2, 5, 4, 2, 1, // cases 176 - 191 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 2, 3, 3, 2, // cases 192 - 207 - 3, 4, 4, 5, 4, 5, 5, 2, 4, 3, 5, 4, 3, 2, 4, 1, // cases 208 - 223 - 3, 4, 4, 5, 4, 5, 3, 4, 4, 5, 5, 2, 3, 4, 2, 1, // cases 224 - 239 - 2, 3, 3, 2, 3, 4, 2, 1, 3, 2, 4, 1, 2, 1, 1, 0, // cases 240 - 255 - // CELL_SHAPE_WEDGE - 0, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 3, 2, 3, 3, 2, // cases 0 - 15 - 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 4, 4, 1, // cases 16 - 31 - 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 4, 3, 2, 4, 1, // cases 32 - 47 - 2, 3, 3, 4, 3, 4, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0, // cases 48 - 63 - // CELL_SHAPE_PYRAMID - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2, // cases 0 - 15 - 2, 3, 3, 2, 3, 4, 2, 1, 3, 2, 4, 1, 2, 1, 1, 0, // cases 16 - 31 - 0 // dummy - }; - // clang-format on + VTKM_EXEC static inline vtkm::IdComponent GetOutCellTableOffset(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent tableOffset[] = { + // CELL_SHAPE_EMPTY + // CELL_SHAPE_VERTEX + // CELL_SHAPE_POLY_VERTEX + // CELL_SHAPE_LINE + // CELL_SHAPE_POLY_LINE + // CELL_SHAPE_TRIANGLE + // CELL_SHAPE_TRIANGLE_STRIP + // CELL_SHAPE_POLYGON + // CELL_SHAPE_PIXEL + // CELL_SHAPE_QUAD + // CELL_SHAPE_TETRA + 0, 0, 1, 2, 4, 5, 7, 9, // cases 0 - 7 + 10, 11, 13, 15, 16, 18, 19, 20, // cases 8 - 15 + // CELL_SHAPE_VOXEL + // CELL_SHAPE_HEXAHEDRON + 20, 20, 21, 22, 24, 25, 27, 29, // cases 0 - 7 + 32, 33, 35, 37, 40, 42, 45, 48, // cases 8 - 15 + 50, 51, 53, 55, 58, 60, 63, 66, // cases 16 - 23 + 70, 72, 75, 78, 82, 85, 89, 93, // cases 24 - 31 + 96, 97, 99, 101, 104, 106, 109, 112, // cases 32 - 39 + 116, 118, 121, 124, 128, 131, 135, 139, // cases 40 - 47 + 142, 144, 147, 150, 152, 155, 159, 163, // cases 48 - 55 + 166, 169, 173, 177, 180, 184, 189, 194, // cases 56 - 63 + 196, 197, 199, 201, 204, 206, 209, 212, // cases 64 - 71 + 216, 218, 221, 224, 228, 231, 235, 239, // cases 72 - 79 + 242, 244, 247, 250, 254, 257, 261, 265, // cases 80 - 87 + 270, 273, 277, 281, 286, 290, 295, 300, // cases 88 - 95 + 304, 306, 309, 312, 316, 319, 323, 325, // cases 96 - 103 + 328, 331, 335, 339, 344, 348, 353, 356, // cases 104 - 111 + 358, 361, 365, 369, 372, 376, 381, 384, // cases 112 - 119 + 386, 390, 395, 400, 404, 409, 411, 415, // cases 120 - 127 + 416, 417, 419, 421, 424, 426, 429, 432, // cases 128 - 135 + 436, 438, 441, 444, 448, 451, 455, 459, // cases 136 - 143 + 462, 464, 467, 470, 474, 477, 481, 485, // cases 144 - 151 + 490, 493, 495, 499, 502, 506, 509, 514, // cases 152 - 159 + 516, 518, 521, 524, 528, 531, 535, 539, // cases 160 - 167 + 544, 547, 551, 555, 560, 564, 569, 574, // cases 168 - 175 + 578, 581, 585, 589, 592, 596, 601, 606, // cases 176 - 183 + 610, 614, 617, 622, 624, 629, 633, 635, // cases 184 - 191 + 636, 638, 641, 644, 648, 651, 655, 659, // cases 192 - 199 + 664, 667, 671, 675, 680, 682, 685, 688, // cases 200 - 207 + 690, 693, 697, 701, 706, 710, 715, 720, // cases 208 - 215 + 722, 726, 729, 734, 738, 741, 743, 747, // cases 216 - 223 + 748, 751, 755, 759, 764, 768, 773, 776, // cases 224 - 231 + 780, 784, 789, 794, 796, 799, 803, 805, // cases 232 - 239 + 806, 808, 811, 814, 816, 819, 823, 825, // cases 240 - 247 + 826, 829, 831, 835, 836, 838, 839, 840, // cases 248 - 255 + // CELL_SHAPE_WEDGE + 840, 840, 841, 842, 844, 845, 847, 849, // cases 0 - 7 + 850, 851, 853, 855, 858, 860, 863, 866, // cases 8 - 15 + 868, 869, 871, 873, 876, 878, 881, 884, // cases 16 - 23 + 886, 888, 891, 894, 896, 899, 903, 907, // cases 24 - 31 + 908, 909, 911, 913, 916, 918, 921, 924, // cases 32 - 39 + 926, 928, 931, 934, 938, 941, 943, 947, // cases 40 - 47 + 948, 950, 953, 956, 960, 963, 967, 969, // cases 48 - 55 + 970, 971, 973, 975, 976, 978, 979, 980, // cases 56 - 63 + // CELL_SHAPE_PYRAMID + 980, 980, 981, 982, 984, 985, 987, 989, // cases 0 - 7 + 992, 993, 995, 997, 1000, 1002, 1005, 1008, // cases 8 - 15 + 1010, 1012, 1015, 1018, 1020, 1023, 1027, 1029, // cases 16 - 23 + 1030, 1033, 1035, 1039, 1040, 1042, 1043, 1044, // cases 24 - 31 + 0 // dummy + }; + // clang-format on - vtkm::IdComponent offset = GetNumTrianglesOffset(cellType); - return numTriangles[offset + caseNumber]; -} + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + return tableOffset[offset + caseNumber]; + } + +public: + VTKM_EXEC static inline vtkm::UInt8 GetNumOutCells(vtkm::UInt8 inCellType, vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 numOutCells[] = { + // CELL_SHAPE_EMPTY + // CELL_SHAPE_VERTEX + // CELL_SHAPE_POLY_VERTEX + // CELL_SHAPE_LINE + // CELL_SHAPE_POLY_LINE + // CELL_SHAPE_TRIANGLE + // CELL_SHAPE_TRIANGLE_STRIP + // CELL_SHAPE_POLYGON + // CELL_SHAPE_PIXEL + // CELL_SHAPE_QUAD + // CELL_SHAPE_TETRA + 0, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0, // cases 0 - 15 + // CELL_SHAPE_VOXEL + // CELL_SHAPE_HEXAHEDRON + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2, // cases 0 - 15 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 16 - 31 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 32 - 47 + 2, 3, 3, 2, 3, 4, 4, 3, 3, 4, 4, 3, 4, 5, 5, 2, // cases 48 - 63 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 64 - 79 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 4, // cases 80 - 95 + 2, 3, 3, 4, 3, 4, 2, 3, 3, 4, 4, 5, 4, 5, 3, 2, // cases 96 - 111 + 3, 4, 4, 3, 4, 5, 3, 2, 4, 5, 5, 4, 5, 2, 4, 1, // cases 112 - 127 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 3, // cases 128 - 143 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 2, 4, 3, 4, 3, 5, 2, // cases 144 - 159 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 4, // cases 160 - 175 + 3, 4, 4, 3, 4, 5, 5, 4, 4, 3, 5, 2, 5, 4, 2, 1, // cases 176 - 191 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 2, 3, 3, 2, // cases 192 - 207 + 3, 4, 4, 5, 4, 5, 5, 2, 4, 3, 5, 4, 3, 2, 4, 1, // cases 208 - 223 + 3, 4, 4, 5, 4, 5, 3, 4, 4, 5, 5, 2, 3, 4, 2, 1, // cases 224 - 239 + 2, 3, 3, 2, 3, 4, 2, 1, 3, 2, 4, 1, 2, 1, 1, 0, // cases 240 - 255 + // CELL_SHAPE_WEDGE + 0, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 3, 2, 3, 3, 2, // cases 0 - 15 + 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 4, 4, 1, // cases 16 - 31 + 1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 4, 3, 2, 4, 1, // cases 32 - 47 + 2, 3, 3, 4, 3, 4, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0, // cases 48 - 63 + // CELL_SHAPE_PYRAMID + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 2, // cases 0 - 15 + 2, 3, 3, 2, 3, 4, 2, 1, 3, 2, 4, 1, 2, 1, 1, 0, // cases 16 - 31 + 0 // dummy + }; + // clang-format on -VTKM_EXEC inline vtkm::IdComponent GetTriTableOffset(vtkm::UInt8 cellType, vtkm::UInt8 caseNumber) + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + if (offset == GetNumOutCellsOffset(inCellType + 1)) + { + // This part of the table is empty. + return 0; + } + else + { + return numOutCells[offset + caseNumber]; + } + } + + VTKM_EXEC static inline const vtkm::UInt8* GetCellEdges(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber, + vtkm::UInt8 outCellNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 triTable[][3] = { + // CELL_SHAPE_EMPTY + // CELL_SHAPE_VERTEX + // CELL_SHAPE_POLY_VERTEX + // CELL_SHAPE_LINE + // CELL_SHAPE_POLY_LINE + // CELL_SHAPE_TRIANGLE + // CELL_SHAPE_TRIANGLE_STRIP + // CELL_SHAPE_POLYGON + // CELL_SHAPE_PIXEL + // CELL_SHAPE_QUAD + // CELL_SHAPE_TETRA + // case 0 + { 0, 3, 2 }, // case 1 + { 0, 1, 4 }, // case 2 + { 1, 4, 2 }, { 2, 4, 3 }, // case 3 + { 1, 2, 5 }, // case 4 + { 0, 3, 5 }, { 0, 5, 1 }, // case 5 + { 0, 2, 5 }, { 0, 5, 4 }, // case 6 + { 5, 4, 3 }, // case 7 + { 3, 4, 5 }, // case 8 + { 4, 5, 0 }, { 5, 2, 0 }, // case 9 + { 1, 5, 0 }, { 5, 3, 0 }, // case 10 + { 5, 2, 1 }, // case 11 + { 3, 4, 2 }, { 2, 4, 1 }, // case 12 + { 4, 1, 0 }, // case 13 + { 2, 3, 0 }, // case 14 + // case 15 + // CELL_SHAPE_VOXEL + // CELL_SHAPE_HEXAHEDRON + // case 0 + { 0, 8, 3 }, // case 1 + { 0, 1, 9 }, // case 2 + { 1, 8, 3 }, { 9, 8, 1 }, // case 3 + { 1, 2, 11 }, // case 4 + { 0, 8, 3 }, { 1, 2, 11 }, // case 5 + { 9, 2, 11 }, { 0, 2, 9 }, // case 6 + { 2, 8, 3 }, { 2, 11, 8 }, { 11, 9, 8 }, // case 7 + { 3, 10, 2 }, // case 8 + { 0, 10, 2 }, { 8, 10, 0 }, // case 9 + { 1, 9, 0 }, { 2, 3, 10 }, // case 10 + { 1, 10, 2 }, { 1, 9, 10 }, { 9, 8, 10 }, // case 11 + { 3, 11, 1 }, { 10, 11, 3 }, // case 12 + { 0, 11, 1 }, { 0, 8, 11 }, { 8, 10, 11 }, // case 13 + { 3, 9, 0 }, { 3, 10, 9 }, { 10, 11, 9 }, // case 14 + { 9, 8, 11 }, { 11, 8, 10 }, // case 15 + { 4, 7, 8 }, // case 16 + { 4, 3, 0 }, { 7, 3, 4 }, // case 17 + { 0, 1, 9 }, { 8, 4, 7 }, // case 18 + { 4, 1, 9 }, { 4, 7, 1 }, { 7, 3, 1 }, // case 19 + { 1, 2, 11 }, { 8, 4, 7 }, // case 20 + { 3, 4, 7 }, { 3, 0, 4 }, { 1, 2, 11 }, // case 21 + { 9, 2, 11 }, { 9, 0, 2 }, { 8, 4, 7 }, // case 22 + { 2, 11, 9 }, { 2, 9, 7 }, { 2, 7, 3 }, { 7, 9, 4 }, // case 23 + { 8, 4, 7 }, { 3, 10, 2 }, // case 24 + { 10, 4, 7 }, { 10, 2, 4 }, { 2, 0, 4 }, // case 25 + { 9, 0, 1 }, { 8, 4, 7 }, { 2, 3, 10 }, // case 26 + { 4, 7, 10 }, { 9, 4, 10 }, { 9, 10, 2 }, { 9, 2, 1 }, // case 27 + { 3, 11, 1 }, { 3, 10, 11 }, { 7, 8, 4 }, // case 28 + { 1, 10, 11 }, { 1, 4, 10 }, { 1, 0, 4 }, { 7, 10, 4 }, // case 29 + { 4, 7, 8 }, { 9, 0, 10 }, { 9, 10, 11 }, { 10, 0, 3 }, // case 30 + { 4, 7, 10 }, { 4, 10, 9 }, { 9, 10, 11 }, // case 31 + { 9, 5, 4 }, // case 32 + { 9, 5, 4 }, { 0, 8, 3 }, // case 33 + { 0, 5, 4 }, { 1, 5, 0 }, // case 34 + { 8, 5, 4 }, { 8, 3, 5 }, { 3, 1, 5 }, // case 35 + { 1, 2, 11 }, { 9, 5, 4 }, // case 36 + { 3, 0, 8 }, { 1, 2, 11 }, { 4, 9, 5 }, // case 37 + { 5, 2, 11 }, { 5, 4, 2 }, { 4, 0, 2 }, // case 38 + { 2, 11, 5 }, { 3, 2, 5 }, { 3, 5, 4 }, { 3, 4, 8 }, // case 39 + { 9, 5, 4 }, { 2, 3, 10 }, // case 40 + { 0, 10, 2 }, { 0, 8, 10 }, { 4, 9, 5 }, // case 41 + { 0, 5, 4 }, { 0, 1, 5 }, { 2, 3, 10 }, // case 42 + { 2, 1, 5 }, { 2, 5, 8 }, { 2, 8, 10 }, { 4, 8, 5 }, // case 43 + { 11, 3, 10 }, { 11, 1, 3 }, { 9, 5, 4 }, // case 44 + { 4, 9, 5 }, { 0, 8, 1 }, { 8, 11, 1 }, { 8, 10, 11 }, // case 45 + { 5, 4, 0 }, { 5, 0, 10 }, { 5, 10, 11 }, { 10, 0, 3 }, // case 46 + { 5, 4, 8 }, { 5, 8, 11 }, { 11, 8, 10 }, // case 47 + { 9, 7, 8 }, { 5, 7, 9 }, // case 48 + { 9, 3, 0 }, { 9, 5, 3 }, { 5, 7, 3 }, // case 49 + { 0, 7, 8 }, { 0, 1, 7 }, { 1, 5, 7 }, // case 50 + { 1, 5, 3 }, { 3, 5, 7 }, // case 51 + { 9, 7, 8 }, { 9, 5, 7 }, { 11, 1, 2 }, // case 52 + { 11, 1, 2 }, { 9, 5, 0 }, { 5, 3, 0 }, { 5, 7, 3 }, // case 53 + { 8, 0, 2 }, { 8, 2, 5 }, { 8, 5, 7 }, { 11, 5, 2 }, // case 54 + { 2, 11, 5 }, { 2, 5, 3 }, { 3, 5, 7 }, // case 55 + { 7, 9, 5 }, { 7, 8, 9 }, { 3, 10, 2 }, // case 56 + { 9, 5, 7 }, { 9, 7, 2 }, { 9, 2, 0 }, { 2, 7, 10 }, // case 57 + { 2, 3, 10 }, { 0, 1, 8 }, { 1, 7, 8 }, { 1, 5, 7 }, // case 58 + { 10, 2, 1 }, { 10, 1, 7 }, { 7, 1, 5 }, // case 59 + { 9, 5, 8 }, { 8, 5, 7 }, { 11, 1, 3 }, { 11, 3, 10 }, // case 60 + { 5, 7, 0 }, { 5, 0, 9 }, { 7, 10, 0 }, { 1, 0, 11 }, { 10, 11, 0 }, // case 61 + { 10, 11, 0 }, { 10, 0, 3 }, { 11, 5, 0 }, { 8, 0, 7 }, { 5, 7, 0 }, // case 62 + { 10, 11, 5 }, { 7, 10, 5 }, // case 63 + { 11, 6, 5 }, // case 64 + { 0, 8, 3 }, { 5, 11, 6 }, // case 65 + { 9, 0, 1 }, { 5, 11, 6 }, // case 66 + { 1, 8, 3 }, { 1, 9, 8 }, { 5, 11, 6 }, // case 67 + { 1, 6, 5 }, { 2, 6, 1 }, // case 68 + { 1, 6, 5 }, { 1, 2, 6 }, { 3, 0, 8 }, // case 69 + { 9, 6, 5 }, { 9, 0, 6 }, { 0, 2, 6 }, // case 70 + { 5, 9, 8 }, { 5, 8, 2 }, { 5, 2, 6 }, { 3, 2, 8 }, // case 71 + { 2, 3, 10 }, { 11, 6, 5 }, // case 72 + { 10, 0, 8 }, { 10, 2, 0 }, { 11, 6, 5 }, // case 73 + { 0, 1, 9 }, { 2, 3, 10 }, { 5, 11, 6 }, // case 74 + { 5, 11, 6 }, { 1, 9, 2 }, { 9, 10, 2 }, { 9, 8, 10 }, // case 75 + { 6, 3, 10 }, { 6, 5, 3 }, { 5, 1, 3 }, // case 76 + { 0, 8, 10 }, { 0, 10, 5 }, { 0, 5, 1 }, { 5, 10, 6 }, // case 77 + { 3, 10, 6 }, { 0, 3, 6 }, { 0, 6, 5 }, { 0, 5, 9 }, // case 78 + { 6, 5, 9 }, { 6, 9, 10 }, { 10, 9, 8 }, // case 79 + { 5, 11, 6 }, { 4, 7, 8 }, // case 80 + { 4, 3, 0 }, { 4, 7, 3 }, { 6, 5, 11 }, // case 81 + { 1, 9, 0 }, { 5, 11, 6 }, { 8, 4, 7 }, // case 82 + { 11, 6, 5 }, { 1, 9, 7 }, { 1, 7, 3 }, { 7, 9, 4 }, // case 83 + { 6, 1, 2 }, { 6, 5, 1 }, { 4, 7, 8 }, // case 84 + { 1, 2, 5 }, { 5, 2, 6 }, { 3, 0, 4 }, { 3, 4, 7 }, // case 85 + { 8, 4, 7 }, { 9, 0, 5 }, { 0, 6, 5 }, { 0, 2, 6 }, // case 86 + { 7, 3, 9 }, { 7, 9, 4 }, { 3, 2, 9 }, { 5, 9, 6 }, { 2, 6, 9 }, // case 87 + { 3, 10, 2 }, { 7, 8, 4 }, { 11, 6, 5 }, // case 88 + { 5, 11, 6 }, { 4, 7, 2 }, { 4, 2, 0 }, { 2, 7, 10 }, // case 89 + { 0, 1, 9 }, { 4, 7, 8 }, { 2, 3, 10 }, { 5, 11, 6 }, // case 90 + { 9, 2, 1 }, { 9, 10, 2 }, { 9, 4, 10 }, { 7, 10, 4 }, { 5, 11, 6 }, // case 91 + { 8, 4, 7 }, { 3, 10, 5 }, { 3, 5, 1 }, { 5, 10, 6 }, // case 92 + { 5, 1, 10 }, { 5, 10, 6 }, { 1, 0, 10 }, { 7, 10, 4 }, { 0, 4, 10 }, // case 93 + { 0, 5, 9 }, { 0, 6, 5 }, { 0, 3, 6 }, { 10, 6, 3 }, { 8, 4, 7 }, // case 94 + { 6, 5, 9 }, { 6, 9, 10 }, { 4, 7, 9 }, { 7, 10, 9 }, // case 95 + { 11, 4, 9 }, { 6, 4, 11 }, // case 96 + { 4, 11, 6 }, { 4, 9, 11 }, { 0, 8, 3 }, // case 97 + { 11, 0, 1 }, { 11, 6, 0 }, { 6, 4, 0 }, // case 98 + { 8, 3, 1 }, { 8, 1, 6 }, { 8, 6, 4 }, { 6, 1, 11 }, // case 99 + { 1, 4, 9 }, { 1, 2, 4 }, { 2, 6, 4 }, // case 100 + { 3, 0, 8 }, { 1, 2, 9 }, { 2, 4, 9 }, { 2, 6, 4 }, // case 101 + { 0, 2, 4 }, { 4, 2, 6 }, // case 102 + { 8, 3, 2 }, { 8, 2, 4 }, { 4, 2, 6 }, // case 103 + { 11, 4, 9 }, { 11, 6, 4 }, { 10, 2, 3 }, // case 104 + { 0, 8, 2 }, { 2, 8, 10 }, { 4, 9, 11 }, { 4, 11, 6 }, // case 105 + { 3, 10, 2 }, { 0, 1, 6 }, { 0, 6, 4 }, { 6, 1, 11 }, // case 106 + { 6, 4, 1 }, { 6, 1, 11 }, { 4, 8, 1 }, { 2, 1, 10 }, { 8, 10, 1 }, // case 107 + { 9, 6, 4 }, { 9, 3, 6 }, { 9, 1, 3 }, { 10, 6, 3 }, // case 108 + { 8, 10, 1 }, { 8, 1, 0 }, { 10, 6, 1 }, { 9, 1, 4 }, { 6, 4, 1 }, // case 109 + { 3, 10, 6 }, { 3, 6, 0 }, { 0, 6, 4 }, // case 110 + { 6, 4, 8 }, { 10, 6, 8 }, // case 111 + { 7, 11, 6 }, { 7, 8, 11 }, { 8, 9, 11 }, // case 112 + { 0, 7, 3 }, { 0, 11, 7 }, { 0, 9, 11 }, { 6, 7, 11 }, // case 113 + { 11, 6, 7 }, { 1, 11, 7 }, { 1, 7, 8 }, { 1, 8, 0 }, // case 114 + { 11, 6, 7 }, { 11, 7, 1 }, { 1, 7, 3 }, // case 115 + { 1, 2, 6 }, { 1, 6, 8 }, { 1, 8, 9 }, { 8, 6, 7 }, // case 116 + { 2, 6, 9 }, { 2, 9, 1 }, { 6, 7, 9 }, { 0, 9, 3 }, { 7, 3, 9 }, // case 117 + { 7, 8, 0 }, { 7, 0, 6 }, { 6, 0, 2 }, // case 118 + { 7, 3, 2 }, { 6, 7, 2 }, // case 119 + { 2, 3, 10 }, { 11, 6, 8 }, { 11, 8, 9 }, { 8, 6, 7 }, // case 120 + { 2, 0, 7 }, { 2, 7, 10 }, { 0, 9, 7 }, { 6, 7, 11 }, { 9, 11, 7 }, // case 121 + { 1, 8, 0 }, { 1, 7, 8 }, { 1, 11, 7 }, { 6, 7, 11 }, { 2, 3, 10 }, // case 122 + { 10, 2, 1 }, { 10, 1, 7 }, { 11, 6, 1 }, { 6, 7, 1 }, // case 123 + { 8, 9, 6 }, { 8, 6, 7 }, { 9, 1, 6 }, { 10, 6, 3 }, { 1, 3, 6 }, // case 124 + { 0, 9, 1 }, { 10, 6, 7 }, // case 125 + { 7, 8, 0 }, { 7, 0, 6 }, { 3, 10, 0 }, { 10, 6, 0 }, // case 126 + { 7, 10, 6 }, // case 127 + { 7, 6, 10 }, // case 128 + { 3, 0, 8 }, { 10, 7, 6 }, // case 129 + { 0, 1, 9 }, { 10, 7, 6 }, // case 130 + { 8, 1, 9 }, { 8, 3, 1 }, { 10, 7, 6 }, // case 131 + { 11, 1, 2 }, { 6, 10, 7 }, // case 132 + { 1, 2, 11 }, { 3, 0, 8 }, { 6, 10, 7 }, // case 133 + { 2, 9, 0 }, { 2, 11, 9 }, { 6, 10, 7 }, // case 134 + { 6, 10, 7 }, { 2, 11, 3 }, { 11, 8, 3 }, { 11, 9, 8 }, // case 135 + { 7, 2, 3 }, { 6, 2, 7 }, // case 136 + { 7, 0, 8 }, { 7, 6, 0 }, { 6, 2, 0 }, // case 137 + { 2, 7, 6 }, { 2, 3, 7 }, { 0, 1, 9 }, // case 138 + { 1, 6, 2 }, { 1, 8, 6 }, { 1, 9, 8 }, { 8, 7, 6 }, // case 139 + { 11, 7, 6 }, { 11, 1, 7 }, { 1, 3, 7 }, // case 140 + { 11, 7, 6 }, { 1, 7, 11 }, { 1, 8, 7 }, { 1, 0, 8 }, // case 141 + { 0, 3, 7 }, { 0, 7, 11 }, { 0, 11, 9 }, { 6, 11, 7 }, // case 142 + { 7, 6, 11 }, { 7, 11, 8 }, { 8, 11, 9 }, // case 143 + { 6, 8, 4 }, { 10, 8, 6 }, // case 144 + { 3, 6, 10 }, { 3, 0, 6 }, { 0, 4, 6 }, // case 145 + { 8, 6, 10 }, { 8, 4, 6 }, { 9, 0, 1 }, // case 146 + { 9, 4, 6 }, { 9, 6, 3 }, { 9, 3, 1 }, { 10, 3, 6 }, // case 147 + { 6, 8, 4 }, { 6, 10, 8 }, { 2, 11, 1 }, // case 148 + { 1, 2, 11 }, { 3, 0, 10 }, { 0, 6, 10 }, { 0, 4, 6 }, // case 149 + { 4, 10, 8 }, { 4, 6, 10 }, { 0, 2, 9 }, { 2, 11, 9 }, // case 150 + { 11, 9, 3 }, { 11, 3, 2 }, { 9, 4, 3 }, { 10, 3, 6 }, { 4, 6, 3 }, // case 151 + { 8, 2, 3 }, { 8, 4, 2 }, { 4, 6, 2 }, // case 152 + { 0, 4, 2 }, { 4, 6, 2 }, // case 153 + { 1, 9, 0 }, { 2, 3, 4 }, { 2, 4, 6 }, { 4, 3, 8 }, // case 154 + { 1, 9, 4 }, { 1, 4, 2 }, { 2, 4, 6 }, // case 155 + { 8, 1, 3 }, { 8, 6, 1 }, { 8, 4, 6 }, { 6, 11, 1 }, // case 156 + { 11, 1, 0 }, { 11, 0, 6 }, { 6, 0, 4 }, // case 157 + { 4, 6, 3 }, { 4, 3, 8 }, { 6, 11, 3 }, { 0, 3, 9 }, { 11, 9, 3 }, // case 158 + { 11, 9, 4 }, { 6, 11, 4 }, // case 159 + { 4, 9, 5 }, { 7, 6, 10 }, // case 160 + { 0, 8, 3 }, { 4, 9, 5 }, { 10, 7, 6 }, // case 161 + { 5, 0, 1 }, { 5, 4, 0 }, { 7, 6, 10 }, // case 162 + { 10, 7, 6 }, { 8, 3, 4 }, { 3, 5, 4 }, { 3, 1, 5 }, // case 163 + { 9, 5, 4 }, { 11, 1, 2 }, { 7, 6, 10 }, // case 164 + { 6, 10, 7 }, { 1, 2, 11 }, { 0, 8, 3 }, { 4, 9, 5 }, // case 165 + { 7, 6, 10 }, { 5, 4, 11 }, { 4, 2, 11 }, { 4, 0, 2 }, // case 166 + { 3, 4, 8 }, { 3, 5, 4 }, { 3, 2, 5 }, { 11, 5, 2 }, { 10, 7, 6 }, // case 167 + { 7, 2, 3 }, { 7, 6, 2 }, { 5, 4, 9 }, // case 168 + { 9, 5, 4 }, { 0, 8, 6 }, { 0, 6, 2 }, { 6, 8, 7 }, // case 169 + { 3, 6, 2 }, { 3, 7, 6 }, { 1, 5, 0 }, { 5, 4, 0 }, // case 170 + { 6, 2, 8 }, { 6, 8, 7 }, { 2, 1, 8 }, { 4, 8, 5 }, { 1, 5, 8 }, // case 171 + { 9, 5, 4 }, { 11, 1, 6 }, { 1, 7, 6 }, { 1, 3, 7 }, // case 172 + { 1, 6, 11 }, { 1, 7, 6 }, { 1, 0, 7 }, { 8, 7, 0 }, { 9, 5, 4 }, // case 173 + { 4, 0, 11 }, { 4, 11, 5 }, { 0, 3, 11 }, { 6, 11, 7 }, { 3, 7, 11 }, // case 174 + { 7, 6, 11 }, { 7, 11, 8 }, { 5, 4, 11 }, { 4, 8, 11 }, // case 175 + { 6, 9, 5 }, { 6, 10, 9 }, { 10, 8, 9 }, // case 176 + { 3, 6, 10 }, { 0, 6, 3 }, { 0, 5, 6 }, { 0, 9, 5 }, // case 177 + { 0, 10, 8 }, { 0, 5, 10 }, { 0, 1, 5 }, { 5, 6, 10 }, // case 178 + { 6, 10, 3 }, { 6, 3, 5 }, { 5, 3, 1 }, // case 179 + { 1, 2, 11 }, { 9, 5, 10 }, { 9, 10, 8 }, { 10, 5, 6 }, // case 180 + { 0, 10, 3 }, { 0, 6, 10 }, { 0, 9, 6 }, { 5, 6, 9 }, { 1, 2, 11 }, // case 181 + { 10, 8, 5 }, { 10, 5, 6 }, { 8, 0, 5 }, { 11, 5, 2 }, { 0, 2, 5 }, // case 182 + { 6, 10, 3 }, { 6, 3, 5 }, { 2, 11, 3 }, { 11, 5, 3 }, // case 183 + { 5, 8, 9 }, { 5, 2, 8 }, { 5, 6, 2 }, { 3, 8, 2 }, // case 184 + { 9, 5, 6 }, { 9, 6, 0 }, { 0, 6, 2 }, // case 185 + { 1, 5, 8 }, { 1, 8, 0 }, { 5, 6, 8 }, { 3, 8, 2 }, { 6, 2, 8 }, // case 186 + { 1, 5, 6 }, { 2, 1, 6 }, // case 187 + { 1, 3, 6 }, { 1, 6, 11 }, { 3, 8, 6 }, { 5, 6, 9 }, { 8, 9, 6 }, // case 188 + { 11, 1, 0 }, { 11, 0, 6 }, { 9, 5, 0 }, { 5, 6, 0 }, // case 189 + { 0, 3, 8 }, { 5, 6, 11 }, // case 190 + { 11, 5, 6 }, // case 191 + { 10, 5, 11 }, { 7, 5, 10 }, // case 192 + { 10, 5, 11 }, { 10, 7, 5 }, { 8, 3, 0 }, // case 193 + { 5, 10, 7 }, { 5, 11, 10 }, { 1, 9, 0 }, // case 194 + { 11, 7, 5 }, { 11, 10, 7 }, { 9, 8, 1 }, { 8, 3, 1 }, // case 195 + { 10, 1, 2 }, { 10, 7, 1 }, { 7, 5, 1 }, // case 196 + { 0, 8, 3 }, { 1, 2, 7 }, { 1, 7, 5 }, { 7, 2, 10 }, // case 197 + { 9, 7, 5 }, { 9, 2, 7 }, { 9, 0, 2 }, { 2, 10, 7 }, // case 198 + { 7, 5, 2 }, { 7, 2, 10 }, { 5, 9, 2 }, { 3, 2, 8 }, { 9, 8, 2 }, // case 199 + { 2, 5, 11 }, { 2, 3, 5 }, { 3, 7, 5 }, // case 200 + { 8, 2, 0 }, { 8, 5, 2 }, { 8, 7, 5 }, { 11, 2, 5 }, // case 201 + { 9, 0, 1 }, { 5, 11, 3 }, { 5, 3, 7 }, { 3, 11, 2 }, // case 202 + { 9, 8, 2 }, { 9, 2, 1 }, { 8, 7, 2 }, { 11, 2, 5 }, { 7, 5, 2 }, // case 203 + { 1, 3, 5 }, { 3, 7, 5 }, // case 204 + { 0, 8, 7 }, { 0, 7, 1 }, { 1, 7, 5 }, // case 205 + { 9, 0, 3 }, { 9, 3, 5 }, { 5, 3, 7 }, // case 206 + { 9, 8, 7 }, { 5, 9, 7 }, // case 207 + { 5, 8, 4 }, { 5, 11, 8 }, { 11, 10, 8 }, // case 208 + { 5, 0, 4 }, { 5, 10, 0 }, { 5, 11, 10 }, { 10, 3, 0 }, // case 209 + { 0, 1, 9 }, { 8, 4, 11 }, { 8, 11, 10 }, { 11, 4, 5 }, // case 210 + { 11, 10, 4 }, { 11, 4, 5 }, { 10, 3, 4 }, { 9, 4, 1 }, { 3, 1, 4 }, // case 211 + { 2, 5, 1 }, { 2, 8, 5 }, { 2, 10, 8 }, { 4, 5, 8 }, // case 212 + { 0, 4, 10 }, { 0, 10, 3 }, { 4, 5, 10 }, { 2, 10, 1 }, { 5, 1, 10 }, // case 213 + { 0, 2, 5 }, { 0, 5, 9 }, { 2, 10, 5 }, { 4, 5, 8 }, { 10, 8, 5 }, // case 214 + { 9, 4, 5 }, { 2, 10, 3 }, // case 215 + { 2, 5, 11 }, { 3, 5, 2 }, { 3, 4, 5 }, { 3, 8, 4 }, // case 216 + { 5, 11, 2 }, { 5, 2, 4 }, { 4, 2, 0 }, // case 217 + { 3, 11, 2 }, { 3, 5, 11 }, { 3, 8, 5 }, { 4, 5, 8 }, { 0, 1, 9 }, // case 218 + { 5, 11, 2 }, { 5, 2, 4 }, { 1, 9, 2 }, { 9, 4, 2 }, // case 219 + { 8, 4, 5 }, { 8, 5, 3 }, { 3, 5, 1 }, // case 220 + { 0, 4, 5 }, { 1, 0, 5 }, // case 221 + { 8, 4, 5 }, { 8, 5, 3 }, { 9, 0, 5 }, { 0, 3, 5 }, // case 222 + { 9, 4, 5 }, // case 223 + { 4, 10, 7 }, { 4, 9, 10 }, { 9, 11, 10 }, // case 224 + { 0, 8, 3 }, { 4, 9, 7 }, { 9, 10, 7 }, { 9, 11, 10 }, // case 225 + { 1, 11, 10 }, { 1, 10, 4 }, { 1, 4, 0 }, { 7, 4, 10 }, // case 226 + { 3, 1, 4 }, { 3, 4, 8 }, { 1, 11, 4 }, { 7, 4, 10 }, { 11, 10, 4 }, // case 227 + { 4, 10, 7 }, { 9, 10, 4 }, { 9, 2, 10 }, { 9, 1, 2 }, // case 228 + { 9, 7, 4 }, { 9, 10, 7 }, { 9, 1, 10 }, { 2, 10, 1 }, { 0, 8, 3 }, // case 229 + { 10, 7, 4 }, { 10, 4, 2 }, { 2, 4, 0 }, // case 230 + { 10, 7, 4 }, { 10, 4, 2 }, { 8, 3, 4 }, { 3, 2, 4 }, // case 231 + { 2, 9, 11 }, { 2, 7, 9 }, { 2, 3, 7 }, { 7, 4, 9 }, // case 232 + { 9, 11, 7 }, { 9, 7, 4 }, { 11, 2, 7 }, { 8, 7, 0 }, { 2, 0, 7 }, // case 233 + { 3, 7, 11 }, { 3, 11, 2 }, { 7, 4, 11 }, { 1, 11, 0 }, { 4, 0, 11 }, // case 234 + { 1, 11, 2 }, { 8, 7, 4 }, // case 235 + { 4, 9, 1 }, { 4, 1, 7 }, { 7, 1, 3 }, // case 236 + { 4, 9, 1 }, { 4, 1, 7 }, { 0, 8, 1 }, { 8, 7, 1 }, // case 237 + { 4, 0, 3 }, { 7, 4, 3 }, // case 238 + { 4, 8, 7 }, // case 239 + { 9, 11, 8 }, { 11, 10, 8 }, // case 240 + { 3, 0, 9 }, { 3, 9, 10 }, { 10, 9, 11 }, // case 241 + { 0, 1, 11 }, { 0, 11, 8 }, { 8, 11, 10 }, // case 242 + { 3, 1, 11 }, { 10, 3, 11 }, // case 243 + { 1, 2, 10 }, { 1, 10, 9 }, { 9, 10, 8 }, // case 244 + { 3, 0, 9 }, { 3, 9, 10 }, { 1, 2, 9 }, { 2, 10, 9 }, // case 245 + { 0, 2, 10 }, { 8, 0, 10 }, // case 246 + { 3, 2, 10 }, // case 247 + { 2, 3, 8 }, { 2, 8, 11 }, { 11, 8, 9 }, // case 248 + { 9, 11, 2 }, { 0, 9, 2 }, // case 249 + { 2, 3, 8 }, { 2, 8, 11 }, { 0, 1, 8 }, { 1, 11, 8 }, // case 250 + { 1, 11, 2 }, // case 251 + { 1, 3, 8 }, { 9, 1, 8 }, // case 252 + { 0, 9, 1 }, // case 253 + { 0, 3, 8 }, // case 254 + // case 255 + // CELL_SHAPE_WEDGE + // case 0 + { 0, 6, 2 }, // case 1 + { 0, 1, 7 }, // case 2 + { 6, 1, 7 }, { 6, 2, 1 }, // case 3 + { 1, 2, 8 }, // case 4 + { 6, 1, 0 }, { 6, 8, 1 }, // case 5 + { 0, 2, 8 }, { 7, 0, 8 }, // case 6 + { 7, 6, 8 }, // case 7 + { 3, 5, 6 }, // case 8 + { 3, 5, 0 }, { 5, 2, 0 }, // case 9 + { 0, 1, 7 }, { 6, 3, 5 }, // case 10 + { 1, 7, 3 }, { 1, 3, 5 }, { 1, 5, 2 }, // case 11 + { 2, 8, 1 }, { 6, 3, 5 }, // case 12 + { 0, 3, 1 }, { 1, 3, 5 }, { 1, 5, 8 }, // case 13 + { 6, 3, 5 }, { 0, 8, 7 }, { 0, 2, 8 }, // case 14 + { 7, 3, 5 }, { 7, 5, 8 }, // case 15 + { 7, 4, 3 }, // case 16 + { 7, 4, 3 }, { 0, 6, 2 }, // case 17 + { 0, 1, 3 }, { 1, 4, 3 }, // case 18 + { 1, 4, 3 }, { 1, 3, 6 }, { 1, 6, 2 }, // case 19 + { 7, 4, 3 }, { 2, 8, 1 }, // case 20 + { 7, 4, 3 }, { 6, 1, 0 }, { 6, 8, 1 }, // case 21 + { 0, 4, 3 }, { 0, 8, 4 }, { 0, 2, 8 }, // case 22 + { 6, 8, 3 }, { 3, 8, 4 }, // case 23 + { 6, 7, 4 }, { 6, 4, 5 }, // case 24 + { 0, 7, 5 }, { 7, 4, 5 }, { 2, 0, 5 }, // case 25 + { 1, 6, 0 }, { 1, 5, 6 }, { 1, 4, 5 }, // case 26 + { 2, 1, 5 }, { 5, 1, 4 }, // case 27 + { 2, 8, 1 }, { 6, 7, 5 }, { 7, 4, 5 }, // case 28 + { 0, 7, 5 }, { 7, 4, 5 }, { 0, 5, 1 }, { 1, 5, 8 }, // case 29 + { 0, 2, 8 }, { 0, 8, 4 }, { 0, 4, 5 }, { 0, 5, 6 }, // case 30 + { 8, 4, 5 }, // case 31 + { 4, 8, 5 }, // case 32 + { 4, 8, 5 }, { 0, 6, 2 }, // case 33 + { 4, 8, 5 }, { 0, 1, 7 }, // case 34 + { 4, 8, 5 }, { 6, 1, 7 }, { 6, 2, 1 }, // case 35 + { 1, 5, 4 }, { 2, 5, 1 }, // case 36 + { 1, 5, 4 }, { 1, 6, 5 }, { 1, 0, 6 }, // case 37 + { 5, 4, 7 }, { 5, 7, 0 }, { 5, 0, 2 }, // case 38 + { 6, 4, 7 }, { 6, 5, 4 }, // case 39 + { 6, 3, 8 }, { 3, 4, 8 }, // case 40 + { 0, 3, 4 }, { 0, 4, 8 }, { 0, 8, 2 }, // case 41 + { 7, 0, 1 }, { 6, 3, 4 }, { 6, 4, 8 }, // case 42 + { 1, 7, 3 }, { 1, 3, 2 }, { 2, 3, 8 }, { 8, 3, 4 }, // case 43 + { 2, 6, 1 }, { 6, 3, 1 }, { 3, 4, 1 }, // case 44 + { 0, 3, 1 }, { 1, 3, 4 }, // case 45 + { 7, 0, 4 }, { 4, 0, 2 }, { 4, 2, 3 }, { 3, 2, 6 }, // case 46 + { 7, 3, 4 }, // case 47 + { 7, 8, 5 }, { 7, 5, 3 }, // case 48 + { 0, 6, 2 }, { 7, 8, 5 }, { 7, 5, 3 }, // case 49 + { 0, 1, 3 }, { 1, 5, 3 }, { 1, 8, 5 }, // case 50 + { 2, 1, 6 }, { 6, 1, 3 }, { 5, 1, 8 }, { 3, 1, 5 }, // case 51 + { 1, 3, 7 }, { 1, 5, 3 }, { 1, 2, 5 }, // case 52 + { 1, 0, 6 }, { 1, 6, 5 }, { 1, 5, 7 }, { 7, 5, 3 }, // case 53 + { 0, 2, 5 }, { 0, 5, 3 }, // case 54 + { 3, 6, 5 }, // case 55 + { 7, 8, 6 }, // case 56 + { 0, 7, 8 }, { 0, 8, 2 }, // case 57 + { 0, 1, 6 }, { 1, 8, 6 }, // case 58 + { 2, 1, 8 }, // case 59 + { 6, 7, 1 }, { 6, 1, 2 }, // case 60 + { 0, 7, 1 }, // case 61 + { 0, 2, 6 }, // case 62 + // case 63 + // CELL_SHAPE_PYRAMID + // case 0 + { 3, 4, 0 }, // case 1 + { 5, 1, 0 }, // case 2 + { 5, 1, 4 }, { 1, 3, 4 }, // case 3 + { 6, 2, 1 }, // case 4 + { 3, 4, 0 }, { 6, 2, 1 }, // case 5 + { 5, 2, 0 }, { 6, 2, 5 }, // case 6 + { 2, 3, 4 }, { 2, 4, 6 }, { 4, 5, 6 }, // case 7 + { 2, 7, 3 }, // case 8 + { 2, 7, 4 }, { 4, 0, 2 }, // case 9 + { 5, 1, 0 }, { 2, 7, 3 }, // case 10 + { 5, 7, 4 }, { 1, 7, 5 }, { 2, 7, 1 }, // case 11 + { 6, 3, 1 }, { 7, 3, 6 }, // case 12 + { 4, 6, 7 }, { 0, 6, 4 }, { 1, 6, 0 }, // case 13 + { 7, 5, 6 }, { 3, 5, 7 }, { 0, 5, 3 }, // case 14 + { 7, 4, 5 }, { 7, 5, 6 }, // case 15 + { 7, 5, 4 }, { 7, 6, 5 }, // case 16 + { 5, 0, 3 }, { 6, 5, 3 }, { 7, 6, 3 }, // case 17 + { 1, 0, 4 }, { 7, 1, 4 }, { 6, 1, 7 }, // case 18 + { 6, 1, 3 }, { 7, 6, 3 }, // case 19 + { 7, 5, 4 }, { 7, 1, 5 }, { 7, 2, 1 }, // case 20 + { 3, 7, 0 }, { 7, 5, 0 }, { 7, 2, 5 }, { 2, 1, 5 }, // case 21 + { 4, 2, 0 }, { 7, 2, 4 }, // case 22 + { 7, 2, 3 }, // case 23 + { 2, 4, 3 }, { 5, 4, 2 }, { 6, 5, 2 }, // case 24 + { 2, 5, 0 }, { 2, 6, 5 }, // case 25 + { 6, 1, 0 }, { 4, 6, 0 }, { 3, 6, 4 }, { 3, 2, 6 }, // case 26 + { 2, 6, 1 }, // case 27 + { 1, 4, 3 }, { 1, 5, 4 }, // case 28 + { 1, 5, 0 }, // case 29 + { 4, 3, 0 }, // case 30 + // case 31 + { 0, 0, 0 } // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetOutCellTableOffset(inCellType, caseNumber); + return triTable[offset + outCellNumber]; + } +}; + +template <> +class MarchingCellTables<2> { - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent triTableOffset[] = { - // CELL_SHAPE_EMPTY - // CELL_SHAPE_VERTEX - // CELL_SHAPE_POLY_VERTEX - // CELL_SHAPE_LINE - // CELL_SHAPE_POLY_LINE - // CELL_SHAPE_TRIANGLE - // CELL_SHAPE_TRIANGLE_STRIP - // CELL_SHAPE_POLYGON - // CELL_SHAPE_PIXEL - // CELL_SHAPE_QUAD - // CELL_SHAPE_TETRA - 0, 0, 1, 2, 4, 5, 7, 9, // cases 0 - 7 - 10, 11, 13, 15, 16, 18, 19, 20, // cases 8 - 15 - // CELL_SHAPE_VOXEL - // CELL_SHAPE_HEXAHEDRON - 20, 20, 21, 22, 24, 25, 27, 29, // cases 0 - 7 - 32, 33, 35, 37, 40, 42, 45, 48, // cases 8 - 15 - 50, 51, 53, 55, 58, 60, 63, 66, // cases 16 - 23 - 70, 72, 75, 78, 82, 85, 89, 93, // cases 24 - 31 - 96, 97, 99, 101, 104, 106, 109, 112, // cases 32 - 39 - 116, 118, 121, 124, 128, 131, 135, 139, // cases 40 - 47 - 142, 144, 147, 150, 152, 155, 159, 163, // cases 48 - 55 - 166, 169, 173, 177, 180, 184, 189, 194, // cases 56 - 63 - 196, 197, 199, 201, 204, 206, 209, 212, // cases 64 - 71 - 216, 218, 221, 224, 228, 231, 235, 239, // cases 72 - 79 - 242, 244, 247, 250, 254, 257, 261, 265, // cases 80 - 87 - 270, 273, 277, 281, 286, 290, 295, 300, // cases 88 - 95 - 304, 306, 309, 312, 316, 319, 323, 325, // cases 96 - 103 - 328, 331, 335, 339, 344, 348, 353, 356, // cases 104 - 111 - 358, 361, 365, 369, 372, 376, 381, 384, // cases 112 - 119 - 386, 390, 395, 400, 404, 409, 411, 415, // cases 120 - 127 - 416, 417, 419, 421, 424, 426, 429, 432, // cases 128 - 135 - 436, 438, 441, 444, 448, 451, 455, 459, // cases 136 - 143 - 462, 464, 467, 470, 474, 477, 481, 485, // cases 144 - 151 - 490, 493, 495, 499, 502, 506, 509, 514, // cases 152 - 159 - 516, 518, 521, 524, 528, 531, 535, 539, // cases 160 - 167 - 544, 547, 551, 555, 560, 564, 569, 574, // cases 168 - 175 - 578, 581, 585, 589, 592, 596, 601, 606, // cases 176 - 183 - 610, 614, 617, 622, 624, 629, 633, 635, // cases 184 - 191 - 636, 638, 641, 644, 648, 651, 655, 659, // cases 192 - 199 - 664, 667, 671, 675, 680, 682, 685, 688, // cases 200 - 207 - 690, 693, 697, 701, 706, 710, 715, 720, // cases 208 - 215 - 722, 726, 729, 734, 738, 741, 743, 747, // cases 216 - 223 - 748, 751, 755, 759, 764, 768, 773, 776, // cases 224 - 231 - 780, 784, 789, 794, 796, 799, 803, 805, // cases 232 - 239 - 806, 808, 811, 814, 816, 819, 823, 825, // cases 240 - 247 - 826, 829, 831, 835, 836, 838, 839, 840, // cases 248 - 255 - // CELL_SHAPE_WEDGE - 840, 840, 841, 842, 844, 845, 847, 849, // cases 0 - 7 - 850, 851, 853, 855, 858, 860, 863, 866, // cases 8 - 15 - 868, 869, 871, 873, 876, 878, 881, 884, // cases 16 - 23 - 886, 888, 891, 894, 896, 899, 903, 907, // cases 24 - 31 - 908, 909, 911, 913, 916, 918, 921, 924, // cases 32 - 39 - 926, 928, 931, 934, 938, 941, 943, 947, // cases 40 - 47 - 948, 950, 953, 956, 960, 963, 967, 969, // cases 48 - 55 - 970, 971, 973, 975, 976, 978, 979, 980, // cases 56 - 63 - // CELL_SHAPE_PYRAMID - 980, 980, 981, 982, 984, 985, 987, 989, // cases 0 - 7 - 992, 993, 995, 997, 1000, 1002, 1005, 1008, // cases 8 - 15 - 1010, 1012, 1015, 1018, 1020, 1023, 1027, 1029, // cases 16 - 23 - 1030, 1033, 1035, 1039, 1040, 1042, 1043, 1044, // cases 24 - 31 - 0 // dummy - }; - // clang-format on + VTKM_EXEC static inline vtkm::IdComponent GetNumOutCellsOffset(vtkm::UInt8 inCellType) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent offsets[] = { + 0, // CELL_SHAPE_EMPTY + 0, // CELL_SHAPE_VERTEX + 0, // CELL_SHAPE_POLY_VERTEX + 0, // CELL_SHAPE_LINE + 0, // CELL_SHAPE_POLY_LINE + 0, // CELL_SHAPE_TRIANGLE + 8, // CELL_SHAPE_TRIANGLE_STRIP + 8, // CELL_SHAPE_POLYGON + 8, // CELL_SHAPE_PIXEL + 8, // CELL_SHAPE_QUAD + 24, // CELL_SHAPE_TETRA + 24, // CELL_SHAPE_VOXEL + 24, // CELL_SHAPE_HEXAHEDRON + 24, // CELL_SHAPE_WEDGE + 24, // CELL_SHAPE_PYRAMID + 24 // table size + }; + // clang-format on - vtkm::IdComponent offset = GetNumTrianglesOffset(cellType); - return triTableOffset[offset + caseNumber]; -} + return offsets[inCellType]; + } -VTKM_EXEC inline const vtkm::UInt8* GetTriangleEdges(vtkm::UInt8 cellType, - vtkm::UInt8 caseNumber, - vtkm::UInt8 triangleNumber) + VTKM_EXEC static inline vtkm::IdComponent GetOutCellTableOffset(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent tableOffset[] = { + // CELL_SHAPE_EMPTY + // CELL_SHAPE_VERTEX + // CELL_SHAPE_POLY_VERTEX + // CELL_SHAPE_LINE + // CELL_SHAPE_POLY_LINE + // CELL_SHAPE_TRIANGLE + 0, 0, 1, 2, 3, 4, 5, 6, // cases 0 - 7 + // CELL_SHAPE_TRIANGLE_STRIP + // CELL_SHAPE_POLYGON + // CELL_SHAPE_PIXEL + // CELL_SHAPE_QUAD + 6, 6, 7, 8, 9, 10, 12, 13, // cases 0 - 7 + 14, 15, 16, 18, 19, 20, 21, 22, // cases 8 - 15 + // CELL_SHAPE_TETRA + // CELL_SHAPE_VOXEL + // CELL_SHAPE_HEXAHEDRON + // CELL_SHAPE_WEDGE + // CELL_SHAPE_PYRAMID + 0 // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + return tableOffset[offset + caseNumber]; + } + +public: + VTKM_EXEC static inline vtkm::UInt8 GetNumOutCells(vtkm::UInt8 inCellType, vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 numOutCells[] = { + // CELL_SHAPE_EMPTY + // CELL_SHAPE_VERTEX + // CELL_SHAPE_POLY_VERTEX + // CELL_SHAPE_LINE + // CELL_SHAPE_POLY_LINE + // CELL_SHAPE_TRIANGLE + 0, 1, 1, 1, 1, 1, 1, 0, // cases 0 - 7 + // CELL_SHAPE_TRIANGLE_STRIP + // CELL_SHAPE_POLYGON + // CELL_SHAPE_PIXEL + // CELL_SHAPE_QUAD + 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0, // cases 0 - 15 + // CELL_SHAPE_TETRA + // CELL_SHAPE_VOXEL + // CELL_SHAPE_HEXAHEDRON + // CELL_SHAPE_WEDGE + // CELL_SHAPE_PYRAMID + 0 // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + if (offset == GetNumOutCellsOffset(inCellType + 1)) + { + // This part of the table is empty. + return 0; + } + else + { + return numOutCells[offset + caseNumber]; + } + } + + VTKM_EXEC static inline const vtkm::UInt8* GetCellEdges(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber, + vtkm::UInt8 outCellNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 lineTable[][2] = { + // CELL_SHAPE_EMPTY + // CELL_SHAPE_VERTEX + // CELL_SHAPE_POLY_VERTEX + // CELL_SHAPE_LINE + // CELL_SHAPE_POLY_LINE + // CELL_SHAPE_TRIANGLE + // case 0 + { 0, 2 }, // case 1 + { 1, 0 }, // case 2 + { 1, 2 }, // case 3 + { 2, 1 }, // case 4 + { 0, 1 }, // case 5 + { 2, 0 }, // case 6 + // case 7 + // CELL_SHAPE_TRIANGLE_STRIP + // CELL_SHAPE_POLYGON + // CELL_SHAPE_PIXEL + // CELL_SHAPE_QUAD + // case 0 + { 0, 3 }, // case 1 + { 1, 0 }, // case 2 + { 1, 3 }, // case 3 + { 2, 1 }, // case 4 + { 0, 3 }, { 2, 1 }, // case 5 + { 2, 0 }, // case 6 + { 2, 3 }, // case 7 + { 3, 2 }, // case 8 + { 0, 2 }, // case 9 + { 1, 0 }, { 3, 2 }, // case 10 + { 1, 2 }, // case 11 + { 3, 1 }, // case 12 + { 0, 1 }, // case 13 + { 3, 0 }, // case 14 + // case 15 + // CELL_SHAPE_TETRA + // CELL_SHAPE_VOXEL + // CELL_SHAPE_HEXAHEDRON + // CELL_SHAPE_WEDGE + // CELL_SHAPE_PYRAMID + { 0, 0 } // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetOutCellTableOffset(inCellType, caseNumber); + return lineTable[offset + outCellNumber]; + } +}; + +template +VTKM_EXEC inline vtkm::UInt8 GetNumOutCells(vtkm::UInt8 inCellType, vtkm::UInt8 caseNumber) { - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 triTable[][3] = { - // CELL_SHAPE_EMPTY - // CELL_SHAPE_VERTEX - // CELL_SHAPE_POLY_VERTEX - // CELL_SHAPE_LINE - // CELL_SHAPE_POLY_LINE - // CELL_SHAPE_TRIANGLE - // CELL_SHAPE_TRIANGLE_STRIP - // CELL_SHAPE_POLYGON - // CELL_SHAPE_PIXEL - // CELL_SHAPE_QUAD - // CELL_SHAPE_TETRA - // case 0 - { 0, 3, 2 }, // case 1 - { 0, 1, 4 }, // case 2 - { 1, 4, 2 }, { 2, 4, 3 }, // case 3 - { 1, 2, 5 }, // case 4 - { 0, 3, 5 }, { 0, 5, 1 }, // case 5 - { 0, 2, 5 }, { 0, 5, 4 }, // case 6 - { 5, 4, 3 }, // case 7 - { 3, 4, 5 }, // case 8 - { 4, 5, 0 }, { 5, 2, 0 }, // case 9 - { 1, 5, 0 }, { 5, 3, 0 }, // case 10 - { 5, 2, 1 }, // case 11 - { 3, 4, 2 }, { 2, 4, 1 }, // case 12 - { 4, 1, 0 }, // case 13 - { 2, 3, 0 }, // case 14 - // case 15 - // CELL_SHAPE_VOXEL - // CELL_SHAPE_HEXAHEDRON - // case 0 - { 0, 8, 3 }, // case 1 - { 0, 1, 9 }, // case 2 - { 1, 8, 3 }, { 9, 8, 1 }, // case 3 - { 1, 2, 11 }, // case 4 - { 0, 8, 3 }, { 1, 2, 11 }, // case 5 - { 9, 2, 11 }, { 0, 2, 9 }, // case 6 - { 2, 8, 3 }, { 2, 11, 8 }, { 11, 9, 8 }, // case 7 - { 3, 10, 2 }, // case 8 - { 0, 10, 2 }, { 8, 10, 0 }, // case 9 - { 1, 9, 0 }, { 2, 3, 10 }, // case 10 - { 1, 10, 2 }, { 1, 9, 10 }, { 9, 8, 10 }, // case 11 - { 3, 11, 1 }, { 10, 11, 3 }, // case 12 - { 0, 11, 1 }, { 0, 8, 11 }, { 8, 10, 11 }, // case 13 - { 3, 9, 0 }, { 3, 10, 9 }, { 10, 11, 9 }, // case 14 - { 9, 8, 11 }, { 11, 8, 10 }, // case 15 - { 4, 7, 8 }, // case 16 - { 4, 3, 0 }, { 7, 3, 4 }, // case 17 - { 0, 1, 9 }, { 8, 4, 7 }, // case 18 - { 4, 1, 9 }, { 4, 7, 1 }, { 7, 3, 1 }, // case 19 - { 1, 2, 11 }, { 8, 4, 7 }, // case 20 - { 3, 4, 7 }, { 3, 0, 4 }, { 1, 2, 11 }, // case 21 - { 9, 2, 11 }, { 9, 0, 2 }, { 8, 4, 7 }, // case 22 - { 2, 11, 9 }, { 2, 9, 7 }, { 2, 7, 3 }, { 7, 9, 4 }, // case 23 - { 8, 4, 7 }, { 3, 10, 2 }, // case 24 - { 10, 4, 7 }, { 10, 2, 4 }, { 2, 0, 4 }, // case 25 - { 9, 0, 1 }, { 8, 4, 7 }, { 2, 3, 10 }, // case 26 - { 4, 7, 10 }, { 9, 4, 10 }, { 9, 10, 2 }, { 9, 2, 1 }, // case 27 - { 3, 11, 1 }, { 3, 10, 11 }, { 7, 8, 4 }, // case 28 - { 1, 10, 11 }, { 1, 4, 10 }, { 1, 0, 4 }, { 7, 10, 4 }, // case 29 - { 4, 7, 8 }, { 9, 0, 10 }, { 9, 10, 11 }, { 10, 0, 3 }, // case 30 - { 4, 7, 10 }, { 4, 10, 9 }, { 9, 10, 11 }, // case 31 - { 9, 5, 4 }, // case 32 - { 9, 5, 4 }, { 0, 8, 3 }, // case 33 - { 0, 5, 4 }, { 1, 5, 0 }, // case 34 - { 8, 5, 4 }, { 8, 3, 5 }, { 3, 1, 5 }, // case 35 - { 1, 2, 11 }, { 9, 5, 4 }, // case 36 - { 3, 0, 8 }, { 1, 2, 11 }, { 4, 9, 5 }, // case 37 - { 5, 2, 11 }, { 5, 4, 2 }, { 4, 0, 2 }, // case 38 - { 2, 11, 5 }, { 3, 2, 5 }, { 3, 5, 4 }, { 3, 4, 8 }, // case 39 - { 9, 5, 4 }, { 2, 3, 10 }, // case 40 - { 0, 10, 2 }, { 0, 8, 10 }, { 4, 9, 5 }, // case 41 - { 0, 5, 4 }, { 0, 1, 5 }, { 2, 3, 10 }, // case 42 - { 2, 1, 5 }, { 2, 5, 8 }, { 2, 8, 10 }, { 4, 8, 5 }, // case 43 - { 11, 3, 10 }, { 11, 1, 3 }, { 9, 5, 4 }, // case 44 - { 4, 9, 5 }, { 0, 8, 1 }, { 8, 11, 1 }, { 8, 10, 11 }, // case 45 - { 5, 4, 0 }, { 5, 0, 10 }, { 5, 10, 11 }, { 10, 0, 3 }, // case 46 - { 5, 4, 8 }, { 5, 8, 11 }, { 11, 8, 10 }, // case 47 - { 9, 7, 8 }, { 5, 7, 9 }, // case 48 - { 9, 3, 0 }, { 9, 5, 3 }, { 5, 7, 3 }, // case 49 - { 0, 7, 8 }, { 0, 1, 7 }, { 1, 5, 7 }, // case 50 - { 1, 5, 3 }, { 3, 5, 7 }, // case 51 - { 9, 7, 8 }, { 9, 5, 7 }, { 11, 1, 2 }, // case 52 - { 11, 1, 2 }, { 9, 5, 0 }, { 5, 3, 0 }, { 5, 7, 3 }, // case 53 - { 8, 0, 2 }, { 8, 2, 5 }, { 8, 5, 7 }, { 11, 5, 2 }, // case 54 - { 2, 11, 5 }, { 2, 5, 3 }, { 3, 5, 7 }, // case 55 - { 7, 9, 5 }, { 7, 8, 9 }, { 3, 10, 2 }, // case 56 - { 9, 5, 7 }, { 9, 7, 2 }, { 9, 2, 0 }, { 2, 7, 10 }, // case 57 - { 2, 3, 10 }, { 0, 1, 8 }, { 1, 7, 8 }, { 1, 5, 7 }, // case 58 - { 10, 2, 1 }, { 10, 1, 7 }, { 7, 1, 5 }, // case 59 - { 9, 5, 8 }, { 8, 5, 7 }, { 11, 1, 3 }, { 11, 3, 10 }, // case 60 - { 5, 7, 0 }, { 5, 0, 9 }, { 7, 10, 0 }, { 1, 0, 11 }, { 10, 11, 0 }, // case 61 - { 10, 11, 0 }, { 10, 0, 3 }, { 11, 5, 0 }, { 8, 0, 7 }, { 5, 7, 0 }, // case 62 - { 10, 11, 5 }, { 7, 10, 5 }, // case 63 - { 11, 6, 5 }, // case 64 - { 0, 8, 3 }, { 5, 11, 6 }, // case 65 - { 9, 0, 1 }, { 5, 11, 6 }, // case 66 - { 1, 8, 3 }, { 1, 9, 8 }, { 5, 11, 6 }, // case 67 - { 1, 6, 5 }, { 2, 6, 1 }, // case 68 - { 1, 6, 5 }, { 1, 2, 6 }, { 3, 0, 8 }, // case 69 - { 9, 6, 5 }, { 9, 0, 6 }, { 0, 2, 6 }, // case 70 - { 5, 9, 8 }, { 5, 8, 2 }, { 5, 2, 6 }, { 3, 2, 8 }, // case 71 - { 2, 3, 10 }, { 11, 6, 5 }, // case 72 - { 10, 0, 8 }, { 10, 2, 0 }, { 11, 6, 5 }, // case 73 - { 0, 1, 9 }, { 2, 3, 10 }, { 5, 11, 6 }, // case 74 - { 5, 11, 6 }, { 1, 9, 2 }, { 9, 10, 2 }, { 9, 8, 10 }, // case 75 - { 6, 3, 10 }, { 6, 5, 3 }, { 5, 1, 3 }, // case 76 - { 0, 8, 10 }, { 0, 10, 5 }, { 0, 5, 1 }, { 5, 10, 6 }, // case 77 - { 3, 10, 6 }, { 0, 3, 6 }, { 0, 6, 5 }, { 0, 5, 9 }, // case 78 - { 6, 5, 9 }, { 6, 9, 10 }, { 10, 9, 8 }, // case 79 - { 5, 11, 6 }, { 4, 7, 8 }, // case 80 - { 4, 3, 0 }, { 4, 7, 3 }, { 6, 5, 11 }, // case 81 - { 1, 9, 0 }, { 5, 11, 6 }, { 8, 4, 7 }, // case 82 - { 11, 6, 5 }, { 1, 9, 7 }, { 1, 7, 3 }, { 7, 9, 4 }, // case 83 - { 6, 1, 2 }, { 6, 5, 1 }, { 4, 7, 8 }, // case 84 - { 1, 2, 5 }, { 5, 2, 6 }, { 3, 0, 4 }, { 3, 4, 7 }, // case 85 - { 8, 4, 7 }, { 9, 0, 5 }, { 0, 6, 5 }, { 0, 2, 6 }, // case 86 - { 7, 3, 9 }, { 7, 9, 4 }, { 3, 2, 9 }, { 5, 9, 6 }, { 2, 6, 9 }, // case 87 - { 3, 10, 2 }, { 7, 8, 4 }, { 11, 6, 5 }, // case 88 - { 5, 11, 6 }, { 4, 7, 2 }, { 4, 2, 0 }, { 2, 7, 10 }, // case 89 - { 0, 1, 9 }, { 4, 7, 8 }, { 2, 3, 10 }, { 5, 11, 6 }, // case 90 - { 9, 2, 1 }, { 9, 10, 2 }, { 9, 4, 10 }, { 7, 10, 4 }, { 5, 11, 6 }, // case 91 - { 8, 4, 7 }, { 3, 10, 5 }, { 3, 5, 1 }, { 5, 10, 6 }, // case 92 - { 5, 1, 10 }, { 5, 10, 6 }, { 1, 0, 10 }, { 7, 10, 4 }, { 0, 4, 10 }, // case 93 - { 0, 5, 9 }, { 0, 6, 5 }, { 0, 3, 6 }, { 10, 6, 3 }, { 8, 4, 7 }, // case 94 - { 6, 5, 9 }, { 6, 9, 10 }, { 4, 7, 9 }, { 7, 10, 9 }, // case 95 - { 11, 4, 9 }, { 6, 4, 11 }, // case 96 - { 4, 11, 6 }, { 4, 9, 11 }, { 0, 8, 3 }, // case 97 - { 11, 0, 1 }, { 11, 6, 0 }, { 6, 4, 0 }, // case 98 - { 8, 3, 1 }, { 8, 1, 6 }, { 8, 6, 4 }, { 6, 1, 11 }, // case 99 - { 1, 4, 9 }, { 1, 2, 4 }, { 2, 6, 4 }, // case 100 - { 3, 0, 8 }, { 1, 2, 9 }, { 2, 4, 9 }, { 2, 6, 4 }, // case 101 - { 0, 2, 4 }, { 4, 2, 6 }, // case 102 - { 8, 3, 2 }, { 8, 2, 4 }, { 4, 2, 6 }, // case 103 - { 11, 4, 9 }, { 11, 6, 4 }, { 10, 2, 3 }, // case 104 - { 0, 8, 2 }, { 2, 8, 10 }, { 4, 9, 11 }, { 4, 11, 6 }, // case 105 - { 3, 10, 2 }, { 0, 1, 6 }, { 0, 6, 4 }, { 6, 1, 11 }, // case 106 - { 6, 4, 1 }, { 6, 1, 11 }, { 4, 8, 1 }, { 2, 1, 10 }, { 8, 10, 1 }, // case 107 - { 9, 6, 4 }, { 9, 3, 6 }, { 9, 1, 3 }, { 10, 6, 3 }, // case 108 - { 8, 10, 1 }, { 8, 1, 0 }, { 10, 6, 1 }, { 9, 1, 4 }, { 6, 4, 1 }, // case 109 - { 3, 10, 6 }, { 3, 6, 0 }, { 0, 6, 4 }, // case 110 - { 6, 4, 8 }, { 10, 6, 8 }, // case 111 - { 7, 11, 6 }, { 7, 8, 11 }, { 8, 9, 11 }, // case 112 - { 0, 7, 3 }, { 0, 11, 7 }, { 0, 9, 11 }, { 6, 7, 11 }, // case 113 - { 11, 6, 7 }, { 1, 11, 7 }, { 1, 7, 8 }, { 1, 8, 0 }, // case 114 - { 11, 6, 7 }, { 11, 7, 1 }, { 1, 7, 3 }, // case 115 - { 1, 2, 6 }, { 1, 6, 8 }, { 1, 8, 9 }, { 8, 6, 7 }, // case 116 - { 2, 6, 9 }, { 2, 9, 1 }, { 6, 7, 9 }, { 0, 9, 3 }, { 7, 3, 9 }, // case 117 - { 7, 8, 0 }, { 7, 0, 6 }, { 6, 0, 2 }, // case 118 - { 7, 3, 2 }, { 6, 7, 2 }, // case 119 - { 2, 3, 10 }, { 11, 6, 8 }, { 11, 8, 9 }, { 8, 6, 7 }, // case 120 - { 2, 0, 7 }, { 2, 7, 10 }, { 0, 9, 7 }, { 6, 7, 11 }, { 9, 11, 7 }, // case 121 - { 1, 8, 0 }, { 1, 7, 8 }, { 1, 11, 7 }, { 6, 7, 11 }, { 2, 3, 10 }, // case 122 - { 10, 2, 1 }, { 10, 1, 7 }, { 11, 6, 1 }, { 6, 7, 1 }, // case 123 - { 8, 9, 6 }, { 8, 6, 7 }, { 9, 1, 6 }, { 10, 6, 3 }, { 1, 3, 6 }, // case 124 - { 0, 9, 1 }, { 10, 6, 7 }, // case 125 - { 7, 8, 0 }, { 7, 0, 6 }, { 3, 10, 0 }, { 10, 6, 0 }, // case 126 - { 7, 10, 6 }, // case 127 - { 7, 6, 10 }, // case 128 - { 3, 0, 8 }, { 10, 7, 6 }, // case 129 - { 0, 1, 9 }, { 10, 7, 6 }, // case 130 - { 8, 1, 9 }, { 8, 3, 1 }, { 10, 7, 6 }, // case 131 - { 11, 1, 2 }, { 6, 10, 7 }, // case 132 - { 1, 2, 11 }, { 3, 0, 8 }, { 6, 10, 7 }, // case 133 - { 2, 9, 0 }, { 2, 11, 9 }, { 6, 10, 7 }, // case 134 - { 6, 10, 7 }, { 2, 11, 3 }, { 11, 8, 3 }, { 11, 9, 8 }, // case 135 - { 7, 2, 3 }, { 6, 2, 7 }, // case 136 - { 7, 0, 8 }, { 7, 6, 0 }, { 6, 2, 0 }, // case 137 - { 2, 7, 6 }, { 2, 3, 7 }, { 0, 1, 9 }, // case 138 - { 1, 6, 2 }, { 1, 8, 6 }, { 1, 9, 8 }, { 8, 7, 6 }, // case 139 - { 11, 7, 6 }, { 11, 1, 7 }, { 1, 3, 7 }, // case 140 - { 11, 7, 6 }, { 1, 7, 11 }, { 1, 8, 7 }, { 1, 0, 8 }, // case 141 - { 0, 3, 7 }, { 0, 7, 11 }, { 0, 11, 9 }, { 6, 11, 7 }, // case 142 - { 7, 6, 11 }, { 7, 11, 8 }, { 8, 11, 9 }, // case 143 - { 6, 8, 4 }, { 10, 8, 6 }, // case 144 - { 3, 6, 10 }, { 3, 0, 6 }, { 0, 4, 6 }, // case 145 - { 8, 6, 10 }, { 8, 4, 6 }, { 9, 0, 1 }, // case 146 - { 9, 4, 6 }, { 9, 6, 3 }, { 9, 3, 1 }, { 10, 3, 6 }, // case 147 - { 6, 8, 4 }, { 6, 10, 8 }, { 2, 11, 1 }, // case 148 - { 1, 2, 11 }, { 3, 0, 10 }, { 0, 6, 10 }, { 0, 4, 6 }, // case 149 - { 4, 10, 8 }, { 4, 6, 10 }, { 0, 2, 9 }, { 2, 11, 9 }, // case 150 - { 11, 9, 3 }, { 11, 3, 2 }, { 9, 4, 3 }, { 10, 3, 6 }, { 4, 6, 3 }, // case 151 - { 8, 2, 3 }, { 8, 4, 2 }, { 4, 6, 2 }, // case 152 - { 0, 4, 2 }, { 4, 6, 2 }, // case 153 - { 1, 9, 0 }, { 2, 3, 4 }, { 2, 4, 6 }, { 4, 3, 8 }, // case 154 - { 1, 9, 4 }, { 1, 4, 2 }, { 2, 4, 6 }, // case 155 - { 8, 1, 3 }, { 8, 6, 1 }, { 8, 4, 6 }, { 6, 11, 1 }, // case 156 - { 11, 1, 0 }, { 11, 0, 6 }, { 6, 0, 4 }, // case 157 - { 4, 6, 3 }, { 4, 3, 8 }, { 6, 11, 3 }, { 0, 3, 9 }, { 11, 9, 3 }, // case 158 - { 11, 9, 4 }, { 6, 11, 4 }, // case 159 - { 4, 9, 5 }, { 7, 6, 10 }, // case 160 - { 0, 8, 3 }, { 4, 9, 5 }, { 10, 7, 6 }, // case 161 - { 5, 0, 1 }, { 5, 4, 0 }, { 7, 6, 10 }, // case 162 - { 10, 7, 6 }, { 8, 3, 4 }, { 3, 5, 4 }, { 3, 1, 5 }, // case 163 - { 9, 5, 4 }, { 11, 1, 2 }, { 7, 6, 10 }, // case 164 - { 6, 10, 7 }, { 1, 2, 11 }, { 0, 8, 3 }, { 4, 9, 5 }, // case 165 - { 7, 6, 10 }, { 5, 4, 11 }, { 4, 2, 11 }, { 4, 0, 2 }, // case 166 - { 3, 4, 8 }, { 3, 5, 4 }, { 3, 2, 5 }, { 11, 5, 2 }, { 10, 7, 6 }, // case 167 - { 7, 2, 3 }, { 7, 6, 2 }, { 5, 4, 9 }, // case 168 - { 9, 5, 4 }, { 0, 8, 6 }, { 0, 6, 2 }, { 6, 8, 7 }, // case 169 - { 3, 6, 2 }, { 3, 7, 6 }, { 1, 5, 0 }, { 5, 4, 0 }, // case 170 - { 6, 2, 8 }, { 6, 8, 7 }, { 2, 1, 8 }, { 4, 8, 5 }, { 1, 5, 8 }, // case 171 - { 9, 5, 4 }, { 11, 1, 6 }, { 1, 7, 6 }, { 1, 3, 7 }, // case 172 - { 1, 6, 11 }, { 1, 7, 6 }, { 1, 0, 7 }, { 8, 7, 0 }, { 9, 5, 4 }, // case 173 - { 4, 0, 11 }, { 4, 11, 5 }, { 0, 3, 11 }, { 6, 11, 7 }, { 3, 7, 11 }, // case 174 - { 7, 6, 11 }, { 7, 11, 8 }, { 5, 4, 11 }, { 4, 8, 11 }, // case 175 - { 6, 9, 5 }, { 6, 10, 9 }, { 10, 8, 9 }, // case 176 - { 3, 6, 10 }, { 0, 6, 3 }, { 0, 5, 6 }, { 0, 9, 5 }, // case 177 - { 0, 10, 8 }, { 0, 5, 10 }, { 0, 1, 5 }, { 5, 6, 10 }, // case 178 - { 6, 10, 3 }, { 6, 3, 5 }, { 5, 3, 1 }, // case 179 - { 1, 2, 11 }, { 9, 5, 10 }, { 9, 10, 8 }, { 10, 5, 6 }, // case 180 - { 0, 10, 3 }, { 0, 6, 10 }, { 0, 9, 6 }, { 5, 6, 9 }, { 1, 2, 11 }, // case 181 - { 10, 8, 5 }, { 10, 5, 6 }, { 8, 0, 5 }, { 11, 5, 2 }, { 0, 2, 5 }, // case 182 - { 6, 10, 3 }, { 6, 3, 5 }, { 2, 11, 3 }, { 11, 5, 3 }, // case 183 - { 5, 8, 9 }, { 5, 2, 8 }, { 5, 6, 2 }, { 3, 8, 2 }, // case 184 - { 9, 5, 6 }, { 9, 6, 0 }, { 0, 6, 2 }, // case 185 - { 1, 5, 8 }, { 1, 8, 0 }, { 5, 6, 8 }, { 3, 8, 2 }, { 6, 2, 8 }, // case 186 - { 1, 5, 6 }, { 2, 1, 6 }, // case 187 - { 1, 3, 6 }, { 1, 6, 11 }, { 3, 8, 6 }, { 5, 6, 9 }, { 8, 9, 6 }, // case 188 - { 11, 1, 0 }, { 11, 0, 6 }, { 9, 5, 0 }, { 5, 6, 0 }, // case 189 - { 0, 3, 8 }, { 5, 6, 11 }, // case 190 - { 11, 5, 6 }, // case 191 - { 10, 5, 11 }, { 7, 5, 10 }, // case 192 - { 10, 5, 11 }, { 10, 7, 5 }, { 8, 3, 0 }, // case 193 - { 5, 10, 7 }, { 5, 11, 10 }, { 1, 9, 0 }, // case 194 - { 11, 7, 5 }, { 11, 10, 7 }, { 9, 8, 1 }, { 8, 3, 1 }, // case 195 - { 10, 1, 2 }, { 10, 7, 1 }, { 7, 5, 1 }, // case 196 - { 0, 8, 3 }, { 1, 2, 7 }, { 1, 7, 5 }, { 7, 2, 10 }, // case 197 - { 9, 7, 5 }, { 9, 2, 7 }, { 9, 0, 2 }, { 2, 10, 7 }, // case 198 - { 7, 5, 2 }, { 7, 2, 10 }, { 5, 9, 2 }, { 3, 2, 8 }, { 9, 8, 2 }, // case 199 - { 2, 5, 11 }, { 2, 3, 5 }, { 3, 7, 5 }, // case 200 - { 8, 2, 0 }, { 8, 5, 2 }, { 8, 7, 5 }, { 11, 2, 5 }, // case 201 - { 9, 0, 1 }, { 5, 11, 3 }, { 5, 3, 7 }, { 3, 11, 2 }, // case 202 - { 9, 8, 2 }, { 9, 2, 1 }, { 8, 7, 2 }, { 11, 2, 5 }, { 7, 5, 2 }, // case 203 - { 1, 3, 5 }, { 3, 7, 5 }, // case 204 - { 0, 8, 7 }, { 0, 7, 1 }, { 1, 7, 5 }, // case 205 - { 9, 0, 3 }, { 9, 3, 5 }, { 5, 3, 7 }, // case 206 - { 9, 8, 7 }, { 5, 9, 7 }, // case 207 - { 5, 8, 4 }, { 5, 11, 8 }, { 11, 10, 8 }, // case 208 - { 5, 0, 4 }, { 5, 10, 0 }, { 5, 11, 10 }, { 10, 3, 0 }, // case 209 - { 0, 1, 9 }, { 8, 4, 11 }, { 8, 11, 10 }, { 11, 4, 5 }, // case 210 - { 11, 10, 4 }, { 11, 4, 5 }, { 10, 3, 4 }, { 9, 4, 1 }, { 3, 1, 4 }, // case 211 - { 2, 5, 1 }, { 2, 8, 5 }, { 2, 10, 8 }, { 4, 5, 8 }, // case 212 - { 0, 4, 10 }, { 0, 10, 3 }, { 4, 5, 10 }, { 2, 10, 1 }, { 5, 1, 10 }, // case 213 - { 0, 2, 5 }, { 0, 5, 9 }, { 2, 10, 5 }, { 4, 5, 8 }, { 10, 8, 5 }, // case 214 - { 9, 4, 5 }, { 2, 10, 3 }, // case 215 - { 2, 5, 11 }, { 3, 5, 2 }, { 3, 4, 5 }, { 3, 8, 4 }, // case 216 - { 5, 11, 2 }, { 5, 2, 4 }, { 4, 2, 0 }, // case 217 - { 3, 11, 2 }, { 3, 5, 11 }, { 3, 8, 5 }, { 4, 5, 8 }, { 0, 1, 9 }, // case 218 - { 5, 11, 2 }, { 5, 2, 4 }, { 1, 9, 2 }, { 9, 4, 2 }, // case 219 - { 8, 4, 5 }, { 8, 5, 3 }, { 3, 5, 1 }, // case 220 - { 0, 4, 5 }, { 1, 0, 5 }, // case 221 - { 8, 4, 5 }, { 8, 5, 3 }, { 9, 0, 5 }, { 0, 3, 5 }, // case 222 - { 9, 4, 5 }, // case 223 - { 4, 10, 7 }, { 4, 9, 10 }, { 9, 11, 10 }, // case 224 - { 0, 8, 3 }, { 4, 9, 7 }, { 9, 10, 7 }, { 9, 11, 10 }, // case 225 - { 1, 11, 10 }, { 1, 10, 4 }, { 1, 4, 0 }, { 7, 4, 10 }, // case 226 - { 3, 1, 4 }, { 3, 4, 8 }, { 1, 11, 4 }, { 7, 4, 10 }, { 11, 10, 4 }, // case 227 - { 4, 10, 7 }, { 9, 10, 4 }, { 9, 2, 10 }, { 9, 1, 2 }, // case 228 - { 9, 7, 4 }, { 9, 10, 7 }, { 9, 1, 10 }, { 2, 10, 1 }, { 0, 8, 3 }, // case 229 - { 10, 7, 4 }, { 10, 4, 2 }, { 2, 4, 0 }, // case 230 - { 10, 7, 4 }, { 10, 4, 2 }, { 8, 3, 4 }, { 3, 2, 4 }, // case 231 - { 2, 9, 11 }, { 2, 7, 9 }, { 2, 3, 7 }, { 7, 4, 9 }, // case 232 - { 9, 11, 7 }, { 9, 7, 4 }, { 11, 2, 7 }, { 8, 7, 0 }, { 2, 0, 7 }, // case 233 - { 3, 7, 11 }, { 3, 11, 2 }, { 7, 4, 11 }, { 1, 11, 0 }, { 4, 0, 11 }, // case 234 - { 1, 11, 2 }, { 8, 7, 4 }, // case 235 - { 4, 9, 1 }, { 4, 1, 7 }, { 7, 1, 3 }, // case 236 - { 4, 9, 1 }, { 4, 1, 7 }, { 0, 8, 1 }, { 8, 7, 1 }, // case 237 - { 4, 0, 3 }, { 7, 4, 3 }, // case 238 - { 4, 8, 7 }, // case 239 - { 9, 11, 8 }, { 11, 10, 8 }, // case 240 - { 3, 0, 9 }, { 3, 9, 10 }, { 10, 9, 11 }, // case 241 - { 0, 1, 11 }, { 0, 11, 8 }, { 8, 11, 10 }, // case 242 - { 3, 1, 11 }, { 10, 3, 11 }, // case 243 - { 1, 2, 10 }, { 1, 10, 9 }, { 9, 10, 8 }, // case 244 - { 3, 0, 9 }, { 3, 9, 10 }, { 1, 2, 9 }, { 2, 10, 9 }, // case 245 - { 0, 2, 10 }, { 8, 0, 10 }, // case 246 - { 3, 2, 10 }, // case 247 - { 2, 3, 8 }, { 2, 8, 11 }, { 11, 8, 9 }, // case 248 - { 9, 11, 2 }, { 0, 9, 2 }, // case 249 - { 2, 3, 8 }, { 2, 8, 11 }, { 0, 1, 8 }, { 1, 11, 8 }, // case 250 - { 1, 11, 2 }, // case 251 - { 1, 3, 8 }, { 9, 1, 8 }, // case 252 - { 0, 9, 1 }, // case 253 - { 0, 3, 8 }, // case 254 - // case 255 - // CELL_SHAPE_WEDGE - // case 0 - { 0, 6, 2 }, // case 1 - { 0, 1, 7 }, // case 2 - { 6, 1, 7 }, { 6, 2, 1 }, // case 3 - { 1, 2, 8 }, // case 4 - { 6, 1, 0 }, { 6, 8, 1 }, // case 5 - { 0, 2, 8 }, { 7, 0, 8 }, // case 6 - { 7, 6, 8 }, // case 7 - { 3, 5, 6 }, // case 8 - { 3, 5, 0 }, { 5, 2, 0 }, // case 9 - { 0, 1, 7 }, { 6, 3, 5 }, // case 10 - { 1, 7, 3 }, { 1, 3, 5 }, { 1, 5, 2 }, // case 11 - { 2, 8, 1 }, { 6, 3, 5 }, // case 12 - { 0, 3, 1 }, { 1, 3, 5 }, { 1, 5, 8 }, // case 13 - { 6, 3, 5 }, { 0, 8, 7 }, { 0, 2, 8 }, // case 14 - { 7, 3, 5 }, { 7, 5, 8 }, // case 15 - { 7, 4, 3 }, // case 16 - { 7, 4, 3 }, { 0, 6, 2 }, // case 17 - { 0, 1, 3 }, { 1, 4, 3 }, // case 18 - { 1, 4, 3 }, { 1, 3, 6 }, { 1, 6, 2 }, // case 19 - { 7, 4, 3 }, { 2, 8, 1 }, // case 20 - { 7, 4, 3 }, { 6, 1, 0 }, { 6, 8, 1 }, // case 21 - { 0, 4, 3 }, { 0, 8, 4 }, { 0, 2, 8 }, // case 22 - { 6, 8, 3 }, { 3, 8, 4 }, // case 23 - { 6, 7, 4 }, { 6, 4, 5 }, // case 24 - { 0, 7, 5 }, { 7, 4, 5 }, { 2, 0, 5 }, // case 25 - { 1, 6, 0 }, { 1, 5, 6 }, { 1, 4, 5 }, // case 26 - { 2, 1, 5 }, { 5, 1, 4 }, // case 27 - { 2, 8, 1 }, { 6, 7, 5 }, { 7, 4, 5 }, // case 28 - { 0, 7, 5 }, { 7, 4, 5 }, { 0, 5, 1 }, { 1, 5, 8 }, // case 29 - { 0, 2, 8 }, { 0, 8, 4 }, { 0, 4, 5 }, { 0, 5, 6 }, // case 30 - { 8, 4, 5 }, // case 31 - { 4, 8, 5 }, // case 32 - { 4, 8, 5 }, { 0, 6, 2 }, // case 33 - { 4, 8, 5 }, { 0, 1, 7 }, // case 34 - { 4, 8, 5 }, { 6, 1, 7 }, { 6, 2, 1 }, // case 35 - { 1, 5, 4 }, { 2, 5, 1 }, // case 36 - { 1, 5, 4 }, { 1, 6, 5 }, { 1, 0, 6 }, // case 37 - { 5, 4, 7 }, { 5, 7, 0 }, { 5, 0, 2 }, // case 38 - { 6, 4, 7 }, { 6, 5, 4 }, // case 39 - { 6, 3, 8 }, { 3, 4, 8 }, // case 40 - { 0, 3, 4 }, { 0, 4, 8 }, { 0, 8, 2 }, // case 41 - { 7, 0, 1 }, { 6, 3, 4 }, { 6, 4, 8 }, // case 42 - { 1, 7, 3 }, { 1, 3, 2 }, { 2, 3, 8 }, { 8, 3, 4 }, // case 43 - { 2, 6, 1 }, { 6, 3, 1 }, { 3, 4, 1 }, // case 44 - { 0, 3, 1 }, { 1, 3, 4 }, // case 45 - { 7, 0, 4 }, { 4, 0, 2 }, { 4, 2, 3 }, { 3, 2, 6 }, // case 46 - { 7, 3, 4 }, // case 47 - { 7, 8, 5 }, { 7, 5, 3 }, // case 48 - { 0, 6, 2 }, { 7, 8, 5 }, { 7, 5, 3 }, // case 49 - { 0, 1, 3 }, { 1, 5, 3 }, { 1, 8, 5 }, // case 50 - { 2, 1, 6 }, { 6, 1, 3 }, { 5, 1, 8 }, { 3, 1, 5 }, // case 51 - { 1, 3, 7 }, { 1, 5, 3 }, { 1, 2, 5 }, // case 52 - { 1, 0, 6 }, { 1, 6, 5 }, { 1, 5, 7 }, { 7, 5, 3 }, // case 53 - { 0, 2, 5 }, { 0, 5, 3 }, // case 54 - { 3, 6, 5 }, // case 55 - { 7, 8, 6 }, // case 56 - { 0, 7, 8 }, { 0, 8, 2 }, // case 57 - { 0, 1, 6 }, { 1, 8, 6 }, // case 58 - { 2, 1, 8 }, // case 59 - { 6, 7, 1 }, { 6, 1, 2 }, // case 60 - { 0, 7, 1 }, // case 61 - { 0, 2, 6 }, // case 62 - // case 63 - // CELL_SHAPE_PYRAMID - // case 0 - { 3, 4, 0 }, // case 1 - { 5, 1, 0 }, // case 2 - { 5, 1, 4 }, { 1, 3, 4 }, // case 3 - { 6, 2, 1 }, // case 4 - { 3, 4, 0 }, { 6, 2, 1 }, // case 5 - { 5, 2, 0 }, { 6, 2, 5 }, // case 6 - { 2, 3, 4 }, { 2, 4, 6 }, { 4, 5, 6 }, // case 7 - { 2, 7, 3 }, // case 8 - { 2, 7, 4 }, { 4, 0, 2 }, // case 9 - { 5, 1, 0 }, { 2, 7, 3 }, // case 10 - { 5, 7, 4 }, { 1, 7, 5 }, { 2, 7, 1 }, // case 11 - { 6, 3, 1 }, { 7, 3, 6 }, // case 12 - { 4, 6, 7 }, { 0, 6, 4 }, { 1, 6, 0 }, // case 13 - { 7, 5, 6 }, { 3, 5, 7 }, { 0, 5, 3 }, // case 14 - { 7, 4, 5 }, { 7, 5, 6 }, // case 15 - { 7, 5, 4 }, { 7, 6, 5 }, // case 16 - { 5, 0, 3 }, { 6, 5, 3 }, { 7, 6, 3 }, // case 17 - { 1, 0, 4 }, { 7, 1, 4 }, { 6, 1, 7 }, // case 18 - { 6, 1, 3 }, { 7, 6, 3 }, // case 19 - { 7, 5, 4 }, { 7, 1, 5 }, { 7, 2, 1 }, // case 20 - { 3, 7, 0 }, { 7, 5, 0 }, { 7, 2, 5 }, { 2, 1, 5 }, // case 21 - { 4, 2, 0 }, { 7, 2, 4 }, // case 22 - { 7, 2, 3 }, // case 23 - { 2, 4, 3 }, { 5, 4, 2 }, { 6, 5, 2 }, // case 24 - { 2, 5, 0 }, { 2, 6, 5 }, // case 25 - { 6, 1, 0 }, { 4, 6, 0 }, { 3, 6, 4 }, { 3, 2, 6 }, // case 26 - { 2, 6, 1 }, // case 27 - { 1, 4, 3 }, { 1, 5, 4 }, // case 28 - { 1, 5, 0 }, // case 29 - { 4, 3, 0 }, // case 30 - // case 31 - { 0, 0, 0 } // dummy - }; - // clang-format on + return MarchingCellTables::GetNumOutCells(inCellType, caseNumber); +} - vtkm::IdComponent offset = GetTriTableOffset(cellType, caseNumber); - return triTable[offset + triangleNumber]; +template +VTKM_EXEC inline const vtkm::UInt8* GetCellEdges(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber, + vtkm::UInt8 triangleNumber) +{ + return MarchingCellTables::GetCellEdges(inCellType, caseNumber, triangleNumber); } + } } } // namespace vtkm::worklet::marching_cells diff --git a/vtkm/filter/contour/worklet/contour/MarchingCellTables.h.in b/vtkm/filter/contour/worklet/contour/MarchingCellTables.h.in index fe10790601..eb1745557f 100644 --- a/vtkm/filter/contour/worklet/contour/MarchingCellTables.h.in +++ b/vtkm/filter/contour/worklet/contour/MarchingCellTables.h.in @@ -27,7 +27,7 @@ $# Ignore the following comment. It is meant for the generated file. #ifndef vtk_m_MarchingCellTables_h #define vtk_m_MarchingCellTables_h $py( -shape_names = ( +shape_names = [ "CELL_SHAPE_EMPTY", "CELL_SHAPE_VERTEX", "CELL_SHAPE_POLY_VERTEX", @@ -43,19 +43,54 @@ shape_names = ( "CELL_SHAPE_HEXAHEDRON", "CELL_SHAPE_WEDGE", "CELL_SHAPE_PYRAMID", -) -shape_tables = { +] +shape_tables_2D = { "CELL_SHAPE_EMPTY" : [], "CELL_SHAPE_VERTEX" : [], - # TODO "CELL_SHAPE_LINE" : [], + "CELL_SHAPE_POLY_LINE" : [], + "CELL_SHAPE_TRIANGLE" : [ + [], + [(0, 2, 255)], + [(1, 0, 255)], + [(1, 2, 255)], + [(2, 1, 255)], + [(0, 1, 255)], + [(2, 0, 255)], + [] + ], # Special implementation + "CELL_SHAPE_POLYGON" : [], + "CELL_SHAPE_QUAD" : [ + [], + [(0, 3, 255)], + [(1, 0, 255)], + [(1, 3, 255)], + [(2, 1, 255)], + [(0, 3, 255), (2, 1, 255)], + [(2, 0, 255)], + [(2, 3, 255)], + [(3, 2, 255)], + [(0, 2, 255)], + [(1, 0, 255), (3, 2, 255)], + [(1, 2, 255)], + [(3, 1, 255)], + [(0, 1, 255)], + [(3, 0, 255)], + [], + ], + "CELL_SHAPE_TETRA" : [], + "CELL_SHAPE_HEXAHEDRON" : [], + "CELL_SHAPE_WEDGE" : [], + "CELL_SHAPE_PYRAMID" : [], +} +shape_tables_3D = { + "CELL_SHAPE_EMPTY" : [], + "CELL_SHAPE_VERTEX" : [], + "CELL_SHAPE_LINE" : [], "CELL_SHAPE_POLY_LINE" : [], - # TODO "CELL_SHAPE_TRIANGLE" : [], - # Special implementation "CELL_SHAPE_POLYGON" : [], - # TODO "CELL_SHAPE_QUAD" : [], "CELL_SHAPE_TETRA" : [ [], @@ -453,134 +488,304 @@ namespace marching_cells // Make sure the table indices are the same as VTK-m's shape IDs. $for(shape_index in range(len(shape_names)))\ -$if(shape_names[shape_index] in shape_tables)\ +$if(shape_names[shape_index] in shape_tables_3D)\ VTKM_STATIC_ASSERT(vtkm::$(shape_names[shape_index]) == $(shape_index)); $endif\ $endfor\ -VTKM_EXEC inline vtkm::IdComponent GetNumTrianglesOffset(vtkm::UInt8 cellType) +template +class MarchingCellTables; + +template <> +class MarchingCellTables<3> { - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent offsets[] = { + VTKM_EXEC static inline vtkm::IdComponent GetNumOutCellsOffset(vtkm::UInt8 inCellType) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent offsets[] = { $py(offset = 0)\ $for(shape_name in shape_names)\ - $(offset), // $(shape_name) + $(offset), // $(shape_name) $py( -if shape_name in shape_tables: - offset = offset + len(shape_tables[shape_name]) +if shape_name in shape_tables_3D: + offset = offset + len(shape_tables_3D[shape_name]) else: - shape_tables[shape_name] = [] + shape_tables_3D[shape_name] = [] )\ $endfor\ - 0 // dummy - }; - // clang-format on + $(offset) // table size + }; + // clang-format on - return offsets[cellType]; -} + return offsets[inCellType]; + } -VTKM_EXEC inline vtkm::UInt8 GetNumTriangles(vtkm::UInt8 cellType, vtkm::UInt8 caseNumber) -{ - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 numTriangles[] = { + VTKM_EXEC static inline vtkm::IdComponent GetOutCellTableOffset(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent tableOffset[] = { +$py( +offset = 0 +def table_offset_list(shape_name): + global offset + result = " " + start_case = 0 + display_case = 0 + for triangle_list in shape_tables_3D[shape_name]: + result = result + str(offset) + ", " + offset += len(triangle_list) + display_case += 1 + if display_case == 8: + result = result + " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n " + start_case += display_case + display_case = 0 + if display_case == 0: + result = result[:-6] + else: + result += " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n" + return result +)\ +$extend(table_offset_list)\ +$for(shape_name in shape_names)\ + // $(shape_name) +$table_offset_list(shape_name)\ +$endfor\ + 0 // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + return tableOffset[offset + caseNumber]; + } + +public: + VTKM_EXEC static inline vtkm::UInt8 GetNumOutCells(vtkm::UInt8 inCellType, vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 numOutCells[] = { $py( def num_triangles_list(shape_name): - result = " " + result = " " start_case = 0 display_case = 0 - for triangle_list in shape_tables[shape_name]: + for triangle_list in shape_tables_3D[shape_name]: result = result + str(len(triangle_list)) + ", " display_case += 1 if display_case == 16: - result = result + " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n " + result = result + " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n " start_case += display_case display_case = 0 if display_case == 0: - result = result[:-4] + result = result[:-6] else: result += " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n" return result )\ $extend(num_triangles_list)\ $for(shape_name in shape_names)\ - // $(shape_name) + // $(shape_name) $num_triangles_list(shape_name)\ $endfor\ - 0 // dummy - }; - // clang-format on + 0 // dummy + }; + // clang-format on - vtkm::IdComponent offset = GetNumTrianglesOffset(cellType); - return numTriangles[offset + caseNumber]; -} + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + if (offset == GetNumOutCellsOffset(inCellType + 1)) + { + // This part of the table is empty. + return 0; + } + else + { + return numOutCells[offset + caseNumber]; + } + } -VTKM_EXEC inline vtkm::IdComponent GetTriTableOffset(vtkm::UInt8 cellType, vtkm::UInt8 caseNumber) + VTKM_EXEC static inline const vtkm::UInt8* GetCellEdges(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber, + vtkm::UInt8 outCellNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 triTable[][3] = { +$py( +def triangles(triangle_list): + result = "" + for tri in triangle_list: + result += "{ " + str(tri[0]) + ", " + str(tri[1]) + ", " + str(tri[2]) + " }, " + return result +)\ +$extend(triangles)\ +$for(shape_name in shape_names)\ + // $(shape_name) +$py(casenum = 0)\ +$for(triangle_list in shape_tables_3D[shape_name])\ + $triangles(triangle_list)// case $(casenum) +$py(casenum += 1)\ +$endfor\ +$endfor\ + { 0, 0, 0 } // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetOutCellTableOffset(inCellType, caseNumber); + return triTable[offset + outCellNumber]; + } +}; + +template <> +class MarchingCellTables<2> { - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent triTableOffset[] = { + VTKM_EXEC static inline vtkm::IdComponent GetNumOutCellsOffset(vtkm::UInt8 inCellType) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent offsets[] = { +$py(offset = 0)\ +$for(shape_name in shape_names)\ + $(offset), // $(shape_name) +$py( +if shape_name in shape_tables_2D: + offset = offset + len(shape_tables_2D[shape_name]) +else: + shape_tables_2D[shape_name] = [] +)\ +$endfor\ + $(offset) // table size + }; + // clang-format on + + return offsets[inCellType]; + } + + VTKM_EXEC static inline vtkm::IdComponent GetOutCellTableOffset(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent tableOffset[] = { $py( offset = 0 def table_offset_list(shape_name): global offset - result = " " + result = " " start_case = 0 display_case = 0 - for triangle_list in shape_tables[shape_name]: + for line_list in shape_tables_2D[shape_name]: result = result + str(offset) + ", " - offset += len(triangle_list) + offset += len(line_list) display_case += 1 if display_case == 8: - result = result + " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n " + result = result + " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n " start_case += display_case display_case = 0 if display_case == 0: - result = result[:-4] + result = result[:-6] else: result += " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n" return result )\ $extend(table_offset_list)\ $for(shape_name in shape_names)\ - // $(shape_name) + // $(shape_name) $table_offset_list(shape_name)\ $endfor\ - 0 // dummy - }; - // clang-format on + 0 // dummy + }; + // clang-format on - vtkm::IdComponent offset = GetNumTrianglesOffset(cellType); - return triTableOffset[offset + caseNumber]; -} + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + return tableOffset[offset + caseNumber]; + } -VTKM_EXEC inline const vtkm::UInt8* GetTriangleEdges(vtkm::UInt8 cellType, - vtkm::UInt8 caseNumber, - vtkm::UInt8 triangleNumber) -{ - // clang-format off - VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 triTable[][3] = { +public: + VTKM_EXEC static inline vtkm::UInt8 GetNumOutCells(vtkm::UInt8 inCellType, vtkm::UInt8 caseNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 numOutCells[] = { $py( -def triangles(triangle_list): +def num_triangles_list(shape_name): + result = " " + start_case = 0 + display_case = 0 + for line_list in shape_tables_2D[shape_name]: + result = result + str(len(line_list)) + ", " + display_case += 1 + if display_case == 16: + result = result + " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n " + start_case += display_case + display_case = 0 + if display_case == 0: + result = result[:-6] + else: + result += " // cases " + str(start_case) + " - " + str(start_case + display_case - 1) + "\n" + return result +)\ +$extend(num_triangles_list)\ +$for(shape_name in shape_names)\ + // $(shape_name) +$num_triangles_list(shape_name)\ +$endfor\ + 0 // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetNumOutCellsOffset(inCellType); + if (offset == GetNumOutCellsOffset(inCellType + 1)) + { + // This part of the table is empty. + return 0; + } + else + { + return numOutCells[offset + caseNumber]; + } + } + + VTKM_EXEC static inline const vtkm::UInt8* GetCellEdges(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber, + vtkm::UInt8 outCellNumber) + { + // clang-format off + VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 lineTable[][2] = { +$py( +def lines(line_list): result = "" - for tri in triangle_list: - result += "{ " + str(tri[0]) + ", " + str(tri[1]) + ", " + str(tri[2]) + " }, " + for line in line_list: + result += "{ " + str(line[0]) + ", " + str(line[1]) + " }, " return result )\ -$extend(triangles)\ +$extend(lines)\ $for(shape_name in shape_names)\ - // $(shape_name) + // $(shape_name) $py(casenum = 0)\ -$for(triangle_list in shape_tables[shape_name])\ - $triangles(triangle_list)// case $(casenum) +$for(line_list in shape_tables_2D[shape_name])\ + $lines(line_list)// case $(casenum) $py(casenum += 1)\ $endfor\ $endfor\ - { 0, 0, 0 } // dummy - }; - // clang-format on + { 0, 0 } // dummy + }; + // clang-format on + + vtkm::IdComponent offset = GetOutCellTableOffset(inCellType, caseNumber); + return lineTable[offset + outCellNumber]; + } +}; - vtkm::IdComponent offset = GetTriTableOffset(cellType, caseNumber); - return triTable[offset + triangleNumber]; +template +VTKM_EXEC inline vtkm::UInt8 GetNumOutCells(vtkm::UInt8 inCellType, vtkm::UInt8 caseNumber) +{ + return MarchingCellTables::GetNumOutCells(inCellType, caseNumber); } + +template +VTKM_EXEC inline const vtkm::UInt8* GetCellEdges(vtkm::UInt8 inCellType, + vtkm::UInt8 caseNumber, + vtkm::UInt8 triangleNumber) +{ + return MarchingCellTables::GetCellEdges(inCellType, caseNumber, triangleNumber); +} + } } } // namespace vtkm::worklet::marching_cells diff --git a/vtkm/filter/contour/worklet/contour/MarchingCells.h b/vtkm/filter/contour/worklet/contour/MarchingCells.h index 68666b2dde..fbf4839c3c 100644 --- a/vtkm/filter/contour/worklet/contour/MarchingCells.h +++ b/vtkm/filter/contour/worklet/contour/MarchingCells.h @@ -74,20 +74,128 @@ make_ScalarField(const vtkm::cont::ArrayHandle& ah) } // --------------------------------------------------------------------------- -template +template +struct OutCellTraits; + +template <> +struct OutCellTraits<3> +{ + static constexpr vtkm::UInt8 NUM_POINTS = 3; + static constexpr vtkm::UInt8 CELL_SHAPE = vtkm::CELL_SHAPE_TRIANGLE; +}; + +template <> +struct OutCellTraits<2> +{ + static constexpr vtkm::UInt8 NUM_POINTS = 2; + static constexpr vtkm::UInt8 CELL_SHAPE = vtkm::CELL_SHAPE_LINE; +}; + +template <> +struct OutCellTraits<1> +{ + static constexpr vtkm::UInt8 NUM_POINTS = 1; + static constexpr vtkm::UInt8 CELL_SHAPE = vtkm::CELL_SHAPE_VERTEX; +}; + +template +VTKM_EXEC vtkm::IdComponent TableNumOutCells(vtkm::UInt8 shape, + FieldType isoValue, + const FieldVecType& fieldIn) +{ + const vtkm::IdComponent numPoints = fieldIn.GetNumberOfComponents(); + // Compute the Marching Cubes case number for this cell. We need to iterate + // the isovalues until the sum >= our visit index. But we need to make + // sure the caseNumber is correct before stopping + vtkm::IdComponent caseNumber = 0; + for (vtkm::IdComponent point = 0; point < numPoints; ++point) + { + caseNumber |= (fieldIn[point] > isoValue) << point; + } + + return vtkm::worklet::marching_cells::GetNumOutCells(shape, caseNumber); +} + +template +VTKM_EXEC vtkm::IdComponent NumOutCellsSpecialCases(std::integral_constant, + vtkm::UInt8 shape, + FieldType isoValue, + const FieldVecType& fieldIn) +{ + return TableNumOutCells<3>(shape, isoValue, fieldIn); +} + +template +VTKM_EXEC vtkm::IdComponent NumOutCellsSpecialCases(std::integral_constant, + vtkm::UInt8 shape, + FieldType isoValue, + const FieldVecType& fieldIn) +{ + if (shape == vtkm::CELL_SHAPE_POLYGON) + { + const vtkm::IdComponent numPoints = fieldIn.GetNumberOfComponents(); + vtkm::IdComponent numCrossings = 0; + bool lastOver = (fieldIn[numPoints - 1] > isoValue); + for (vtkm::IdComponent point = 0; point < numPoints; ++point) + { + bool nextOver = (fieldIn[point] > isoValue); + if (lastOver != nextOver) + { + ++numCrossings; + } + lastOver = nextOver; + } + VTKM_ASSERT((numCrossings % 2) == 0); + return numCrossings / 2; + } + else + { + return TableNumOutCells<2>(shape, isoValue, fieldIn); + } +} + +template +VTKM_EXEC vtkm::IdComponent NumOutCellsSpecialCases(std::integral_constant, + vtkm::UInt8 shape, + FieldType isoValue, + const FieldVecType& fieldIn) +{ + if ((shape == vtkm::CELL_SHAPE_LINE) || (shape == vtkm::CELL_SHAPE_POLY_LINE)) + { + const vtkm::IdComponent numPoints = fieldIn.GetNumberOfComponents(); + vtkm::IdComponent numCrossings = 0; + bool lastOver = (fieldIn[0] > isoValue); + for (vtkm::IdComponent point = 1; point < numPoints; ++point) + { + bool nextOver = (fieldIn[point] > isoValue); + if (lastOver != nextOver) + { + ++numCrossings; + } + lastOver = nextOver; + } + return numCrossings; + } + else + { + return 0; + } +} + +// --------------------------------------------------------------------------- +template class ClassifyCell : public vtkm::worklet::WorkletVisitCellsWithPoints { public: - using ControlSignature = void(WholeArrayIn isoValues, + using ControlSignature = void(WholeArrayIn isovalues, FieldInPoint fieldIn, CellSetIn cellSet, FieldOutCell outNumTriangles); - using ExecutionSignature = void(CellShape, PointCount, _1, _2, _4); + using ExecutionSignature = void(CellShape, _1, _2, _4); using InputDomain = _3; template VTKM_EXEC void operator()(CellShapeType shape, - vtkm::IdComponent numVertices, const IsoValuesType& isovalues, const FieldInType& fieldIn, vtkm::IdComponent& numTriangles) const @@ -97,13 +205,8 @@ public: for (vtkm::Id i = 0; i < numIsoValues; ++i) { - vtkm::IdComponent caseNumber = 0; - for (vtkm::IdComponent j = 0; j < numVertices; ++j) - { - caseNumber |= (fieldIn[j] > isovalues.Get(i)) << j; - } - - sum += vtkm::worklet::marching_cells::GetNumTriangles(shape.Id, caseNumber); + sum += NumOutCellsSpecialCases( + std::integral_constant{}, shape.Id, isovalues.Get(i), fieldIn); } numTriangles = sum; } @@ -128,20 +231,23 @@ public: ExecObject() = default; VTKM_CONT - ExecObject(vtkm::Id size, + ExecObject(vtkm::UInt8 numPointsPerOutCell, + vtkm::Id size, vtkm::cont::ArrayHandle& interpWeights, vtkm::cont::ArrayHandle& interpIds, vtkm::cont::ArrayHandle& interpCellIds, vtkm::cont::ArrayHandle& interpContourId, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) - : InterpWeightsPortal(interpWeights.PrepareForOutput(3 * size, device, token)) - , InterpIdPortal(interpIds.PrepareForOutput(3 * size, device, token)) - , InterpCellIdPortal(interpCellIds.PrepareForOutput(3 * size, device, token)) - , InterpContourPortal(interpContourId.PrepareForOutput(3 * size, device, token)) + : InterpWeightsPortal( + interpWeights.PrepareForOutput(numPointsPerOutCell * size, device, token)) + , InterpIdPortal(interpIds.PrepareForOutput(numPointsPerOutCell * size, device, token)) + , InterpCellIdPortal( + interpCellIds.PrepareForOutput(numPointsPerOutCell * size, device, token)) + , InterpContourPortal( + interpContourId.PrepareForOutput(numPointsPerOutCell * size, device, token)) { - // Interp needs to be 3 times longer than size as they are per point of the - // output triangle + // Interp needs to be scaled as they are per point of the output cell } WritePortalType InterpWeightsPortal; WritePortalType InterpIdPortal; @@ -150,12 +256,14 @@ public: }; VTKM_CONT - EdgeWeightGenerateMetaData(vtkm::Id size, + EdgeWeightGenerateMetaData(vtkm::UInt8 inCellDimension, + vtkm::Id size, vtkm::cont::ArrayHandle& interpWeights, vtkm::cont::ArrayHandle& interpIds, vtkm::cont::ArrayHandle& interpCellIds, vtkm::cont::ArrayHandle& interpContourId) - : Size(size) + : NumPointsPerOutCell(inCellDimension) + , Size(size) , InterpWeights(interpWeights) , InterpIds(interpIds) , InterpCellIds(interpCellIds) @@ -166,7 +274,8 @@ public: VTKM_CONT ExecObject PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token& token) { - return ExecObject(this->Size, + return ExecObject(this->NumPointsPerOutCell, + this->Size, this->InterpWeights, this->InterpIds, this->InterpCellIds, @@ -176,6 +285,7 @@ public: } private: + vtkm::UInt8 NumPointsPerOutCell; vtkm::Id Size; vtkm::cont::ArrayHandle InterpWeights; vtkm::cont::ArrayHandle InterpIds; @@ -183,10 +293,153 @@ private: vtkm::cont::ArrayHandle InterpContourId; }; +// ----------------------------------------------------------------------------- +template +VTKM_EXEC const vtkm::UInt8* TableCellEdges(vtkm::UInt8 shape, + const IsoValuesType& isoValues, + const FieldVecType& fieldIn, + vtkm::IdComponent visitIndex, + vtkm::IdComponent& contourIndex) +{ + const vtkm::IdComponent numPoints = fieldIn.GetNumberOfComponents(); + // Compute the Marching Cubes case number for this cell. We need to iterate + // the isovalues until the sum >= our visit index. But we need to make + // sure the caseNumber is correct before stopping + vtkm::IdComponent caseNumber = 0; + vtkm::IdComponent sum = 0; + vtkm::IdComponent numIsoValues = static_cast(isoValues.GetNumberOfValues()); + + for (contourIndex = 0; contourIndex < numIsoValues; ++contourIndex) + { + const auto value = isoValues.Get(contourIndex); + caseNumber = 0; + for (vtkm::IdComponent point = 0; point < numPoints; ++point) + { + caseNumber |= (fieldIn[point] > value) << point; + } + + sum += vtkm::worklet::marching_cells::GetNumOutCells(shape, caseNumber); + if (sum > visitIndex) + { + break; + } + } + + VTKM_ASSERT(contourIndex < numIsoValues); + + visitIndex = sum - visitIndex - 1; + + return vtkm::worklet::marching_cells::GetCellEdges(shape, caseNumber, visitIndex); +} + +template +VTKM_EXEC const vtkm::UInt8* CellEdgesSpecialCases(std::integral_constant, + vtkm::UInt8 shape, + const IsoValuesType& isoValues, + const FieldVecType& fieldIn, + vtkm::IdComponent visitIndex, + vtkm::IdComponent& contourIndex, + vtkm::Vec2ui_8& vtkmNotUsed(edgeBuffer)) +{ + return TableCellEdges<3>(shape, isoValues, fieldIn, visitIndex, contourIndex); +} + +template +VTKM_EXEC const vtkm::UInt8* CellEdgesSpecialCases(std::integral_constant, + vtkm::UInt8 shape, + const IsoValuesType& isoValues, + const FieldVecType& fieldIn, + vtkm::IdComponent visitIndex, + vtkm::IdComponent& contourIndex, + vtkm::Vec2ui_8& edgeBuffer) +{ + if (shape == vtkm::CELL_SHAPE_POLYGON) + { + vtkm::IdComponent numCrossings = 0; + vtkm::IdComponent numIsoValues = static_cast(isoValues.GetNumberOfValues()); + const vtkm::IdComponent numPoints = fieldIn.GetNumberOfComponents(); + for (contourIndex = 0; contourIndex < numIsoValues; ++contourIndex) + { + auto isoValue = isoValues.Get(contourIndex); + bool lastOver = (fieldIn[0] > isoValue); + for (vtkm::IdComponent point = 1; point <= numPoints; ++point) + { + bool nextOver = (fieldIn[point % numPoints] > isoValue); + if (lastOver != nextOver) + { + // Check to see if we hit the target edge. + if (visitIndex == (numCrossings / 2)) + { + if ((numCrossings % 2) == 0) + { + // Record first point. + edgeBuffer[0] = point - 1; + } + else + { + // Record second (and final) point. + edgeBuffer[1] = point - 1; + return &edgeBuffer[0]; + } + } + ++numCrossings; + } + lastOver = nextOver; + } + VTKM_ASSERT((numCrossings % 2) == 0); + } + VTKM_ASSERT(0 && "Sanity check fail."); + edgeBuffer[0] = edgeBuffer[1] = 0; + return &edgeBuffer[0]; + } + else + { + return TableCellEdges<2>(shape, isoValues, fieldIn, visitIndex, contourIndex); + } +} + +template +VTKM_EXEC const vtkm::UInt8* CellEdgesSpecialCases(std::integral_constant, + vtkm::UInt8 shape, + const IsoValuesType& isoValues, + const FieldVecType& fieldIn, + vtkm::IdComponent visitIndex, + vtkm::IdComponent& contourIndex, + vtkm::Vec2ui_8& edgeBuffer) +{ + VTKM_ASSERT((shape == vtkm::CELL_SHAPE_LINE) || (shape == vtkm::CELL_SHAPE_POLY_LINE)); + (void)shape; + vtkm::IdComponent numCrossings = 0; + vtkm::IdComponent numIsoValues = static_cast(isoValues.GetNumberOfValues()); + const vtkm::IdComponent numPoints = fieldIn.GetNumberOfComponents(); + for (contourIndex = 0; contourIndex < numIsoValues; ++contourIndex) + { + auto isoValue = isoValues.Get(contourIndex); + bool lastOver = (fieldIn[0] > isoValue); + for (vtkm::IdComponent point = 1; point < numPoints; ++point) + { + bool nextOver = (fieldIn[point] > isoValue); + if (lastOver != nextOver) + { + if (visitIndex == numCrossings) + { + edgeBuffer[0] = point - 1; + return &edgeBuffer[0]; + } + ++numCrossings; + } + lastOver = nextOver; + } + } + VTKM_ASSERT(0 && "Sanity check fail."); + edgeBuffer[0] = 0; + return &edgeBuffer[0]; +} + /// \brief Compute the weights for each edge that is used to generate /// a point in the resulting iso-surface // ----------------------------------------------------------------------------- -template +template class EdgeWeightGenerate : public vtkm::worklet::WorkletVisitCellsWithPoints { public: @@ -221,43 +474,26 @@ public: vtkm::IdComponent visitIndex, const IndicesVecType& indices) const { - const vtkm::Id outputPointId = 3 * outputCellId; + const vtkm::Id outputPointId = OutCellTraits::NUM_POINTS * outputCellId; using FieldType = typename vtkm::VecTraits::ComponentType; - vtkm::IdComponent sum = 0, caseNumber = 0; - vtkm::IdComponent i = 0, - numIsoValues = static_cast(isovalues.GetNumberOfValues()); - - for (i = 0; i < numIsoValues; ++i) - { - const FieldType ivalue = isovalues.Get(i); - // Compute the Marching Cubes case number for this cell. We need to iterate - // the isovalues until the sum >= our visit index. But we need to make - // sure the caseNumber is correct before stopping - caseNumber = 0; - for (vtkm::IdComponent j = 0; j < numVertices; ++j) - { - caseNumber |= (fieldIn[j] > ivalue) << j; - } - - sum += GetNumTriangles(shape.Id, caseNumber); - if (sum > visitIndex) - { - break; - } - } - - visitIndex = sum - visitIndex - 1; - // Interpolate for vertex positions and associated scalar values - auto edges = vtkm::worklet::marching_cells::GetTriangleEdges(shape.Id, caseNumber, visitIndex); - for (vtkm::IdComponent triVertex = 0; triVertex < 3; triVertex++) + vtkm::IdComponent contourIndex; + vtkm::Vec2ui_8 edgeBuffer; + const vtkm::UInt8* edges = CellEdgesSpecialCases(std::integral_constant{}, + shape.Id, + isovalues, + fieldIn, + visitIndex, + contourIndex, + edgeBuffer); + for (vtkm::IdComponent triVertex = 0; triVertex < OutCellTraits::NUM_POINTS; triVertex++) { vtkm::IdComponent2 edgeVertices; vtkm::Vec fieldValues; for (vtkm::IdComponent edgePointId = 0; edgePointId < 2; ++edgePointId) { - vtkm::ErrorCode errorCode = vtkm::exec::CellEdgeLocalIndex( + vtkm::ErrorCode errorCode = this->CrossingLocalIndex( numVertices, edgePointId, edges[triVertex], shape, edgeVertices[edgePointId]); if (errorCode != vtkm::ErrorCode::Success) { @@ -271,20 +507,63 @@ public: // in a subsequent call, after we have merged duplicate points metaData.InterpCellIdPortal.Set(outputPointId + triVertex, inputCellId); - metaData.InterpContourPortal.Set(outputPointId + triVertex, static_cast(i)); + metaData.InterpContourPortal.Set(outputPointId + triVertex, + static_cast(contourIndex)); metaData.InterpIdPortal.Set(outputPointId + triVertex, vtkm::Id2(indices[edgeVertices[0]], indices[edgeVertices[1]])); vtkm::FloatDefault interpolant = - static_cast(isovalues.Get(i) - fieldValues[0]) / + static_cast(isovalues.Get(contourIndex) - fieldValues[0]) / static_cast(fieldValues[1] - fieldValues[0]); metaData.InterpWeightsPortal.Set(outputPointId + triVertex, interpolant); } } + + template + static inline VTKM_EXEC vtkm::ErrorCode CrossingLocalIndex(vtkm::IdComponent numPoints, + vtkm::IdComponent pointIndex, + vtkm::IdComponent edgeIndex, + CellShapeTag shape, + vtkm::IdComponent& result); }; +template <> +template +VTKM_EXEC vtkm::ErrorCode EdgeWeightGenerate<1>::CrossingLocalIndex(vtkm::IdComponent numPoints, + vtkm::IdComponent pointIndex, + vtkm::IdComponent edgeIndex, + CellShapeTag shape, + vtkm::IdComponent& result) +{ + VTKM_ASSERT((shape.Id == vtkm::CELL_SHAPE_LINE) || (shape.Id == vtkm::CELL_SHAPE_POLY_LINE)); + (void)shape; + if ((pointIndex < 0) || (pointIndex > 1)) + { + result = -1; + return vtkm::ErrorCode::InvalidPointId; + } + if ((edgeIndex < 0) || (edgeIndex >= (numPoints - 1))) + { + result = -1; + return vtkm::ErrorCode::InvalidEdgeId; + } + result = edgeIndex + pointIndex; + return vtkm::ErrorCode::Success; +} + +template +template +VTKM_EXEC vtkm::ErrorCode EdgeWeightGenerate::CrossingLocalIndex(vtkm::IdComponent numPoints, + vtkm::IdComponent pointIndex, + vtkm::IdComponent edgeIndex, + CellShapeTag shape, + vtkm::IdComponent& result) +{ + return vtkm::exec::CellEdgeLocalIndex(numPoints, pointIndex, edgeIndex, shape, result); +} + // --------------------------------------------------------------------------- struct MultiContourLess { @@ -592,7 +871,8 @@ struct GenerateNormals }; //---------------------------------------------------------------------------- -template @@ -620,7 +900,7 @@ vtkm::cont::CellSetSingleType<> execute( // for each cell, and the number of vertices to be generated vtkm::cont::ArrayHandle numOutputTrisPerCell; { - marching_cells::ClassifyCell classifyCell; + marching_cells::ClassifyCell classifyCell; invoker(classifyCell, isoValuesHandle, inputField, cells, numOutputTrisPerCell); } @@ -628,19 +908,20 @@ vtkm::cont::CellSetSingleType<> execute( vtkm::cont::ArrayHandle contourIds; vtkm::cont::ArrayHandle originalCellIdsForPoints; { - auto scatter = EdgeWeightGenerate::MakeScatter(numOutputTrisPerCell); + auto scatter = EdgeWeightGenerate::MakeScatter(numOutputTrisPerCell); // Maps output cells to input cells. Store this for cell field mapping. sharedState.CellIdMap = scatter.GetOutputToInputMap(); EdgeWeightGenerateMetaData metaData( + Dims, scatter.GetOutputRange(numOutputTrisPerCell.GetNumberOfValues()), sharedState.InterpolationWeights, sharedState.InterpolationEdgeIds, originalCellIdsForPoints, contourIds); - invoker(EdgeWeightGenerate{}, + invoker(EdgeWeightGenerate{}, scatter, cells, //cast to a scalar field if not one, as cellderivative only works on those @@ -699,7 +980,10 @@ vtkm::cont::CellSetSingleType<> execute( //assign the connectivity to the cell set vtkm::cont::CellSetSingleType<> outputCells; - outputCells.Fill(vertices.GetNumberOfValues(), vtkm::CELL_SHAPE_TRIANGLE, 3, connectivity); + outputCells.Fill(vertices.GetNumberOfValues(), + OutCellTraits::CELL_SHAPE, + OutCellTraits::NUM_POINTS, + connectivity); //now that the vertices have been generated we can generate the normals if (sharedState.GenerateNormals) -- GitLab