Skip to content
Snippets Groups Projects
Commit ef51196f authored by René Fritze's avatar René Fritze Committed by René Fritze
Browse files

[intersection] simplify contains

this actually works with just function overloads
parent 83002ebd
No related branches found
No related tags found
1 merge request!31Sfinae and stuff
...@@ -85,10 +85,9 @@ double diameter(const Intersection<G, I>& intersection) ...@@ -85,10 +85,9 @@ double diameter(const Intersection<G, I>& intersection)
* Returns true, if global_point and intersection coincide. * Returns true, if global_point and intersection coincide.
*/ */
template <class G, class I, class D> template <class G, class I, class D>
typename std::enable_if<G::dimension == 1, bool>::type bool contains(const Dune::Intersection<G, I>& intersection,
contains(const Dune::Intersection<G, I>& intersection, const Dune::FieldVector<D, 1>& global_point,
const Dune::FieldVector<D, 1>& global_point, const D& tolerance = Common::FloatCmp::DefaultEpsilon<D>::value())
const D& tolerance = Common::FloatCmp::DefaultEpsilon<D>::value())
{ {
return Common::FloatCmp::eq(intersection.geometry().center(), global_point, tolerance); return Common::FloatCmp::eq(intersection.geometry().center(), global_point, tolerance);
} }
...@@ -100,10 +99,9 @@ contains(const Dune::Intersection<G, I>& intersection, ...@@ -100,10 +99,9 @@ contains(const Dune::Intersection<G, I>& intersection,
* Returns true if global_point lies on the line between the corners of intersection. * Returns true if global_point lies on the line between the corners of intersection.
*/ */
template <class G, class I, class D> template <class G, class I, class D>
typename std::enable_if<G::dimension == 2, bool>::type bool contains(const Dune::Intersection<G, I>& intersection,
contains(const Dune::Intersection<G, I>& intersection, const Dune::FieldVector<D, 2>& global_point,
const Dune::FieldVector<D, 2>& global_point, const D& tolerance = Common::FloatCmp::DefaultEpsilon<D>::value())
const D& tolerance = Common::FloatCmp::DefaultEpsilon<D>::value())
{ {
const auto& geometry = intersection.geometry(); const auto& geometry = intersection.geometry();
// get the global coordinates of the intersections corners // get the global coordinates of the intersections corners
...@@ -139,10 +137,9 @@ contains(const Dune::Intersection<G, I>& intersection, ...@@ -139,10 +137,9 @@ contains(const Dune::Intersection<G, I>& intersection,
* http://math.stackexchange.com/questions/684141/check-if-a-point-is-on-a-plane-minimize-the-use-of-multiplications-and-divisio * http://math.stackexchange.com/questions/684141/check-if-a-point-is-on-a-plane-minimize-the-use-of-multiplications-and-divisio
*/ */
template <class G, class I, class D> template <class G, class I, class D>
typename std::enable_if<G::dimension == 3, bool>::type bool contains(const Dune::Intersection<G, I>& intersection,
contains(const Dune::Intersection<G, I>& intersection, const Dune::FieldVector<D, 3>& global_point,
const Dune::FieldVector<D, 3>& global_point, const D& tolerance = Common::FloatCmp::DefaultEpsilon<D>::value())
const D& tolerance = Common::FloatCmp::DefaultEpsilon<D>::value())
{ {
const auto& geometry = intersection.geometry(); const auto& geometry = intersection.geometry();
// get the global coordinates of the intersections corners, there should be at least 3 (ignore the fourth if there is // get the global coordinates of the intersections corners, there should be at least 3 (ignore the fourth if there is
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment