From 6dd5244ddb8cfdcbec1e67d8ebb3190d99b44409 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 19 Dec 2017 00:56:57 +1100 Subject: [PATCH 1/4] minor warning solved --- vcg/complex/algorithms/update/quality.h | 2 +- wrap/igl/smooth_field.h | 11 +++--- wrap/io_trimesh/import_field.h | 46 ++++++++++++------------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/vcg/complex/algorithms/update/quality.h b/vcg/complex/algorithms/update/quality.h index 9df78464..16801750 100644 --- a/vcg/complex/algorithms/update/quality.h +++ b/vcg/complex/algorithms/update/quality.h @@ -186,7 +186,7 @@ static void FaceFromVertex( MeshType &m) for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD()) { (*fi).Q() =0; - for (size_t i=0;i<(*fi).VN();i++) + for (int i=0;i<(*fi).VN();i++) (*fi).Q() += (*fi).V(i)->Q(); (*fi).Q()/=(FaceQualityType)(*fi).VN(); } diff --git a/wrap/igl/smooth_field.h b/wrap/igl/smooth_field.h index e5e1d0dd..cb421cfa 100644 --- a/wrap/igl/smooth_field.h +++ b/wrap/igl/smooth_field.h @@ -341,11 +341,8 @@ public: Ndir=4; curvRing=2; alpha_curv=0.0; - align_borders=false; - SmoothM=SMMiq; - sharp_thr=0.0; curv_thr=0.4; } @@ -488,10 +485,10 @@ public: //for the moment only cross and line field //initialize direction by curvature if needed - if ((SParam.alpha_curv>0)|| - (SParam.sharp_thr>0)|| - (SParam.curv_thr>0)) - InitByCurvature(mesh,SParam.curvRing); +// if ((SParam.alpha_curv>0)|| +// (SParam.sharp_thr>0)|| +// (SParam.curv_thr>0)) + InitByCurvature(mesh,SParam.curvRing); SelectConstraints(mesh,SParam); //then do the actual smooth diff --git a/wrap/io_trimesh/import_field.h b/wrap/io_trimesh/import_field.h index 2ba37c58..d7c5ad23 100644 --- a/wrap/io_trimesh/import_field.h +++ b/wrap/io_trimesh/import_field.h @@ -109,33 +109,33 @@ public: printf("%d\n",period); fscanf(f,"%c",&final); fseek(f, -1, SEEK_CUR); - printf("%s\n",&final[0]); + //printf("%s\n",&final[0]); }while(strcmp(final,"\"")!=0); // printf("%s\n",skipstr); fflush(stdout); - // for (int i=0;i UV[3]; - // UV[0]= vcg::Point2(u0,v0); - // UV[1]= vcg::Point2(u1,v1); - // UV[2]= vcg::Point2(u2,v2); - // CoordType dir1; - // CoordType dir2; - // vcg::tri::CrossField::GradientToCross(mesh.face[i],UV[0],UV[1],UV[2],dir1,dir2); - // dir1.Normalize(); - // dir2.Normalize(); - // mesh.face[i].PD1()=dir1; - // mesh.face[i].PD2()=dir2; - // } - // fclose(f); - // return true; + for (int i=0;i UV[3]; + UV[0]= vcg::Point2(u0,v0); + UV[1]= vcg::Point2(u1,v1); + UV[2]= vcg::Point2(u2,v2); + CoordType dir1; + CoordType dir2; + vcg::tri::CrossField::GradientToCross(mesh.face[i],UV[0],UV[1],UV[2],dir1,dir2); + dir1.Normalize(); + dir2.Normalize(); + mesh.face[i].PD1()=dir1; + mesh.face[i].PD2()=dir2; + } + fclose(f); + return true; } ///load a field on the mesh, it could be a vfield file (per vertex) From 9a984d23dfa975ce8b01f3e605414bf69b2ac239 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 19 Dec 2017 00:57:20 +1100 Subject: [PATCH 2/4] refactored a bit the code --- wrap/gl/gl_field.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wrap/gl/gl_field.h b/wrap/gl/gl_field.h index f48f0530..b887801e 100644 --- a/wrap/gl/gl_field.h +++ b/wrap/gl/gl_field.h @@ -74,10 +74,11 @@ public: const ScalarType &size, const bool oneside, const bool onlyPD1, - const ScalarType maxN) + const ScalarType maxN, + const ScalarType minN) { CoordType center=(f.cP(0)+f.cP(1)+f.cP(2))/3; - CoordType normal=f.cN(); + //CoordType normal=f.cN(); CoordType dir[4]; vcg::tri::CrossField::CrossVector(f,dir); @@ -92,10 +93,10 @@ public: ScalarType IntervW=MaxW-MinW; if (Norm0>maxN)Norm0=maxN; if (Norm1>maxN)Norm1=maxN; - vcg::Color4b Col0=vcg::Color4b::ColorRamp(0,maxN,Norm0); - vcg::Color4b Col1=vcg::Color4b::ColorRamp(0,maxN,Norm1); - ScalarType W0=(Norm0/maxN)*IntervW+MinW; - ScalarType W1=(Norm1/maxN)*IntervW+MinW; + vcg::Color4b Col0=vcg::Color4b::ColorRamp(minN,maxN,Norm0); + vcg::Color4b Col1=vcg::Color4b::ColorRamp(minN,maxN,Norm1); + ScalarType W0=(Norm0/(maxN-minN))*IntervW+MinW; + ScalarType W1=(Norm1/(maxN-minN))*IntervW+MinW; GLDrawField(dir,center,size,W0,W1,Col0,Col1,oneside,onlyPD1); } } @@ -132,7 +133,8 @@ public: bool onlyPD1, bool oneside, ScalarType GlobalScale=0.002, - const ScalarType maxN=0) + const ScalarType maxN=0, + const ScalarType minN=0) { glPushAttrib(GL_ALL_ATTRIB_BITS); @@ -144,7 +146,7 @@ public: for (unsigned int i=0;i Date: Tue, 19 Dec 2017 01:02:18 +1100 Subject: [PATCH 3/4] removed some bug in Smooth PCA --- vcg/complex/algorithms/polygonal_algorithms.h | 76 ++++++------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/vcg/complex/algorithms/polygonal_algorithms.h b/vcg/complex/algorithms/polygonal_algorithms.h index 6fcc2416..8c2f8b5b 100644 --- a/vcg/complex/algorithms/polygonal_algorithms.h +++ b/vcg/complex/algorithms/polygonal_algorithms.h @@ -30,6 +30,8 @@ #include #include +#include + //define a temporary triangle mesh type class TempFace; class TempVertex; @@ -169,8 +171,7 @@ private: static bool CollapseBorderSmallEdgesStep(PolyMeshType &poly_m, - const ScalarType edge_limit, - ScalarType angleDeg=100) + const ScalarType edge_limit) { //update topology vcg::tri::UpdateTopology::FaceFace(poly_m); @@ -356,11 +357,19 @@ public: vcg::GetPolyTemplatePos(f,TemplatePos,true); CoordType NormT=Normal(TemplatePos); + //get the normal of vertices - CoordType AVN(0,0,0); + //CoordType AVN(0,0,0); + //CoordType AVN0(0,0,0); CoordType Origin(0,0,0); - for (int j=0;jN(); +// for (int j=0;jN(); + + CoordType AVN=vcg::PolygonNormal(f); + //AVN0.Normalize(); +// std::cout<<"AVN "< avgPos(poly_m.vert.size(),CoordType(0,0,0)); std::vector weightSum(poly_m.vert.size(),0); //then compute the templated positions + for (size_t i=0;i TemplatePos; @@ -416,8 +428,7 @@ public: ScalarType val=vcg::PolyArea(poly_m.face[i]); if (val<(AvgArea*0.00001)) val=(AvgArea*0.00001); - ScalarType W=1.0/val;//poly_m.face[i].Q(); - //ScalarType W=1; + ScalarType W=1.0/val; for (size_t j=0;j1)alpha=1; // if (isnan(alpha))alpha=1; CoordType newP=avgPos[i]/weightSum[i]; + //std::cout<<"W "< SumAngle(poly_m.face.size(),0); -// for (size_t i=0;iQ()+=AreaF * CurrAngle/SumAngle[i]; -// } -// } -// } - static void InitQualityVertVoronoiArea(PolyMeshType &poly_m) { for (size_t i=0;i Date: Tue, 19 Dec 2017 01:03:34 +1100 Subject: [PATCH 4/4] small warning resolved --- .../parametrization/tangent_field_operators.h | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/vcg/complex/algorithms/parametrization/tangent_field_operators.h b/vcg/complex/algorithms/parametrization/tangent_field_operators.h index 26a997d6..b181211f 100644 --- a/vcg/complex/algorithms/parametrization/tangent_field_operators.h +++ b/vcg/complex/algorithms/parametrization/tangent_field_operators.h @@ -199,7 +199,7 @@ private: //push the first one SubDEdges.push_back(Edge0); - for (size_t i=1;i=0)&&(IndexF0=0)&&(IndexF1=0)&&(IndexF0<(int)OriginalFace.size())); + assert((IndexF1>=0)&&(IndexF1<(int)OriginalFace.size())); FaceType* F0=OriginalFace[IndexF0]; FaceType* F1=OriginalFace[IndexF1]; @@ -394,7 +394,7 @@ private: const TriangleType &t0, const TriangleType &t1, CoordType &Interpolated, - size_t &Face) + int &Face) { //find smallest edge ScalarType smallestE=std::numeric_limits::max(); @@ -511,7 +511,7 @@ private: directions.clear(); faces.clear(); - for (size_t i=0;i=0); - assert(OrigFIndex::Rotate(f0,f1,dirS); ///then get the closest upf to K*PI/2 rotations - CoordType dir1=f1.cPD1(); + //CoordType dir1=f1.cPD1(); //int ret=I_K_PI(dir1,dirR,f1.cN()); CoordType dir[4]; CrossVector(f1,dir); @@ -936,8 +936,8 @@ public: const CoordType &t1=f.V(1)->PD1(); const CoordType &t2=f.V(2)->PD1(); const CoordType &N0=f.V(0)->N(); - const CoordType &N1=f.V(0)->N(); - const CoordType &N2=f.V(0)->N(); + const CoordType &N1=f.V(1)->N(); + const CoordType &N2=f.V(2)->N(); const CoordType &NF=f.N(); const CoordType bary=CoordType(0.33333,0.33333,0.33333); CoordType tF0,tF1; @@ -948,7 +948,9 @@ public: SetCrossVector(f,tF0,tF1); //then set the magnitudo - ScalarType mag1,mag2; + ScalarType mag1=0; + ScalarType mag2=0; + for (int i=0;i<3;i++) { vcg::Matrix33 rotN=vcg::RotationMatrix(f.V(i)->N(),f.N());