00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __VCG_LIB_EXPORTER_DXF
00041 #define __VCG_LIB_EXPORTER_DXF
00042
00043
00044 namespace vcg {
00045 namespace edg {
00046 namespace io {
00047
00048
00049 template <class EdgeMeshType>
00050 class ExporterDXF
00051 {
00052 public:
00053
00054 ExporterDXF(void){}
00055
00056
00057
00058 static bool Save(EdgeMeshType *mp, const char * filename)
00059 {
00060 FILE * o = fopen(filename,"w");
00061 if(o==NULL) return false;
00062 fprintf(o,"0\n");
00063 fprintf(o,"SECTION\n");
00064 fprintf(o,"2\n");
00065 fprintf(o,"ENTITIES\n");
00066
00067 Save(mp,o);
00068
00069 fprintf(o,"0\n");
00070 fprintf(o,"ENDSEC\n");
00071 fprintf(o,"0\n");
00072 fprintf(o,"EOF\n");
00073 fclose(o);
00074 return true;
00075 }
00076
00077
00078
00079 static void Save(EdgeMeshType *mp, FILE* o )
00080 {
00081 typename EdgeMeshType::EdgeIterator i;
00082 for(i=mp->edges.begin(); i!=mp->edges.end();++i)
00083 {
00084 Point3f p1 = (*i).V(0)->P();
00085 Point3f p2 = (*i).V(1)->P();
00086
00087
00088 fprintf(o,"0\n");
00089 fprintf(o,"LINE\n");
00090 fprintf(o,"8\n");
00091 fprintf(o,"0\n");
00092 fprintf(o,"10\n");
00093
00094 fprintf(o,"%f\n", p1[0]);
00095 fprintf(o,"20\n");
00096 fprintf(o,"%f\n", p1[1]);
00097 fprintf(o,"30\n");
00098 fprintf(o,"%f\n", p1[2]);
00099
00100 fprintf(o,"11\n");
00101 fprintf(o,"%f\n", p2[0]);
00102 fprintf(o,"21\n");
00103 fprintf(o,"%f\n", p2[1]);
00104 fprintf(o,"31\n");
00105 fprintf(o,"%f\n", p2[2]);
00106
00107 }
00108
00109
00110
00111 }
00112
00113
00114 };
00115
00116 };
00117 };
00118 };
00119 #endif