Go to the documentation of this file.00001 #ifndef EXTRUDE_H
00002 #define EXTRUDE_H
00003
00004 namespace vcg {
00005 namespace tri {
00006
00007
00008 template <class MeshType> class Extrude
00009 {
00010 public:
00011 typedef typename MeshType::FacePointer FacePointer;
00012 typedef typename MeshType::EdgePointer EdgePointer;
00013 typedef typename MeshType::VertexPointer VertexPointer;
00014 typedef typename MeshType::FaceType FaceType;
00015 typedef typename MeshType::EdgeType EdgeType;
00016 typedef typename MeshType::VertexIterator VertexIterator;
00017 typedef typename MeshType::EdgeIterator EdgeIterator;
00018 typedef typename MeshType::FaceIterator FaceIterator;
00019
00020 static void ProfileWithCap(MeshType &profile, MeshType &fullSurface, const vcg::Similarityf &sim )
00021 {
00022 fullSurface.Clear();
00023 MeshType lowCapSurf,topCapSurf;
00024 ProfileWithCap(profile,fullSurface,lowCapSurf,topCapSurf,sim);
00025 tri::Append<MeshType,MeshType>::Mesh(fullSurface,lowCapSurf);
00026 tri::Append<MeshType,MeshType>::Mesh(fullSurface,topCapSurf);
00027 tri::Clean<MeshType>::RemoveDuplicateVertex(fullSurface);
00028 bool oriented,orientable;
00029 tri::UpdateTopology<MeshType>::FaceFace(fullSurface);
00030 tri::Clean<MeshType>::OrientCoherentlyMesh(fullSurface,oriented,orientable);
00031 }
00032
00033 static void ProfileWithCap(MeshType &profile, MeshType &sideSurf, MeshType &lowCapSurf, MeshType &topCapSurf, const vcg::Similarityf &sim )
00034 {
00035 sideSurf.Clear();
00036 lowCapSurf.Clear();
00037 topCapSurf.Clear();
00038
00039 for(VertexIterator vi=profile.vert.begin();vi!=profile.vert.end();++vi)
00040 {
00041 VertexIterator vp=tri::Allocator<MeshType>::AddVertices(sideSurf,2);
00042 vp->P()=vi->P();
00043 ++vp;
00044 vp->P()= sim*vi->P() ;
00045 }
00046
00047 for(EdgeIterator ei=profile.edge.begin();ei!=profile.edge.end();++ei)
00048 {
00049 int i0=tri::Index(profile,ei->V(0));
00050 int i1=tri::Index(profile,ei->V(1));
00051
00052 FaceIterator fp= tri::Allocator<MeshType>::AddFaces(sideSurf,2);
00053 fp->V(0) = &sideSurf.vert[i0*2];
00054 fp->V(1) = &sideSurf.vert[i1*2];
00055 fp->V(2) = &sideSurf.vert[i0*2+1];
00056 ++fp;
00057 fp->V(0) = &sideSurf.vert[i1*2+1];
00058 fp->V(1) = &sideSurf.vert[i0*2+1];
00059 fp->V(2) = &sideSurf.vert[i1*2];
00060 }
00061
00062 tri::CapEdgeMesh(profile,lowCapSurf);
00063 if(lowCapSurf.fn==0) CapEdgeMesh(profile,lowCapSurf,true);
00064
00065 tri::Append<MeshType,MeshType>::Mesh(topCapSurf,lowCapSurf);
00066 for(VertexIterator vi=topCapSurf.vert.begin();vi!=topCapSurf.vert.end();++vi)
00067 vi->P() = sim*vi->P();
00068
00069 }
00070
00071 static void ProfileWithCap(MeshType &profile, MeshType &surface, const Point3f offset)
00072 {
00073 Similarityf tra;
00074 tra.SetTranslate(offset);
00075 ProfileWithCap(profile,surface,tra);
00076 }
00077
00078 };
00079
00080 }
00081 }
00082
00083 #endif // EXTRUDE_H