mirror of https://github.com/CGAL/cgal
modify test function
This commit is contained in:
parent
dfc40bde23
commit
59e87e8468
|
|
@ -16,6 +16,20 @@
|
|||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
template <typename K>
|
||||
class Old_compare_squared_distance_3
|
||||
{
|
||||
typedef typename K::FT FT;
|
||||
public:
|
||||
typedef typename K::Comparison_result result_type;
|
||||
|
||||
template <class T1, class T2>
|
||||
CGAL::Needs_FT<result_type>
|
||||
operator()(const T1& p, const T2& q, const FT& d2) const
|
||||
{
|
||||
return CGAL::compare(CGAL::internal::squared_distance(p, q, K()), d2);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
struct Test
|
||||
|
|
@ -41,6 +55,7 @@ struct Test
|
|||
public:
|
||||
Test() : nb_closed_pairs(0){ }
|
||||
|
||||
template<bool optimized_version>
|
||||
void close_triangles(std::vector<P> &points, std::vector<boost::container::small_vector<std::size_t, 3> >& triangles, FT d2){
|
||||
std::vector< CBox > boxes;
|
||||
auto extend_bbox3=[&](const Iterator it, FT& d2){
|
||||
|
|
@ -60,9 +75,14 @@ public:
|
|||
if(v.size()!=0) //they have common vertices
|
||||
return;
|
||||
|
||||
bool comp = K().compare_squared_distance_3_object()(T(points[a[0]], points[a[1]], points[a[2]]),
|
||||
T(points[b[0]], points[b[1]], points[b[2]]),
|
||||
d2)!=CGAL::LARGER;
|
||||
bool comp;
|
||||
T tr1(points[a[0]], points[a[1]], points[a[2]]);
|
||||
T tr2(points[b[0]], points[b[1]], points[b[2]]);
|
||||
if constexpr(optimized_version)
|
||||
comp = K().compare_squared_distance_3_object()(tr1, tr2, d2)!=CGAL::LARGER;
|
||||
else
|
||||
comp = Old_compare_squared_distance_3<K>()(tr1, tr2, d2)!=CGAL::LARGER;
|
||||
|
||||
if(comp)
|
||||
{
|
||||
nb_closed_pairs++;
|
||||
|
|
@ -88,9 +108,15 @@ public:
|
|||
}
|
||||
CGAL::Real_timer t;
|
||||
t.start();
|
||||
close_triangles(input_points, input_triangles, d2);
|
||||
close_triangles<true>(input_points, input_triangles, d2);
|
||||
t.stop();
|
||||
std::cout << "#points = " << input_points.size() << " and #triangles = " << input_triangles.size() << " has " << nb_closed_pairs << " pairs at squared distance " << d2 << " in " << t.time() << " sec." << std::endl;
|
||||
std::cout << "New version: #points = " << input_points.size() << " and #triangles = " << input_triangles.size() << " has " << nb_closed_pairs << " pairs at squared distance " << d2 << " in " << t.time() << " sec." << std::endl;
|
||||
nb_closed_pairs=0;
|
||||
t.reset();
|
||||
t.start();
|
||||
close_triangles<false>(input_points, input_triangles, d2);
|
||||
t.stop();
|
||||
std::cout << "Old version: #points = " << input_points.size() << " and #triangles = " << input_triangles.size() << " has " << nb_closed_pairs << " pairs at squared distance " << d2 << " in " << t.time() << " sec." << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -139,9 +165,11 @@ int main(int argc, char** argv)
|
|||
average_length/=(3*input_triangles.size());
|
||||
|
||||
// Test<CGAL::Exact_predicates_inexact_constructions_kernel>().run(filename, 100*max/input_points.size());
|
||||
std::cout << "EPICK" << std::endl;
|
||||
Test<CGAL::Exact_predicates_inexact_constructions_kernel>().run(filename, average_length*average_length/256);
|
||||
Test<CGAL::Exact_predicates_inexact_constructions_kernel>().run(filename, min_sq_length*4);
|
||||
|
||||
std::cout << "EPECK" << std::endl;
|
||||
Test<CGAL::Exact_predicates_exact_constructions_kernel>().run(filename, average_length*average_length/256);
|
||||
Test<CGAL::Exact_predicates_exact_constructions_kernel>().run(filename, min_sq_length*4);
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ compare_squared_distance_disjoint(const typename K::Triangle_3& tr1,
|
|||
typename K::Comparison_result res(LARGER);
|
||||
|
||||
// The tiangle are supposed to be disjoint
|
||||
assertion(!do_intersect(tr1, tr2));
|
||||
assert(!do_intersect(tr1, tr2));
|
||||
|
||||
for(int i=0; i<3; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include <CGAL/number_utils.h>
|
||||
#include <memory>
|
||||
#include <CGAL/boost/graph/internal/Has_member_id.h>
|
||||
#include <CGAL/Distance_3/Point_3_Point_3.h>
|
||||
#include <CGAL/Distance_3>
|
||||
#include <CGAL/Dynamic_property_map.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
|
|||
Loading…
Reference in New Issue