From 470e156a19bd8d46d12556db1ab62d518c8fb3ff Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Sun, 14 Jun 2015 23:16:02 +0000 Subject: [PATCH] added function AdjustDirectionsOnTangentspace ando some minor changes --- .../parametrization/tangent_field_operators.h | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/vcg/complex/algorithms/parametrization/tangent_field_operators.h b/vcg/complex/algorithms/parametrization/tangent_field_operators.h index a6650270..6b4beb3c 100644 --- a/vcg/complex/algorithms/parametrization/tangent_field_operators.h +++ b/vcg/complex/algorithms/parametrization/tangent_field_operators.h @@ -516,7 +516,7 @@ private: public: - static bool FindSeparatrices(const typename vcg::face::Pos &vPos, + static size_t FindSeparatrices(const typename vcg::face::Pos &vPos, std::vector &directions, std::vector &faces, std::vector &WrongTris, @@ -638,17 +638,17 @@ public: directions.push_back(InterpDir); faces.push_back(currF); } - if (expVal==-1)return true; - if (directions.size()<=expVal)return true; - + if (expVal==-1)return directions.size(); + if (directions.size()<=expVal)return directions.size(); + size_t sampledDir=directions.size(); int to_erase=directions.size()-expVal; do { ReduceOneDirectionField(directions,faces); to_erase--; }while (to_erase!=0); - return false; + return sampledDir; } static CoordType FollowDirection(const FaceType &f0, @@ -1218,7 +1218,7 @@ public: for (size_t i=0;iPD2().Normalize(); } + static void AdjustDirectionsOnTangentspace(MeshType &mesh) + { + for (size_t i=0;iIsD())continue; + CoordType Ntest=mesh.face[i].PD1()^mesh.face[i].PD2(); + Ntest.Normalize(); + CoordType Ntarget=mesh.face[i].N(); + if ((Ntest*Ntarget)>0.999)continue; + + //find the rotation matrix that maps between normals + vcg::Matrix33 rotation=vcg::RotationMatrix(Ntest,Ntarget); + mesh.face[i].PD1()=rotation*mesh.face[i].PD1(); + mesh.face[i].PD2()=rotation*mesh.face[i].PD2(); + } + } + static void OrientDirectionFaceCoherently(MeshType &mesh) { for (size_t i=0;i