summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.cpp
blob: e0c271663b48650dfbb8a44fc5e381e0ea121ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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;
}