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

Method compute_from_hex_mesh

src/Attributes/VertexValanceAttribute.cpp:89–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void VertexValanceAttribute::compute_from_hex_mesh(Mesh& mesh) {
90 const size_t num_vertices = mesh.get_num_vertices();
91 const size_t num_voxels = mesh.get_num_voxels();
92 const size_t num_vertex_per_voxel = mesh.get_vertex_per_voxel();
93 assert(num_vertex_per_voxel == 8);
94 // Vertex ordering
95 // 3 _________ 2
96 // /: /|
97 // 7/ : / |
98 // +--------+6 |
99 // | : | |
100 // | 0:.....|..|1
101 // | ; | /
102 // +--------+/
103 // 4 5
104
105 VectorF& vertex_valance = m_values;
106 vertex_valance = VectorF::Zero(num_vertices);
107
108 std::set<Duplet> edges;
109 for (size_t i=0; i<num_voxels; i++) {
110 VectorI voxel = mesh.get_voxel(i);
111 Duplet edge[12] = {
112 {voxel[0], voxel[1]},
113 {voxel[1], voxel[2]},
114 {voxel[2], voxel[3]},
115 {voxel[3], voxel[0]},
116 {voxel[4], voxel[5]},
117 {voxel[5], voxel[6]},
118 {voxel[6], voxel[7]},
119 {voxel[7], voxel[4]},
120 {voxel[0], voxel[4]},
121 {voxel[1], voxel[5]},
122 {voxel[2], voxel[6]},
123 {voxel[3], voxel[7]} };
124
125 edges.insert(edge[0]);
126 edges.insert(edge[1]);
127 edges.insert(edge[2]);
128 edges.insert(edge[3]);
129 edges.insert(edge[4]);
130 edges.insert(edge[5]);
131 edges.insert(edge[6]);
132 edges.insert(edge[7]);
133 edges.insert(edge[8]);
134 edges.insert(edge[9]);
135 edges.insert(edge[10]);
136 edges.insert(edge[11]);
137 }
138
139 for (auto edge : edges) {
140 const auto& data = edge.get_ori_data();
141 vertex_valance[data[0]] ++;
142 vertex_valance[data[1]] ++;
143 }
144}

Callers

nothing calls this directly

Calls 5

get_voxelMethod · 0.80
get_num_verticesMethod · 0.45
get_num_voxelsMethod · 0.45
get_vertex_per_voxelMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected