iMSTK
Interactive Medical Simulation Toolkit
imstkTetrahedralMesh.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 #include "imstkVecDataArray.h"
12 
13 #include <array>
14 
15 namespace imstk
16 {
26 {
27 public:
28  TetrahedralMesh() = default;
29  ~TetrahedralMesh() override = default;
30 
31  static std::string StrainParameterName;
32 
33  IMSTK_TYPE_NAME(TetrahedralMesh)
34 
35 
36  std::shared_ptr<SurfaceMesh> extractSurfaceMesh() override;
39 
43  Vec4d computeBarycentricWeights(const int tetId, const Vec3d& pos) const override;
44 
48  void computeTetrahedronBoundingBox(const size_t& tetId, Vec3d& min, Vec3d& max) const;
49 
50 // Accessors
54  void setTetrahedraAsRemoved(const unsigned int tetId)
55  {
56  m_removedMeshElems.reserve(getNumTetrahedra());
57  m_removedMeshElems.push_back(tetId);
58  }
59 
60  const std::vector<int>& getRemovedTetrahedra() const { return m_removedMeshElems; }
62 
66  double getVolume() override;
67 
68  int getNumTetrahedra() const { return getNumCells(); }
69  void setTetrahedraIndices(std::shared_ptr<VecDataArray<int, 4>> indices) { setCells(indices); }
70  std::shared_ptr<VecDataArray<int, 4>> getTetrahedraIndices() const { return getCells(); }
71 
76  std::unique_ptr<TetrahedralMesh> clone()
77  {
78  return std::unique_ptr<TetrahedralMesh>(cloneImplementation());
79  }
80 
89  std::shared_ptr<VecDataArray<double, 3>> getStrainParameters();
90  void setStrainParameters(std::shared_ptr<VecDataArray<double, 3>> strainParameters);
92 
93 protected:
94  std::vector<int> m_removedMeshElems;
95 
96 private:
97  TetrahedralMesh* cloneImplementation() const;
98 };
99 } // namespace imstk
std::unique_ptr< TetrahedralMesh > clone()
Polymorphic clone, hides the declaration in superclass return own type.
Compound Geometry.
std::shared_ptr< SurfaceMesh > extractSurfaceMesh() override
This method extracts the conforming triangular mesh from the tetrahedral mesh.
int getNumCells() const override
Returns the number of cells.
Represents a set of tetrahedrons & vertices via an array of Vec3d double vertices & Vec4i integer ind...
void setCells(std::shared_ptr< VecDataArray< int, N >> indices)
Get/Set cell connectivity.
std::shared_ptr< VecDataArray< double, 3 > > getStrainParameters()
Get/Set the strain parameters for the tetrahedral mesh the strain parameters are expected to be a Vec...
void computeTetrahedronBoundingBox(const size_t &tetId, Vec3d &min, Vec3d &max) const
Compute the bounding box of a given tetrahedron.
Vec4d computeBarycentricWeights(const int tetId, const Vec3d &pos) const override
compute the barycentric weights of a given point in 3D space for a given the tetrahedra ...
double getVolume() override
Compute and return the volume of the tetrahedral mesh.
void setTetrahedraAsRemoved(const unsigned int tetId)
Get/set method for removed elements from the mesh.
Base class for all volume mesh types.