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

Method split_long_edges

tools/MeshUtils/LongEdgeRemoval.cpp:60–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60void LongEdgeRemoval::split_long_edges(Float max_length) {
61 const size_t dim = m_vertices.cols();
62 const size_t num_ori_vertices = m_vertices.rows();
63 size_t vertex_count = num_ori_vertices;
64 std::vector<VectorF> new_vertices;
65 for (auto& itr : m_edge_map) {
66 const auto& edge = itr.first;
67 const auto& raw_edge = edge.get_ori_data();
68 std::list<VectorF> chain;
69 chain.push_back(m_vertices.row(raw_edge[0]));
70 chain.push_back(m_vertices.row(raw_edge[1]));
71 Float edge_length = (chain.front() - chain.back()).norm();
72 split(chain, chain.begin(), edge_length, max_length);
73
74 DupletMap<size_t>::ValueType vertex_indices;
75 vertex_indices.push_back(raw_edge[0]);
76 const auto begin = std::next(chain.begin());
77 const auto end = std::prev(chain.end());
78 for (auto itr = begin; itr != end; itr++) {
79 new_vertices.push_back(*itr);
80 vertex_indices.push_back(vertex_count);
81 vertex_count++;
82 }
83 vertex_indices.push_back(raw_edge[1]);
84
85 itr.second = vertex_indices;
86 }
87
88 m_vertices.conservativeResize(vertex_count, dim);
89 if (new_vertices.size() > 0) {
90 m_vertices.block(num_ori_vertices, 0,
91 vertex_count - num_ori_vertices, dim) =
92 MatrixUtils::rowstack(new_vertices);
93 }
94}
95
96size_t LongEdgeRemoval::retriangulate() {
97 const size_t num_faces = m_faces.rows();

Callers 6

mainFunction · 0.80
fix_meshFunction · 0.80
old_fix_meshFunction · 0.80
repousse_allFunction · 0.80
repousseFunction · 0.80
mainFunction · 0.80

Calls 6

nextFunction · 0.85
normMethod · 0.80
splitFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected