iMSTK
Interactive Medical Simulation Toolkit
imstkHexahedralMesh.cpp
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 #include "imstkHexahedralMesh.h"
8 #include "imstkLogger.h"
9 #include "imstkSurfaceMesh.h"
10 #include "imstkVecDataArray.h"
11 
12 namespace imstk
13 {
14 void
16 {
18 }
19 
20 void
22 {
24 }
25 
26 double
28 {
29  Vec3d v[8];
30  Mat3d A;
31  Vec3d a, b, c;
32  double volume = 0.0;
33  const VecDataArray<double, 3>& vertices = *m_vertexPositions;
34  for (const Vec8i& hexArray : *m_indices)
35  {
36  for (int i = 0; i < 8; ++i)
37  {
38  v[i] = vertices[hexArray[i]];
39  }
40 
41  a = v[7] - v[0];
42  b = v[1] - v[0];
43  c = v[3] - v[5];
44 
45  A << a[0], b[0], c[0],
46  a[1], b[1], c[1],
47  a[2], b[2], c[2];
48 
49  volume += A.determinant();
50 
51  b = v[4] - v[0];
52  c = v[5] - v[6];
53 
54  A << a[0], b[0], c[0],
55  a[1], b[1], c[1],
56  a[2], b[2], c[2];
57 
58  volume += A.determinant();
59 
60  b = v[2] - v[0];
61  c = v[6] - v[3];
62 
63  A << a[0], b[0], c[0],
64  a[1], b[1], c[1],
65  a[2], b[2], c[2];
66 
67  volume += A.determinant();
68  }
69 
70  return volume / 6.0;
71 }
72 
73 std::shared_ptr<SurfaceMesh>
75 {
76  LOG(FATAL) << "error: not implemented.";
77  return nullptr;
78 }
79 } // namespace imstk
void clear() override
Clear all the mesh data.
void print() const override
Print the hexahedral mesh.
void print() const override
Print the surface mesh.
Compound Geometry.
std::shared_ptr< SurfaceMesh > extractSurfaceMesh() override
Extract surface Mesh.
void clear() override
Clears all the mesh data.
Definition: imstkCellMesh.h:52
double getVolume() override
Compute and return the volume of the hexahedral mesh.