PeriDyno 1.0.0
Loading...
Searching...
No Matches
PolyExtrude.h
Go to the documentation of this file.
1
16
17#pragma once
21#include "Group.h"
22
23namespace dyno
24{
25 template<typename TDataType>
26 class PolyExtrude : public Group<TDataType>
27 {
29
30 public:
31 typedef typename TDataType::Real Real;
32 typedef typename TDataType::Coord Coord;
33
34
35
37
38 protected:
39
40
42 {
43 int oriP[10];
44
45 int newP[10];
46
47 int primID = -1;
48
50 {
51 iniArray();
52 };
53
54 Prim_point_Point(bool useOri, int prim, int p0, int p1, int p2)
55 {
56 iniArray();
57
58 if (useOri)
59 {
60 this->oriP[0] = p0;
61 this->oriP[1] = p1;
62 this->oriP[2] = p2;
63 }
64 else
65 {
66 this->newP[0] = p0;
67 this->newP[1] = p1;
68 this->newP[2] = p2;
69 }
70 this->primID = prim;
71 };
72 Prim_point_Point(bool useOri, int prim, int p)
73 {
74 iniArray();
75
76 if (useOri)
77 {
78 for (int i = 0; i < sizeof(oriP) / sizeof(oriP[0]); i++)
79 {
80 if (oriP[i] == -1) { oriP[i] = p; }
81 }
82 }
83 else
84 {
85 for (int i = 0; i < sizeof(newP) / sizeof(newP[0]); i++)
86 {
87 if (newP[i] == -1) { newP[i] = p; }
88 }
89 }
90 this->primID = prim;
91 };
92 void setNewID_byOriID(int np, int op)
93 {
94 for (int i = 0; i < sizeof(oriP) / sizeof(oriP[0]); i++)
95 {
96 if (oriP[i] == op)
97 {
98 this->newP[i] = np;
99 break;
100 }
101
102 }
103 }
104 void iniArray()
105 {
106 for (int i = 0; i < sizeof(oriP) / sizeof(oriP[0]); i++)
107 {
108 oriP[i] = -1;
109 }
110
111 for (int i = 0; i < sizeof(newP) / sizeof(newP[0]); i++)
112 {
113 newP[i] = -1;
114 }
115 }
116 };
117
118
120 {
121 int layer = -1;
122 int oriPoint = -1;
123
125 point_layer(int p, int L)
126 {
127 this->layer = L;
128 this->oriPoint = p;
129 };
130
131 bool operator<(const point_layer& other) const
132 {
133 if (this->layer < other.layer)
134 {
135 return true;
136 }
137 else if (this->layer == other.layer)
138 {
139 if (this->oriPoint < other.oriPoint)
140 return true;
141 else
142 return false;
143 }
144 else
145 {
146 return false;
147 }
148 }
149
150 int getpoint() { return this->oriPoint; }
151 int getlayer() { return this->layer; }
152 };
153
154
155 public:
156
157 DEF_VAR(unsigned, Divisions, 1, "Divisions");
158
159 DEF_VAR(Real, Distance, 0.2, "Distance");
160
162
164
166
167 DEF_VAR(bool, ReverseNormal, false, "ReverseNormal");
168
169 protected:
170 void resetStates() override;
171
172 void pointcount(std::map<int, int>& mapp, int p)
173 {
174 if (mapp.count(p))
175 {
176 mapp[p] = mapp.at(p) + 1;
177 }
178 else
179 {
180 mapp[p] = 1;
181 }
182 }
183
184 void substrFromTwoString(std::string& first, std::string& Second, std::string& line, std::string& MyStr, int& index);
185
186 private:
188
189 void extrude(std::vector<Vec3f>& vertices,std::vector<TopologyModule::Triangle>& triangles);
190
191 std::shared_ptr<GLWireframeVisualModule> glModule3;
192
193
194 };
195
196
197
199}
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
DEF_INSTANCE_STATE(EdgeSet< TDataType >, NormalSet, "")
DEF_VAR(unsigned, Divisions, 1, "Divisions")
void extrude(std::vector< Vec3f > &vertices, std::vector< TopologyModule::Triangle > &triangles)
void pointcount(std::map< int, int > &mapp, int p)
DEF_INSTANCE_IN(TriangleSet< TDataType >, TriangleSet, "")
TDataType::Real Real
Definition PolyExtrude.h:31
DEF_VAR(bool, ReverseNormal, false, "ReverseNormal")
TDataType::Coord Coord
Definition PolyExtrude.h:32
std::shared_ptr< GLWireframeVisualModule > glModule3
void resetStates() override
DECLARE_TCLASS(PolyExtrude, TDataType)
void substrFromTwoString(std::string &first, std::string &Second, std::string &line, std::string &MyStr, int &index)
DEF_VAR(Real, Distance, 0.2, "Distance")
DEF_INSTANCE_STATE(TriangleSet< TDataType >, TriangleSet, "")
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
void setNewID_byOriID(int np, int op)
Definition PolyExtrude.h:92
Prim_point_Point(bool useOri, int prim, int p)
Definition PolyExtrude.h:72
Prim_point_Point(bool useOri, int prim, int p0, int p1, int p2)
Definition PolyExtrude.h:54
bool operator<(const point_layer &other) const