| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifndef __VCGLIB_EXPORTERSMF |
| 42 |
#define __VCGLIB_EXPORTERSMF |
| 43 |
|
| 44 |
#include <vcg/space/point3.h> |
| 45 |
|
| 46 |
namespace vcg { |
| 47 |
namespace tetra { |
| 48 |
namespace io { |
| 49 |
|
| 50 |
template <typename MESHTYPE> |
| 51 |
struct ExporterTS{ |
| 52 |
|
| 53 |
typedef typename MESHTYPE::VertexPointer VertexPointer; |
| 54 |
typedef typename MESHTYPE::VertexType VertexType; |
| 55 |
typedef typename MESHTYPE::TetraType FaceType; |
| 56 |
typedef typename MESHTYPE::VertexIterator VertexIterator; |
| 57 |
typedef typename MESHTYPE::TetraIterator TetraIterator; |
| 58 |
typedef typename MESHTYPE::ScalarType ScalarType; |
| 59 |
typedef Point3<ScalarType> Point3x; |
| 60 |
|
| 61 |
static FILE *& F(){static FILE * f; return f;} |
| 62 |
|
| 63 |
inline static void WritePos(const Point3<ScalarType> &p){ |
| 64 |
fprintf(F(),"%g %g %g\n",p[0],p[1],p[2]); |
| 65 |
} |
| 66 |
inline static void WritePos(const Point4<ScalarType> &p){ |
| 67 |
fprintf(F(),"%g %g %g %g\n",p[0],p[1],p[2],p[3]); |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
static int Save( MESHTYPE & m, const char * filename ) |
| 73 |
{ |
| 74 |
|
| 75 |
F() = fopen(filename,"w"); |
| 76 |
if(F() == NULL ) |
| 77 |
{ |
| 78 |
printf( "The file could not be opened\n" ); |
| 79 |
return -1; |
| 80 |
} |
| 81 |
else |
| 82 |
{ |
| 83 |
fprintf(F(), "%i\n", m.vn ); |
| 84 |
fprintf(F(), "%i\n", m.tn ); |
| 85 |
VertexIterator vi; |
| 86 |
for (vi = m.vert.begin(); vi != m.vert.end();++vi) |
| 87 |
|
| 88 |
WritePos((*vi).P()); |
| 89 |
|
| 90 |
TetraIterator ti; |
| 91 |
for( ti = m.tetra.begin(); ti != m.tetra.end(); ++ti) |
| 92 |
fprintf(F(), "%d %d %d %d \n", |
| 93 |
(*ti).V(0)-&*m.vert.begin(), |
| 94 |
(*ti).V(1)-&*m.vert.begin(), |
| 95 |
(*ti).V(2)-&*m.vert.begin(), |
| 96 |
(*ti).V(3)-&*m.vert.begin()); |
| 97 |
} |
| 98 |
return 0; |
| 99 |
} |
| 100 |
}; |
| 101 |
}; |
| 102 |
}; |
| 103 |
}; |
| 104 |
|
| 105 |
#endif |
| 106 |
|