diff options
author | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-06-27 01:03:45 +0000 |
---|---|---|
committer | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-06-27 01:03:45 +0000 |
commit | d221f79cfb7d84941d791835e52fa4a596269cc6 (patch) | |
tree | cde0df00ef5e7ec21c6a9e123e5d35bd7f5968f3 /src/common/include | |
parent | 0741c3eabbfece1c73ac76aa44adbe2904b6124d (diff) | |
parent | 5645e9fcbe5730462b2befb8685d3bb6857279be (diff) |
merged trunk
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/kernels@3644 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 2be9ba6b6a381e677081a751e7d8f8c1d79385b0
Diffstat (limited to 'src/common/include')
-rw-r--r-- | src/common/include/gudhi/Off_reader.h | 2 | ||||
-rw-r--r-- | src/common/include/gudhi/distance_functions.h | 50 | ||||
-rw-r--r-- | src/common/include/gudhi/graph_simplicial_complex.h | 6 | ||||
-rw-r--r-- | src/common/include/gudhi/random_point_generators.h | 3 | ||||
-rw-r--r-- | src/common/include/gudhi/writing_persistence_to_file.h | 8 |
5 files changed, 63 insertions, 6 deletions
diff --git a/src/common/include/gudhi/Off_reader.h b/src/common/include/gudhi/Off_reader.h index 024f0568..05a1e145 100644 --- a/src/common/include/gudhi/Off_reader.h +++ b/src/common/include/gudhi/Off_reader.h @@ -137,7 +137,7 @@ class Off_reader { if (!std::ifstream::sentry(stream_)) return false; std::getline(stream_, uncomment_line); } while (uncomment_line[0] == '#'); - return (bool)stream_; + return static_cast<bool>(stream_); } template<typename OffVisitor> diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index f7baed6f..5ef12f2e 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -25,7 +25,10 @@ #include <gudhi/Debug_utils.h> +#include <gudhi/Miniball.hpp> + #include <boost/range/metafunctions.hpp> +#include <boost/range/size.hpp> #include <cmath> // for std::sqrt #include <type_traits> // for std::decay @@ -68,6 +71,53 @@ class Euclidean_distance { } }; +/** @brief Compute the radius of the minimal enclosing ball between Points given by a range of coordinates. + * The points are assumed to have the same dimension. */ +class Minimal_enclosing_ball_radius { + public: + /** \brief Minimal_enclosing_ball_radius from two points. + * + * @param[in] point_1 First point. + * @param[in] point_2 second point. + * @return The minimal enclosing ball radius for the two points (aka. Euclidean distance / 2.). + * + * \tparam Point must be a range of Cartesian coordinates. + * + */ + template< typename Point > + typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type + operator()(const Point& point_1, const Point& point_2) const { + return Euclidean_distance()(point_1, point_2) / 2.; + } + /** \brief Minimal_enclosing_ball_radius from a point cloud. + * + * @param[in] point_cloud The points. + * @return The minimal enclosing ball radius for the points. + * + * \tparam Point_cloud must be a range of points with Cartesian coordinates. + * Point_cloud is a range over a range of Coordinate. + * + */ + template< typename Point_cloud, + typename Point_iterator = typename boost::range_const_iterator<Point_cloud>::type, + typename Point = typename std::iterator_traits<Point_iterator>::value_type, + typename Coordinate_iterator = typename boost::range_const_iterator<Point>::type, + typename Coordinate = typename std::iterator_traits<Coordinate_iterator>::value_type> + Coordinate + operator()(const Point_cloud& point_cloud) const { + using Min_sphere = Miniball::Miniball<Miniball::CoordAccessor<Point_iterator, Coordinate_iterator>>; + + Min_sphere ms(boost::size(*point_cloud.begin()), point_cloud.begin(), point_cloud.end()); +#ifdef DEBUG_TRACES + std::cout << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " + << boost::size(point_cloud) << " | dimension = " + << boost::size(*point_cloud.begin()) << std::endl; +#endif // DEBUG_TRACES + + return std::sqrt(ms.squared_radius()); + } +}; + } // namespace Gudhi #endif // DISTANCE_FUNCTIONS_H_ diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 6ab7b0b4..49fe56cc 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -42,6 +42,12 @@ struct vertex_filtration_t { typedef boost::vertex_property_tag kind; }; +/** \brief Proximity_graph contains the vertices and edges with their filtration values in order to store the result + * of `Gudhi::compute_proximity_graph` function. + * + * \tparam SimplicialComplexForProximityGraph furnishes `Filtration_value` type definition. + * + */ template <typename SimplicialComplexForProximityGraph> using Proximity_graph = typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS , boost::property < vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value > diff --git a/src/common/include/gudhi/random_point_generators.h b/src/common/include/gudhi/random_point_generators.h index 1f8f2cd8..f8107c8b 100644 --- a/src/common/include/gudhi/random_point_generators.h +++ b/src/common/include/gudhi/random_point_generators.h @@ -190,7 +190,8 @@ template <typename Kernel, typename OutputIterator> static void generate_uniform_points_on_torus_d(const Kernel &k, int dim, std::size_t num_slices, OutputIterator out, double radius_noise_percentage = 0., - std::vector<typename Kernel::FT> current_point = std::vector<typename Kernel::FT>()) { + std::vector<typename Kernel::FT> current_point = + std::vector<typename Kernel::FT>()) { CGAL::Random rng; int point_size = static_cast<int>(current_point.size()); if (point_size == 2 * dim) { diff --git a/src/common/include/gudhi/writing_persistence_to_file.h b/src/common/include/gudhi/writing_persistence_to_file.h index 4c5ce918..34448576 100644 --- a/src/common/include/gudhi/writing_persistence_to_file.h +++ b/src/common/include/gudhi/writing_persistence_to_file.h @@ -20,8 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WRITING_PERSISTENCE_TO_FILE_H -#define WRITING_PERSISTENCE_TO_FILE_H +#ifndef WRITING_PERSISTENCE_TO_FILE_H_ +#define WRITING_PERSISTENCE_TO_FILE_H_ #include <iostream> #include <string> @@ -112,6 +112,6 @@ void write_persistence_intervals_to_stream(const Persistence_interval_range& int } } -} +} // namespace Gudhi -#endif // WRITING_PERSISTENCE_TO_FILE_H +#endif // WRITING_PERSISTENCE_TO_FILE_H_ |