/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2004-2012 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ #include // input output #include #include #include #include #include #include #include //#include using namespace vcg; class MyEdge; class MyFace; class MyVertex; struct MyUsedTypes : public UsedTypes< Use::AsVertexType, Use::AsFaceType>{}; class MyVertex : public Vertex< MyUsedTypes, vertex::Coord3f, vertex::BitFlags >{}; class MyFace : public Face < MyUsedTypes, face::VertexRef, face::FFAdj, face::WedgeTexCoord2f, face::Mark, face::BitFlags > {}; class MyMesh : public tri::TriMesh< std::vector, std::vector >{}; int main(int ,char ** ) { MyMesh m,tm; tri::io::ImporterPLY::Open(m,"../../meshes/bunny10k_textured.ply"); tri::Allocator::AddVertices(tm,m.fn*3); tri::Allocator::AddFaces(tm,m.fn); for(size_t i=0;i::RemoveDuplicateVertex(tm); std::vector > fpVec; tri::UpdateTopology::FaceFace(tm); tri::Clean::ConnectedComponents(tm,fpVec); printf("Mesh has %i texture components\n",fpVec.size()); tri::io::ExporterPLY::Save(tm,"out.ply"); std::vector< std::vector > outline3Vec; std::vector< std::vector > outline2Vec; tri::OutlineUtil::ConvertMeshBoundaryToOutline3Vec(tm, outline3Vec); printf("Mesh has %i texture components\n",outline3Vec.size()); tri::OutlineUtil::ConvertOutline3VeToOutline2Vec(outline3Vec,outline2Vec); PolyDumper::Param pp; Similarity2f sim; sim.sca=1024.0f; std::vector trVec(outline2Vec.size(),sim); printf("Mesh has %i texture components\n",outline2Vec.size()); PolyDumper::dumpOutline2VecPNG("PrePack.png",outline2Vec,trVec,pp); const Point2f containerSize(1024,1024); Point2f finalSize(1024,1024); PolyPacker::PackAsAxisAlignedRect(outline2Vec,containerSize,trVec,finalSize); PolyDumper::dumpOutline2VecPNG("PostPack.png",outline2Vec,trVec,pp); return 0; }