PeriDyno 1.0.0
Loading...
Searching...
No Matches
QuadSet.h
Go to the documentation of this file.
1
16
17#pragma once
18#include "EdgeSet.h"
19
20namespace dyno
21{
22 class QKey
23 {
24 public:
25 DYN_FUNC QKey()
26 {
27 id[0] = EMPTY;
28 id[1] = EMPTY;
29 id[2] = EMPTY;
30 id[3] = EMPTY;
31 }
32
33 DYN_FUNC QKey(PointType v0, PointType v1, PointType v2, PointType v3)
34 {
35 id[0] = v0;
36 id[1] = v1;
37 id[2] = v2;
38 id[3] = v3;
39
40
41 }
42
43 DYN_FUNC inline PointType operator[] (unsigned int i) { return id[i]; }
44 DYN_FUNC inline PointType operator[] (unsigned int i) const { return id[i]; }
45
46 DYN_FUNC inline bool operator>= (const QKey& other) const {
47 if (id[0] >= other.id[0]) return true;
48 if (id[0] == other.id[0] && id[1] >= other.id[1]) return true;
49 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] >= other.id[2]) return true;
50 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] == other.id[2] && id[3] >= other.id[3]) return true;
51
52 return false;
53 }
54
55 DYN_FUNC inline bool operator> (const QKey& 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 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] > other.id[2]) return true;
59 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] == other.id[2] && id[3] > other.id[3]) return true;
60
61 return false;
62 }
63
64 DYN_FUNC inline bool operator<= (const QKey& other) const {
65 if (id[0] <= other.id[0]) return true;
66 if (id[0] == other.id[0] && id[1] <= other.id[1]) return true;
67 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] <= other.id[2]) return true;
68 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] == other.id[2] && id[3] <= other.id[3]) return true;
69 return false;
70 }
71
72 DYN_FUNC inline bool operator< (const QKey& other) const {
73 if (id[0] < other.id[0]) return true;
74 if (id[0] == other.id[0] && id[1] < other.id[1]) return true;
75 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] < other.id[2]) return true;
76 if (id[0] == other.id[0] && id[1] == other.id[1] && id[2] == other.id[2] && id[3] < other.id[3]) return true;
77 return false;
78 }
79
80 DYN_FUNC inline bool operator== (const QKey& other) const {
81 return id[0] == other.id[0] && id[1] == other.id[1] && id[2] == other.id[2] && id[3] == other.id[3];
82 }
83
84 DYN_FUNC inline bool operator!= (const QKey& other) const {
85 return id[0] != other.id[0] || id[1] != other.id[1] || id[2] != other.id[2] || id[3] != other.id[3];
86 }
87
88 private:
89 DYN_FUNC inline void swap(PointType& v0, PointType& v1)
90 {
91 PointType vt = v0;
92 v0 = v0 < v1 ? v0 : v1;
93 v1 = vt < v1 ? v1 : vt;
94 }
95
96 PointType id[4];
97 };
98
99 template<typename TDataType>
100 class QuadSet : public EdgeSet<TDataType>
101 {
102 public:
103 typedef typename TDataType::Real Real;
104 typedef typename TDataType::Coord Coord;
105 typedef typename TopologyModule::Quad Quad;
106
109
111
112 void setQuads(std::vector<Quad>& quads);
113 void setQuads(DArray<Quad>& quads);
114
116
117 //void loadObjFile(std::string filename);
118
120
121 bool isEmpty() override;
122
123 public:
124 DEF_ARRAY_OUT(Coord, VertexNormal, DeviceType::GPU, "");
125
126 protected:
127 void updateTopology() override;
128
129 void updateEdges() override;
130
132
133 virtual void updateQuads() {};
134
135 private:
138
140 };
141}
142
DYN_FUNC QKey(PointType v0, PointType v1, PointType v2, PointType v3)
Definition QuadSet.h:33
DYN_FUNC PointType operator[](unsigned int i)
Definition QuadSet.h:43
DYN_FUNC bool operator>(const QKey &other) const
Definition QuadSet.h:55
PointType id[4]
Definition QuadSet.h:96
DYN_FUNC void swap(PointType &v0, PointType &v1)
Definition QuadSet.h:89
DYN_FUNC bool operator!=(const QKey &other) const
Definition QuadSet.h:84
DYN_FUNC bool operator<(const QKey &other) const
Definition QuadSet.h:72
DYN_FUNC bool operator==(const QKey &other) const
Definition QuadSet.h:80
DYN_FUNC bool operator>=(const QKey &other) const
Definition QuadSet.h:46
DYN_FUNC QKey()
Definition QuadSet.h:25
DYN_FUNC bool operator<=(const QKey &other) const
Definition QuadSet.h:64
void copyFrom(QuadSet< TDataType > &quadSet)
bool isEmpty() override
void updateTopology() override
void updateVertexNormal()
void setQuads(DArray< Quad > &quads)
void setQuads(std::vector< Quad > &quads)
DArray<::dyno::TopologyModule::Edg2Quad > mEdg2Quad
Definition QuadSet.h:139
TopologyModule::Quad Quad
Definition QuadSet.h:105
TDataType::Real Real
Definition QuadSet.h:103
DArray< Quad > & getQuads()
Definition QuadSet.h:110
DArrayList< int > & getVertex2Quads()
virtual void updateQuads()
Definition QuadSet.h:133
DArray< Quad > mQuads
Definition QuadSet.h:136
DEF_ARRAY_OUT(Coord, VertexNormal, DeviceType::GPU, "")
TDataType::Coord Coord
Definition QuadSet.h:104
void updateEdges() override
DArrayList< int > mVer2Quad
Definition QuadSet.h:137
VectorND< PointType, 4 > Quad
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