MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute_signed_hex_volume

Method compute_signed_hex_volume

src/Attributes/VoxelVolumeAttribute.cpp:77–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77Float VoxelVolumeAttribute::compute_signed_hex_volume(Mesh& mesh, size_t voxel_idx) {
78 VectorI voxel = mesh.get_voxel(voxel_idx);
79 assert(voxel.size() == 8);
80 // v
81 // 3----------2
82 // |\ ^ |\
83 // | \ | | \
84 // | \ | | \
85 // | 7------+---6
86 // | | +-- |-- | -> u
87 // 0---+---\--1 |
88 // \ | \ \ |
89 // \ | \ \ |
90 // \| w \|
91 // 4----------5
92
93 Vector3F v[8] = {
94 mesh.get_vertex(voxel[0]),
95 mesh.get_vertex(voxel[1]),
96 mesh.get_vertex(voxel[2]),
97 mesh.get_vertex(voxel[3]),
98 mesh.get_vertex(voxel[4]),
99 mesh.get_vertex(voxel[5]),
100 mesh.get_vertex(voxel[6]),
101 mesh.get_vertex(voxel[7])
102 };
103
104 Vector3F face_centers[6] = {
105 0.25 * (v[0] + v[1] + v[2] + v[3]),
106 0.25 * (v[4] + v[5] + v[6] + v[7]),
107 0.25 * (v[0] + v[1] + v[5] + v[4]),
108 0.25 * (v[2] + v[3] + v[7] + v[6]),
109 0.25 * (v[0] + v[4] + v[7] + v[3]),
110 0.25 * (v[1] + v[2] + v[6] + v[5]),
111 };
112
113 Vector3F centroid = 0.125 * (
114 v[0] + v[1] + v[2] + v[3] +
115 v[4] + v[5] + v[6] + v[7]);
116
117 return
118 ::compute_abs_tet_volume(centroid, face_centers[0], v[0], v[1]) +
119 ::compute_abs_tet_volume(centroid, face_centers[0], v[1], v[2]) +
120 ::compute_abs_tet_volume(centroid, face_centers[0], v[2], v[3]) +
121 ::compute_abs_tet_volume(centroid, face_centers[0], v[3], v[0]) +
122
123 ::compute_abs_tet_volume(centroid, face_centers[1], v[4], v[5]) +
124 ::compute_abs_tet_volume(centroid, face_centers[1], v[5], v[6]) +
125 ::compute_abs_tet_volume(centroid, face_centers[1], v[6], v[7]) +
126 ::compute_abs_tet_volume(centroid, face_centers[1], v[7], v[4]) +
127
128 ::compute_abs_tet_volume(centroid, face_centers[2], v[0], v[1]) +
129 ::compute_abs_tet_volume(centroid, face_centers[2], v[1], v[5]) +
130 ::compute_abs_tet_volume(centroid, face_centers[2], v[5], v[4]) +
131 ::compute_abs_tet_volume(centroid, face_centers[2], v[4], v[0]) +
132
133 ::compute_abs_tet_volume(centroid, face_centers[3], v[2], v[3]) +
134 ::compute_abs_tet_volume(centroid, face_centers[3], v[3], v[7]) +

Callers

nothing calls this directly

Calls 4

compute_abs_tet_volumeFunction · 0.85
get_voxelMethod · 0.80
sizeMethod · 0.45
get_vertexMethod · 0.45

Tested by

no test coverage detected