diff --git a/vcg/complex/algorithms/stat.h b/vcg/complex/algorithms/stat.h index 64b9a2aa..676314a0 100644 --- a/vcg/complex/algorithms/stat.h +++ b/vcg/complex/algorithms/stat.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace vcg { @@ -264,6 +265,17 @@ public: return area/ScalarType(2.0); } + static ScalarType ComputePolyMeshArea(MeshType & m) + { + ScalarType area=0; + + for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) + if(!(*fi).IsD()) + area += PolyArea(*fi); + + return area; + } + static ScalarType ComputeBorderLength(MeshType & m) { RequireFFAdjacency(m); diff --git a/vcg/space/polygon3.h b/vcg/space/polygon3.h index 2e02e6fc..031523df 100644 --- a/vcg/space/polygon3.h +++ b/vcg/space/polygon3.h @@ -126,6 +126,9 @@ typename PolygonType::ScalarType PolyArea(const PolygonType &F) typedef typename PolygonType::CoordType CoordType; typedef typename PolygonType::ScalarType ScalarType; + if (F.VN() == 3) + return vcg::DoubleArea(F) / 2; + CoordType bary=PolyBarycenter(F); ScalarType Area=0; for (size_t i=0;i<(size_t)F.VN();i++)