diff --git a/vcg/complex/algorithms/polygonal_algorithms.h b/vcg/complex/algorithms/polygonal_algorithms.h index afd98e15..fbbb9a28 100644 --- a/vcg/complex/algorithms/polygonal_algorithms.h +++ b/vcg/complex/algorithms/polygonal_algorithms.h @@ -77,8 +77,8 @@ class PolygonalAlgorithm typedef typename vcg::face::Pos PosType; public: static bool CollapseEdges(PolyMeshType &poly_m, - const std::vector &CollapsePos, - const std::vector &InterpPos) + const std::vector &CollapsePos, + const std::vector &InterpPos) { //this set how to remap the vertices after deletion @@ -166,119 +166,7 @@ public: return collapsed; } private: -// static bool CollapseBorderSmallEdgesStep(PolyMeshType &poly_m, -// const ScalarType edge_limit) -// { -// bool collapsed=false; -// //update topology -// vcg::tri::UpdateTopology::FaceFace(poly_m); - -// //update border vertices -// //UpdateBorderVertexFromPFFAdj(poly_m); -// vcg::tri::UpdateFlags::VertexBorderFromFaceAdj(poly_m); - -// //get border edges -// std::vector > IsBorder; -// //BorderEdgeFromPFFAdj(poly_m,IsBorder); -// vcg::tri::UpdateFlags::VertexBorderFromFaceAdj(poly_m); -// //deselect all vertices -// vcg::tri::UpdateFlags::VertexClearS(poly_m); - -// //this set how to remap the vertices after deletion -// std::map VertexRemap; - -// //go over all faces and check the ones needed to be deleted -// for (size_t i=0;iIsB(); -// bool IsBV1=v1->IsB(); - -// //in these cases is not possible to collapse -// if ((!IsBV0)&&(!IsBV1))continue; -// //if ((!IsBorder[i][j])&&(IsBV0)&&(IsBV1))continue; -// bool IsBorderE=poly_m.face[i].FFp(j); -// if ((IsBorderE)&&(IsBV0)&&(IsBV1))continue; -// if (v0->IsS())continue; -// if (v1->IsS())continue; - -// assert((IsBV0)||(IsBV1)); -// CoordType pos0=v0->P(); -// CoordType pos1=v1->P(); -// ScalarType currL=(pos0-pos1).Norm(); -// if (currL>edge_limit)continue; - -// //then collapse the point -// CoordType InterpPos; -// if ((IsBV0)&&(!IsBV1))InterpPos=pos0; -// if ((!IsBV0)&&(IsBV1))InterpPos=pos1; -// if ((IsBV0)&&(IsBV1))InterpPos=(pos0+pos1)/2.0; - -// //put on the same position -// v0->P()=InterpPos; -// v1->P()=InterpPos; - -// //select the the two vertices -// v0->SetS(); -// v1->SetS(); - -// //set the remap -// VertexRemap[v1]=v0; - -// collapsed=true; -// } -// } - -// //then remap vertices -// for (size_t i=0;i FaceV; -// for (int j=0;j &IsBorder) - // { - // IsBorder.resize(F.VN(),false); - // for (int j=0;j > &IsBorder) - // { - // IsBorder.resize(poly_m.face.size()); - // for (size_t i=0;i > IsBorderE; - // BorderEdgeFromPFFAdj(poly_m,IsBorderE); - - // //then update per vertex - // vcg::tri::UpdateFlags::VertexClearB(poly_m); - // for (size_t i=0;iSetB(); - // poly_m.face[i].V1(j)->SetB(); - // } - // } - // } - enum PolyQualityType{QAngle,QPlanar,QTemplate}; @@ -1023,6 +871,26 @@ public: return MaxDispl; } + static ScalarType Area(PolyMeshType &poly_m) + { + ScalarType MeshArea=0; + for (size_t i=0;iQ()+=AreaF/(ScalarType)poly_m.face[i].VN(); + } + } }; }//end namespace vcg