diff --git a/wrap/io_tetramesh/export_smf.h b/wrap/io_tetramesh/export_smf.h deleted file mode 100644 index 8525e51e..00000000 --- a/wrap/io_tetramesh/export_smf.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * -* Copyright(C) 2004 \/)\/ * * 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. * * * ****************************************************************************/ -/**************************************************************************** - History - -$Log: not supported by cvs2svn $ -Revision 1.3 2004/05/10 13:14:28 ganovelli -converted to library style (namespaces etc..) - - -****************************************************************************/ #ifndef __VCGLIB_IMPORTERSMF -#define __VCGLIB_IMPORTERSMF #include - -namespace vcg { -namespace tetra { -namespace io { - -template -class ExporterTS{ - - typedef typename MESHTYPE::VertexPointer VertexPointer; - typedef typename MESHTYPE::VertexType VertexType; - typedef typename MESHTYPE::TetraType FaceType; - typedef typename MESHTYPE::VertexIterator VertexIterator; - typedef typename MESHTYPE::FaceIterator FaceIterator; - typedef MESHTYPE::ScalarType ScalarType; - typedef Point3 Point3x; - - -int Save( MESHTYPE & m, const char * filename ) { - FILE *f; - f = fopen(filename,"w"); - if(f == NULL ) - { - printf( "The file could not be opened\n" ); - return -1; - } - else - { - fprintf(f, "%i", m.vn ); - fprintf(f, "%i", m.tn ); - VertexIterator vi; - for (vi = m.vert.begin(); vi != m.vert.end();++vi) - fprintf(f, "%f %f %f \n", (*vi).P()[0],(*vi).P()[1],(*vi).P()[2] ); - - TetraIterator ti; - fr( ti = m.tetra.begin(); ti != m.tetra.end(); ++ti) - fprintf(f, "%d %d %d %d \n", - (*ti)->V(0)-&*m.tetra.begin(), - (*ti)->V(1)-&*m.tetra.begin(), - (*ti)->V(2)-&*m.tetra.begin(), - (*ti)->V(3)-&*m.tetra.begin()); - } return 0; } };// end class };// end of io };// end of tri };// end of vcg #endif \ No newline at end of file diff --git a/wrap/io_tetramesh/export_ts.h b/wrap/io_tetramesh/export_ts.h new file mode 100644 index 00000000..749feb87 --- /dev/null +++ b/wrap/io_tetramesh/export_ts.h @@ -0,0 +1,100 @@ +/**************************************************************************** +* VCGLib o o * +* Visual and Computer Graphics Library o o * +* _ O _ * +* Copyright(C) 2004 \/)\/ * +* 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. * +* * +****************************************************************************/ +/**************************************************************************** + History + +$Log: not supported by cvs2svn $ +Revision 1.1 2004/06/03 13:16:32 ganovelli +created + +Revision 1.3 2004/05/10 13:14:28 ganovelli +converted to library style (namespaces etc..) + + +****************************************************************************/ +#ifndef __VCGLIB_EXPORTERSMF +#define __VCGLIB_EXPORTERSMF + +#include + +namespace vcg { +namespace tetra { +namespace io { + +template +struct ExporterTS{ + + typedef typename MESHTYPE::VertexPointer VertexPointer; + typedef typename MESHTYPE::VertexType VertexType; + typedef typename MESHTYPE::TetraType FaceType; + typedef typename MESHTYPE::VertexIterator VertexIterator; + typedef typename MESHTYPE::TetraIterator TetraIterator; + typedef MESHTYPE::ScalarType ScalarType; + typedef Point3 Point3x; + + static FILE *& F(){static FILE * f; return f;} + + inline static void WritePos(const Point3 &p){ + fprintf(F(),"%g %g %g\n",p[0],p[1],p[2]); + } + inline static void WritePos(const Point4 &p){ + fprintf(F(),"%g %g %g %g\n",p[0],p[1],p[2],p[3]); + } + + + +int Save( MESHTYPE & m, const char * filename ) +{ + + F() = fopen(filename,"w"); + if(F() == NULL ) + { + printf( "The file could not be opened\n" ); + return -1; + } + else + { + fprintf(F(), "%i\n", m.vn ); + fprintf(F(), "%i\n", m.tn ); + VertexIterator vi; + for (vi = m.vert.begin(); vi != m.vert.end();++vi) + //fprintf(F(), "%f %f %f \n", (*vi).P()[0],(*vi).P()[1],(*vi).P()[2] ); + WritePos((*vi).P()); + + TetraIterator ti; + for( ti = m.tetra.begin(); ti != m.tetra.end(); ++ti) + fprintf(F(), "%d %d %d %d \n", + (*ti).V(0)-&*m.vert.begin(), + (*ti).V(1)-&*m.vert.begin(), + (*ti).V(2)-&*m.vert.begin(), + (*ti).V(3)-&*m.vert.begin()); + } + return 0; +} + };// end class + };// end of io + };// end of tri +};// end of vcg + +#endif + diff --git a/wrap/io_tetramesh/import_ts.h b/wrap/io_tetramesh/import_ts.h index f4d3adea..218628e5 100644 --- a/wrap/io_tetramesh/import_ts.h +++ b/wrap/io_tetramesh/import_ts.h @@ -18,6 +18,14 @@ class ImporterTS{ typedef typename Tetramesh::ScalarType ScalarType; typedef Point3 Point3x; + static FILE *& F(){static FILE * f; return f;} + + inline static ReadPos( Point3 &p){ + fscanf(F(),"%g %g %g\n",&p[0],&p[1],&p[2]); + } + inline static ReadPos( Point4 &p){ + fscanf(F(),"%g %g %g %g\n",&p[0],&p[1],&p[2],&p[3]); + } public: static int Open( Tetramesh & m, const char * filename ) { int nvertex; @@ -30,41 +38,39 @@ static int Open( Tetramesh & m, const char * filename ) { int tp2; int tp3; float mass; - FILE *f; typename Tetramesh::VertexType p1; - f = fopen(filename,"r"); - if(f == NULL ) + F() = fopen(filename,"r"); + if(F() == NULL ) { printf( "The file was not opened\n" ); return -1; } else { - fscanf(f, "%i", &nvertex ); - fscanf(f, "%i", &ntetra ); + fscanf(F(), "%i", &nvertex ); + fscanf(F(), "%i", &ntetra ); int j; for (j=0;j