From ffcdfa9f8814803ee63e9f8d620993f6a0922cf7 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 28 Jan 2013 16:03:57 +0000 Subject: [PATCH] Added a couple of throw vcg::MissingComponentException and refactored a bit --- wrap/io_trimesh/import_field.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/wrap/io_trimesh/import_field.h b/wrap/io_trimesh/import_field.h index bea0a97a..428abdf4 100644 --- a/wrap/io_trimesh/import_field.h +++ b/wrap/io_trimesh/import_field.h @@ -119,6 +119,10 @@ public: //if (errorMsg) sprintf(errorMsg,"Wrong element number. Found: %d. Expected: %d.",nnv,mesh->vn); return false; } + + if( per_vertex && !HasPerVertexCurvatureDir(mesh)) throw vcg::MissingComponentException("PerVertexCurvatureDir"); + if(!per_vertex && !HasPerFaceCurvatureDir(mesh)) throw vcg::MissingComponentException("PerFaceCurvatureDir"); + while (fscanf(f,"%c",&c)!=EOF) if (c=='\n') break; // skip // skip strange string line while (fscanf(f,"%c",&c)!=EOF) if (c=='\n') break; @@ -140,23 +144,13 @@ public: if (per_vertex) { - mesh.vert[i].PD1().X()=(ScalarType) u.X(); - mesh.vert[i].PD1().Y()=(ScalarType) u.Y(); - mesh.vert[i].PD1().Z()=(ScalarType) u.Z(); - mesh.vert[i].PD2().X()=(ScalarType) v.X(); - mesh.vert[i].PD2().Y()=(ScalarType) v.Y(); - mesh.vert[i].PD2().Z()=(ScalarType) v.Z(); + mesh.vert[i].PD1().Import(u); + mesh.vert[i].PD2().Import(v); } else { - mesh.face[i].PD1().X()=(ScalarType) u.X(); - mesh.face[i].PD1().Y()=(ScalarType) u.Y(); - mesh.face[i].PD1().Z()=(ScalarType) u.Z(); - mesh.face[i].PD2().X()=(ScalarType) v.X(); - mesh.face[i].PD2().Y()=(ScalarType) v.Y(); - mesh.face[i].PD2().Z()=(ScalarType) v.Z(); - mesh.face[i].PD1().Normalize(); - mesh.face[i].PD2().Normalize(); + mesh.face[i].PD1().Import(u); + mesh.face[i].PD2().Import(v); } } }