added compute area function for polygonal meshes
This commit is contained in:
parent
37183c1e53
commit
c067321435
|
@ -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);
|
||||
|
|
|
@ -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++)
|
||||
|
|
Loading…
Reference in New Issue