trimesh_implicit_smooth.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 ****************************************************************************/
00033 #include<vcg/complex/complex.h>
00034 
00035 #include<wrap/io_trimesh/import_ply.h>
00036 #include<wrap/io_trimesh/export_ply.h>
00037 
00038 #include<vcg/complex/algorithms/implicit_smooth.h>
00039 
00040 using namespace vcg;
00041 using namespace std;
00042 
00043 class MyEdge;
00044 class MyFace;
00045 class MyVertex;
00046 struct MyUsedTypes : public vcg::UsedTypes<     vcg::Use<MyVertex>   ::AsVertexType,
00047                                             vcg::Use<MyEdge>     ::AsEdgeType,
00048                                             vcg::Use<MyFace>     ::AsFaceType>{};
00049 
00050 class MyVertex  : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags  >{};
00051 class MyFace    : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::BitFlags > {};
00052 class MyEdge    : public vcg::Edge<MyUsedTypes>{};
00053 class MyMesh    : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge>  > {};
00054 
00055 
00056 int main( int argc, char **argv )
00057 {
00058   MyMesh m;
00059   if(argc < 2 )
00060   {
00061     printf("Usage: trimesh_implicit_smooth mesh.ply\n");
00062     return -1;
00063   }
00064 
00065   int ret= tri::io::ImporterPLY<MyMesh>::Open(m,argv[1]);
00066   if(ret!=0)
00067   {
00068     printf("Unable to open %s for '%s'\n",argv[1],tri::io::ImporterPLY<MyMesh>::ErrorMsg(ret));
00069     return -1;
00070   }
00071 
00072   tri::UpdateTopology<MyMesh>::FaceFace(m);
00073 
00074   ImplicitSmoother<MyMesh>::Parameter par;
00075   par.lambda = 0.5f;
00076   ImplicitSmoother<MyMesh>::Compute(m,par);
00077 
00078   tri::io::ExporterPLY<MyMesh>::Save(m,"smooth.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY);
00079 
00080   return 0;
00081 }


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