| 9 | namespace PyMesh { |
| 10 | |
| 11 | class MeshSeparator { |
| 12 | public: |
| 13 | MeshSeparator(const MatrixIr& elements); |
| 14 | |
| 15 | enum ConnectivityType { |
| 16 | VERTEX, |
| 17 | FACE, |
| 18 | VOXEL |
| 19 | }; |
| 20 | |
| 21 | /** |
| 22 | * Connectivity type define what is considered as "connected". |
| 23 | */ |
| 24 | void set_connectivity_type(ConnectivityType connectivity) { |
| 25 | m_connectivity_type = connectivity; |
| 26 | } |
| 27 | |
| 28 | size_t separate(); |
| 29 | |
| 30 | MatrixIr get_component(size_t i) const { |
| 31 | return m_components.at(i); |
| 32 | } |
| 33 | |
| 34 | VectorI get_sources(size_t i) const { |
| 35 | return m_sources.at(i); |
| 36 | } |
| 37 | |
| 38 | void clear(); |
| 39 | |
| 40 | private: |
| 41 | void compute_connectivity(); |
| 42 | void compute_vertex_connectivity(); |
| 43 | void compute_face_connectivity(); |
| 44 | void compute_voxel_connectivity(); |
| 45 | |
| 46 | MatrixIr flood(size_t seed, VectorI& sources); |
| 47 | std::vector<size_t> get_adjacent_element(size_t fi); |
| 48 | |
| 49 | private: |
| 50 | std::vector<MatrixIr> m_components; |
| 51 | std::vector<VectorI> m_sources; |
| 52 | MatrixIr m_elements; |
| 53 | std::vector<bool> m_visited; |
| 54 | |
| 55 | ConnectivityType m_connectivity_type; |
| 56 | |
| 57 | using VertexConnector = Singleton; |
| 58 | using FaceConnector = Duplet; |
| 59 | using TetConnector = Triplet; |
| 60 | using HexConnector = Quadruplet; |
| 61 | using AdjElements = MultipletMap<Singleton, size_t>::ValueType; |
| 62 | |
| 63 | MultipletMap<Singleton, size_t> m_vertex_connectivity; |
| 64 | MultipletMap<Duplet, size_t> m_face_connectivity; |
| 65 | MultipletMap<Triplet, size_t> m_tet_connectivity; |
| 66 | MultipletMap<Quadruplet, size_t> m_hex_connectivity; |
| 67 | }; |
| 68 |
no outgoing calls
no test coverage detected