iMSTK
Interactive Medical Simulation Toolkit
imstkHexahedralMesh.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkMacros.h"
10 #include "imstkVolumetricMesh.h"
11 
12 namespace imstk
13 {
19 class HexahedralMesh : public VolumetricMesh<8>
20 {
21 public:
22  HexahedralMesh() = default;
23  ~HexahedralMesh() override = default;
24 
25  IMSTK_TYPE_NAME(HexahedralMesh)
26 
27 
28  void clear() override;
31 
35  void print() const override;
36 
39  std::shared_ptr<SurfaceMesh> extractSurfaceMesh() override;
40 
41 // Accessors
45  int getNumHexahedra() const { return getNumCells(); }
46 
50  double getVolume() override;
51 
56  std::unique_ptr<HexahedralMesh> clone()
57  {
58  return std::unique_ptr<HexahedralMesh>(cloneImplementation());
59  }
60 
61 private:
62  HexahedralMesh* cloneImplementation() const
63  {
64  // Do shallow copy
65  HexahedralMesh* geom = new HexahedralMesh(*this);
66  // Deal with deep copy members
67  geom->m_indices = std::make_shared<VecDataArray<int, 8>>(*m_indices);
68  for (auto i : m_cellAttributes)
69  {
70  geom->m_cellAttributes[i.first] = i.second->clone();
71  }
72  geom->m_initialVertexPositions = std::make_shared<VecDataArray<double, 3>>(*m_initialVertexPositions);
73  geom->m_vertexPositions = std::make_shared<VecDataArray<double, 3>>(*m_vertexPositions);
74  for (auto i : m_vertexAttributes)
75  {
76  geom->m_vertexAttributes[i.first] = i.second->clone();
77  }
78  return geom;
79  }
80 };
81 } // namespace imstk
Hexahedral mesh class.
void clear() override
Clear all the mesh data.
int getNumHexahedra() const
Returns the number of hexahedra.
void print() const override
Print the hexahedral mesh.
std::unique_ptr< HexahedralMesh > clone()
Polymorphic clone, hides the declaration in superclass return own type.
Compound Geometry.
int getNumCells() const override
Returns the number of cells.
std::shared_ptr< SurfaceMesh > extractSurfaceMesh() override
Extract surface Mesh.
Base class for all volume mesh types.
double getVolume() override
Compute and return the volume of the hexahedral mesh.