PeriDyno 1.0.0
Loading...
Searching...
No Matches
EdgeSet.h
Go to the documentation of this file.
1
16#pragma once
17#include "PointSet.h"
18
19namespace dyno
20{
21 class EKey
22 {
23 public:
24 DYN_FUNC EKey()
25 {
26 id[0] = EMPTY;
27 id[1] = EMPTY;
28 }
29
30 DYN_FUNC EKey(PointType v0, PointType v1)
31 {
32 id[0] = v0;
33 id[1] = v1;
34
35 swap(id[0], id[1]);
36 }
37
38 DYN_FUNC inline PointType operator[] (unsigned int i) { return id[i]; }
39 DYN_FUNC inline PointType operator[] (unsigned int i) const { return id[i]; }
40
41 DYN_FUNC inline bool operator>= (const EKey& other) const {
42 if (id[0] >= other.id[0]) return true;
43 if (id[0] == other.id[0] && id[1] >= other.id[1]) return true;
44
45 return false;
46 }
47
48 DYN_FUNC inline bool operator> (const EKey& other) const {
49 if (id[0] > other.id[0]) return true;
50 if (id[0] == other.id[0] && id[1] > other.id[1]) return true;
51
52 return false;
53 }
54
55 DYN_FUNC inline bool operator<= (const EKey& other) const {
56 if (id[0] <= other.id[0]) return true;
57 if (id[0] == other.id[0] && id[1] <= other.id[1]) return true;
58
59 return false;
60 }
61
62 DYN_FUNC inline bool operator< (const EKey& other) const {
63 if (id[0] < other.id[0]) return true;
64 if (id[0] == other.id[0] && id[1] < other.id[1]) return true;
65
66 return false;
67 }
68
69 DYN_FUNC inline bool operator== (const EKey& other) const {
70 return id[0] == other.id[0] && id[1] == other.id[1];
71 }
72
73 DYN_FUNC inline bool operator!= (const EKey& other) const {
74 return id[0] != other.id[0] || id[1] != other.id[1];
75 }
76
77 DYN_FUNC inline bool isValid() const {
78 return id[0] != EMPTY && id[1] != EMPTY;
79 }
80
81 private:
82 DYN_FUNC inline void swap(PointType& v0, PointType& v1)
83 {
84 PointType vt = v0;
85 v0 = v0 < v1 ? v0 : v1;
86 v1 = vt < v1 ? v1 : vt;
87 }
88
89 PointType id[2];
90 };
91
92 template<typename TDataType>
93 class EdgeSet : public PointSet<TDataType>
94 {
95 public:
96 typedef typename TDataType::Real Real;
97 typedef typename TDataType::Coord Coord;
98 typedef typename TopologyModule::Edge Edge;
99
100 EdgeSet();
101 ~EdgeSet() override;
102
103 void setEdges(std::vector<Edge>& edges);
104 void setEdges(DArray<Edge>& edges);
105
113
120
127
128 void copyFrom(EdgeSet<TDataType>& edgeSet);
129
130 bool isEmpty() override;
131
132 void clear() override;
133
134 //TODO:
135 void loadSmeshFile(std::string filename) {};
136
137 protected:
141 virtual void updateEdges() {};
142
143 void updateTopology() override;
144
145 protected:
147
152 };
153}
154
DYN_FUNC bool operator!=(const EKey &other) const
Definition EdgeSet.h:73
DYN_FUNC bool isValid() const
Definition EdgeSet.h:77
PointType id[2]
Definition EdgeSet.h:89
DYN_FUNC EKey(PointType v0, PointType v1)
Definition EdgeSet.h:30
DYN_FUNC bool operator>(const EKey &other) const
Definition EdgeSet.h:48
DYN_FUNC bool operator<(const EKey &other) const
Definition EdgeSet.h:62
DYN_FUNC EKey()
Definition EdgeSet.h:24
DYN_FUNC bool operator<=(const EKey &other) const
Definition EdgeSet.h:55
DYN_FUNC bool operator>=(const EKey &other) const
Definition EdgeSet.h:41
DYN_FUNC PointType operator[](unsigned int i)
Definition EdgeSet.h:38
DYN_FUNC void swap(PointType &v0, PointType &v1)
Definition EdgeSet.h:82
DYN_FUNC bool operator==(const EKey &other) const
Definition EdgeSet.h:69
DArrayList< int > & vertex2Edge()
Get the Ver2 Edge object.
Definition EdgeSet.h:126
void setEdges(DArray< Edge > &edges)
DArray< Edge > & getEdges()
Get all edges with each one containing the indices of two edge ends.
Definition EdgeSet.h:119
bool isEmpty() override
TDataType::Coord Coord
Definition EdgeSet.h:97
TDataType::Real Real
Definition EdgeSet.h:96
void copyFrom(EdgeSet< TDataType > &edgeSet)
Definition EdgeSet.cpp:24
void clear() override
virtual void updateEdges()
Definition EdgeSet.h:141
void loadSmeshFile(std::string filename)
Definition EdgeSet.h:135
DArrayList< int > mVer2Edge
Definition EdgeSet.h:151
void updateTopology() override
Definition EdgeSet.cpp:30
~EdgeSet() override
Definition EdgeSet.cpp:10
DArray< Edge > mEdges
Definition EdgeSet.h:146
void requestPointNeighbors(DArrayList< int > &lists)
Request the neighboring ids of each point according to the mesh topology Be sure update() is called a...
void setEdges(std::vector< Edge > &edges)
TopologyModule::Edge Edge
Definition EdgeSet.h:98
VectorND< PointType, 2 > Edge
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Array< T, DeviceType::GPU > DArray
Definition Array.inl:89
int PointType
constexpr int EMPTY
ArrayList< ElementType, DeviceType::GPU > DArrayList
Definition ArrayList.inl:83