35 #include "DGtal/io/Color.h"
44 template<
typename TPo
int>
53 out <<
"# generated from MeshWriter from the DGTal library"<< endl;
54 out << aMesh.nbVertex() <<
" " << aMesh.nbFaces() <<
" " << 0 <<
" " << endl;
56 for(
unsigned int i=0; i< aMesh.nbVertex(); i++){
57 out << aMesh.getVertex(i)[0] <<
" " << aMesh.getVertex(i)[1] <<
" "<< aMesh.getVertex(i)[2] << endl;
60 for (
unsigned int i=0; i< aMesh.nbFaces(); i++){
61 vector<unsigned int> aFace = aMesh.getFace(i);
62 out << aFace.size() <<
" " ;
63 for(
unsigned int j=0; j<aFace.size(); j++){
64 unsigned int indexVertex = aFace.at(j);
65 out << indexVertex <<
" " ;
70 out << ((double) col.
red())/255.0 <<
" "
71 << ((
double) col.
green())/255.0 <<
" "<< ((
double) col.
blue())/255.0
72 <<
" " << ((
double) col.
alpha())/255.0 ;
78 trace.
error() <<
"OFF writer IO error on export " << endl;
90 template<
typename TPo
int>
98 out <<
"# OBJ format"<< endl;
99 out <<
"# generated from MeshWriter from the DGTal library"<< endl;
101 out <<
"o anObj" << endl;
105 for(
unsigned int i=0; i< aMesh.nbVertex(); i++){
106 out <<
"v " << aMesh.getVertex(i)[0] <<
" " << aMesh.getVertex(i)[1] <<
" "<< aMesh.getVertex(i)[2] << endl;
110 for (
unsigned int i=0; i< aMesh.nbFaces(); i++){
111 vector<unsigned int> aFace = aMesh.getFace(i);
113 for(
unsigned int j=0; j<aFace.size(); j++){
114 unsigned int indexVertex = aFace.at(j);
115 out << (indexVertex+1) <<
" " ;
122 trace.
error() <<
"OBJ writer IO error on export " << endl;
132 template <
typename TPo
int>
136 string extension = aFilename.substr(aFilename.find_last_of(
".") + 1);
138 out.open(aFilename.c_str());
139 if(extension==
"off") {
141 }
else if(extension==
"obj") {