diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2017-12-08 15:05:47 +0100 |
---|---|---|
committer | Hein-Pieter van Braam <hp@tmm.cx> | 2017-12-08 15:47:15 +0100 |
commit | bf05309af734431c3b3cf869a63ed477439a6739 (patch) | |
tree | 72c1c939f9035c711f50ec94b0270ea60e0bb4e4 /thirdparty/thekla_atlas/nvmesh/geometry | |
parent | b3b4727dff009dda0a65b8a013ec04d52a54b367 (diff) |
Import thekla_atlas
As requested by reduz, an import of thekla_atlas into thirdparty/
Diffstat (limited to 'thirdparty/thekla_atlas/nvmesh/geometry')
4 files changed, 136 insertions, 0 deletions
diff --git a/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.cpp b/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.cpp new file mode 100644 index 0000000000..69fd1deb24 --- /dev/null +++ b/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.cpp @@ -0,0 +1,54 @@ +// This code is in the public domain -- Ignacio Castaño <castano@gmail.com> + +#include "nvmesh.h" // pch + +#include "Bounds.h" + +#include "nvmesh/BaseMesh.h" +#include "nvmesh/halfedge/Mesh.h" +#include "nvmesh/halfedge/Vertex.h" + +#include "nvmath/Box.inl" + +using namespace nv; + +Box MeshBounds::box(const BaseMesh * mesh) +{ + nvCheck(mesh != NULL); + + Box bounds; + bounds.clearBounds(); + + const uint vertexCount = mesh->vertexCount(); + for (uint v = 0; v < vertexCount; v++) + { + const BaseMesh::Vertex & vertex = mesh->vertexAt(v); + bounds.addPointToBounds( vertex.pos ); + } + + return bounds; +} + +Box MeshBounds::box(const HalfEdge::Mesh * mesh) +{ + nvCheck(mesh != NULL); + + Box bounds; + bounds.clearBounds(); + + const uint vertexCount = mesh->vertexCount(); + for (uint v = 0; v < vertexCount; v++) + { + const HalfEdge::Vertex * vertex = mesh->vertexAt(v); + nvDebugCheck(vertex != NULL); + bounds.addPointToBounds( vertex->pos ); + } + + return bounds; +} + +/*Sphere MeshBounds::sphere(const HalfEdge::Mesh * mesh) +{ + // @@ TODO + return Sphere(); +}*/ diff --git a/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.h b/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.h new file mode 100644 index 0000000000..1cb5b7b905 --- /dev/null +++ b/thirdparty/thekla_atlas/nvmesh/geometry/Bounds.h @@ -0,0 +1,28 @@ +// This code is in the public domain -- Ignacio Castaño <castano@gmail.com> + +#pragma once +#ifndef NV_MESH_MESHBOUNDS_H +#define NV_MESH_MESHBOUNDS_H + +#include <nvmath/Sphere.h> +#include <nvmath/Box.h> + +#include <nvmesh/nvmesh.h> + +namespace nv +{ + class BaseMesh; + namespace HalfEdge { class Mesh; } + + // Bounding volumes computation. + namespace MeshBounds + { + Box box(const BaseMesh * mesh); + Box box(const HalfEdge::Mesh * mesh); + + Sphere sphere(const HalfEdge::Mesh * mesh); + } + +} // nv namespace + +#endif // NV_MESH_MESHBOUNDS_H diff --git a/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.cpp b/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.cpp new file mode 100644 index 0000000000..e0c271663b --- /dev/null +++ b/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.cpp @@ -0,0 +1,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; +} diff --git a/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.h b/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.h new file mode 100644 index 0000000000..0be863b79e --- /dev/null +++ b/thirdparty/thekla_atlas/nvmesh/geometry/Measurements.h @@ -0,0 +1,18 @@ +// This code is in the public domain -- castano@gmail.com + +#pragma once +#ifndef NV_MESH_MESHMEASUREMENTS_H +#define NV_MESH_MESHMEASUREMENTS_H + +#include "nvmesh/nvmesh.h" + +namespace nv +{ + namespace HalfEdge { class Mesh; } + + float computeSurfaceArea(const HalfEdge::Mesh * mesh); + float computeParametricArea(const HalfEdge::Mesh * mesh); + +} // nv namespace + +#endif // NV_MESH_MESHMEASUREMENTS_H |