15 this->varColumns()->setRange(3, 50);
16 this->varRadius()->setRange(-10.0f, 10.0f);
17 this->varEndSegment()->setRange(0, 39);
22 this->inPointSet()->tagOptional(
true);
26 this->varLocation()->attach(callback);
27 this->varScale()->attach(callback);
28 this->varRotation()->attach(callback);
30 this->varColumns()->attach(callback);
31 this->varEndSegment()->attach(callback);
32 this->varRadius()->attach(callback);
33 this->varReverseNormal()->attach(callback);
34 this->varUseRamp()->attach(callback);
35 this->varCurve()->attach(callback);
37 auto tsRender = std::make_shared<GLSurfaceVisualModule>();
38 tsRender->setColor(
Color(0.8f, 0.52f, 0.25f));
39 tsRender->setVisible(
true);
40 this->stateTriangleSet()->connect(tsRender->inTriangleSet());
43 auto exES = std::make_shared<ExtractEdgeSetFromPolygonSet<TDataType>>();
44 this->statePolygonSet()->connect(exES->inPolygonSet());
47 auto esRender = std::make_shared<GLWireframeVisualModule>();
48 esRender->varBaseColor()->setValue(
Color(0, 0, 0));
49 exES->outEdgeSet()->connect(esRender->inEdgeSet());
53 this->stateTriangleSet()->promoteOuput();
54 this->statePolygonSet()->promoteOuput();
56 this->statePolygonSet()->promoteOuput();
57 this->stateTriangleSet()->promoteOuput();
71 if (!this->inPointSet()->isEmpty())
73 pointsize = this->inPointSet()->getData().getPointSize();
76 auto useRamp = this->varUseRamp()->getValue();
77 auto Ramp = this->varCurve()->getValue();
82 if (!this->inPointSet()->isEmpty())
84 s.
copyFrom(this->inPointSet()->getData());
92 std::vector<Coord> vertices;
93 std::vector<TopologyModule::Triangle> triangle;
94 pointsize = floatCoordArray.size();
99 for (
size_t i = 0; i < pointsize; i++)
101 Location =
Coord(floatCoordArray[i].x, floatCoordArray[i].y, 0);
103 vertices.push_back(Location);
115 auto center = this->varLocation()->getValue();
116 auto rot = this->varRotation()->getValue();
117 auto scale = this->varScale()->getValue();
119 auto radius = this->varRadius()->getValue();
120 auto row = pointsize - 1;
121 auto columns = this->varColumns()->getValue();
122 auto end_segment = this->varEndSegment()->getValue();
124 auto triangleSet = this->stateTriangleSet()->getDataPtr();
125 auto polySet = this->statePolygonSet()->getDataPtr();
127 std::vector<Coord> vertices;
128 std::vector<TopologyModule::Triangle> triangle;
132 Real angle =
M_PI / 180 * 360 / columns;
133 Real temp_angle = angle;
136 if (!this->inPointSet()->isEmpty() | (useRamp && pointsize > 0))
138 for (
int k = 0; k <= row; k++)
140 Real tempy = c_sa[k][1];
141 Real radius = c_sa[k][0] + this->varRadius()->getData();
143 for (
int j = 0; j < columns; j++) {
145 temp_angle = j * angle;
147 Location = {
sin(temp_angle) * radius , tempy ,
cos(temp_angle) * radius };
149 vertices.push_back(Location);
155 int pt_side_len = vertices.size();
157 for (
int i = 1; i < end_segment; i++)
159 float offset = i / (float(end_segment) - i);
161 for (
int p = 0; p < columns; p++)
163 int top_start = pt_side_len - columns + p;
165 Coord toppt = { (vertices[top_start][0] + offset * 0) / (1 + offset), c_sa[c_sa.size() - 1][1], (vertices[top_start][2] + offset * 0) / (1 + offset) };
167 vertices.push_back(toppt);
172 for (
int i = 1; i < end_segment; i++)
174 float offset = i / (float(end_segment) - i);
176 for (
int p = 0; p < columns; p++)
178 Coord buttompt = { (vertices[p][0] + offset * 0) / (1 + offset), c_sa[0][1], (vertices[p][2] + offset * 0) / (1 + offset) };
180 vertices.push_back(buttompt);
185 vertices.push_back(
Coord(0, c_sa[0][1], 0));
186 uint buttomCenter = vertices.size() - 1;
187 vertices.push_back(
Coord(0, c_sa[c_sa.size() - 1][1], 0));
188 uint topCenter = vertices.size() - 1;
191 uint numOfPolygon = columns * row + 2 * columns * end_segment;
195 uint endQuadNum = ((int(end_segment) - 1) * int(columns) < 0 ? 0 : (int(end_segment) - 1) *
int(columns));
197 uint QuadNum = columns * row + 2 * endQuadNum;
198 for (
uint j = 0; j < QuadNum; j++)
204 uint TriangleNum = (int(end_segment) - 1) < 0 ? 0 : columns * 2;
205 for (
uint j = 0; j < TriangleNum; j++)
212 polygonIndices.resize(counter);
217 for (
uint i = 0; i < columns; i++)
219 for (
uint j = 0; j < row; j++)
221 auto& index = polygonIndices[incre];
223 uint p1 = i + j * columns;
224 uint p2 = (i + 1) % columns + j * columns;
225 uint p3 = (i + 1) % columns + j * columns + columns;
226 uint p4 = i + j * columns + columns;
241 uint sidePtNum = columns * row;
242 for (
uint i = 0; i < columns; i++)
244 for (
uint j = 0; j < end_segment - 1; j++)
246 auto& index = polygonIndices[incre];
248 uint p1 = i + j * columns + (sidePtNum);
249 uint p2 = (i + 1) % columns + j * columns + (sidePtNum);
250 uint p3 = (i + 1) % columns + j * columns + columns + (sidePtNum);
251 uint p4 = i + j * columns + columns + (sidePtNum);
264 uint sideTopPtNum = incre;
265 for (
uint i = 0; i < columns; i++)
267 for (
uint j = 0; j < end_segment - 1; j++)
269 auto& index = polygonIndices[incre];
271 uint temp = sideTopPtNum;
277 uint p1 = i + j * columns + (temp);
278 uint p2 = (i + 1) % columns + j * columns + (temp);
279 uint p3 = (i + 1) % columns + j * columns + columns + (sideTopPtNum);
280 uint p4 = i + j * columns + columns + (sideTopPtNum);
291 uint buttomPtNum = incre;
294 for (
uint i = 0; i < columns; i++)
296 auto& index = polygonIndices[incre];
297 uint p1 = sideTopPtNum + i;
298 uint p2 = sideTopPtNum + (i + 1) % columns;
309 if (end_segment == 1)
313 for (
uint i = 0; i < columns; i++)
315 auto& index = polygonIndices[incre];
316 uint p1 = buttomPtNum + i;
317 uint p2 = buttomPtNum + (i + 1) % columns;
318 uint p3 = buttomCenter;
337 return center + q.
rotate(v - center);
340 int numpt = vertices.size();
342 for (
int i = 0; i < numpt; i++)
344 vertices[i] = RV(vertices[i] * scale + RV(center));
349 polySet->setPoints(vertices);
350 polySet->setPolygons(polygonIndices);
353 polygonIndices.clear();
355 auto& ts = this->stateTriangleSet()->getData();
356 polySet->turnIntoTriangleSet(ts);