From 4bd1bb2376a32de787995ac44ce616aa52ba64a6 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 5 Dec 2017 23:24:47 +1100 Subject: [PATCH 1/4] refactored the class and removed unused functions --- vcg/complex/algorithms/dual_meshing.h | 84 ++++++--------------------- 1 file changed, 19 insertions(+), 65 deletions(-) diff --git a/vcg/complex/algorithms/dual_meshing.h b/vcg/complex/algorithms/dual_meshing.h index 8d15673a..1a0f8ede 100644 --- a/vcg/complex/algorithms/dual_meshing.h +++ b/vcg/complex/algorithms/dual_meshing.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace vcg { namespace tri { @@ -61,65 +62,8 @@ class DualMeshing vertSeq.push_back(indexV); } - if (startV.IsB()) - { - vcg::face::Pos firstPos=posVec[0]; - firstPos.FlipE(); - assert(firstPos.IsBorder()); - - int indexVt0=vcg::tri::Index(primal,firstPos.V()); - int indexVt1=vcg::tri::Index(primal,firstPos.VFlip()); - std::pair key(std::min(indexVt0,indexVt1), - std::max(indexVt0,indexVt1)); - assert(EdgeMap.count(key)>0); - int indexV0=EdgeMap[key]; - - vcg::face::Pos lastPos=posVec.back(); - assert(lastPos.IsBorder()); - - indexVt0=vcg::tri::Index(primal,lastPos.V()); - indexVt1=vcg::tri::Index(primal,lastPos.VFlip()); - key=std::pair (std::min(indexVt0,indexVt1), - std::max(indexVt0,indexVt1)); - assert(EdgeMap.count(key)>0); - int indexV1=EdgeMap[key]; - - vertSeq.push_back(indexV1); - vertSeq.push_back(indexV0); - } } - static void CreateBorderEdgeVert(PolyMeshType &primal, - PolyMeshType &dual, - std::map, int> &VertMap) - { - VertMap.clear(); - vcg::tri::UpdateFlags::VertexClearB(primal); - - for (size_t i=0;iSetB(); - v1->SetB(); - - int V0Index=vcg::tri::Index(primal,v0); - int V1Index=vcg::tri::Index(primal,v1); - CoordType pos=(v0->P()+v1->P())/2; - vcg::tri::Allocator::AddVertex(dual,pos); - std::pair key(std::min(V0Index,V1Index), - std::max(V0Index,V1Index)); - - VertMap[key]=dual.vert.size()-1; - } - } static void CreateFaceVert(PolyMeshType &primal, PolyMeshType &dual, @@ -137,7 +81,6 @@ class DualMeshing int num=0; if (snapBorder)//search for border edge { - std::vector BorderPos; for (int j=0;jIsB())continue; @@ -145,7 +88,7 @@ class DualMeshing num++; } if (num>0) - pos/=num; + pos/=num; } if (num==0) @@ -153,15 +96,22 @@ class DualMeshing for (int j=0;jP(); - int indexV=vcg::tri::Index(primal,primal.face[i].V(j)); - if (VertFace[indexV]!=-1)continue; - VertFace[indexV]=i; } pos/=(ScalarType)primal.face[i].VN(); } vcg::tri::Allocator::AddVertex(dual,pos); VertMap[i]=dual.vert.size()-1; + dual.vert.back().Q()=i; } + + //then initialize VF first face + for (size_t i=0;i::FaceFace(primal); + vcg::tri::UpdateFlags::VertexBorderFromFaceAdj(primal); std::map, int> VertEdgeMap; - CreateBorderEdgeVert(primal,dual,VertEdgeMap); + std::cout<<"Creating Dual Vertices"< VertFaceMap,VertFace; CreateFaceVert(primal,dual,VertFaceMap,VertFace,snapBorder); + std::cout<<"Creating Dual Faces"< VertSeq; @@ -195,9 +147,11 @@ public: dual.face.back().Alloc(VertSeq.size()); for (size_t j=0;j::RemoveUnreferencedVertex(dual); + //finally remove valence 1 vertices on the border + vcg::PolygonalAlgorithm::RemoveValence2Vertices(dual); } }; From 5fb81001f3fd3ed804340e8d102af527f658e35c Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 5 Dec 2017 23:26:19 +1100 Subject: [PATCH 2/4] added anisotropy --- wrap/igl/miq_parametrization.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/wrap/igl/miq_parametrization.h b/wrap/igl/miq_parametrization.h index 51a531a5..6ed928fa 100644 --- a/wrap/igl/miq_parametrization.h +++ b/wrap/igl/miq_parametrization.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -74,6 +74,8 @@ public: bool crease_as_feature; //true if roound selected vert bool round_selected; + //the anisotropy in MIQ sense (see paper) + double miqAnisotropy; MIQParameters() { @@ -89,6 +91,7 @@ public: Ndir=4; crease_thr=0.2; hexaLine=false; + miqAnisotropy=1; } }; @@ -163,9 +166,9 @@ private: } } - igl::miq(V,F,X1,X2,UV,FUV,MiqP.gradient,MiqP.stiffness,MiqP.directRound, + igl::copyleft::comiso::miq(V,F,X1,X2,UV,FUV,MiqP.gradient,MiqP.stiffness,MiqP.directRound, MiqP.stiffness_iter,MiqP.local_iter,MiqP.doRound,MiqP.round_singularities, - extra_round,hard_features); + extra_round,hard_features,MiqP.miqAnisotropy); // then copy UV for (size_t i=0;i Date: Tue, 5 Dec 2017 23:27:22 +1100 Subject: [PATCH 3/4] added OrientedCone function and solved minor errors --- vcg/complex/algorithms/create/platonic.h | 57 +++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/vcg/complex/algorithms/create/platonic.h b/vcg/complex/algorithms/create/platonic.h index 8309c0e1..9d654e52 100644 --- a/vcg/complex/algorithms/create/platonic.h +++ b/vcg/complex/algorithms/create/platonic.h @@ -522,6 +522,47 @@ void Cone( MeshType& in, } } +template +void OrientedCone(MeshType & m, + const typename MeshType::CoordType origin, + const typename MeshType::CoordType end, + const typename MeshType::ScalarType r1, + const typename MeshType::ScalarType r2, + const int SubDiv = 36 ) +{ + typedef typename MeshType::ScalarType ScalarType; + typedef typename MeshType::CoordType CoordType; + typedef Matrix44 Matrix44x; + Cone(m,r1,r2,Distance(origin,end),SubDiv); + +// tri::UpdatePosition::Translate(m,CoordType(0,1,0)); +// tri::UpdatePosition::Scale(m,CoordType(1,0.5f,1)); +// tri::UpdatePosition::Scale(m,CoordType(xScale,1.0f,yScale)); + +// float height = Distance(origin,end); +// tri::UpdatePosition::Scale(m,CoordType(radius,height,radius)); + CoordType norm = end-origin; + ScalarType angleRad = Angle(CoordType(0,1,0),norm); + const ScalarType Delta= 0.000000001; + Matrix44x rotM; + if (fabs(angleRad)::Matrix(m,rotM); + tri::UpdatePosition::Translate(m,origin); + +} + template void Box(MeshType &in, const typename MeshType::BoxType & bb ) @@ -1000,9 +1041,21 @@ void OrientedEllipticPrism(MeshType & m, const typename MeshType::CoordType orig tri::UpdatePosition::Scale(m,CoordType(radius,height,radius)); CoordType norm = end-origin; ScalarType angleRad = Angle(CoordType(0,1,0),norm); - CoordType axis = CoordType(0,1,0)^norm; + const ScalarType Delta= 0.000000001; Matrix44x rotM; - rotM.SetRotateRad(angleRad,axis); + if (fabs(angleRad)::Matrix(m,rotM); tri::UpdatePosition::Translate(m,origin); From 950b95f9d5f9a35e8e033dfdf6eadaf91211b7aa Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Tue, 5 Dec 2017 18:27:17 +0100 Subject: [PATCH 4/4] minor fix --- vcg/complex/algorithms/curve_on_manifold.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcg/complex/algorithms/curve_on_manifold.h b/vcg/complex/algorithms/curve_on_manifold.h index c791667e..713e5498 100644 --- a/vcg/complex/algorithms/curve_on_manifold.h +++ b/vcg/complex/algorithms/curve_on_manifold.h @@ -201,7 +201,7 @@ public: { VertexPointer v0 = FindVertexSnap(f0,ip0); VertexPointer v1 = FindVertexSnap(f1,ip1); - assert(v1>0 && v0>0 && v0!=v1); + assert(v1 != NULL && v1 != NULL && v0 != v1); FacePointer ff0,ff1; int e0,e1; ret &= face::FindSharedFaces(v0,v1,ff0,ff1,e0,e1);