solve conflict

This commit is contained in:
kanhuang 2013-12-16 23:13:56 +08:00
parent 67548ccfdd
commit 92b28effe4
3 changed files with 157 additions and 3 deletions

View File

@ -1059,6 +1059,161 @@ void simple_benchmark(Visibility_2_fst &visibility_fst,
<< "Model 2 uses " << ptime2 + qtime2 << " sec" << std::endl; << "Model 2 uses " << ptime2 + qtime2 << " sec" << std::endl;
} }
template<class Visibility_2>
void pure_benchmark_one_unit(
typename Visibility_2::Input_arrangement_2 &arr,
const Query_choice &choice,
typename Visibility_2::Input_arrangement_2::Face_const_handle &fit,
Visibility_2 visibility,
double& qtime,
int& query_cnt) {
typedef typename Visibility_2::Input_arrangement_2 Input_arrangement_2;
typedef typename Input_arrangement_2::Face_const_handle Face_const_handle;
typedef typename Visibility_2::Output_arrangement_2 Output_arrangement_2;
typedef typename Input_arrangement_2::Halfedge_const_handle
Halfedge_const_handle;
typedef typename Input_arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Input_arrangement_2::Ccb_halfedge_const_circulator
Ccb_halfedge_const_circulator;
typedef typename Output_arrangement_2::Face_handle Face_handle;
typedef typename Geometry_traits_2::Point_2 Point_2;
typedef typename Geometry_traits_2::FT Number_type;
typedef Timer Benchmark_timer;
Benchmark_timer timer;
Ccb_halfedge_const_circulator circ = fit->outer_ccb();
Ccb_halfedge_const_circulator curr = circ;
do {
Halfedge_const_handle he = curr;
Point_2 curr_query_pt;
bool selected_query_pt = true;
switch (choice) {
case VERTEX:
curr_query_pt = he->target()->point();
break;
case EDGE:
curr_query_pt = random_linear_interpolation<Point_2, Number_type>
(he->source()->point(), he->target()->point());
break;
case FACE:
Ccb_halfedge_const_circulator curr_next = curr;
curr_next++;
Halfedge_const_handle he_next = curr_next;
Point_2 p1 = he->source()->point();
Point_2 p2 = he->target()->point();
Point_2 p3 = he_next->target()->point();
Point_2 avg((p1.x() + p2.x() + p3.x())/3, (p1.y() + p2.y() + p3.y())/3);
if (is_inside_face<Input_arrangement_2>(arr, fit, avg)) {
curr_query_pt = avg;
}
else {
selected_query_pt = false;
}
break;
}
if (!selected_query_pt) {
curr++;
if (curr == circ) {
break;
}
continue;
}
Output_arrangement_2 out_arr;
timer.reset();
timer.start();
Face_handle fh;
if (choice == CGAL::FACE) {
fh = visibility.compute_visibility(curr_query_pt, fit, out_arr);
query_cnt++;
}
else {
fh = visibility.compute_visibility(curr_query_pt, he, out_arr);
query_cnt++;
}
timer.stop();
qtime += timer.time();
timer.reset();
} while (++curr != circ);
}
template<class Visibility_2>
void pure_benchmark( Visibility_2 &visibility,
const Query_choice &choice,
std::ifstream &input) {
typedef typename Visibility_2::Input_arrangement_2
Input_arrangement_2;
typedef typename Input_arrangement_2::Halfedge_const_handle
Halfedge_const_handle;
typedef typename Input_arrangement_2::Geometry_traits_2 Geometry_traits_2;
typedef typename Input_arrangement_2::Face_const_iterator Face_const_iterator;
typedef typename Input_arrangement_2::Face_const_handle Face_const_handle;
typedef typename Input_arrangement_2::Hole_const_iterator Hole_const_iterator;
typedef typename Input_arrangement_2::Halfedge_const_handle
Halfedge_const_handle;
typedef typename Input_arrangement_2::Ccb_halfedge_const_circulator
Ccb_halfedge_const_circulator;
typedef typename Geometry_traits_2::Point_2 Point_2;
typedef typename Geometry_traits_2::Segment_2 Segment_2;
Input_arrangement_2 arr;
create_arrangement_from_env_file<Input_arrangement_2>(arr, input);
int query_cnt(0);
double qtime(0), ptime(0);
if (Visibility_2::Supports_general_polygon_tag::value) {
Face_const_iterator fit;
Timer timer;
timer.start();
visibility.attach(arr);
timer.stop();
ptime = timer.time();
for (fit = arr.faces_begin() ; fit != arr.faces_end() ; fit++) {
if (!fit->is_unbounded()) {
pure_benchmark_one_unit<Visibility_2>( arr,
choice,
fit,
visibility,
qtime,
query_cnt);
}
}
}
else {
Input_arrangement_2 arr_trimmed;
Face_const_handle fch = construct_biggest_arr_with_no_holes
<Input_arrangement_2>(arr, arr_trimmed);
Timer timer;
timer.start();
visibility.attach(arr_trimmed);
timer.stop();
ptime = timer.time();
pure_benchmark_one_unit<Visibility_2>( arr_trimmed,
choice,
fch,
visibility,
qtime,
query_cnt);
}
std::cout << "Preprocessing: " << std::endl
<< "cost " << ptime << " sec" << std::endl;
std::cout << query_cnt << " queries are done.\n"
<< "cost " << qtime << " sec" << std::endl;
std::cout << "total time is:" << ptime + qtime << " sec" << std::endl;
}
template<class Segment_2, class Point_2> template<class Segment_2, class Point_2>
int intersect_seg(const Segment_2& seg1, const Segment_2& seg2, Segment_2& seg_out, Point_2& p_out) int intersect_seg(const Segment_2& seg1, const Segment_2& seg2, Segment_2& seg_out, Point_2& p_out)
{ {

View File

@ -27,7 +27,6 @@
#include <CGAL/Arr_segment_traits_2.h> #include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h> #include <CGAL/Arrangement_2.h>
#include <CGAL/Simple_polygon_visibility_2.h> #include <CGAL/Simple_polygon_visibility_2.h>
#include <CGAL/Naive_visibility_2.h>
#include <CGAL/Triangular_expansion_visibility_2.h> #include <CGAL/Triangular_expansion_visibility_2.h>
#include <CGAL/Rotational_sweep_visibility_2.h> #include <CGAL/Rotational_sweep_visibility_2.h>
#include <CGAL/test_model_methods.h> #include <CGAL/test_model_methods.h>

View File

@ -18,7 +18,7 @@
// //
// Author(s): Francisc Bungiu <fbungiu@gmail.com> // Author(s): Francisc Bungiu <fbungiu@gmail.com>
// Michael Hemmer <michael.hemmer@cgal.org> // Michael Hemmer <michael.hemmer@cgal.org>
// Kan Huang <huangkandiy@gmail.com // Kan Huang <huangkandiy@gmail.com>
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/Cartesian.h> #include <CGAL/Cartesian.h>
@ -74,7 +74,7 @@ void benchmark_two_classes(std::string name1, std::string name2, CGAL::Query_cho
} }
void print_usage() { void print_usage() {
std::cout << "Usage: ./benchmark [filename] [Class type 1] [Class type 2] [Query type] [Regularize]\n"; std::cout << "Usage: ./simple_benchmark [filename] [Class type 1] [Class type 2] [Query type] [Regularize]\n";
std::cout << "where [Class type] could be S(simple), R(rotational sweep) and T(triangular), indicating which classes you want to test.\n"; std::cout << "where [Class type] could be S(simple), R(rotational sweep) and T(triangular), indicating which classes you want to test.\n";
std::cout << "[Query type] can be: {vertex, edge, face}.\n"; std::cout << "[Query type] can be: {vertex, edge, face}.\n";
std::cout << "[Regularize] can be: {true, false}.\n"; std::cout << "[Regularize] can be: {true, false}.\n";