/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2011 \/)\/ * * 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. * * * ****************************************************************************/ #ifndef EXPORT_CTM_H #define EXPORT_CTM_H namespace vcg { namespace tri { namespace io { template class ExporterCTM { public: typedef typename SaveMeshType::VertexPointer VertexPointer; typedef typename SaveMeshType::FaceIterator FaceIterator; static int Save(SaveMeshType &m, const char * filename, int mask=0, bool lossLessFlag=false, float relativePrecision=0.0001) { tri::Allocator::CompactVertexVector(m); tri::Allocator::CompactFaceVector(m); CTMuint aVertCount=m.vn; CTMuint aTriCount=m.fn; std::vector aVertices(aVertCount*3); std::vector aColors(aVertCount*4); std::vector aQuality(aVertCount*4); std::vector aIndices(aTriCount*3); int err; CTMcontext context; // Create a new exporter context context = ctmNewContext(CTM_EXPORT); if(lossLessFlag) ctmCompressionMethod(context, CTM_METHOD_MG1); else { ctmCompressionMethod(context, CTM_METHOD_MG2); ctmVertexPrecision(context, relativePrecision); } // Prepare vertex and faces for(unsigned int i=0;i