trimesh_cylclip.cpp
Go to the documentation of this file.
00001 #include <math.h>
00002 #include <stdio.h>
00003 #include <vcg/complex/algorithms/update/color.h>
00004 #include <vcg/complex/algorithms/create/platonic.h>
00005 #include <wrap/io_trimesh/import_ply.h>
00006 #include <wrap/io_trimesh/export_ply.h>
00007 #include <vcg/complex/algorithms/cylinder_clipping.h>
00008 
00009 using namespace vcg;
00010 using namespace std;
00011 
00012 class MyEdge;
00013 class MyFace;
00014 class MyVertex;
00015 struct MyUsedTypes : public UsedTypes<  Use<MyVertex>   ::AsVertexType,
00016                                         Use<MyEdge>     ::AsEdgeType,
00017                                         Use<MyFace>     ::AsFaceType >{};
00018 
00019 class MyVertex : public Vertex<MyUsedTypes, vertex::Normal3f, vertex::Coord3f, vertex::BitFlags, vertex::Color4b >{};
00020 class MyFace   : public Face<MyUsedTypes, face::Mark, face::Normal3f, face::FFAdj, face::BitFlags, face::VertexRef, face::Color4b > {};
00021 class MyEdge   : public Edge<MyUsedTypes, edge::BitFlags>{};
00022 class MyMesh   : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
00023 
00024 int main()
00025 {
00026     MyMesh m;
00027     tri::Hexahedron(m);
00028     tri::UpdateBounding<MyMesh>::Box(m);
00029     tri::UpdateTopology<MyMesh>::FaceFace(m);    //for FFAdj
00030     tri::UpdateNormal<MyMesh>::PerVertexNormalized(m);
00031     tri::UpdateFlags<MyMesh>::Clear(m);
00032 
00033     Point3f origin(0.8f,-0.4,0);
00034     Point3f end= origin+Point3f(0,1,0);
00035     float radius = 0.5f;
00036     MyMesh cm;
00037     tri::OrientedCylinder(cm,origin,end,radius,64,4);
00038     tri::io::ExporterPLY<MyMesh>::Save(cm,"cyl.ply");
00039 
00040     tri::CylinderClipping<MyMesh>::Apply(m,origin,end,radius);
00041     tri::CylinderClipping<MyMesh>::Apply(m,origin,end,radius/2.0f);
00042 
00043     tri::io::ExporterPLY<MyMesh>::Save(m,"cube.ply");
00044     return 0;
00045 }


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:38:16