godot/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.cpp
Hein-Pieter van Braam bf05309af7 Import thekla_atlas
As requested by reduz, an import of thekla_atlas into thirdparty/
2017-12-08 15:47:15 +01:00

37 lines
816 B
C++

// This code is in the public domain -- castano@gmail.com
#include "nvmesh.h" // pch
#include "Measurements.h"
#include "nvmesh/halfedge/Mesh.h"
#include "nvmesh/halfedge/Face.h"
using namespace nv;
float nv::computeSurfaceArea(const HalfEdge::Mesh * mesh)
{
float area = 0;
for (HalfEdge::Mesh::ConstFaceIterator it(mesh->faces()); !it.isDone(); it.advance())
{
const HalfEdge::Face * face = it.current();
area += face->area();
}
nvDebugCheck(area >= 0);
return area;
}
float nv::computeParametricArea(const HalfEdge::Mesh * mesh)
{
float area = 0;
for (HalfEdge::Mesh::ConstFaceIterator it(mesh->faces()); !it.isDone(); it.advance())
{
const HalfEdge::Face * face = it.current();
area += face->parametricArea();
}
return area;
}