diff --git a/Documentation/release/dev/htg-geometry-fill-material.md b/Documentation/release/dev/htg-geometry-fill-material.md new file mode 100644 index 0000000000000000000000000000000000000000..243162be600c9c193a5906218cfd2efcc371f114 --- /dev/null +++ b/Documentation/release/dev/htg-geometry-fill-material.md @@ -0,0 +1,5 @@ +## Add FillMaterial option to HTG Geometry filter + +`vtkHyperTreeGridGeometry` now has a `FillMaterial` option. +Enabled by default, the filter produces the same result as before. +When disabled, only the interface lines are added to the resulting polydata (nothing where there are no interfaces or on the edges). diff --git a/Filters/HyperTree/Testing/Cxx/CMakeLists.txt b/Filters/HyperTree/Testing/Cxx/CMakeLists.txt index f4ec43c05ab59c7a8b97416c28567fbc9bc331ff..3e88c8d35ce0db8ef01203e6f53e2c9d978af93a 100644 --- a/Filters/HyperTree/Testing/Cxx/CMakeLists.txt +++ b/Filters/HyperTree/Testing/Cxx/CMakeLists.txt @@ -11,6 +11,7 @@ set(test_sources TestHyperTreeGrid2DInterfaceShift.cxx + TestHyperTreeGrid2DGeometryFillMaterial.cxx,NO_VALID,NO_OUTPUT TestHyperTreeGrid3DAxisCutCoincidentPlane.cxx TestHyperTreeGrid3DIntercepts.cxx TestHyperTreeGrid3DInterface.cxx diff --git a/Filters/HyperTree/Testing/Cxx/TestHyperTreeGrid2DGeometryFillMaterial.cxx b/Filters/HyperTree/Testing/Cxx/TestHyperTreeGrid2DGeometryFillMaterial.cxx new file mode 100644 index 0000000000000000000000000000000000000000..af249cfe1a15a5549d5763ec5cfd37768e5a5f44 --- /dev/null +++ b/Filters/HyperTree/Testing/Cxx/TestHyperTreeGrid2DGeometryFillMaterial.cxx @@ -0,0 +1,61 @@ +// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen +// SPDX-License-Identifier: BSD-3-Clause + +#include "vtkActor.h" +#include "vtkCamera.h" +#include "vtkCellData.h" +#include "vtkDataArray.h" +#include "vtkHyperTreeGridGeometry.h" +#include "vtkLogger.h" +#include "vtkNew.h" +#include "vtkPolyData.h" +#include "vtkTestUtilities.h" +#include "vtkXMLHyperTreeGridReader.h" + +int TestHyperTreeGrid2DGeometryFillMaterial(int argc, char* argv[]) +{ + // HTG reader + vtkNew<vtkXMLHyperTreeGridReader> reader; + + // Test data + char* fileNameC = + vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/HTG/donut_XZ_shift_2d.htg"); + reader->SetFileName(fileNameC); + delete[] fileNameC; + + // Geometry filter + vtkNew<vtkHyperTreeGridGeometry> geometryFilter; + geometryFilter->SetInputConnection(reader->GetOutputPort()); + geometryFilter->Update(); + + vtkPolyData* geometry = geometryFilter->GetPolyDataOutput(); + if (!geometry) + { + vtkLog(ERROR, "Unable to retrieve htg geometry."); + return EXIT_FAILURE; + } + + if (geometry->GetNumberOfPoints() != 456 || geometry->GetNumberOfCells() != 114) + { + vtkLog(ERROR, "Incorrect number of points or cells."); + return EXIT_FAILURE; + } + + geometryFilter->FillMaterialOff(); + geometryFilter->Update(); + + vtkPolyData* interfaceLines = geometryFilter->GetPolyDataOutput(); + if (!interfaceLines) + { + vtkLog(ERROR, "Unable to retrieve htg geometry."); + return EXIT_FAILURE; + } + + if (interfaceLines->GetNumberOfPoints() != 282 || interfaceLines->GetNumberOfCells() != 100) + { + vtkLog(ERROR, "Incorrect number of points or cells."); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry.cxx b/Filters/HyperTree/vtkHyperTreeGridGeometry.cxx index 8cf8f3a1fda4965960d8173517f47865317332ba..cf53711b9ccacead45761a9145a30e6f0604676e 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry.cxx +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry.cxx @@ -70,17 +70,18 @@ int vtkHyperTreeGridGeometry::ProcessTrees(vtkHyperTreeGrid* input, vtkDataObjec case 1: implementation = std::unique_ptr<vtkHyperTreeGridGeometry1DImpl>( new vtkHyperTreeGridGeometry1DImpl(input, outPoints, outCells, this->InData, this->OutData, - this->PassThroughCellIds, this->OriginalCellIdArrayName)); + this->PassThroughCellIds, this->OriginalCellIdArrayName, this->FillMaterial)); break; case 2: implementation = std::unique_ptr<vtkHyperTreeGridGeometry2DImpl>( new vtkHyperTreeGridGeometry2DImpl(input, outPoints, outCells, this->InData, this->OutData, - this->PassThroughCellIds, this->OriginalCellIdArrayName)); + this->PassThroughCellIds, this->OriginalCellIdArrayName, this->FillMaterial)); break; case 3: - implementation = std::unique_ptr<vtkHyperTreeGridGeometry3DImpl>( - new vtkHyperTreeGridGeometry3DImpl(this->Merging, input, outPoints, outCells, this->InData, - this->OutData, this->PassThroughCellIds, this->OriginalCellIdArrayName)); + implementation = + std::unique_ptr<vtkHyperTreeGridGeometry3DImpl>(new vtkHyperTreeGridGeometry3DImpl( + this->Merging, input, outPoints, outCells, this->InData, this->OutData, + this->PassThroughCellIds, this->OriginalCellIdArrayName, this->FillMaterial)); break; default: vtkErrorMacro("Incorrect dimension of input: " << dimension); @@ -92,7 +93,7 @@ int vtkHyperTreeGridGeometry::ProcessTrees(vtkHyperTreeGrid* input, vtkDataObjec // Set output geometry and topology output->SetPoints(outPoints); - if (dimension == 1) + if (dimension == 1 || !this->FillMaterial) { output->SetLines(outCells); } diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry.h b/Filters/HyperTree/vtkHyperTreeGridGeometry.h index d78452703db06011bf433ab16593f270c9e2a3a8..0b0f290f59aaf69bb0780d036f5fbc8b08b7cd4d 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry.h +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry.h @@ -60,7 +60,7 @@ public: vtkGetMacro(Merging, bool); ///@} - //@{ + ///@{ /** * Set/Get for the PassThroughCellIds boolean. * @@ -73,7 +73,9 @@ public: vtkSetMacro(PassThroughCellIds, bool); vtkGetMacro(PassThroughCellIds, bool); vtkBooleanMacro(PassThroughCellIds, bool); + ///@} + ///@{ /** * Set/Get the OriginalCellIdArrayName string. * @@ -84,7 +86,19 @@ public: */ vtkSetMacro(OriginalCellIdArrayName, std::string); vtkGetMacro(OriginalCellIdArrayName, std::string); - //@} + ///@} + + ///@{ + /** + * If false, only draw the interface (lines). + * Otherwise, draw the full cell with interface (poly). + * + * default is true + */ + vtkSetMacro(FillMaterial, bool); + vtkGetMacro(FillMaterial, bool); + vtkBooleanMacro(FillMaterial, bool); + ///@} protected: vtkHyperTreeGridGeometry() = default; @@ -123,6 +137,8 @@ protected: private: vtkHyperTreeGridGeometry(const vtkHyperTreeGridGeometry&) = delete; void operator=(const vtkHyperTreeGridGeometry&) = delete; + + bool FillMaterial = true; }; VTK_ABI_NAMESPACE_END diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.cxx b/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.cxx index 65718863c7fa800a552be9561c9d0ba0468f5de3..2d42b43247e834419c94071d9045998790f0d385 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.cxx +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.cxx @@ -14,9 +14,9 @@ VTK_ABI_NAMESPACE_BEGIN vtkHyperTreeGridGeometry1DImpl::vtkHyperTreeGridGeometry1DImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName) + const std::string& originalCellIdArrayName, bool fillMaterial) : vtkHyperTreeGridGeometrySmallDimensionsImpl(input, outPoints, outCells, inCellDataAttributes, - outCellDataAttributes, passThroughCellIds, originalCellIdArrayName) + outCellDataAttributes, passThroughCellIds, originalCellIdArrayName, fillMaterial) { // The orientation value indicates the axis on which the HTG 1D is oriented. this->Axis = this->Input->GetOrientation(); diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.h b/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.h index 1d8cc55fa263976c196ef40955eedb8e3fc5ec35..54d8cf5b0fa79afb60d1f81d263f7adf297b0883 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.h +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry1DImpl.h @@ -23,7 +23,7 @@ public: vtkHyperTreeGridGeometry1DImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName); + const std::string& originalCellIdArrayName, bool fillMaterial); ~vtkHyperTreeGridGeometry1DImpl() override = default; diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.cxx b/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.cxx index 49e85bbab61bcc6f0e97b2cb959984bfad7ea8c0..1daca52cfa48f36fcd37544cae99725aeee6c06d 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.cxx +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.cxx @@ -6,7 +6,6 @@ #include "vtkHyperTreeGrid.h" #include "vtkHyperTreeGridNonOrientedGeometryCursor.h" #include "vtkPoints.h" -#include "vtkUnsignedCharArray.h" VTK_ABI_NAMESPACE_BEGIN @@ -14,9 +13,9 @@ VTK_ABI_NAMESPACE_BEGIN vtkHyperTreeGridGeometry2DImpl::vtkHyperTreeGridGeometry2DImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName) + const std::string& originalCellIdArrayName, bool fillMaterial) : vtkHyperTreeGridGeometrySmallDimensionsImpl(input, outPoints, outCells, inCellDataAttributes, - outCellDataAttributes, passThroughCellIds, originalCellIdArrayName) + outCellDataAttributes, passThroughCellIds, originalCellIdArrayName, fillMaterial) { /** * The Orientation value indicates the plane on which the HTG 2D is oriented: @@ -63,7 +62,7 @@ void vtkHyperTreeGridGeometry2DImpl::ProcessLeafCellWithOneInterface( valCrt = valNext; vtkIdType niPt = (iPt + 1) % 4; valNext = distancesToInterface[niPt]; - if (sign * valCrt >= 0.) + if (this->FillMaterial && sign * valCrt >= 0.) { outputIndexPoints.emplace_back(this->OutPoints->InsertNextPoint(xyzCrt)); } diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.h b/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.h index e032a18c71adef6f35005b650738d490c59e4c16..d454bb191571e09083ff9b5a570a3061ea9ee144 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.h +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry2DImpl.h @@ -23,7 +23,7 @@ public: vtkHyperTreeGridGeometry2DImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName); + const std::string& originalCellIdArrayName, bool fillMaterial); ~vtkHyperTreeGridGeometry2DImpl() override = default; diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.cxx b/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.cxx index d955f2e03ea217b3dd0a75cdfc396b1a48920316..78ad9491b64a417ab9873e907b0989f5f159c94a 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.cxx +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.cxx @@ -76,9 +76,9 @@ struct vtkHyperTreeGridGeometry3DImpl::HTG3DPoint vtkHyperTreeGridGeometry3DImpl::vtkHyperTreeGridGeometry3DImpl(bool mergePoints, vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, - bool passThroughCellIds, const std::string& originalCellIdArrayName) + bool passThroughCellIds, const std::string& originalCellIdArrayName, bool fillMaterial) : vtkHyperTreeGridGeometryImpl(input, outPoints, outCells, inCellDataAttributes, - outCellDataAttributes, passThroughCellIds, originalCellIdArrayName) + outCellDataAttributes, passThroughCellIds, originalCellIdArrayName, fillMaterial) { if (mergePoints) { diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.h b/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.h index 7dd35b40f1922cf3156ec9e14bf3f2bd8a662487..2b1ddad68c552884b957acdfa29ce78a0b0df5d6 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.h +++ b/Filters/HyperTree/vtkHyperTreeGridGeometry3DImpl.h @@ -26,7 +26,7 @@ public: vtkHyperTreeGridGeometry3DImpl(bool mergePoints, vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName); + const std::string& originalCellIdArrayName, bool fillMaterial); ~vtkHyperTreeGridGeometry3DImpl() override; diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.cxx b/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.cxx index e514978134ca39490acc6d1ee113240df5f3f4c3..48bf66609c076eee7d511eab21bf9b6f78b35a97 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.cxx +++ b/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.cxx @@ -18,12 +18,13 @@ VTK_ABI_NAMESPACE_BEGIN vtkHyperTreeGridGeometryImpl::vtkHyperTreeGridGeometryImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName) + const std::string& originalCellIdArrayName, bool fillMaterial) : Input(input) , OutPoints(outPoints) , OutCells(outCells) , InCellDataAttributes(inCellDataAttributes) , OutCellDataAttributes(outCellDataAttributes) + , FillMaterial(fillMaterial) , PassThroughCellIds(passThroughCellIds) , OriginalCellIdArrayName(originalCellIdArrayName) { diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.h b/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.h index d5cdca95448793914b68069f42e1945d1f18cc1b..fb0f17d9c3692306aedb26214d161d4d738abe0d 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.h +++ b/Filters/HyperTree/vtkHyperTreeGridGeometryImpl.h @@ -34,7 +34,7 @@ public: vtkHyperTreeGridGeometryImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName); + const std::string& originalCellIdArrayName, bool fillMaterial); virtual ~vtkHyperTreeGridGeometryImpl() = default; @@ -88,17 +88,18 @@ protected: /** * Input parameters retrieved from constructor */ - vtkHyperTreeGrid* Input; - vtkPoints* OutPoints; - vtkCellArray* OutCells; - vtkDataSetAttributes* InCellDataAttributes; - vtkDataSetAttributes* OutCellDataAttributes; + vtkHyperTreeGrid* Input = nullptr; + vtkPoints* OutPoints = nullptr; + vtkCellArray* OutCells = nullptr; + vtkDataSetAttributes* InCellDataAttributes = nullptr; + vtkDataSetAttributes* OutCellDataAttributes = nullptr; + bool FillMaterial = true; /** * Retrieved from input for quick access */ - vtkDataArray* InIntercepts; - vtkDataArray* InNormals; + vtkDataArray* InIntercepts = nullptr; + vtkDataArray* InNormals = nullptr; /** * True if input HTG have an interface and if @@ -133,8 +134,8 @@ private: /** * Retrieved from input for quick access */ - vtkUnsignedCharArray* InGhostArray; - vtkBitArray* InMaskArray; + vtkUnsignedCharArray* InGhostArray = nullptr; + vtkBitArray* InMaskArray = nullptr; /** * Input parameters retrieved from constructor diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.cxx b/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.cxx index 3f48b1393314cbafb5075de09475071eba0a75a0..bfe858bda60c3fc16e8ca04f2cb91512944e5b7b 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.cxx +++ b/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.cxx @@ -15,9 +15,9 @@ VTK_ABI_NAMESPACE_BEGIN vtkHyperTreeGridGeometrySmallDimensionsImpl::vtkHyperTreeGridGeometrySmallDimensionsImpl( vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, - bool passThroughCellIds, const std::string& originalCellIdArrayName) + bool passThroughCellIds, const std::string& originalCellIdArrayName, bool fillMaterial) : vtkHyperTreeGridGeometryImpl(input, outPoints, outCells, inCellDataAttributes, - outCellDataAttributes, passThroughCellIds, originalCellIdArrayName) + outCellDataAttributes, passThroughCellIds, originalCellIdArrayName, fillMaterial) { } @@ -96,7 +96,10 @@ void vtkHyperTreeGridGeometrySmallDimensionsImpl::ProcessLeafCellWithInterface( { if (!this->ProbeForCellInterface(cursor->GetGlobalNodeIndex(), false)) { // case type >= 2, pure cell - this->ProcessLeafCellWithoutInterface(cursor); + if (this->FillMaterial) + { + this->ProcessLeafCellWithoutInterface(cursor); + } return; } diff --git a/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.h b/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.h index b18f669f5b5e721b6608a16eb472d58eda726ac6..bfe5da1c3e64d928c9d2a80e2e88db317fdfe408 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.h +++ b/Filters/HyperTree/vtkHyperTreeGridGeometrySmallDimensionsImpl.h @@ -29,7 +29,7 @@ public: vtkHyperTreeGridGeometrySmallDimensionsImpl(vtkHyperTreeGrid* input, vtkPoints* outPoints, vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes, vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds, - const std::string& originalCellIdArrayName); + const std::string& originalCellIdArrayName, bool fillMaterial); ~vtkHyperTreeGridGeometrySmallDimensionsImpl() override = default;