VTK-m  2.0
DataSetMeshTriangulation3DMarchingCubes.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 // Copyright (c) 2018, The Regents of the University of California, through
11 // Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
12 // from the U.S. Dept. of Energy). All rights reserved.
13 //
14 // Redistribution and use in source and binary forms, with or without modification,
15 // are permitted provided that the following conditions are met:
16 //
17 // (1) Redistributions of source code must retain the above copyright notice, this
18 // list of conditions and the following disclaimer.
19 //
20 // (2) Redistributions in binary form must reproduce the above copyright notice,
21 // this list of conditions and the following disclaimer in the documentation
22 // and/or other materials provided with the distribution.
23 //
24 // (3) Neither the name of the University of California, Lawrence Berkeley National
25 // Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
26 // used to endorse or promote products derived from this software without
27 // specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32 // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38 // OF THE POSSIBILITY OF SUCH DAMAGE.
39 //
40 //=============================================================================
41 //
42 // This code is an extension of the algorithm presented in the paper:
43 // Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
44 // Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
45 // Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
46 // (LDAV), October 2016, Baltimore, Maryland.
47 //
48 // The PPP2 algorithm and software were jointly developed by
49 // Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
50 // Oliver Ruebel (LBNL)
51 //==============================================================================
52 
53 
54 #ifndef vtk_m_worklet_contourtree_augmented_data_set_mesh_triangulation_3d_marchingcubes_h
55 #define vtk_m_worklet_contourtree_augmented_data_set_mesh_triangulation_3d_marchingcubes_h
56 
57 #include <cstdlib>
58 
64 
65 namespace vtkm
66 {
67 namespace worklet
68 {
69 namespace contourtree_augmented
70 {
71 
73  : public DataSetMesh
75 { // class DataSetMeshTriangulation3DMarchingCubes
76 public:
77  //Constants and case tables
78 
85  static constexpr int MAX_OUTDEGREE = 6; // True for Freudenthal and Marching Cubes
86 
87  // mesh depended helper functions
88  void SetPrepareForExecutionBehavior(bool getMax);
89 
91  vtkm::cont::Token& token) const;
92 
94 
96 
98  IdArrayType& boundaryVertexArray, // output
99  IdArrayType& boundarySortIndexArray, // output
100  MeshBoundary3DExec* meshBoundaryExecObj =
101  nullptr // optional input, included for consistency with ContourTreeMesh
102  ) const;
103 
107  const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler& localToGlobalIdRelabeler,
108  IdArrayType& ownedVertices) const;
109 
110 private:
111  bool UseGetMax; // Define the behavior ofr the PrepareForExecution function
112 }; // class DataSetMesh_Triangulation
113 
114 // creates input mesh
116  vtkm::Id3 meshSize)
117  : DataSetMesh(meshSize)
118 
119 {
120  // Initialize the case tables in vtkm
123  m3d_marchingcubes::N_ALL_NEIGHBOURS,
126  m3d_marchingcubes::
127  CubeVertexPermutations_PermVecLength>( // create 2D array of vectors of lenghts ...PermVecLength
129  m3d_marchingcubes::CubeVertexPermutations, // the array to convert
134  m3d_marchingcubes::
135  VertexConnections_VecLength>( // create 2D array of vectors o lenght ...VecLength
137  m3d_marchingcubes::LinkVertexConnectionsSix, // the array to convert
139  m3d_marchingcubes::VertexConnections_VecLength, // total number of elements
142  m3d_marchingcubes::
143  VertexConnections_VecLength>( // create 2D array of vectors o lenght ...VecLength
145  m3d_marchingcubes::LinkVertexConnectionsEighteen, // the array to convert
147  m3d_marchingcubes::VertexConnections_VecLength, // total number of elements
149  this->InCubeConnectionsSix =
157 }
158 
160 {
161  this->UseGetMax = getMax;
162 }
163 
164 // Get VTKM execution object that represents the structure of the mesh and provides the mesh helper functions on the device
167  vtkm::cont::Token& token) const
168 {
170  this->UseGetMax,
171  this->SortIndices,
172  this->SortOrder,
177  this->InCubeConnectionsSix,
179  device,
180  token);
181 }
182 
184  const
185 {
186  return MeshBoundary3DExec(this->MeshSize, this->SortOrder);
187 }
188 
190  IdArrayType& boundaryVertexArray, // output
191  IdArrayType& boundarySortIndexArray, // output
192  MeshBoundary3DExec* meshBoundaryExecObj // input
193 ) const
194 {
195  vtkm::Id numBoundary = 2 * this->MeshSize[1] * this->MeshSize[0] // xy faces
196  + 2 * this->MeshSize[1] * (this->MeshSize[2] - 2) // yz faces - excluding vertices on xy
197  + 2 * (this->MeshSize[0] - 2) * (this->MeshSize[2] - 2); // xz face interiors
198  auto boundaryId = vtkm::cont::ArrayHandleIndex(numBoundary);
199  ComputeMeshBoundary3D computeMeshBoundary3dWorklet;
200  vtkm::cont::Invoker invoke;
201  invoke(computeMeshBoundary3dWorklet,
202  boundaryId, // input
203  this->SortIndices, // input
204  (meshBoundaryExecObj == NULL) ? this->GetMeshBoundaryExecutionObject()
205  : *meshBoundaryExecObj, // input
206  boundaryVertexArray, // output
207  boundarySortIndexArray // output
208  );
209 }
210 
211 // Overwrite the implemenation from the base DataSetMesh parent class
213  const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler& localToGlobalIdRelabeler,
214  IdArrayType& ownedVertices) const
215 {
216  return this->GetOwnedVerticesByGlobalIdImpl(this, localToGlobalIdRelabeler, ownedVertices);
217 }
218 
219 } // namespace contourtree_augmented
220 } // worklet
221 } // vtkm
222 
223 #endif
vtkm::worklet::contourtree_augmented::MeshBoundary3DExec
Definition: MeshBoundary3D.h:272
Types.h
vtkm::cont::make_ArrayHandle
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:217
vtkm::cont::ArrayHandle< vtkm::Int8 >
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::GetOwnedVerticesByGlobalId
void GetOwnedVerticesByGlobalId(const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler &localToGlobalIdRelabeler, IdArrayType &ownedVertices) const
Get of global indices of the vertices owned by this mesh.
Definition: DataSetMeshTriangulation3DMarchingCubes.h:212
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::make_ArrayHandleGroupVec
VTKM_CONT vtkm::cont::ArrayHandleGroupVec< ArrayHandleType, NUM_COMPONENTS > make_ArrayHandleGroupVec(const ArrayHandleType &array)
make_ArrayHandleGroupVec is convenience function to generate an ArrayHandleGroupVec.
Definition: ArrayHandleGroupVec.h:244
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::InCubeConnectionsSix_NumElements
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 InCubeConnectionsSix_NumElements
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:162
vtkm::worklet::contourtree_augmented::DataSetMesh::SortOrder
IdArrayType SortOrder
Definition: DataSetMesh.h:107
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::InCubeConnectionsEighteen
m3d_marchingcubes::InCubeConnectionsType InCubeConnectionsEighteen
Definition: DataSetMeshTriangulation3DMarchingCubes.h:84
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::LinkVertexConnectionsSix
m3d_marchingcubes::LinkVertexConnectionsType LinkVertexConnectionsSix
Definition: DataSetMeshTriangulation3DMarchingCubes.h:81
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::InCubeConnectionsSix
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt32 InCubeConnectionsSix[InCubeConnectionsSix_NumElements]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:163
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::PrepareForExecution
MeshStructureMarchingCubes PrepareForExecution(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Definition: DataSetMeshTriangulation3DMarchingCubes.h:165
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::LinkVertexConnectionsType
typename vtkm::cont::ArrayHandleGroupVec< vtkm::cont::ArrayHandle< vtkm::IdComponent >, VertexConnections_VecLength > LinkVertexConnectionsType
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:140
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::InCubeConnectionsSix
m3d_marchingcubes::InCubeConnectionsType InCubeConnectionsSix
Definition: DataSetMeshTriangulation3DMarchingCubes.h:83
vtkm::worklet::contourtree_augmented::DataSetMesh::SortIndices
IdArrayType SortIndices
Definition: DataSetMesh.h:111
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::VertexConnections_VecLength
constexpr vtkm::UInt8 VertexConnections_VecLength
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:136
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::UseGetMax
bool UseGetMax
Definition: DataSetMeshTriangulation3DMarchingCubes.h:111
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::CubeVertexPermutations_NumPermutations
constexpr vtkm::UInt8 CubeVertexPermutations_NumPermutations
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:114
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::EdgeBoundaryDetectionMasks
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::Int8 EdgeBoundaryDetectionMasks[N_ALL_NEIGHBOURS]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:82
vtkm::worklet::contourtree_augmented::DataSetMesh::GetOwnedVerticesByGlobalIdImpl
void GetOwnedVerticesByGlobalIdImpl(const MeshTypeObj *mesh, const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler &localToGlobalIdRelabeler, IdArrayType &ownedVertices) const
Compute a list of the global Iss of all vertices that logically belong to the data block represented ...
Definition: DataSetMesh.h:216
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::CubeVertexPermutations
m3d_marchingcubes::CubeVertexPermutationsType CubeVertexPermutations
Definition: DataSetMeshTriangulation3DMarchingCubes.h:80
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::InCubeConnectionsEighteen_NumElements
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 InCubeConnectionsEighteen_NumElements
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:170
ComputeMeshBoundary3D.h
MeshBoundary3D.h
DataSetMesh.h
vtkm::cont::Invoker
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::EdgeBoundaryDetectionMasks
m3d_marchingcubes::EdgeBoundaryDetectionMasksType EdgeBoundaryDetectionMasks
Definition: DataSetMeshTriangulation3DMarchingCubes.h:79
MeshStructureMarchingCubes.h
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::LinkVertexConnectionsEighteen
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent LinkVertexConnectionsEighteen[LinkVertexConnectionsEighteen_NumPairs *VertexConnections_VecLength]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:156
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::LinkVertexConnectionsSix
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent LinkVertexConnectionsSix[LinkVertexConnectionsSix_NumPairs *VertexConnections_VecLength]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:145
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::LinkVertexConnectionsSix_NumPairs
constexpr vtkm::UInt8 LinkVertexConnectionsSix_NumPairs
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:134
vtkm::worklet::contourtree_augmented::DataSetMesh::MeshSize
vtkm::Id3 MeshSize
Definition: DataSetMesh.h:103
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::LinkVertexConnectionsEighteen_NumPairs
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt8 LinkVertexConnectionsEighteen_NumPairs
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:150
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::InCubeConnectionsType
typename vtkm::cont::ArrayHandle< vtkm::UInt32 > InCubeConnectionsType
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:161
vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler
A utility class that converts Ids from local to global given a mesh.
Definition: IdRelabeler.h:79
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::GetBoundaryVertices
void GetBoundaryVertices(IdArrayType &boundaryVertexArray, IdArrayType &boundarySortIndexArray, MeshBoundary3DExec *meshBoundaryExecObj=nullptr) const
Definition: DataSetMeshTriangulation3DMarchingCubes.h:189
vtkm::cont::ExecutionObjectBase
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::Vec< vtkm::Id, 3 >
vtkm::CopyFlag::Off
@ Off
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes
Definition: DataSetMeshTriangulation3DMarchingCubes.h:72
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::GetMeshBoundaryExecutionObject
MeshBoundary3DExec GetMeshBoundaryExecutionObject() const
Definition: DataSetMeshTriangulation3DMarchingCubes.h:183
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::CubeVertexPermutations
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent CubeVertexPermutations[CubeVertexPermutations_NumPermutations *CubeVertexPermutations_PermVecLength]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:126
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::MAX_OUTDEGREE
static constexpr int MAX_OUTDEGREE
Definition: DataSetMeshTriangulation3DMarchingCubes.h:85
vtkm::cont::ArrayHandleGroupVec< vtkm::cont::ArrayHandle< vtkm::IdComponent >, CubeVertexPermutations_PermVecLength >
vtkm::worklet::contourtree_augmented::DataSetMesh
Definition: DataSetMesh.h:97
vtkm::worklet::contourtree_augmented::MeshStructureMarchingCubes
Definition: MeshStructureMarchingCubes.h:72
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::InCubeConnectionsEighteen
VTKM_STATIC_CONSTEXPR_ARRAY vtkm::UInt32 InCubeConnectionsEighteen[InCubeConnectionsEighteen_NumElements]
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:172
vtkm::worklet::contourtree_augmented::m3d_marchingcubes::CubeVertexPermutations_PermVecLength
constexpr vtkm::UInt8 CubeVertexPermutations_PermVecLength
Definition: filter/scalar_topology/worklet/contourtree_augmented/meshtypes/marchingcubes_3D/Types.h:116
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::SetPrepareForExecutionBehavior
void SetPrepareForExecutionBehavior(bool getMax)
Definition: DataSetMeshTriangulation3DMarchingCubes.h:159
vtkm::worklet::contourtree_augmented::ComputeMeshBoundary3D
Definition: ComputeMeshBoundary3D.h:69
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::DataSetMeshTriangulation3DMarchingCubes
DataSetMeshTriangulation3DMarchingCubes(vtkm::Id3 meshSize)
Definition: DataSetMeshTriangulation3DMarchingCubes.h:115
vtkm::cont::ArrayHandleIndex
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
vtkm::worklet::contourtree_augmented::DataSetMeshTriangulation3DMarchingCubes::LinkVertexConnectionsEighteen
m3d_marchingcubes::LinkVertexConnectionsType LinkVertexConnectionsEighteen
Definition: DataSetMeshTriangulation3DMarchingCubes.h:82