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

Method connect_end_loops

tools/Wires/Inflator/SimpleInflator.cpp:192–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void SimpleInflator::connect_end_loops() {
193 const size_t dim = m_wire_network->get_dim();
194 const Float ave_thickness = m_thickness.sum() / m_thickness.size();
195 const auto& edge_lengths = m_wire_network->get_attribute("edge_length");
196 const size_t num_edges = m_wire_network->get_num_edges();
197 const size_t loop_size = m_profile->size();
198
199 const MatrixIr connecting_faces = generate_faces_connecting_loops(
200 loop_size, dim != 2);
201 const size_t num_connecting_faces = connecting_faces.rows();
202
203 for (size_t i=0; i<num_edges; i++) {
204 Float edge_length = edge_lengths(i, 0);
205 const auto& end_loops = m_end_loops[i];
206 const size_t num_segments = std::max(1.0,
207 std::round(edge_length / ave_thickness / m_aspect_max));
208 MatrixFr pts((num_segments+1)*loop_size, dim);
209
210 for (size_t j=0; j<num_segments+1; j++) {
211 Float alpha = Float(j) / Float(num_segments);
212 pts.block(j*loop_size, 0, loop_size, dim) =
213 end_loops.first * (1.0 - alpha) + end_loops.second * alpha;
214 }
215
216 MatrixIr faces(num_connecting_faces * num_segments, 3);
217 for (size_t j=0; j<num_segments; j++) {
218 faces.block(j*num_connecting_faces, 0, num_connecting_faces, 3) =
219 connecting_faces.array() + j*loop_size;
220 }
221
222 m_vertex_list.push_back(pts);
223 m_face_list.push_back(faces.array() + m_num_vertex_accumulated);
224 m_face_source_list.push_back(int(i)*(-1)-1);
225 m_num_vertex_accumulated += pts.rows();
226 }
227}
228
229void SimpleInflator::finalize() {
230 const size_t dim = m_wire_network->get_dim();

Callers

nothing calls this directly

Calls 5

get_dimMethod · 0.45
sizeMethod · 0.45
get_attributeMethod · 0.45
get_num_edgesMethod · 0.45

Tested by

no test coverage detected