From d0cd299f34fbb9de730b89cc94f42a55c62bd42f Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 23 Mar 2020 16:05:31 +1100 Subject: [PATCH] added subdivision step for polygonal mesh --- vcg/complex/algorithms/polygonal_algorithms.h | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/vcg/complex/algorithms/polygonal_algorithms.h b/vcg/complex/algorithms/polygonal_algorithms.h index 33eac195..03c41a7a 100644 --- a/vcg/complex/algorithms/polygonal_algorithms.h +++ b/vcg/complex/algorithms/polygonal_algorithms.h @@ -78,7 +78,93 @@ class PolygonalAlgorithm typedef typename PolyMeshType::CoordType CoordType; typedef typename PolyMeshType::ScalarType ScalarType; typedef typename vcg::face::Pos PosType; + + static void SetFacePos(PolyMeshType &poly_m, + int IndexF,std::vector &Pos) + { + poly_m.face[IndexF].Dealloc(); + poly_m.face[IndexF].Alloc(Pos.size()); + //std::cout<::AddVertex(poly_m,Pos[i]); + + for (size_t i=0;i Bary; + for (size_t i=0;i, CoordType> EdgeVert; + for (size_t i=0;i Key(std::min(Pos0,Pos1),std::max(Pos0,Pos1)); + EdgeVert[Key]=Avg; + } + + int sizeF=poly_m.face.size(); + for (size_t i=0;i Pos; + for (size_t j=0;j Key0(std::min(Pos0,Pos1),std::max(Pos0,Pos1)); + Pos0=EdgeVert[Key0]; + Pos.push_back(Pos0); + Pos.push_back(Pos1); + } + //get also the barycenter + CoordType BaryP=Bary[i]; + + //then retrieve the face + std::vector PosQ; + PosQ.push_back(Pos[0]); + PosQ.push_back(Pos[1]); + PosQ.push_back(Pos[2]); + PosQ.push_back(BaryP); + SetFacePos(poly_m,i,PosQ); + + int sizeV=Pos.size(); + //int start=0; + for (size_t j=2;j::AddFaces(poly_m,1); + std::vector PosQ; + PosQ.push_back(Pos[(j)%Pos.size()]); + PosQ.push_back(Pos[(j+1)%Pos.size()]); + PosQ.push_back(Pos[(j+2)%Pos.size()]); + PosQ.push_back(BaryP); + //start+=2; + SetFacePos(poly_m,poly_m.face.size()-1,PosQ); + //break; + } + } + vcg::tri::Clean::RemoveDuplicateVertex(poly_m); + vcg::tri::Allocator::CompactEveryVector(poly_m); + } + static bool CollapseEdges(PolyMeshType &poly_m, const std::vector &CollapsePos, const std::vector &InterpPos)