CGAL 6.2 - dD Frechet Distance

Loading...
Searching...
No Matches
Frechet_distance/Frechet_DS_3.cpp
#include <CGAL/Frechet_distance.h>
#include <CGAL/Frechet_distance_traits_3.h>
#include <CGAL/Frechet_distance/Neighbor_search.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/IO/WKT.h>
#include <ostream>
#include <fstream>
#include <filesystem>
using Kernel = CGAL::Simple_cartesian<double>;
using Traits = CGAL::Frechet_distance_traits_3<Kernel>;
using Point = Traits::Point_d;
using Curve = std::vector<Point>;
using Curves = std::vector<Curve>;
int main()
{
Curves curves;
const std::filesystem::path data{"./data_3d"};
for (auto const& dir_entry : std::filesystem::directory_iterator{data}){
std::ifstream in(dir_entry.path());
curves.push_back(Curve());
CGAL::IO::read_linestring_WKT(in, curves.back());
}
Curve query = curves.back();
curves.pop_back();
CGAL::Frechet_distance::Neighbor_search<Curve, Traits> ds(curves);
for(const Curve& c : curves){
std::pair<double, double> res = CGAL::bounded_error_Frechet_distance(c, query, 0.000001);
std::cout << "The Frechet distance between the polylines is between " << res.first << " and " << res.second << std::endl;
}
double distance = 16;
std::vector<std::size_t> result = ds.get_close_curves(query, distance);
std::cout << result.size() << " curves at Frechet distance closer than " << distance << std::endl;
return 0;
}
CGAL::Frechet_distance::Neighbor_search
A data structure to store polylines with a function that enables to find those polylines which are cl...
Definition: Neighbor_search.h:44
CGAL::Frechet_distance::Neighbor_search::get_close_curves
std::vector< std::size_t > get_close_curves(const PointRange &query, double distance)
returns the indices of the inserted polylines that are closer than distance to the polyline query.
Definition: Neighbor_search.h:79
CGAL::Frechet_distance_traits_3
Definition: Frechet_distance_traits_3.h:34
CGAL::bounded_error_Frechet_distance
std::pair< double, double > bounded_error_Frechet_distance(const PointRange &polyline1, const PointRange &polyline2, const double error_bound, const NamedParameters &np=parameters::default_values())
returns an estimate of the Fréchet distance between the two polylines that is at most error_bound awa...
Definition: Frechet_distance.h:173
CGAL::IO::read_linestring_WKT
bool read_linestring_WKT(std::istream &in, LineString &polyline)
Kernel
CGAL::Simple_cartesian