VCG Library
trimesh_base.cpp
Go to the documentation of this file.
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 ****************************************************************************/
32 #include<vcg/complex/complex.h>
33 #include<wrap/io_trimesh/import_off.h>
34 
35 class MyVertex; class MyEdge; class MyFace;
36 struct MyUsedTypes : public vcg::UsedTypes<vcg::Use<MyVertex> ::AsVertexType,
37  vcg::Use<MyEdge> ::AsEdgeType,
38  vcg::Use<MyFace> ::AsFaceType>{};
39 
40 class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
41 class MyFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VertexRef, vcg::face::BitFlags > {};
42 class MyEdge : public vcg::Edge< MyUsedTypes> {};
43 
44 class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};
45 
46 class MyVertex0 : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::BitFlags >{};
47 class MyVertex1 : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
48 class MyVertex2 : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Color4b, vcg::vertex::CurvatureDirf,
49  vcg::vertex::Qualityf, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
50 
51 
52 int main( int argc, char **argv )
53 {
54  if(argc<2)
55  {
56  printf("Usage trimesh_base <meshfilename.obj>\n");
57  return -1;
58  }
61  MyMesh m;
62 
63  if(vcg::tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=vcg::tri::io::ImporterOFF<MyMesh>::NoError)
64  {
65  printf("Error reading file %s\n",argv[1]);
66  exit(0);
67  }
68 
69  vcg::tri::RequirePerVertexNormal(m);
71  printf("Input mesh vn:%i fn:%i\n",m.VN(),m.FN());
72  printf( "Mesh has %i vert and %i faces\n", m.VN(), m.FN() );
73 
74  return 0;
75 }