From 894ebb26f6fd48907fbac99acb79c20cf679a49e Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Fri, 25 May 2012 13:33:36 +0000 Subject: [PATCH] added RemoveHugeConnectedComponentsDiameter function --- vcg/complex/algorithms/clean.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/vcg/complex/algorithms/clean.h b/vcg/complex/algorithms/clean.h index b8c15028..fc7922e1 100644 --- a/vcg/complex/algorithms/clean.h +++ b/vcg/complex/algorithms/clean.h @@ -1687,6 +1687,7 @@ static std::pair RemoveSmallConnectedComponentsSize(MeshType &m, int m return std::make_pair(TotalCC,DeletedCC); } + /// Remove the connected components smaller than a given diameter // it returns a pair with the number of connected components and the number of deleted ones. static std::pair RemoveSmallConnectedComponentsDiameter(MeshType &m, ScalarType maxDiameter) @@ -1717,6 +1718,36 @@ static std::pair RemoveSmallConnectedComponentsDiameter(MeshType &m, Sc return std::make_pair(TotalCC,DeletedCC); } +/// Remove the connected components greater than a given diameter +// it returns a pair with the number of connected components and the number of deleted ones. +static std::pair RemoveHugeConnectedComponentsDiameter(MeshType &m, ScalarType minDiameter) +{ + std::vector< std::pair > CCV; + int TotalCC=ConnectedComponents(m, CCV); + int DeletedCC=0; + tri::ConnectedIterator ci; + for(unsigned int i=0;i FPV; + for(ci.start(m,CCV[i].second);!ci.completed();++ci) + { + FPV.push_back(*ci); + bb.Add((*ci)->P(0)); + bb.Add((*ci)->P(1)); + bb.Add((*ci)->P(2)); + } + if(bb.Diag()>minDiameter) + { + DeletedCC++; + typename std::vector::iterator fpvi; + for(fpvi=FPV.begin(); fpvi!=FPV.end(); ++fpvi) + tri::Allocator::DeleteFace(m,(**fpvi)); + } + } + return std::make_pair(TotalCC,DeletedCC); +} + }; // end class /*@}*/