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

Class ShortEdgeRemoval

tools/MeshUtils/ShortEdgeRemoval.h:12–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace PyMesh {
11
12class ShortEdgeRemoval {
13 public:
14 ShortEdgeRemoval(const MatrixFr& vertices, const MatrixIr& faces);
15
16 public:
17 /**
18 * Importance is an integer value per vertex. The vertex with higher
19 * importance would keep its position during edge collapsing. Mid-point
20 * is used when collapsing edge with same importance at each end.
21 *
22 * Vertex with negative importance is not considered during collapsing.
23 * i.e. they will keep their original location.
24 */
25 void set_importance(const VectorI& importance) {
26 m_importance = importance;
27 }
28 /**
29 * Remove all edges that <= thresold
30 * If thresold=0, remove all degenerated edges.
31 */
32 size_t run(Float threshold);
33 MatrixFr get_vertices() const;
34 MatrixIr get_faces() const { return m_faces; }
35 VectorI get_face_indices() const { return m_face_indices; }
36
37 private:
38 using Edge = Duplet;
39
40 void init();
41 void update();
42 void init_vertex_map();
43 void init_face_indices();
44 void init_edges();
45 void init_edge_length_heap();
46 void init_vertex_face_neighbors();
47 void update_vertices();
48 void update_faces();
49 void update_importance();
50 void collapse(Float threshold);
51 bool edge_is_valid(size_t edge_idx) const;
52 bool edge_can_be_collapsed(size_t edge_idx) const;
53 bool collapse_would_cause_fold_over(size_t edge_idx,
54 const VectorF& v) const;
55 bool faces_would_flip(size_t i1, size_t i2, const VectorF& v,
56 const std::vector<size_t>& faces) const;
57 bool face_would_flip(const VectorF& v_old, const VectorF& v_new,
58 const VectorF& v_o1, const VectorF& v_o2) const;
59 void collapse_edge(size_t edge_idx);
60 VectorF get_vertex(size_t i) const;
61 Float min_edge_length() const;
62 Float compute_edge_length(const Edge& e) const;
63 size_t get_num_vertices() const;
64 size_t get_num_faces() const;
65 size_t get_dim() const;
66
67 private:
68 std::vector<size_t> m_vertex_map;
69 std::vector<Edge> m_edges;

Callers 1

__collapse_CMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected