Commit d66dd09c authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[isection][empty] provide free function to query if isection is empty

parent 8b161c90
......@@ -31,6 +31,7 @@
#include <frackit/distance/distance.hh>
#include <frackit/magnitude/magnitude.hh>
#include <frackit/intersection/intersect.hh>
#include <frackit/intersection/emptyintersection.hh>
#include <frackit/intersection/intersectionpredicates.hh>
#include "impl_admissibledimension.hh"
......@@ -176,7 +177,7 @@ public:
const auto isection = !useIntersectionEps_ ? intersect(geo1, geo2)
: intersect(geo1, geo2, intersectionEps_);
if ( !IntersectionPredicates::isEmpty(isection) )
if ( !isEmptyIntersection(isection) )
{
// check if dimensionality constraint is violated
if (!allowEquiDimIS_ && !ConstraintImpl::isAdmissibleDimension(isection, dim-1))
......
......@@ -24,6 +24,7 @@
#define FRACKIT_EMPTY_INTERSECTION_HH
#include <string>
#include <variant>
namespace Frackit {
......@@ -61,6 +62,33 @@ template<int wd>
struct IsEmptyIntersection<EmptyIntersection<wd>>
{ static constexpr bool value = true; };
/*!
* \brief Returns true if a geometry describes an empty intersection.
* \tparam IsGeometry the geometry of an intersection
*/
template<class IsGeometry>
constexpr bool isEmptyIntersection(const IsGeometry& is)
{ return IsEmptyIntersection<IsGeometry>::value; }
/*!
* \brief Overload for intersection variant
*/
template<class... T>
bool isEmptyIntersection(const std::variant<T...>& intersection)
{ return std::visit([&] (auto&& is) { return isEmptyIntersection(is); }, intersection); }
/*!
* \brief Overload for general intersections possibly
* containing possibly various types.
*/
template<class Geo>
bool isEmptyIntersection(const std::vector<Geo>& intersections)
{
return std::all_of(intersections.begin(),
intersections.end(),
[&] (const auto& is) { return isEmptyIntersection(is); } );
}
} // end namespace Frackit
#endif // FRACKIT_EMPTY_INTERSECTION_HH
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment