Wildmeshing Toolkit
PointMesh.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "MeshCRTP.hpp"
4 #include "Tuple.hpp"
5 
6 #include <Eigen/Core>
7 
8 namespace wmtk {
9 // Simple mesh without topology. Mainly useful for testing attributes without having to construct
10 // topologies
11 class PointMesh : public MeshCRTP<PointMesh>
12 {
13 private:
14  Tuple vertex_tuple_from_id(int64_t id) const;
15 
16 public:
17  friend class MeshCRTP<PointMesh>;
18  template <typename U, typename MeshType, int Dim>
19  friend class attribute::Accessor;
20  PointMesh();
21  ~PointMesh() override;
22  PointMesh(int64_t size);
23  PointMesh(const PointMesh& o) = delete;
24  PointMesh(PointMesh&& o) = default;
25  PointMesh& operator=(const PointMesh& o) = delete;
26  PointMesh& operator=(PointMesh&& o) = default;
27 
28  [[noreturn]] Tuple switch_tuple(const Tuple& tuple, PrimitiveType type) const override;
29  bool is_ccw(const Tuple& tuple) const override;
30  using Mesh::is_boundary;
31  bool is_boundary(PrimitiveType pt, const Tuple& tuple) const override;
32  bool is_boundary_vertex(const Tuple& tuple) const;
33 
34  void initialize(int64_t count);
35 
36 
37  bool is_valid(const Tuple& tuple)
38  const final override;
39 
40  bool is_connectivity_valid() const override { return true; }
41 
42  std::vector<std::vector<TypedAttributeHandle<int64_t>>> connectivity_attributes()
43  const override;
44 
45  std::vector<Tuple> orient_vertices(const Tuple& tuple) const override;
46 
47 protected:
48  using MeshCRTP<PointMesh>::id; // getting the (simplex) prototype
49  int64_t id(const Tuple& tuple, PrimitiveType type) const;
50 
58  Tuple tuple_from_id(const PrimitiveType type, const int64_t gid) const override;
59 };
60 
61 inline int64_t PointMesh::id(const Tuple& tuple, PrimitiveType type) const
62 {
63  switch (type) {
64  case PrimitiveType::Vertex: return tuple.m_global_cid;
68  default: assert(false); // "Tuple switch: Invalid primitive type"
69  }
70 
71  return -1;
72 }
73 } // namespace wmtk
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_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:106
std::vector< Tuple > orient_vertices(const Tuple &tuple) const override
Definition: PointMesh.cpp:84
PointMesh & operator=(const PointMesh &o)=delete
Tuple vertex_tuple_from_id(int64_t id) const
Definition: PointMesh.cpp:4
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: PointMesh.cpp:71
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition: Mesh.cpp:106
PointMesh(PointMesh &&o)=default
Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const override
switch the orientation of the Tuple of the given dimension
Definition: PointMesh.cpp:21
PointMesh(const PointMesh &o)=delete
bool is_valid(const Tuple &tuple) const final override
check validity of tuple including its hash
Definition: PointMesh.cpp:62
~PointMesh() override
std::vector< std::vector< TypedAttributeHandle< int64_t > > > connectivity_attributes() const override
Returns a vector of vectors of attribute handles.
Definition: PointMesh.cpp:77
bool is_ccw(const Tuple &tuple) const override
TODO this needs dimension?
Definition: PointMesh.cpp:25
bool is_boundary_vertex(const Tuple &tuple) const
Definition: PointMesh.cpp:45
PointMesh & operator=(PointMesh &&o)=default
void initialize(int64_t count)
Definition: PointMesh.cpp:51
bool is_connectivity_valid() const override
Definition: PointMesh.hpp:40
int64_t m_global_cid
Definition: Tuple.hpp:46
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
Definition: Accessor.hpp:6