Wildmeshing Toolkit
PointMesh.cpp
Go to the documentation of this file.
1 #include "PointMesh.hpp"
2 
3 namespace wmtk {
5 {
6  return Tuple(-1, -1, -1, id);
7 }
8 
9 PointMesh::~PointMesh() = default;
11  : MeshCRTP<PointMesh>(0)
12 {}
13 
14 
15 PointMesh::PointMesh(int64_t size)
16  : PointMesh()
17 {
18  initialize(size);
19 }
20 
22 {
23  throw std::runtime_error("Tuple switch: Invalid primitive type");
24 }
25 bool PointMesh::is_ccw(const Tuple&) const
26 {
27  // trivial orientation so nothing can happen
28  return true;
29 }
30 bool PointMesh::is_boundary(PrimitiveType pt, const Tuple& tuple) const
31 {
32  switch (pt) {
33  case PrimitiveType::Vertex: return is_boundary_vertex(tuple);
37  default: break;
38  }
39  assert(
40  false); // "tried to compute the boundary of a point mesh for an invalid simplex dimension"
41  // every point is on the interior as it has no boundary simplices
42  return false;
43 }
44 
46 {
47  // every point is on the interior as it has no boundary simplices
48  return false;
49 }
50 
51 void PointMesh::initialize(int64_t count)
52 {
53  set_capacities({count});
56  for (int64_t i = 0; i < capacity(PrimitiveType::Vertex); ++i) {
57  v_flag_accessor.index_access().scalar_attribute(i) |= 0x1;
58  }
59 }
60 
61 
62 bool PointMesh::is_valid(const Tuple& tuple) const
63 {
64  if (!Mesh::is_valid(tuple)) {
65  return false;
66  }
67  return true;
68 }
69 
70 
71 Tuple PointMesh::tuple_from_id(const PrimitiveType type, const int64_t gid) const
72 {
73  assert(type == PrimitiveType::Vertex); // "Tuple switch: Invalid primitive type"
74  return vertex_tuple_from_id(gid);
75 }
76 
77 std::vector<std::vector<TypedAttributeHandle<int64_t>>> PointMesh::connectivity_attributes() const
78 {
79  std::vector<std::vector<TypedAttributeHandle<int64_t>>> handles(0);
80 
81  return handles;
82 }
83 
84 std::vector<Tuple> PointMesh::orient_vertices(const Tuple& tuple) const
85 {
86  return {tuple};
87 }
88 
89 } // namespace wmtk
A Curiously Recurring Template Pattern shim to enable generic specialization of functions.
Definition: MeshCRTP.hpp:24
void set_capacities(std::vector< int64_t > capacities)
int64_t capacity(PrimitiveType type) const
read in the m_capacities return the upper bound for the number of entities of the given dimension
virtual bool is_valid(const Tuple &tuple) const
check validity of tuple including its hash
Definition: Mesh.cpp:112
void reserve_attributes_to_fit()
reserve space for all attributes data types for all dimensional simplices
const attribute::Accessor< char > get_flag_accessor(PrimitiveType type) const
Definition: Mesh.cpp:158
std::vector< Tuple > orient_vertices(const Tuple &tuple) const override
Definition: PointMesh.cpp:84
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
Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const override
switch the orientation of the Tuple of the given dimension
Definition: PointMesh.cpp:21
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
void initialize(int64_t count)
Definition: PointMesh.cpp:51
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
CachingBaseType & index_access()
Definition: Accessor.hpp:95
T & scalar_attribute(const int64_t index)
Definition: Accessor.hpp:6