trimesh_diskparam.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-2009                                           \/)\/    *
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 ****************************************************************************/
00023 
00024 #include<vcg/simplex/vertex/base.h>
00025 #include<vcg/simplex/vertex/component.h>
00026 
00027 #include <vcg/complex/used_types.h>
00028 
00029 #include<vcg/simplex/face/base.h>
00030 #include<vcg/simplex/face/component.h>
00031 #include<vcg/complex/complex.h>
00032 #include<vcg/complex/algorithms/create/platonic.h>
00033 #include<vcg/complex/algorithms/parametrization/poisson_solver.h>
00034 #include<vcg/complex/algorithms/update/texture.h>
00035 #include<wrap/io_trimesh/import_ply.h>
00036 #include<wrap/io_trimesh/export_ply.h>
00037 
00038 using namespace vcg;
00039 using namespace std;
00040 
00041 class MyEdge;
00042 class MyFace;
00043 class MyVertex;
00044 struct MyUsedTypes : public UsedTypes<  Use<MyVertex>   ::AsVertexType,
00045                                         Use<MyEdge>     ::AsEdgeType,
00046                                         Use<MyFace>     ::AsFaceType>{};
00047 
00048 class MyVertex  : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::TexCoord2f, vertex::BitFlags  >{};
00049 class MyFace    : public Face< MyUsedTypes, face::VertexRef, face::BitFlags, face::FFAdj , face::WedgeTexCoord2f> {};
00050 class MyEdge    : public Edge<MyUsedTypes>{};
00051 class MyMesh    : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge>  > {};
00052 
00053 
00054 int main( int argc, char **argv )
00055 {
00056   MyMesh m;
00057   if(argc < 2 ) return -1;
00058 
00059   printf("Reading %s\n",argv[1]);
00060   int ret= tri::io::ImporterPLY<MyMesh>::Open(m,argv[1]);
00061   if(ret!=0)
00062   {
00063     printf("Unable to open %s for '%s'\n",argv[1],tri::io::ImporterPLY<MyMesh>::ErrorMsg(ret));
00064     return -1;
00065   }
00066 
00067   printf("Mesh has %i vn %i fn\n",m.VN(),m.FN());
00068   tri::PoissonSolver<MyMesh> PS(m);
00069 
00070   if(!PS.IsFeaseable())
00071   {
00072     printf("mesh is not homeomorphic to a disk\n");
00073     return -1;
00074   } else
00075     printf("OK - mesh is homeomorphic to a disk\n");
00076 
00077   PS.Init();
00078   PS.SetBorderAsFixed();
00079   PS.FixDefaultVertices();
00080   PS.SolvePoisson(true);
00081 
00082   tri::UpdateTexture<MyMesh>::WedgeTexFromVertexTex(m);
00083   tri::io::ExporterPLY<MyMesh>::Save(m,"pippo.ply",tri::io::Mask::IOM_WEDGTEXCOORD);
00084 
00085   return 0;
00086 }


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