1 /****************************************************************************
2 * VCGLib                                                            o o     *
3 * Visual and Computer Graphics Library                            o     o   *
4 *                                                                _   O  _   *
5 * Copyright(C) 2004-2016                                           \/)\/    *
6 * Visual Computing Lab                                            /\/|      *
7 * ISTI - Italian National Research Council                           |      *
8 *                                                                    \      *
9 * All rights reserved.                                                      *
10 *                                                                           *
11 * This program is free software; you can redistribute it and/or modify      *
12 * it under the terms of the GNU General Public License as published by      *
13 * the Free Software Foundation; either version 2 of the License, or         *
14 * (at your option) any later version.                                       *
15 *                                                                           *
16 * This program is distributed in the hope that it will be useful,           *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
20 * for more details.                                                         *
21 *                                                                           *
22 ****************************************************************************/
23 /*! \file trimesh_curvature.cpp
24 \ingroup code_sample
25 
26 \brief an example showing the various techniques for computing curvatures
27 
28 */
29 #include <vcg/complex/complex.h>
30 
31 #include <vcg/complex/algorithms/create/platonic.h>
32 #include <vcg/complex/algorithms/update/curvature.h>
33 
34 #include<wrap/io_trimesh/export_off.h>
35 
36 class MyEdge;
37 class MyFace;
38 class MyVertex;
39 struct MyUsedTypes : public vcg::UsedTypes<	vcg::Use<MyVertex>   ::AsVertexType,
40                                             vcg::Use<MyEdge>     ::AsEdgeType,
41                                             vcg::Use<MyFace>     ::AsFaceType>{};
42 
43 class MyVertex  : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::VFAdj, vcg::vertex::CurvatureDirf, vcg::vertex::Curvaturef, vcg::vertex::BitFlags  >{};
44 class MyFace    : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VFAdj, vcg::face::VertexRef, vcg::face::BitFlags > {};
45 class MyEdge    : public vcg::Edge<MyUsedTypes>{};
46 class MyMesh    : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge>  > {};
47 
main(int,char **)48 int main( int /*argc*/, char **/*argv*/ )
49 {
50   MyMesh m;
51   vcg::tri::Torus(m,30,10);
52 
53   vcg::tri::UpdateTopology<MyMesh>::FaceFace(m);
54   vcg::tri::UpdateTopology<MyMesh>::VertexFace(m);
55 
56   // Two different techniques for computing Discrete Gaussian and Mean Curvature
57   // they require the presence of the vertex::Curvature component
58   vcg::tri::UpdateCurvature<MyMesh>::PerVertex(m);
59   vcg::tri::UpdateCurvature<MyMesh>::MeanAndGaussian(m);
60 
61   // Two different techniques for computing Principal Curvature Directions
62   // they require the presence of the vertex::CurvatureDir component
63   vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirections(m);
64   vcg::tri::UpdateCurvature<MyMesh>::PrincipalDirectionsNormalCycle(m);
65   printf("Input mesh  vn:%i fn:%i\n",m.VN(),m.FN());
66 
67   return 0;
68 }
69