24#ifndef __VCGLIB_PLATONIC
25#define __VCGLIB_PLATONIC
27#include<vcg/math/base.h>
28#include<vcg/complex/algorithms/refine.h>
29#include<vcg/complex/algorithms/update/position.h>
30#include<vcg/complex/algorithms/update/bounding.h>
31#include<vcg/complex/algorithms/clean.h>
32#include<vcg/complex/algorithms/polygon_support.h>
33#include<vcg/complex/algorithms/smooth.h>
53template <
class TetraMeshType>
56 typedef typename TetraMeshType::CoordType CoordType;
57 typedef typename TetraMeshType::VertexPointer VertexPointer;
58 typedef typename TetraMeshType::VertexIterator VertexIterator;
59 typedef typename TetraMeshType::FaceIterator FaceIterator;
66 VertexIterator vi=in.vert.begin();
67 ivp[0]=&*vi;(*vi).P()=CoordType ( 1.0, 1.0, 1.0); ++vi;
68 ivp[1]=&*vi;(*vi).P()=CoordType (-1.0, 1.0,-1.0); ++vi;
69 ivp[2]=&*vi;(*vi).P()=CoordType (-1.0,-1.0, 1.0); ++vi;
70 ivp[3]=&*vi;(*vi).P()=CoordType ( 1.0,-1.0,-1.0);
72 FaceIterator fi=in.face.begin();
73 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
74 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3]; ++fi;
75 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[1]; ++fi;
76 (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[1];
86template <
class DodMeshType>
89 typedef typename DodMeshType::CoordType CoordType;
91 const double phi = (1 + std::sqrt(5)) / 2;
92 const double a = 1 / std::sqrt(3);
93 const double b = a / phi;
94 const double c = a * phi;
96 std::vector<std::array<double, 3>> vertices = {
97 {a, a, a}, {a, a, -a}, {a, -a, a}, {a, -a, -a},
98 {-a, a, a}, {-a, a, -a}, {-a, -a, a}, {-a, -a, -a},
99 {0, b, c}, {0, b, -c}, {0, -b, c}, {0, -b, -c},
100 {b, c, 0}, {b, -c, 0}, {-b, c, 0}, {-b, -c, 0},
101 {c, 0, b}, {c, 0, -b}, {-c, 0, b}, {-c, 0, -b}
103 for(
size_t i = 0; i < vertices.size(); i++) {
107 std::vector<std::array<int, 5>> faces = {
121 for(
size_t i = 0; i < faces.size(); i++) {
123 in.face.back().SetF(2);
125 in.face.back().SetF(0); in.face.back().SetF(2);
127 in.face.back().SetF(0);
136template <
class DodMeshType>
139 typedef DodMeshType MeshType;
140 typedef typename MeshType::CoordType CoordType;
141 typedef typename MeshType::VertexPointer VertexPointer;
142 typedef typename MeshType::VertexIterator VertexIterator;
143 typedef typename MeshType::FaceIterator FaceIterator;
144 typedef typename MeshType::ScalarType ScalarType;
145 const int N_penta=12;
146 const int N_points=62;
148 int penta[N_penta*3*3]=
149 {20,11, 18, 18, 11, 8, 8, 11, 4,
150 13,23, 4, 4, 23, 8, 8, 23, 16,
151 13, 4, 30, 30, 4, 28, 28, 4, 11,
152 16,34, 8, 8, 34, 18, 18, 34, 36,
153 11,20, 28, 28, 20, 45, 45, 20, 38,
154 13,30, 23, 23, 30, 41, 41, 30, 47,
155 16,23, 34, 34, 23, 50, 50, 23, 41,
156 20,18, 38, 38, 18, 52, 52, 18, 36,
157 30,28, 47, 47, 28, 56, 56, 28, 45,
158 50,60, 34, 34, 60, 36, 36, 60, 52,
159 45,38, 56, 56, 38, 60, 60, 38, 52,
160 50,41, 60, 60, 41, 56, 56, 41, 47 };
162 ScalarType p=(1.0 + math::Sqrt(5.0)) / 2.0;
165 const ScalarType scale = std::sqrt(p2*p2*3);
170 ScalarType vv[N_points*3]=
172 0, 0, 2*p2, p2, 0, p3, p, p2, p3,
173 0, p, p3, -p, p2, p3, -p2, 0, p3,
174 -p, -p2, p3, 0, -p, p3, p, -p2, p3,
175 p3, p, p2, p2, p2, p2, 0, p3, p2,
176 -p2, p2, p2, -p3, p, p2, -p3, -p, p2,
177 -p2, -p2, p2, 0, -p3, p2, p2, -p2, p2,
178 p3, -p, p2, p3, 0, p, p2, p3, p,
179 -p2, p3, p, -p3, 0, p, -p2, -p3, p,
180 p2, -p3, p, 2*p2, 0, 0, p3, p2, 0,
181 p, p3, 0, 0, 2*p2, 0, -p, p3, 0,
182 -p3, p2, 0, -2*p2, 0, 0, -p3, -p2, 0,
183 -p, -p3, 0, 0, -2*p2, 0, p, -p3, 0,
184 p3, -p2, 0, p3, 0, -p, p2, p3, -p,
185 -p2, p3, -p, -p3, 0, -p, -p2, -p3, -p,
186 p2, -p3, -p, p3, p, -p2, p2, p2, -p2,
187 0, p3, -p2, -p2, p2, -p2, -p3, p, -p2,
188 -p3, -p, -p2, -p2, -p2, -p2, 0, -p3, -p2,
189 p2, -p2, -p2, p3, -p, -p2, p2, 0, -p3,
190 p, p2, -p3, 0, p, -p3, -p, p2, -p3,
191 -p2, 0, -p3, -p, -p2, -p3, 0, -p, -p3,
192 p, -p2, -p3, 0, 0, -2*p2
202 for (i=0; i<N_points; i++) used[i]=
false;
204 int reindex[20+12 *10];
205 ScalarType xx,yy,zz, sx,sy,sz;
207 int order[5]={0,1,8,6,2};
210 VertexIterator vi=in.vert.begin();
212 for (i=0; i<12; i++) {
214 for (
int j=0; j<5; j++) {
215 h= penta[ i*9 + order[j] ]-1;
216 xx=vv[h*3];yy=vv[h*3+1];zz=vv[h*3+2]; sx+=xx; sy+=yy; sz+=zz;
218 (*vi).P()=CoordType( xx, yy, zz ); vi++;
223 (*vi).P()=CoordType( sx/5.0, sy/5.0, sz/5.0 ); vi++;
227 std::vector<VertexPointer> index(in.vn);
229 for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &(*vi);
231 FaceIterator fi=in.face.begin();
233 for (i=0; i<12; i++) {
235 (*fi).V(0)=index[added[i] ];
236 (*fi).V(1)=index[reindex[penta[i*9 + order[j ] ] -1 ] ];
237 (*fi).V(2)=index[reindex[penta[i*9 + order[(j+1)%5] ] -1 ] ];
238 if (HasPerFaceFlags(in)) {
248template <
class OctMeshType>
256 typedef OctMeshType MeshType;
257 typedef typename MeshType::CoordType CoordType;
258 typedef typename MeshType::VertexPointer VertexPointer;
259 typedef typename MeshType::VertexIterator VertexIterator;
260 typedef typename MeshType::FaceIterator FaceIterator;
266 VertexPointer ivp[6];
268 VertexIterator vi=in.vert.begin();
269 ivp[0]=&*vi;(*vi).P()=CoordType ( 1, 0, 0); ++vi;
270 ivp[1]=&*vi;(*vi).P()=CoordType ( 0, 1, 0); ++vi;
271 ivp[2]=&*vi;(*vi).P()=CoordType ( 0, 0, 1); ++vi;
272 ivp[3]=&*vi;(*vi).P()=CoordType (-1, 0, 0); ++vi;
273 ivp[4]=&*vi;(*vi).P()=CoordType ( 0,-1, 0); ++vi;
274 ivp[5]=&*vi;(*vi).P()=CoordType ( 0, 0,-1);
276 FaceIterator fi=in.face.begin();
277 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
278 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[4]; ++fi;
279 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[5]; ++fi;
280 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[1]; ++fi;
281 (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[5]; ++fi;
282 (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[4]; ++fi;
283 (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[2]; ++fi;
284 (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[1];
287template <
class IcoMeshType>
295 typedef IcoMeshType MeshType;
296 typedef typename MeshType::ScalarType ScalarType;
297 typedef typename MeshType::CoordType CoordType;
298 typedef typename MeshType::VertexPointer VertexPointer;
299 typedef typename MeshType::VertexIterator VertexIterator;
300 typedef typename MeshType::FaceIterator FaceIterator;
302 ScalarType L=ScalarType((math::Sqrt(5.0)+1.0)/2.0);
304 CoordType ( 0, L, 1),
305 CoordType ( 0, L,-1),
306 CoordType ( 0,-L, 1),
307 CoordType ( 0,-L,-1),
309 CoordType ( L, 1, 0),
310 CoordType ( L,-1, 0),
311 CoordType (-L, 1, 0),
312 CoordType (-L,-1, 0),
314 CoordType ( 1, 0, L),
315 CoordType (-1, 0, L),
316 CoordType ( 1, 0,-L),
321 {1,0,4},{0,1,6},{2,3,5},{3,2,7},
322 {4,5,10},{5,4,8},{6,7,9},{7,6,11},
323 {8,9,2},{9,8,0},{10,11,1},{11,10,3},
324 {0,8,4},{0,6,9},{1,4,10},{1,11,6},
325 {2,5,8},{2,9,7},{3,10,5},{3,7,11}
332 VertexPointer ivp[12];
336 for(i=0,vi=in.vert.begin();vi!=in.vert.end();++i,++vi){
342 for(i=0,fi=in.face.begin();fi!=in.face.end();++i,++fi){
343 (*fi).V(0)=ivp[ff[i][0]];
344 (*fi).V(1)=ivp[ff[i][1]];
345 (*fi).V(2)=ivp[ff[i][2]];
349template <
class MeshType>
357 typedef typename MeshType::CoordType CoordType;
358 typedef typename MeshType::VertexPointer VertexPointer;
359 typedef typename MeshType::VertexIterator VertexIterator;
360 typedef typename MeshType::FaceIterator FaceIterator;
366 VertexPointer ivp[8];
368 VertexIterator vi=in.vert.begin();
370 ivp[7]=&*vi;(*vi).P()=CoordType (-1,-1,-1); ++vi;
371 ivp[6]=&*vi;(*vi).P()=CoordType ( 1,-1,-1); ++vi;
372 ivp[5]=&*vi;(*vi).P()=CoordType (-1, 1,-1); ++vi;
373 ivp[4]=&*vi;(*vi).P()=CoordType ( 1, 1,-1); ++vi;
374 ivp[3]=&*vi;(*vi).P()=CoordType (-1,-1, 1); ++vi;
375 ivp[2]=&*vi;(*vi).P()=CoordType ( 1,-1, 1); ++vi;
376 ivp[1]=&*vi;(*vi).P()=CoordType (-1, 1, 1); ++vi;
377 ivp[0]=&*vi;(*vi).P()=CoordType ( 1, 1, 1);
379 FaceIterator fi=in.face.begin();
380 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
381 (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[1]; ++fi;
382 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[4]; ++fi;
383 (*fi).V(0)=ivp[6]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[2]; ++fi;
384 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[1]; ++fi;
385 (*fi).V(0)=ivp[5]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[4]; ++fi;
386 (*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[6]; ++fi;
387 (*fi).V(0)=ivp[4]; (*fi).V(1)=ivp[6]; (*fi).V(2)=ivp[5]; ++fi;
388 (*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[6]; (*fi).V(2)=ivp[3]; ++fi;
389 (*fi).V(0)=ivp[2]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[6]; ++fi;
390 (*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[5]; ++fi;
391 (*fi).V(0)=ivp[1]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[3];
393 if (HasPerFaceFlags(in)) {
394 FaceIterator fi=in.face.begin();
395 for (
int k=0; k<12; k++) {
402template <
class MeshType>
410 typedef typename MeshType::CoordType CoordType;
411 typedef typename MeshType::VertexPointer VertexPointer;
412 typedef typename MeshType::VertexIterator VertexIterator;
413 typedef typename MeshType::FaceIterator FaceIterator;
419 VertexPointer ivp[4];
421 VertexIterator vi=in.vert.begin();
422 ivp[0]=&*vi;(*vi).P()=CoordType ( 1, 0, 0); ++vi;
423 ivp[1]=&*vi;(*vi).P()=CoordType ( 0, 1, 0); ++vi;
424 ivp[2]=&*vi;(*vi).P()=CoordType (-1, 0, 0); ++vi;
425 ivp[3]=&*vi;(*vi).P()=CoordType ( 0,-1, 0);
427 FaceIterator fi=in.face.begin();
428 (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
429 (*fi).V(0)=ivp[2]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[0];
431 if (HasPerFaceFlags(in)) {
432 FaceIterator fi=in.face.begin();
433 for (
int k=0; k<2; k++) {
439template <
class MeshType>
452 typedef typename MeshType::CoordType CoordType;
453 typedef typename MeshType::VertexIterator VertexIterator;
463 for(
int i=0;i<subdiv;++i)
470 for(
int i=0;i<in.vn;++i)
472 in.vert[i].P().Normalize();
476 tri::Smooth<MeshType>::VertexCoordLaplacian(in,10,
true);
479 const float halfAngleRad = angleRad / 2.0f;
480 const float width = sin(halfAngleRad);
483 for(VertexIterator vi=in.vert.begin(); vi!=in.vert.end();++vi)
485 float cosVi = vi->P().Norm();
486 float angVi = asin (cosVi);
487 vi->P()[2] = cos(angVi) - cos(halfAngleRad);
494template <
class MeshType>
501void Sphere(MeshType &in,
const int subdiv = 3 )
503 typedef typename MeshType::CoordType CoordType;
504 typedef typename MeshType::VertexIterator VertexIterator;
505 typedef typename MeshType::FaceIterator FaceIterator;
508 for(VertexIterator vi = in.vert.begin(); vi!=in.vert.end();++vi)
511 for(
int i = 0 ; i < subdiv; ++i)
514 for(FaceIterator fi=in.face.begin();fi!=in.face.end();++fi)
516 CoordType me01 = (fi->P(0)+fi->P(1))/2.0;
517 CoordType me12 = (fi->P(1)+fi->P(2))/2.0;
518 CoordType me20 = (fi->P(2)+fi->P(0))/2.0;
527 for(VertexIterator vi = in.vert.begin(); vi != in.vert.end(); ++vi)
532template <
class MeshType>
541void Sphere(MeshType & m,
const typename MeshType::CoordType & position,
typename MeshType::ScalarType radius = 0,
const int subdiv = 3)
559template <
class MeshType>
561 const typename MeshType::ScalarType r1,
562 const typename MeshType::ScalarType r2,
563 const typename MeshType::ScalarType h,
564 const int SubDiv = 36 )
566 typedef typename MeshType::CoordType CoordType;
567 typedef typename MeshType::VertexPointer VertexPointer;
568 typedef typename MeshType::VertexIterator VertexIterator;
569 typedef typename MeshType::FaceIterator FaceIterator;
584 VertexPointer *ivp =
new VertexPointer[VN];
586 VertexIterator vi=in.vert.begin();
587 ivp[0]=&*vi;(*vi).P()=CoordType ( 0,-h/2.0,0 ); ++vi;
588 ivp[1]=&*vi;(*vi).P()=CoordType ( 0, h/2.0,0 ); ++vi;
594 for(i=0;i<SubDiv;++i)
596 double a = math::ToRad(i*360.0/SubDiv);
597 ivp[cnt]=&*vi; (*vi).P()= CoordType(r1*cos(a), -h/2.0, r1*sin(a)); ++vi;++cnt;
604 for(i=0;i<SubDiv;++i)
606 double a = math::ToRad(i*360.0/SubDiv);
607 ivp[cnt]=&*vi; (*vi).P()= CoordType( r2*cos(a), h/2.0, r2*sin(a)); ++vi;++cnt;
611 FaceIterator fi=in.face.begin();
613 if(r1!=0)
for(i=0;i<SubDiv;++i,++fi) {
615 (*fi).V(1)=ivp[b1+i];
616 (*fi).V(2)=ivp[b1+(i+1)%SubDiv];
619 if(r2!=0)
for(i=0;i<SubDiv;++i,++fi) {
621 (*fi).V(2)=ivp[b2+i];
622 (*fi).V(1)=ivp[b2+(i+1)%SubDiv];
625 if(r1==0)
for(i=0;i<SubDiv;++i,++fi)
628 (*fi).V(1)=ivp[b2+i];
629 (*fi).V(2)=ivp[b2+(i+1)%SubDiv];
631 if(r2==0)
for(i=0;i<SubDiv;++i,++fi){
633 (*fi).V(2)=ivp[b1+i];
634 (*fi).V(1)=ivp[b1+(i+1)%SubDiv];
637 if(r1!=0 && r2!=0)
for(i=0;i<SubDiv;++i)
639 (*fi).V(0)=ivp[b1+i];
640 (*fi).V(1)=ivp[b2+i];
641 (*fi).V(2)=ivp[b2+(i+1)%SubDiv];
643 (*fi).V(0)=ivp[b1+i];
644 (*fi).V(1)=ivp[b2+(i+1)%SubDiv];
645 (*fi).V(2)=ivp[b1+(i+1)%SubDiv];
650template <
class MeshType>
662 const typename MeshType::CoordType origin,
663 const typename MeshType::CoordType end,
664 const typename MeshType::ScalarType r1,
665 const typename MeshType::ScalarType r2,
666 const int SubDiv = 36 )
668 typedef typename MeshType::ScalarType ScalarType;
669 typedef typename MeshType::CoordType CoordType;
670 typedef Matrix44<typename MeshType::ScalarType> Matrix44x;
671 Cone(m,r1,r2,Distance(origin,end),SubDiv);
675 CoordType norm = end-origin;
676 ScalarType angleRad = Angle(CoordType(0,1,0),norm);
677 const ScalarType Delta= 0.000000001;
679 if (fabs(angleRad)<Delta)
682 if (fabs(angleRad-M_PI)<Delta)
684 CoordType axis = CoordType(0,0,1)^norm;
685 rotM.SetRotateRad(angleRad,axis);
689 CoordType axis = CoordType(0,1,0)^norm;
690 rotM.SetRotateRad(angleRad,axis);
697template <
class MeshType >
704void Box(MeshType &in,
const typename MeshType::BoxType & bb )
706 typedef typename MeshType::CoordType CoordType;
707 typedef typename MeshType::VertexPointer VertexPointer;
708 typedef typename MeshType::VertexIterator VertexIterator;
709 typedef typename MeshType::FaceIterator FaceIterator;
713 VertexPointer ivp[8];
715 VertexIterator vi=in.vert.begin();
716 ivp[0]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.min[1],bb.min[2]); ++vi;
717 ivp[1]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.min[1],bb.min[2]); ++vi;
718 ivp[2]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.max[1],bb.min[2]); ++vi;
719 ivp[3]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.max[1],bb.min[2]); ++vi;
720 ivp[4]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.min[1],bb.max[2]); ++vi;
721 ivp[5]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.min[1],bb.max[2]); ++vi;
722 ivp[6]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.max[1],bb.max[2]); ++vi;
723 ivp[7]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.max[1],bb.max[2]);
738 if (HasPerFaceFlags(in)) {
739 FaceIterator fi=in.face.begin();
740 for (
int k=0; k<12; k++) {
748template <
class MeshType>
758void Torus(MeshType &m,
float hRingRadius,
float vRingRadius,
int hRingDiv=24,
int vRingDiv=12 )
760 typedef typename MeshType::CoordType CoordType;
761 typedef typename MeshType::ScalarType ScalarType;
762 typedef Matrix44<ScalarType> Matrix44x;
764 ScalarType angleStepV = (2.0f*M_PI)/vRingDiv;
765 ScalarType angleStepH = (2.0f*M_PI)/hRingDiv;
768 for(
int i=0;i<hRingDiv+1;++i)
770 Matrix44x RotM; RotM.SetRotateRad(
float(i%hRingDiv)*angleStepH,CoordType(0,0,1));
771 for(
int j=0;j<vRingDiv+1;++j)
774 p[0]= vRingRadius*cos(
float(j%vRingDiv)*angleStepV) + hRingRadius;
776 p[2]= vRingRadius*sin(
float(j%vRingDiv)*angleStepV);
778 m.vert[i*(vRingDiv+1)+j].P() = RotM*p;
789template <
class ScalarType>
790static ScalarType _SQfnC(ScalarType a, ScalarType b){
791 return math::Sgn(cos(a))*pow(fabs(cos(a)),b);
793template <
class ScalarType>
794static ScalarType _SQfnS(ScalarType a, ScalarType b){
795 return math::Sgn(sin(a))*pow(fabs(sin(a)),b);
810template <
class MeshType>
811void SuperToroid(MeshType &m,
float hRingRadius,
float vRingRadius,
float vSquareness,
float hSquareness,
int hRingDiv=24,
int vRingDiv=12 )
813 typedef typename MeshType::CoordType CoordType;
814 typedef typename MeshType::ScalarType ScalarType;
816 ScalarType angleStepV = (2.0f*M_PI)/vRingDiv;
817 ScalarType angleStepH = (2.0f*M_PI)/hRingDiv;
822 for(
int i=0;i<hRingDiv+1;++i)
824 u=float(i%hRingDiv)*angleStepH;
826 for(
int j=vRingDiv;j>=0;--j)
829 v=float(j%vRingDiv)*angleStepV;
830 p[0]= (hRingRadius+vRingRadius*_SQfnC(u,vSquareness))*_SQfnC(v,hSquareness);;
831 p[1]= (hRingRadius+vRingRadius*_SQfnC(u,vSquareness))*_SQfnS(v,hSquareness);
832 p[2] = vRingRadius*_SQfnS(u,vSquareness);
833 m.vert[i*(vRingDiv+1)+count].P() = p;
852template <
class MeshType>
853void SuperEllipsoid(MeshType &m,
float rFeature,
float sFeature,
float tFeature,
int hRingDiv=24,
int vRingDiv=12 )
855 typedef typename MeshType::CoordType CoordType;
856 typedef typename MeshType::ScalarType ScalarType;
858 ScalarType angleStepV = (2.0f*M_PI)/vRingDiv;
859 ScalarType angleStepH = (1.0f*M_PI)/hRingDiv;
863 for(
int i=0;i<hRingDiv+1;++i)
867 for(
int j=0;j<vRingDiv+1;++j)
870 v=ScalarType(j%vRingDiv)*angleStepV;
871 p[0] = _SQfnC(v,2/rFeature)*_SQfnC(u,2/rFeature);
872 p[1] = _SQfnC(v,2/sFeature)*_SQfnS(u,2/sFeature);
873 p[2] = _SQfnS(v,2/tFeature);
874 m.vert[i*(vRingDiv+1)+j].P() = p;
880 bool oriented, orientable;
896template <
class MeshType,
class InCoordType,
class InFaceIndexType >
899 typedef typename MeshType::CoordType CoordType;
905 for(
size_t i=0;i<v.size();++i)
907 const InCoordType &vv = v[i];
908 in.vert[i].P() = CoordType( vv[0],vv[1],vv[2]);
911 for(
size_t i=0;i<f.size();++i)
913 const InFaceIndexType &ff= f[i];
914 assert( ff[0]>=0 && ff[0]<in.vn);
915 assert( ff[1]>=0 && ff[1]<in.vn);
916 assert( ff[2]>=0 && ff[2]<in.vn);
917 in.face[i].V(0) = &in.vert[ ff[0] ];
918 in.face[i].V(1) = &in.vert[ ff[1] ];
919 in.face[i].V(2) = &in.vert[ ff[2] ];
926template <
class MeshType,
class V>
936 std::vector<Point3i> dummyfaceVec;
941template <
class TriMeshType,
class EdgeMeshType >
951 tri::RequireCompactness(in);
952 std::vector<typename tri::UpdateTopology<TriMeshType>::PEdge> edgevec;
955 for(
size_t i=0;i<in.vert.size();++i)
959 for(
size_t i=0;i<edgevec.size();++i)
961 int i0 = tri::Index(in,edgevec[i].v[0]);
962 int i1 = tri::Index(in,edgevec[i].v[1]);
966 if(in.vert[i0].IsS()) out.vert[i0].SetS();
967 if(in.vert[i1].IsS()) out.vert[i1].SetS();
970 for(
size_t i=0;i<out.vert.size();++i)
981template <
class MeshType>
992void Grid(MeshType & in,
int w,
int h,
float wl,
float hl,
float *data=0)
994 typedef typename MeshType::CoordType CoordType;
999 float wld=wl/float(w-1);
1000 float hld=hl/float(h-1);
1002 for(
int i=0;i<h;++i)
1003 for(
int j=0;j<w;++j)
1005 if(data) zVal=data[i*w+j];
1006 in.vert[i*w+j].P()=CoordType ( j*wld, i*hld, zVal) ;
1015template <
class MeshType>
1025 assert(in.vn == (
int)in.vert.size());
1026 assert(in.vn >= w*h);
1037 for(
int i=0;i<h-1;++i)
1038 for(
int j=0;j<w-1;++j)
1040 in.face[2*(i*(w-1)+j)+0].V(0) = &(in.vert[(i+1)*w+j+1]);
1041 in.face[2*(i*(w-1)+j)+0].V(1) = &(in.vert[(i+0)*w+j+1]);
1042 in.face[2*(i*(w-1)+j)+0].V(2) = &(in.vert[(i+0)*w+j+0]);
1044 in.face[2*(i*(w-1)+j)+1].V(0) = &(in.vert[(i+0)*w+j+0]);
1045 in.face[2*(i*(w-1)+j)+1].V(1) = &(in.vert[(i+1)*w+j+0]);
1046 in.face[2*(i*(w-1)+j)+1].V(2) = &(in.vert[(i+1)*w+j+1]);
1049 if (HasPerFaceFlags(in)) {
1050 for (
int k=0; k<(h-1)*(w-1)*2; k++) {
1063template <
class MeshType>
1074 tri::RequireCompactness(in);
1075 assert(in.vn <= w*h);
1087 for(
int i=0;i<h-1;++i)
1088 for(
int j=0;j<w-1;++j)
1090 int V0i= grid[(i+0)*w+j+0];
1091 int V1i= grid[(i+0)*w+j+1];
1092 int V2i= grid[(i+1)*w+j+0];
1093 int V3i= grid[(i+1)*w+j+1];
1096 bool quad = (V0i>=0 && V1i>=0 && V2i>=0 && V3i>=0 ) && tri::HasPerFaceFlags(in);
1098 if(V0i>=0 && V2i>=0 && V3i>=0 )
1101 f->V(0)=&(in.vert[V3i]);
1102 f->V(1)=&(in.vert[V2i]);
1103 f->V(2)=&(in.vert[V0i]);
1104 if (quad) f->SetF(2);
1107 if(V0i>=0 && V1i>=0 && V3i>=0 )
1110 f->V(0)=&(in.vert[V0i]);
1111 f->V(1)=&(in.vert[V1i]);
1112 f->V(2)=&(in.vert[V3i]);
1113 if (quad) f->SetF(2);
1118 if(V2i>=0 && V0i>=0 && V1i>=0 )
1121 f->V(0)=&(in.vert[V2i]);
1122 f->V(1)=&(in.vert[V0i]);
1123 f->V(2)=&(in.vert[V1i]);
1126 if(V1i>=0 && V3i>=0 && V2i>=0 )
1129 f->V(0)=&(in.vert[V1i]);
1130 f->V(1)=&(in.vert[V3i]);
1131 f->V(2)=&(in.vert[V2i]);
1137template <
class MeshType>
1146void Annulus(MeshType & m,
float externalRadius,
float internalRadius,
int slices)
1151 for (
int j = 0; j < slices; ++j)
1153 float x = cos( 2.0 * M_PI / slices * j);
1154 float y = sin( 2.0 * M_PI / slices * j);
1156 (*vi).P() =
typename MeshType::CoordType(x,y,0)*internalRadius;
1158 (*vi).P() =
typename MeshType::CoordType(x,y,0)*externalRadius;
1161 typename MeshType::FaceIterator fi ;
1162 for (
int j = 0; j < slices; ++j)
1165 (*fi).V(0) = &m.vert[ ((j+0)*2+0)%(slices*2) ];
1166 (*fi).V(1) = &m.vert[ ((j+1)*2+1)%(slices*2) ];
1167 (*fi).V(2) = &m.vert[ ((j+0)*2+1)%(slices*2) ];
1170 (*fi).V(0) = &m.vert[ ((j+1)*2+0)%(slices*2) ];
1171 (*fi).V(1) = &m.vert[ ((j+1)*2+1)%(slices*2) ];
1172 (*fi).V(2) = &m.vert[ ((j+0)*2+0)%(slices*2) ];
1176template <
class MeshType>
1187void OrientedAnnulus(MeshType & m,
typename MeshType::CoordType center,
typename MeshType::CoordType norm,
float externalRadius,
float internalRadius,
int slices)
1189 typedef typename MeshType::ScalarType ScalarType;
1190 typedef typename MeshType::CoordType CoordType;
1191 Annulus(m,externalRadius,internalRadius, slices);
1192 ScalarType angleRad = Angle(CoordType(0,0,1),norm);
1193 CoordType axis = CoordType(0,0,1)^norm;
1195 Matrix44<ScalarType> rotM;
1196 rotM.SetRotateRad(angleRad,axis);
1202template <
class MeshType>
1210void Circle2D(MeshType & m,
float radius=1.0,
int sides=32)
1213 for (
int j = 0; j < sides; ++j)
1215 float x = cos( 2.0 * M_PI / sides * j)*radius;
1216 float y = sin( 2.0 * M_PI / sides * j)*radius;
1220for (
int j = 0; j < sides; ++j)
1223 int b = (j+1)%sides;
1227template <
class MeshType>
1238 (*vi).P() =
typename MeshType::CoordType(0,0,0);
1241 for (
int j = 0; j < slices; ++j)
1243 float x = cos( 2.0 * M_PI / slices * j);
1244 float y = sin( 2.0 * M_PI / slices * j);
1246 (*vi).P() =
typename MeshType::CoordType(x,y,0);
1249 typename MeshType::FaceIterator fi ;
1250 for (
int j = 0; j < slices; ++j)
1252 int a = 1+(j+0)%slices;
1253 int b = 1+(j+1)%slices;
1255 (*fi).V(0) = &m.vert[ 0 ];
1256 (*fi).V(1) = &m.vert[ a ];
1257 (*fi).V(2) = &m.vert[ b ];
1261template <
class MeshType>
1271void OrientedDisk(MeshType &m,
typename MeshType::CoordType center,
typename MeshType::CoordType norm,
float radius,
int slices)
1273 typedef typename MeshType::ScalarType ScalarType;
1274 typedef typename MeshType::CoordType CoordType;
1278 ScalarType angleRad = Angle(CoordType(0,0,1),norm);
1279 CoordType axis = CoordType(0,0,1)^norm;
1281 Matrix44<ScalarType> rotM;
1282 rotM.SetRotateRad(angleRad,axis);
1287template <
class MeshType>
1301void OrientedEllipticPrism(MeshType & m,
const typename MeshType::CoordType origin,
const typename MeshType::CoordType end,
float radius,
float xScale,
float yScale,
bool capped,
int slices=32,
int stacks=4 )
1303 typedef typename MeshType::ScalarType ScalarType;
1304 typedef typename MeshType::CoordType CoordType;
1305 typedef Matrix44<typename MeshType::ScalarType> Matrix44x;
1311 float height = Distance(origin,end);
1313 CoordType norm = end-origin;
1314 ScalarType angleRad = Angle(CoordType(0,1,0),norm);
1315 const ScalarType Delta= 0.000000001;
1317 if (fabs(angleRad)<Delta)
1320 if (fabs(angleRad-M_PI)<Delta)
1322 CoordType axis = CoordType(0,0,1)^norm;
1323 rotM.SetRotateRad(angleRad,axis);
1327 CoordType axis = CoordType(0,1,0)^norm;
1328 rotM.SetRotateRad(angleRad,axis);
1335template <
class MeshType>
1347void OrientedCylinder(MeshType & m,
const typename MeshType::CoordType origin,
const typename MeshType::CoordType end,
float radius,
bool capped,
int slices=32,
int stacks=4 )
1353template <
class MeshType>
1362void Cylinder(MeshType & m,
int slices,
int stacks,
bool capped=
false)
1366 for (
int i = 0; i < stacks+1; ++i)
1367 for (
int j = 0; j < slices; ++j)
1370 x = cos( 2.0 * M_PI / slices * j);
1371 y = sin( 2.0 * M_PI / slices * j);
1372 h = 2 * i / (float)(stacks) - 1;
1374 (*vi).P() =
typename MeshType::CoordType(x,h,y);
1378 for (
int j = 0; j < stacks; ++j)
1379 for (
int i = 0; i < slices; ++i)
1382 a = (j+0)*slices + i;
1383 b = (j+1)*slices + i;
1384 c = (j+1)*slices + (i+1)%slices;
1385 d = (j+0)*slices + (i+1)%slices;
1401 for (
int i = 0; i < slices; ++i)
1403 base = (stacks)*slices;
1404 for (
int i = 0; i < slices; ++i)
1407 if (HasPerFaceFlags(m)) {
1408 for (
typename MeshType::FaceIterator fi=m.face.begin(); fi!=m.face.end(); fi++) {
1424template <
class MeshType>
1427 typedef typename MeshType::VertexPointer VertexPointer;
1428 typedef typename MeshType::FacePointer FacePointer;
1429 typedef typename MeshType::CoordType CoordType;
1430 if(height==0) height = mIn.bbox.Diag()/100.0f;
1431 if(inset==0) inset = mIn.bbox.Diag()/200.0f;
1436 for(
size_t i=0;i<mIn.face.size();++i)
if(!mIn.face[i].IsV())
1439 std::vector<VertexPointer> vertVec;
1440 std::vector<FacePointer> faceVec;
1441 tri::PolygonSupport<MeshType,MeshType>::ExtractPolygon(&(mIn.face[i]),vertVec,faceVec);
1442 size_t vn = vertVec.size();
1443 size_t fn = faceVec.size();
1445 CoordType extrude_dir(0,0,0);
1446 for(
size_t j=0;j<faceVec.size();++j)
1447 extrude_dir+=vcg::NormalizedTriangleNormal(*faceVec[j]) * DoubleArea(*faceVec[j]);
1448 extrude_dir.Normalize();
1449 extrude_dir = extrude_dir*height/2.0f;
1451 CoordType bary(0,0,0);
1452 for(
size_t j=0;j<faceVec.size();++j)
1453 bary+= Barycenter(*faceVec[j]);
1454 bary/=float(faceVec.size());
1458 std::map<size_t,size_t> topVertMap;
1459 std::map<size_t,size_t> botVertMap;
1463 for(
size_t j=0;j<vn;++j){
1464 CoordType delta = (vertVec[j]->P() - bary);
1466 delta = delta*inset;
1468 topVertMap[tri::Index(mIn,vertVec[j])] = tri::Index(faceM,faceM.vert.back());
1470 botVertMap[tri::Index(mIn,vertVec[j])] = tri::Index(faceM,faceM.vert.back());
1474 for(
size_t j=0;j<fn;++j)
1476 topVertMap[tri::Index(mIn, faceVec[j]->V(0))],
1477 topVertMap[tri::Index(mIn, faceVec[j]->V(1))],
1478 topVertMap[tri::Index(mIn, faceVec[j]->V(2))]);
1480 for(
size_t j=0;j<fn;++j)
1482 botVertMap[tri::Index(mIn, faceVec[j]->V(0))],
1483 botVertMap[tri::Index(mIn, faceVec[j]->V(1))],
1484 botVertMap[tri::Index(mIn, faceVec[j]->V(2))]);
1487 for(
size_t j=0;j<vn;++j){
1496 for(
size_t j=0;j<2*vn;++j)
1497 faceM.face[j].SetS();
1504 tri::Smooth<MeshType>::VertexCoordLaplacian(faceM,2,
true,
true);
1513template <
class MeshType>
1525 if(radius==0) radius = mIn.bbox.Diag()/100.0f;
1526 if (mIn.edge.size() > 0)
1528 for (
size_t i = 0; i < mIn.edge.size(); ++i) {
1531 mCyl, mIn.edge[i].V(0)->P(), mIn.edge[i].V(1)->P(), radius,
true, slices, stacks);
1538 std::vector<PEdge> edgeVec;
1540 for (
size_t i = 0; i < edgeVec.size(); ++i) {
1543 mCyl, edgeVec[i].v[0]->P(), edgeVec[i].v[1]->P(), radius,
true, slices, stacks);
1549template <
class MeshType>
1560 if(radius==0) radius = mIn.bbox.Diag()/100.0f;
1561 for(
size_t i=0;i<mIn.vert.size();++i)
1571template <
class MeshType>
1584 typedef typename MeshType::CoordType CoordType;
1585 if(radius==0) radius = mIn.bbox.Diag()/100.0f;
1586 if(height==0) height = mIn.bbox.Diag()/200.0f;
1587 for(
size_t i=0;i<mIn.vert.size();++i)
1589 CoordType p = mIn.vert[i].P();
1590 CoordType n = mIn.vert[i].N().Normalize();
1599template <
class MeshType>
1606 typedef typename MeshType::CoordType MV;
1608 MV(-0.000122145 , -0.2 ,0.35),
1609 MV(0.000122145 , -0.2 ,-0.35),MV(-0.000122145 , 0.2 ,0.35),MV(0.000122145 , 0.2 ,-0.35),MV(0.999878 , -0.2 ,0.350349),MV(1.00012 , -0.2 ,-0.349651),MV(0.999878 , 0.2 ,0.350349),MV(1.00012 , 0.2 ,-0.349651),MV(1.28255 , 0.1 ,0.754205),MV(1.16539 , 0.1 ,1.03705),MV(0.88255 , 0.1 ,1.15421),
1610 MV(0.599707 , 0.1 ,1.03705),MV(0.48255 , 0.1 ,0.754205),MV(0.599707 , 0.1 ,0.471362),MV(0.88255 , 0.1 ,0.354205),MV(1.16539 , 0.1 ,0.471362),MV(1.28255 , -0.1 ,0.754205),MV(1.16539 , -0.1 ,1.03705),MV(0.88255 , -0.1 ,1.15421),MV(0.599707 , -0.1 ,1.03705),MV(0.48255 , -0.1 ,0.754205),
1611 MV(0.599707 , -0.1 ,0.471362),MV(1.16539 , -0.1 ,0.471362),MV(0.88255 , -0.1 ,0.354205),MV(3.49164e-005 , 0 ,-0.1),MV(1.74582e-005 , -0.0866025 ,-0.05),MV(-1.74582e-005 , -0.0866025 ,0.05),MV(-3.49164e-005 , 8.74228e-009 ,0.1),MV(-1.74582e-005 , 0.0866025 ,0.05),MV(1.74582e-005 , 0.0866025 ,-0.05),MV(-0.399913 , 1.99408e-022 ,-0.25014),
1612 MV(-0.399956 , -0.216506 ,-0.12514),MV(-0.400044 , -0.216506 ,0.12486),MV(-0.400087 , 2.18557e-008 ,0.24986),MV(-0.400044 , 0.216506 ,0.12486),MV(-0.399956 , 0.216506 ,-0.12514),MV(0.479764 , 0.1 ,0.754205),MV(0.362606 , 0.1 ,1.03705),MV(0.0797637 , 0.1 ,1.15421),MV(-0.203079 , 0.1 ,1.03705),MV(-0.320236 , 0.1 ,0.754205),
1613 MV(-0.203079 , 0.1 ,0.471362),MV(0.0797637 , 0.1 ,0.354205),MV(0.362606 , 0.1 ,0.471362),MV(0.479764 , -0.1 ,0.754205),MV(0.362606 , -0.1 ,1.03705),MV(0.0797637 , -0.1 ,1.15421),MV(-0.203079 , -0.1 ,1.03705),MV(-0.320236 , -0.1 ,0.754205),MV(0.0797637 , -0.1 ,0.354205),MV(0.362606 , -0.1 ,0.471362),
1614 MV(-0.203079 , -0.1 ,0.471362), };
1617 {3,1,0},{4,5,7},{7,6,4},{0,1,5},{5,4,0},{1,3,7},{7,5,1},{3,2,6},{6,7,3},{2,0,4},
1618 {4,6,2},{10,9,8},{10,12,11},{10,13,12},{10,14,13},{10,15,14},{10,8,15},{8,17,16},{8,9,17},{9,18,17},
1619 {9,10,18},{10,19,18},{10,11,19},{11,20,19},{11,12,20},{12,21,20},{12,13,21},{13,23,21},{13,14,23},{14,22,23},
1620 {14,15,22},{15,16,22},{15,8,16},{23,16,17},{23,17,18},{23,18,19},{23,19,20},{23,20,21},{23,22,16},{25,27,26},
1621 {25,28,27},{25,29,28},{25,24,29},{24,31,30},{24,25,31},{25,32,31},{25,26,32},{26,33,32},{26,27,33},{27,34,33},
1622 {27,28,34},{28,35,34},{28,29,35},{29,30,35},{29,24,30},{35,30,31},{35,31,32},{35,32,33},{35,33,34},{42,37,36},
1623 {42,38,37},{42,39,38},{42,40,39},{42,41,40},{42,36,43},{36,45,44},{36,37,45},{37,46,45},{37,38,46},{38,47,46},
1624 {38,39,47},{39,48,47},{39,40,48},{40,51,48},{40,41,51},{41,49,51},{41,42,49},{42,50,49},{42,43,50},{43,44,50},
1625 {43,36,44},{51,44,45},{51,45,46},{51,46,47},{51,47,48},{51,49,50},{51,50,44},
1634 for(i=0;i<in.vn;i++)
1635 in.vert[i].P()=vv[i];;
1637 std::vector<typename MeshType::VertexPointer> index(in.vn);
1639 typename MeshType::VertexIterator vi;
1640 for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &*vi;
1641 for(j=0;j<in.fn;++j)
1643 in.face[j].V(0)=index[ff[j][0]];
1644 in.face[j].V(1)=index[ff[j][1]];
1645 in.face[j].V(2)=index[ff[j][2]];
1649template <
class MeshType>
1661void OrientedRect(MeshType &square,
float width,
float height,
typename MeshType::CoordType c,
typename MeshType::CoordType dir=
typename MeshType::CoordType(0,0,0),
float angleDeg=0,
typename MeshType::CoordType preRotTra =
typename MeshType::CoordType(0,0,0))
1663 typedef typename MeshType::ScalarType ScalarType;
1664 typedef typename MeshType::CoordType CoordType;
1665 float zeros[4]={0,0,0,0};
1667 Matrix44<ScalarType> rotM;
1668 tri::Grid(square,2,2,width,height,zeros);
1672 rotM.SetRotateDeg(angleDeg,dir);
1679template <
class MeshType>
1690void OrientedSquare(MeshType &square,
float width,
typename MeshType::CoordType c,
typename MeshType::CoordType dir=
typename MeshType::CoordType(0,0,0),
float angleDeg=0,
typename MeshType::CoordType preRotTra =
typename MeshType::CoordType(0,0,0))
1692 OrientedRect(square,width,width,c,dir,angleDeg,preRotTra);
Class to safely add and delete elements in a mesh.
Definition: allocate.h:97
static VertexIterator AddVertex(MeshType &m, const CoordType &p)
Wrapper to AddVertices() to add a single vertex with given coords.
Definition: allocate.h:295
static void DeleteVertex(MeshType &m, VertexType &v)
Definition: allocate.h:935
static VertexIterator AddVertices(MeshType &m, size_t n, PointerUpdater< VertexPointer > &pu)
Add n vertices to the mesh. Function to add n vertices to the mesh. The elements are added always to ...
Definition: allocate.h:189
static FaceIterator AddFaces(MeshType &m, size_t n)
Function to add n faces to the mesh. First wrapper, with no parameters.
Definition: allocate.h:615
static EdgeIterator AddEdge(MeshType &m, VertexPointer v0, VertexPointer v1)
Definition: allocate.h:387
static FaceIterator AddFace(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2)
Definition: allocate.h:539
static void MeshCopy(MeshLeft &ml, ConstMeshRight &mr, bool selected=false, const bool adjFlag=false)
Copy the second mesh over the first one. The first mesh is destroyed. If requested only the selected ...
Definition: append.h:601
static void Mesh(MeshLeft &ml, ConstMeshRight &mr, const bool selected=false, const bool adjFlag=false)
Append the second mesh to the first one.
Definition: append.h:253
Class of static functions to clean//restore meshs.
Definition: clean.h:165
static int RemoveDuplicateVertex(MeshType &m, bool RemoveDegenerateFlag=true)
Definition: clean.h:206
static int MergeCloseVertex(MeshType &m, const ScalarType radius)
Definition: clean.h:2015
static void Box(ComputeMeshType &m)
Calculates the bounding box of the given mesh m.
Definition: bounding.h:45
Management, updating and computation of per-vertex and per-face flags (like border flags).
Definition: flag.h:44
static void VertexBorderFromFaceBorder(MeshType &m)
Compute the PerVertex Border flag deriving it from the border flag of faces.
Definition: flag.h:428
static void FaceBorderFromFF(MeshType &m)
Compute the border flags for the faces using the Face-Face Topology.
Definition: flag.h:170
static void PerVertexNormalizedPerFace(ComputeMeshType &m)
Equivalent to PerVertexNormalized() and PerFace().
Definition: normal.h:296
This class is used to update vertex position according to a transformation matrix.
Definition: position.h:47
static void Matrix(ComputeMeshType &m, const Matrix44< ScalarType > &M, bool update_also_normals=true)
Multiply.
Definition: position.h:60
static size_t VertexInvert(MeshType &m)
This function inverts the selection flag for all the vertices.
Definition: selection.h:367
static void Clear(MeshType &m)
This function clears the selection flag for all the elements of a mesh (vertices, edges,...
Definition: selection.h:271
static size_t VertexFromFaceStrict(MeshType &m, bool preserveSelection=false)
Select ONLY the vertices that are touched ONLY by selected faces.
Definition: selection.h:431
static size_t VertexFromBorderFlag(MeshType &m, bool preserveSelection=false)
This function select the vertices with the border flag set.
Definition: selection.h:508
Auxiliary data structure for computing face face adjacency information.
Definition: topology.h:149
Generation of per-vertex and per-face topological information.
Definition: topology.h:43
static void FaceFace(MeshType &m)
Update the Face-Face topological relation by allowing to retrieve for each face what other faces shar...
Definition: topology.h:395
void OrientedDisk(MeshType &m, typename MeshType::CoordType center, typename MeshType::CoordType norm, float radius, int slices)
Build a disk oriented in 3D space.
Definition: platonic.h:1271
void OrientedCone(MeshType &m, const typename MeshType::CoordType origin, const typename MeshType::CoordType end, const typename MeshType::ScalarType r1, const typename MeshType::ScalarType r2, const int SubDiv=36)
Build a cone/frustum oriented from origin to end.
Definition: platonic.h:661
void BuildFromFaceEdgeSel(TriMeshType &in, EdgeMeshType &out)
Build an edge mesh from the selected edges of a triangle mesh.
Definition: platonic.h:949
void BuildCylinderVertexShell(MeshType &mIn, MeshType &mOut, float radius=0, float height=0, int slices=16, int stacks=1)
Build a cylindrical shell on each vertex aligned with its normal.
Definition: platonic.h:1582
void OrientedRect(MeshType &square, float width, float height, typename MeshType::CoordType c, typename MeshType::CoordType dir=typename MeshType::CoordType(0, 0, 0), float angleDeg=0, typename MeshType::CoordType preRotTra=typename MeshType::CoordType(0, 0, 0))
Build a rectangle in 3D with orientation and optional pre-rotation.
Definition: platonic.h:1661
void Icosahedron(IcoMeshType &in)
Build an icosahedron as a triangular mesh.
Definition: platonic.h:293
void OrientedAnnulus(MeshType &m, typename MeshType::CoordType center, typename MeshType::CoordType norm, float externalRadius, float internalRadius, int slices)
Build an oriented annulus in 3D, centered and rotated.
Definition: platonic.h:1187
void BuildMeshFromCoordVectorIndexVector(MeshType &in, const std::vector< InCoordType > &v, const std::vector< InFaceIndexType > &f)
Build a mesh from coordinate and face-index vectors.
Definition: platonic.h:897
void Cone(MeshType &in, const typename MeshType::ScalarType r1, const typename MeshType::ScalarType r2, const typename MeshType::ScalarType h, const int SubDiv=36)
r1 = raggio 1, r2 = raggio2, h = altezza (asse y)
Definition: platonic.h:560
void OrientedCylinder(MeshType &m, const typename MeshType::CoordType origin, const typename MeshType::CoordType end, float radius, bool capped, int slices=32, int stacks=4)
Build an oriented cylinder along a segment, optionally capped.
Definition: platonic.h:1347
void OrientedEllipticPrism(MeshType &m, const typename MeshType::CoordType origin, const typename MeshType::CoordType end, float radius, float xScale, float yScale, bool capped, int slices=32, int stacks=4)
Build an oriented elliptic prism (scaled cylinder), optionally capped.
Definition: platonic.h:1301
void Torus(MeshType &m, float hRingRadius, float vRingRadius, int hRingDiv=24, int vRingDiv=12)
Build a torus mesh around Z axis.
Definition: platonic.h:758
void BuildCylinderEdgeShell(MeshType &mIn, MeshType &mOut, float radius=0, int slices=16, int stacks=1)
Build a tubular shell around edges using oriented cylinders.
Definition: platonic.h:1523
void BuildMeshFromCoordVector(MeshType &in, const V &v)
Build a point-only mesh from coordinate vector (no faces).
Definition: platonic.h:934
void Circle2D(MeshType &m, float radius=1.0, int sides=32)
Build a 2D circle as a polyline (edges only) in XY plane.
Definition: platonic.h:1210
void Dodecahedron(DodMeshType &in)
Build a dodecahedron as a triangular mesh.
Definition: platonic.h:87
void Grid(MeshType &in, int w, int h, float wl, float hl, float *data=0)
Build a regular height-field grid mesh (vertices and faces).
Definition: platonic.h:992
void Octahedron(OctMeshType &in)
Build an octahedron as a triangular mesh.
Definition: platonic.h:254
void BuildSphereVertexShell(MeshType &mIn, MeshType &mOut, float radius=0, int recDiv=2)
Build a spherical shell on each vertex by instancing a small sphere.
Definition: platonic.h:1558
void BuildPrismFaceShell(MeshType &mIn, MeshType &mOut, float height=0, float inset=0, bool smoothFlag=false)
Build a shell made of face-aligned prisms for each face.
Definition: platonic.h:1425
void Hexahedron(MeshType &in)
Build a hexahedron (cube) as a triangular mesh.
Definition: platonic.h:355
void OrientedSquare(MeshType &square, float width, typename MeshType::CoordType c, typename MeshType::CoordType dir=typename MeshType::CoordType(0, 0, 0), float angleDeg=0, typename MeshType::CoordType preRotTra=typename MeshType::CoordType(0, 0, 0))
Build an oriented square (special case of OrientedRect).
Definition: platonic.h:1690
void Annulus(MeshType &m, float externalRadius, float internalRadius, int slices)
Build an annulus (ring) in the XY plane.
Definition: platonic.h:1146
void Square(MeshType &in)
Build a unit square in the XY plane as two triangles.
Definition: platonic.h:408
void SuperEllipsoid(MeshType &m, float rFeature, float sFeature, float tFeature, int hRingDiv=24, int vRingDiv=12)
Build a superellipsoid (superquadric sphere-like surface).
Definition: platonic.h:853
void Sphere(MeshType &in, const int subdiv=3)
Build a geodesic sphere by recursive icosahedron refinement.
Definition: platonic.h:501
void Cylinder(MeshType &m, int slices, int stacks, bool capped=false)
Build a unit cylinder aligned to Y, optionally capped.
Definition: platonic.h:1362
void DodecahedronSym(DodMeshType &in)
Build a symmetric dodecahedron as a triangular mesh.
Definition: platonic.h:137
void SuperToroid(MeshType &m, float hRingRadius, float vRingRadius, float vSquareness, float hSquareness, int hRingDiv=24, int vRingDiv=12)
Build a supertoroid (superquadric torus).
Definition: platonic.h:811
void SparseFaceGrid(MeshType &in, const std::vector< int > &grid, int w, int h)
Build faces for a sparsely sampled regular grid.
Definition: platonic.h:1072
void GenerateCameraMesh(MeshType &in)
Build a simple camera-shaped mesh (mainly for visualization).
Definition: platonic.h:1605
void Box(MeshType &in, const typename MeshType::BoxType &bb)
Build a box aligned with the axes from a bounding box.
Definition: platonic.h:704
void SphericalCap(MeshType &in, float angleRad, const int subdiv=3)
Build a spherical cap from a hexagon refined on the sphere.
Definition: platonic.h:450
void Disk(MeshType &m, int slices)
Build a unit disk (triangle fan) in the XY plane.
Definition: platonic.h:1234
void FaceGrid(MeshType &in, int w, int h)
Build faces for a regular grid given pre-allocated vertices.
Definition: platonic.h:1023
void Tetrahedron(TetraMeshType &in)
Build a tetrahedron as a triangular mesh.
Definition: platonic.h:54