Visual Computing Library  devel
Loading...
Searching...
No Matches
functions.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_ALGORITHMS_CORE_DISTANCE_FUNCTIONS_H
24#define VCL_ALGORITHMS_CORE_DISTANCE_FUNCTIONS_H
25
26#include "distance.h"
27
28namespace vcl {
29
30namespace detail {
31
45template<typename Obj1, typename Obj2, typename ST>
46concept BoundedDistFunctionExists =
47 requires (Obj1 o1, Obj2 o2, ST v) { boundedDistance(o1, o2, v); };
48
49} // namespace detail
50
77template<typename Obj1, typename Obj2>
79{
80 auto f = [](const Obj1& o1, const Obj2& o2) {
81 return distance(o1, o2);
82 };
83
84 return f;
85}
86
126template<typename Obj1, typename Obj2, typename ScalarType = double>
128{
129 if constexpr (detail::BoundedDistFunctionExists<Obj1, Obj2, ScalarType>) {
130 auto f = [](const Obj1& o1, const Obj2& o2, ScalarType s) {
131 return boundedDistance(o1, o2, s);
132 };
133
134 return f;
135 }
136 else {
137 auto f = [](const Obj1& o1, const Obj2& o2, ScalarType) {
138 return distance(o1, o2);
139 };
140
141 return f;
142 }
143}
144
145} // namespace vcl
146
147#endif // VCL_ALGORITHMS_CORE_DISTANCE_FUNCTIONS_H
A class representing a box in N-dimensional space.
Definition box.h:46
auto boundedDistFunction()
Return a proper bounded distance function between a Obj1 object and an Obj2 object.
Definition functions.h:127
auto boundedDistance(const PointType &p, const TriangleType &triangle, ScalarType maxDist, PointType &closest, bool signedDist=false)
Compute the bounded distance between a 3D point and a 3D triangle.
Definition distance.h:203
auto distance(const PointType &point0, const PointType &point1)
Compute the distance between two Points of any dimension.
Definition distance.h:45
auto distFunction()
Return a proper dist function between a Obj1 object and an Obj2 object.
Definition functions.h:78