added compute area function for polygonal meshes

This commit is contained in:
Luigi Malomo 2018-05-28 14:58:38 +02:00
parent 37183c1e53
commit c067321435
2 changed files with 15 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include <vcg/complex/algorithms/closest.h>
#include <vcg/space/index/grid_static_ptr.h>
#include <vcg/complex/algorithms/inertia.h>
#include <vcg/space/polygon3.h>
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);

View File

@ -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++)