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

Method compute_from_mesh

src/Attributes/VertexVolumeAttribute.cpp:10–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8using namespace PyMesh;
9
10void VertexVolumeAttribute::compute_from_mesh(Mesh& mesh) {
11 const size_t dim = mesh.get_dim();
12 const size_t num_vertices = mesh.get_num_vertices();
13 const size_t num_voxels = mesh.get_num_voxels();
14 const size_t num_vertex_per_voxel = mesh.get_vertex_per_voxel();
15 if (dim != 3 || num_voxels == 0) return;
16
17 VectorI& voxels = mesh.get_voxels();
18 VectorF& volumes = get_voxel_volumes(mesh);
19 VectorF& vertex_volumes = m_values;
20
21 vertex_volumes = VectorF::Zero(num_vertices);
22
23 for (size_t i=0; i<num_voxels; i++) {
24 for (size_t j=0; j<num_vertex_per_voxel; j++) {
25 size_t index = i*num_vertex_per_voxel + j;
26 vertex_volumes[voxels[index]] += volumes[i];
27 }
28 }
29
30 vertex_volumes /= num_vertex_per_voxel;
31}
32
33VectorF& VertexVolumeAttribute::get_voxel_volumes(Mesh& mesh) {
34 std::string voxel_volume_attribute("voxel_volume");

Callers

nothing calls this directly

Calls 5

get_dimMethod · 0.45
get_num_verticesMethod · 0.45
get_num_voxelsMethod · 0.45
get_vertex_per_voxelMethod · 0.45
get_voxelsMethod · 0.45

Tested by

no test coverage detected