Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __VCGLIB_EXPORTERFIELD
00024 #define __VCGLIB_EXPORTERFIELD
00025
00026 #include <vcg/complex/algorithms/parametrization/tangent_field_operators.h>
00027
00028 namespace vcg {
00029 namespace tri {
00030 namespace io {
00031
00035 template <class MeshType>
00036 class ExporterFIELD
00037 {
00038 typedef typename MeshType::ScalarType ScalarType;
00039 typedef typename MeshType::FaceType FaceType;
00040 typedef typename MeshType::VertexType VertexType;
00041 typedef typename MeshType::CoordType CoordType;
00042
00043 public:
00044
00047 static void SaveFaceFIELD(MeshType &mesh,
00048 const char *path)
00049 {
00050
00051 FILE *f = fopen(path,"wt");
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 int nf = mesh.fn;
00065 fprintf(f,"# frame generated with VCG \n");
00066 fprintf(f,"target frame \n");
00067 fprintf(f,"%d\n",nf);
00068
00069
00070
00071 if (!HasPerFaceCurvatureDir(mesh))
00072 throw vcg::MissingComponentException("PerFaceCurvatureDir");
00073
00074 fprintf(f,"k1 k2 k1v_x k1v_y k1v_z k2v_x k2v_y k2v_z\n");
00075
00076 for (int i=0; i<nf; i++){
00077 vcg::Point3<float> u;
00078 u.Import(mesh.face[i].PD1());
00079 vcg::Point3<float> v;
00080 v.Import(mesh.face[i].PD2());
00081
00082 fprintf(f,"1 1 %f %f %f %f %f %f\n",
00083 (u.X()),(u.Y()),(u.Z()),
00084 (v.X()),(v.Y()),(v.Z()));
00085 }
00086 fclose(f);
00087 }
00088
00089
00093 static void Save4ROSY(MeshType &mesh,
00094 const char *path)
00095 {
00096 FILE *f = fopen(path,"wt");
00097 fprintf(f,"%d\n",mesh.vn);
00098 fprintf(f,"4\n");
00099 for (unsigned int i=0;i<mesh.vert.size();i++)
00100 {
00101 float dirX=(float)mesh.vert[i].PD1().X();
00102 float dirY=(float)mesh.vert[i].PD1().Y();
00103 float dirZ=(float)mesh.vert[i].PD1().Z();
00104 fprintf(f,"%f %f %f \n",dirX,dirY,dirZ);
00105
00106 }
00107 fclose(f);
00108 }
00109
00110
00111 static void Save2AngleFace(MeshType &mesh,
00112 const char *path)
00113 {
00114 FILE *f = fopen(path,"wt");
00115 fprintf(f,"#%d param_field\n",mesh.fn);
00116 for (unsigned int i=0;i<mesh.face.size();i++)
00117 {
00118 ScalarType alpha1,alpha2;
00119 CoordType PD1Test=mesh.face[i].PD1();
00120 CoordType PD2Test=mesh.face[i].PD2();
00121 vcg::tri::CrossField<MeshType>::CrossFieldToAngles(mesh.face[i],alpha1,alpha2,1);
00122 fprintf(f,"%d %f %f \n",i,alpha1,alpha2);
00123 }
00124 fclose(f);
00125 }
00126
00127 };
00128
00129
00130
00131 }
00132 }
00133 }
00134
00135 #endif
00136