export_ts.h
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                                                \/)\/    *
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   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.1  2004/10/11 17:41:41  ganovelli
00028 added
00029 
00030 Revision 1.1  2004/06/03 13:16:32  ganovelli
00031 created
00032 
00033 Revision 1.3  2004/05/10 13:14:28  ganovelli
00034 converted to library style (namespaces etc..)
00035 
00036 
00037 ****************************************************************************/
00038 #ifndef __VCGLIB_EXPORTERSMF
00039 #define __VCGLIB_EXPORTERSMF
00040 
00041 #include <vcg/space/point3.h>
00042 
00043 namespace vcg {
00044 namespace tetra {
00045 namespace io {
00046 
00047 template <typename  MESHTYPE>
00048 struct ExporterTS{
00049 
00050         typedef typename MESHTYPE::VertexPointer VertexPointer;
00051         typedef typename MESHTYPE::VertexType VertexType;
00052         typedef typename MESHTYPE::TetraType FaceType;
00053         typedef typename MESHTYPE::VertexIterator VertexIterator;
00054         typedef typename MESHTYPE::TetraIterator TetraIterator;
00055         typedef typename MESHTYPE::ScalarType ScalarType;
00056         typedef Point3<ScalarType> Point3x;
00057         
00058         static FILE *& F(){static FILE * f; return f;}
00059 
00060         inline static void WritePos(const Point3<ScalarType> &p){
00061                 fprintf(F(),"%g %g %g\n",p[0],p[1],p[2]);
00062         }
00063         inline static void WritePos(const Point4<ScalarType> &p){
00064                 fprintf(F(),"%g %g %g %g\n",p[0],p[1],p[2],p[3]);
00065         }
00066 
00067 
00068 
00069 static int Save( MESHTYPE & m, const char * filename )
00070 {       
00071         
00072         F() = fopen(filename,"w");
00073         if(F() == NULL ) 
00074                 {
00075                         printf( "The file could not be opened\n" );
00076                         return -1;
00077                 }
00078    else
00079    {
00080                 fprintf(F(), "%i\n", m.vn );
00081                 fprintf(F(), "%i\n", m.tn );
00082                 VertexIterator vi;
00083                 for (vi = m.vert.begin(); vi != m.vert.end();++vi)
00084                         //fprintf(F(), "%f %f %f \n", (*vi).P()[0],(*vi).P()[1],(*vi).P()[2] );
00085                         WritePos((*vi).P());
00086 
00087                 TetraIterator ti;
00088                 for( ti = m.tetra.begin(); ti != m.tetra.end(); ++ti)
00089                         fprintf(F(), "%d %d %d %d \n",
00090                                                         (*ti).V(0)-&*m.vert.begin(),
00091                                                         (*ti).V(1)-&*m.vert.begin(),
00092                                                         (*ti).V(2)-&*m.vert.begin(),
00093                                                         (*ti).V(3)-&*m.vert.begin());
00094          }
00095  return 0;
00096 }
00097         };// end class
00098                 };// end of io
00099         };// end of tri
00100 };// end of vcg
00101 
00102 #endif
00103 


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