Files
igl/include/igl/box_surface_area.cpp
Alec JacobsonandAlec Jacobson 112c1b8e48 Dynamic updates to AABB tree; intersection-blocking mesh decimation (#2301)
* working insertion and rotation b-b-b-but pointers aren't stuck to m_primitive

* insert now maintains primitive's pointers;+rotate is now getting heights in right ballpark

* sibling rotations working (and helping); dry run test working (and helping)

* working insertion, deletion (detach), and refit with padding.

* working; inexact

* working; inexact

* working; inexact

* note about poor assumptions

* working well after bug fixes. before refactor into functions

* simple self-intersection test function

* moved all functions to files

* docs

* blocking directly in qslim. better docs. aabb templates/tests;

* dont use size_t and fix namespace

* brute-force too fast on linux

* rm overloads in qslim/decimate; cgal template

* fix coplanar bug; factor out raytri.c

* fix and cgal debug

* refactor fast_find; fix bugs in fast_find; fix bugs in shared_vertex

* tutorials running again

* cleaned up aabb tutorials; templates

* format docs

* docs. arg names

* template name

* improve docs

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* debugging test

* ebuggin test

* ebuggin test

* add epsilon to ray_triangle ifs

* erroneous includes

* rm leftover includes

* fix cmake bug

* uh actually fix cmake bug

* missing delete

* simple insert test

* don't pad all leaves F.rows() times

* fix pad bug

---------

Co-authored-by: Alec Jacobson <alecjacobson@adobe.com>
2023-10-14 07:32:50 -04:00

36 lines
1.1 KiB
C++

#include "box_surface_area.h"
template <typename DerivedCorner>
IGL_INLINE typename DerivedCorner::Scalar igl::box_surface_area(
const Eigen::MatrixBase<DerivedCorner> & min_corner,
const Eigen::MatrixBase<DerivedCorner> & max_corner)
{
using Scalar = typename DerivedCorner::Scalar;
const auto dimensions = (max_corner - min_corner).eval();
const auto num_dimensions = dimensions.size();
Scalar surface_area = 0;
for (int i = 0; i < num_dimensions; ++i) {
for (int j = i + 1; j < num_dimensions; ++j) {
surface_area += 2 * dimensions[i] * dimensions[j];
}
}
return surface_area;
}
template <typename Scalar, int AmbientDim>
IGL_INLINE Scalar igl::box_surface_area(
const Eigen::AlignedBox<Scalar,AmbientDim> & box)
{
return igl::box_surface_area(box.min(),box.max());
}
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
// generated by autoexplicit.sh
template double igl::box_surface_area<double, 2>(Eigen::AlignedBox<double, 2> const&);
template double igl::box_surface_area<double, 3>(Eigen::AlignedBox<double, 3> const&);
#endif