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

Method compute_from_mesh

src/Attributes/VoxelCentroidAttribute.cpp:8–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace PyMesh;
7
8void VoxelCentroidAttribute::compute_from_mesh(Mesh& mesh) {
9 const size_t num_voxels = mesh.get_num_voxels();
10 const size_t vertex_per_voxel = mesh.get_vertex_per_voxel();
11
12 VectorF& centroids = m_values;
13 centroids.resize(num_voxels*3);
14
15 for (size_t i=0; i<num_voxels; i++) {
16 VectorI voxel = mesh.get_voxel(i);
17
18 Vector3F centroid = Vector3F::Zero();
19 for (size_t j=0; j<vertex_per_voxel; j++) {
20 centroid += mesh.get_vertex(voxel[j]);
21 }
22 centroid /= vertex_per_voxel;
23
24 centroids.segment<3>(i*3) = centroid;
25 }
26}

Callers

nothing calls this directly

Calls 4

get_voxelMethod · 0.80
get_num_voxelsMethod · 0.45
get_vertex_per_voxelMethod · 0.45
get_vertexMethod · 0.45

Tested by

no test coverage detected