Wildmeshing Toolkit
EdgeMesh.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Core>
5 #include "MeshCRTP.hpp"
6 #include "Tuple.hpp"
7 
8 namespace wmtk {
9 
10 namespace operations::utils {
11 class MultiMeshEdgeSplitFunctor;
12 class MultiMeshEdgeCollapseFunctor;
13 class UpdateEdgeOperationMultiMeshMapFunctor;
14 } // namespace operations::utils
15 class EdgeMesh : public MeshCRTP<EdgeMesh>
16 {
17 public:
18  friend class MeshCRTP<EdgeMesh>;
19  template <typename U, typename MeshType, int Dim>
20  friend class attribute::Accessor;
24  EdgeMesh();
25  ~EdgeMesh() override;
26  EdgeMesh(const EdgeMesh& o) = delete;
27  EdgeMesh(EdgeMesh&& o) = default;
28  EdgeMesh& operator=(const EdgeMesh& o) = delete;
29  EdgeMesh& operator=(EdgeMesh&& o) = default;
30 
31  Tuple switch_tuple(const Tuple& tuple, PrimitiveType type) const override;
32 
33  bool is_ccw(const Tuple& tuple) const override;
34  using Mesh::is_boundary;
35  bool is_boundary(PrimitiveType, const Tuple& tuple) const override;
36  bool is_boundary_vertex(const Tuple& tuple) const;
37 
38 
39  void initialize(Eigen::Ref<const RowVectors2l> E, bool is_free = false);
40  void initialize_free(int64_t count);
41 
42  void initialize(
43  Eigen::Ref<const RowVectors2l> EV,
44  Eigen::Ref<const RowVectors2l> EE,
45  Eigen::Ref<const VectorXl> VE);
46 
47  bool is_valid(const Tuple& tuple) const final override;
48 
49  bool is_connectivity_valid() const override;
50 
51  std::vector<std::vector<TypedAttributeHandle<int64_t>>> connectivity_attributes()
52  const override;
53 
54  Tuple switch_vertex(const Tuple& tuple) const;
55  Tuple switch_edge(const Tuple& tuple) const;
56 
57  std::vector<Tuple> orient_vertices(const Tuple& tuple) const override;
58 
59 protected:
60  int64_t id(const Tuple& tuple, PrimitiveType type) const;
61  using MeshCRTP<EdgeMesh>::id; // getting the (simplex) prototype
62 
63  int64_t id_vertex(const Tuple& tuple) const { return id(tuple, PrimitiveType::Vertex); }
64  int64_t id_edge(const Tuple& tuple) const { return id(tuple, PrimitiveType::Edge); }
65 
73  Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const override;
74 
75  Tuple tuple_from_global_ids(int64_t eid, int64_t vid) const;
76 
77 protected:
79 
82 
83  Tuple vertex_tuple_from_id(int64_t id) const;
84  Tuple edge_tuple_from_id(int64_t id) const;
85 
86  // internal structure that encapsulations the actual execution of split and collapse
88 };
89 
90 inline Tuple EdgeMesh::switch_vertex(const Tuple& tuple) const
91 {
92  return switch_tuple(tuple, PrimitiveType::Vertex);
93 }
94 inline Tuple EdgeMesh::switch_edge(const Tuple& tuple) const
95 {
96  return switch_tuple(tuple, PrimitiveType::Edge);
97 }
98 inline int64_t EdgeMesh::id(const Tuple& tuple, PrimitiveType type) const
99 {
100  switch (type) {
101  case PrimitiveType::Vertex: {
102  const attribute::Accessor<int64_t, EdgeMesh> ev_accessor =
103  create_const_accessor<int64_t>(m_ev_handle);
104  auto ev = ev_accessor.const_vector_attribute<2>(tuple);
105  return ev(tuple.m_local_vid);
106  }
107  case PrimitiveType::Edge: {
108  return tuple.m_global_cid;
109  }
112  default: assert(false); // "Tuple id: Invalid primitive type")
113  }
114 
115  return -1;
116 }
117 } // namespace wmtk
Tuple switch_edge(const Tuple &tuple) const
Definition: EdgeMesh.hpp:94
attribute::TypedAttributeHandle< int64_t > m_ee_handle
Definition: EdgeMesh.hpp:81
Tuple tuple_from_global_ids(int64_t eid, int64_t vid) const
Definition: EdgeMesh.cpp:196
Tuple switch_vertex(const Tuple &tuple) const
Definition: EdgeMesh.hpp:90
int64_t id_edge(const Tuple &tuple) const
Definition: EdgeMesh.hpp:64
bool is_connectivity_valid() const override
Definition: EdgeMesh.cpp:236
EdgeMesh & operator=(EdgeMesh &&o)=default
Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const override
switch the orientation of the Tuple of the given dimension
Definition: EdgeMesh.cpp:38
bool is_boundary_vertex(const Tuple &tuple) const
Definition: EdgeMesh.cpp:31
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:106
void initialize_free(int64_t count)
Definition: EdgeMesh.cpp:141
Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const override
internal function that returns the tuple of requested type, and has the global index cid
Definition: EdgeMesh.cpp:148
Tuple edge_tuple_from_id(int64_t id) const
Definition: EdgeMesh.cpp:188
std::vector< Tuple > orient_vertices(const Tuple &tuple) const override
Definition: EdgeMesh.cpp:286
attribute::TypedAttributeHandle< int64_t > m_ev_handle
Definition: EdgeMesh.hpp:80
Tuple vertex_tuple_from_id(int64_t id) const
Definition: EdgeMesh.cpp:171
bool is_ccw(const Tuple &tuple) const override
TODO this needs dimension?
Definition: EdgeMesh.cpp:92
int64_t id_vertex(const Tuple &tuple) const
Definition: EdgeMesh.hpp:63
attribute::TypedAttributeHandle< int64_t > m_ve_handle
Definition: EdgeMesh.hpp:78
~EdgeMesh() override
void initialize(Eigen::Ref< const RowVectors2l > E, bool is_free=false)
Definition: EdgeMesh.cpp:132
EdgeMesh(const EdgeMesh &o)=delete
EdgeMesh & operator=(const EdgeMesh &o)=delete
bool is_valid(const Tuple &tuple) const final override
check validity of tuple including its hash
Definition: EdgeMesh.cpp:214
EdgeMesh(EdgeMesh &&o)=default
std::vector< std::vector< TypedAttributeHandle< int64_t > > > connectivity_attributes() const override
Returns a vector of vectors of attribute handles.
Definition: EdgeMesh.cpp:275
A Curiously Recurring Template Pattern shim to enable generic specialization of functions.
Definition: MeshCRTP.hpp:24
int64_t id(const Tuple &tuple, PrimitiveType type) const
return the global id of the Tuple of the given dimension
Definition: Mesh.hpp:1020
bool is_free() const
Definition: Mesh.hpp:987
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:106
int8_t m_local_vid
Definition: Tuple.hpp:47
int64_t m_global_cid
Definition: Tuple.hpp:46
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
ConstMapResult< D > const_vector_attribute(const ArgType &t) const
Definition: Accessor.hpp:6