| 58 | } |
| 59 | |
| 60 | void 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 | |
| 96 | size_t LongEdgeRemoval::retriangulate() { |
| 97 | const size_t num_faces = m_faces.rows(); |