trimesh_normal.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004-2012                                           \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00029 #include<vcg/complex/complex.h>
00030 
00031 #include<wrap/io_trimesh/import_off.h>
00032 
00033 #include<vcg/complex/algorithms/update/normal.h>
00034 
00035 using namespace vcg;
00036 using namespace std;
00037 
00038 class MyEdge;
00039 class MyFace;
00040 class MyVertex;
00041 struct MyUsedTypes : public UsedTypes<  Use<MyVertex>   ::AsVertexType,
00042                                         Use<MyEdge>     ::AsEdgeType,
00043                                         Use<MyFace>     ::AsFaceType>{};
00044 
00045 class MyVertex  : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags  >{};
00046 class MyFace    : public Face< MyUsedTypes, face::FFAdj,  face::VertexRef, face::BitFlags > {};
00047 class MyEdge    : public Edge<MyUsedTypes>{};
00048 class MyMesh    : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge>  > {};
00049 
00050 int main( int argc, char **argv )
00051 {
00052   if(argc<2)
00053   {
00054     printf("Usage trimesh_base <meshfilename.obj>\n");
00055     return -1;
00056   }
00057 
00058   MyMesh m;
00059 
00060   if(tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=0)
00061   {
00062     printf("Error reading file  %s\n",argv[1]);
00063     exit(0);
00064   }
00065 
00066   Matrix44f m44 = Matrix44f::Identity();
00067 
00068   tri::UpdateNormal<MyMesh>::PerVertexClear(m);
00069   tri::UpdateNormal<MyMesh>::PerVertex(m);
00070   tri::UpdateNormal<MyMesh>::PerVertexAngleWeighted(m);
00071   tri::UpdateNormal<MyMesh>::PerVertexNelsonMaxWeighted(m);
00072   tri::UpdateNormal<MyMesh>::PerFace(m);
00073   tri::UpdateNormal<MyMesh>::PerVertexFromCurrentFaceNormal(m);
00074   tri::UpdateNormal<MyMesh>::PerFaceFromCurrentVertexNormal(m);
00075   tri::UpdateNormal<MyMesh>::NormalizePerVertex(m);
00076   tri::UpdateNormal<MyMesh>::NormalizePerFace(m);
00077   tri::UpdateNormal<MyMesh>::NormalizePerFaceByArea(m);
00078   tri::UpdateNormal<MyMesh>::PerBitQuadFaceNormalized(m);
00079   tri::UpdateNormal<MyMesh>::PerVertexMatrix(m,m44);
00080   tri::UpdateNormal<MyMesh>::PerFaceMatrix(m,m44);
00081   tri::UpdateNormal<MyMesh>::PerWedgeCrease(m, math::ToRad(45.0f));
00082 
00083   return 0;
00084 }


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