BWAPI
|
00001 // Copyright (c) 2005 Tel-Aviv University (Israel). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00005 // the terms of the Q Public License version 1.0. 00006 // See the file LICENSE.QPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Arrangement_on_surface_2/include/CGAL/Arr_counting_traits_2.h $ 00015 // $Id: Arr_counting_traits_2.h 50366 2009-07-05 12:56:48Z efif $ 00016 // 00017 // Author(s) : Efi Fogel <efif@post.tau.ac.il> 00018 00019 #ifndef CGAL_ARR_COUNTING_TRAITS_H 00020 #define CGAL_ARR_COUNTING_TRAITS_H 00021 00029 #include <iostream> 00030 #include <string.h> 00031 00032 #include <CGAL/basic.h> 00033 #include <CGAL/Arr_enums.h> 00034 00035 CGAL_BEGIN_NAMESPACE 00036 00040 template <class Base_traits> 00041 class Arr_counting_traits_2 : public Base_traits { 00042 public: 00043 enum Operation_id { 00044 COMPARE_X_OP = 0, 00045 COMPARE_XY_OP, 00046 CONSTRUCT_MIN_VERTEX_OP, 00047 CONSTRUCT_MAX_VERTEX_OP, 00048 IS_VERTICAL_OP, 00049 COMPARE_Y_AT_X_OP, 00050 EQUAL_POINTS_OP, 00051 EQUAL_CURVES_OP, 00052 COMPARE_Y_AT_X_LEFT_OP, 00053 COMPARE_Y_AT_X_RIGHT_OP, 00054 MAKE_X_MONOTONE_OP, 00055 SPLIT_OP, 00056 INTERSECT_OP, 00057 ARE_MERGEABLE_OP, 00058 MERGE_OP, 00059 CONSTRUCT_OPPOSITE_OP, 00060 COMPARE_ENDPOINTS_XY_OP, 00061 00062 PARAMETER_SPACE_IN_X_CURVE_END_OP, 00063 PARAMETER_SPACE_IN_X_POINT_OP, 00064 PARAMETER_SPACE_IN_X_CURVE_OP, 00065 COMPARE_Y_NEAR_BOUNDARY_OP, 00066 COMPARE_Y_ON_BOUNDARY_OP, 00067 IS_ON_X_IDENTIFICATION_POINT_OP, 00068 IS_ON_X_IDENTIFICATION_CURVE_OP, 00069 00070 PARAMETER_SPACE_IN_Y_CURVE_END_OP, 00071 PARAMETER_SPACE_IN_Y_POINT_OP, 00072 PARAMETER_SPACE_IN_Y_CURVE_OP, 00073 COMPARE_X_NEAR_BOUNDARY_POINT_CURVE_END_OP, 00074 COMPARE_X_NEAR_BOUNDARY_CURVE_ENDS_OP, 00075 COMPARE_X_ON_BOUNDARY_OP, 00076 IS_ON_Y_IDENTIFICATION_POINT_OP, 00077 IS_ON_Y_IDENTIFICATION_CURVE_OP, 00078 00079 NUMBER_OF_OPERATIONS 00080 }; 00081 00082 typedef Base_traits Base; 00083 typedef Arr_counting_traits_2<Base> Self; 00084 00086 Arr_counting_traits_2() : Base() 00087 { 00088 clear_counters(); 00089 increment(); 00090 } 00091 00093 Arr_counting_traits_2(Arr_counting_traits_2 & other) : Base(other) 00094 { 00095 clear_counters(); 00096 increment(); 00097 } 00098 00100 unsigned int count(Operation_id id) const 00101 { return m_counters[id]; } 00102 00103 unsigned int count_compare_x() const 00104 { return m_counters[COMPARE_X_OP]; } 00105 00106 unsigned int count_compare_xy() const 00107 { return m_counters[COMPARE_XY_OP]; } 00108 00109 unsigned int count_construct_min_vertex() const 00110 { return m_counters[CONSTRUCT_MIN_VERTEX_OP]; } 00111 00112 unsigned int count_construct_max_vertex() const 00113 { return m_counters[CONSTRUCT_MAX_VERTEX_OP]; } 00114 00115 unsigned int count_is_vertical() const 00116 { return m_counters[IS_VERTICAL_OP]; } 00117 00118 unsigned int count_compare_y_at_x() const 00119 { return m_counters[COMPARE_Y_AT_X_OP]; } 00120 00121 unsigned int count_equal_points() const 00122 { return m_counters[EQUAL_POINTS_OP]; } 00123 00124 unsigned int count_equal_curves() const 00125 { return m_counters[EQUAL_CURVES_OP]; } 00126 00127 unsigned int count_compare_y_at_x_left() const 00128 { return m_counters[COMPARE_Y_AT_X_LEFT_OP]; } 00129 00130 unsigned int count_compare_y_at_x_right() const 00131 { return m_counters[COMPARE_Y_AT_X_RIGHT_OP]; } 00132 00133 unsigned int count_make_x_monotone() const 00134 { return m_counters[MAKE_X_MONOTONE_OP]; } 00135 00136 unsigned int count_split() const 00137 { return m_counters[SPLIT_OP]; } 00138 00139 unsigned int count_intersect() const 00140 { return m_counters[INTERSECT_OP]; } 00141 00142 unsigned int count_are_mergeable() const 00143 { return m_counters[ARE_MERGEABLE_OP]; } 00144 00145 unsigned int count_merge() const 00146 { return m_counters[MERGE_OP]; } 00147 00148 unsigned int count_construct_opposite() const 00149 { return m_counters[CONSTRUCT_OPPOSITE_OP]; } 00150 00151 unsigned int count_compare_endpoints_xy() const 00152 { return m_counters[COMPARE_ENDPOINTS_XY_OP]; } 00153 00154 // left-right 00155 00156 unsigned int count_parameter_space_in_x_curve_end() const 00157 { return m_counters[PARAMETER_SPACE_IN_X_CURVE_END_OP]; } 00158 00159 unsigned int count_parameter_space_in_x_curve() const 00160 { return m_counters[PARAMETER_SPACE_IN_X_CURVE_OP]; } 00161 00162 unsigned int count_parameter_space_in_x_point() const 00163 { return m_counters[PARAMETER_SPACE_IN_X_POINT_OP]; } 00164 00165 unsigned int count_compare_y_near_boundary() const 00166 { return m_counters[COMPARE_Y_NEAR_BOUNDARY_OP]; } 00167 00168 unsigned int count_compare_y_on_boundary() const 00169 { return m_counters[COMPARE_Y_ON_BOUNDARY_OP]; } 00170 00171 // bottom-top 00172 00173 unsigned int count_parameter_space_in_y_curve_end() const 00174 { return m_counters[PARAMETER_SPACE_IN_Y_CURVE_END_OP]; } 00175 00176 unsigned int count_parameter_space_in_y_curve() const 00177 { return m_counters[PARAMETER_SPACE_IN_Y_CURVE_OP]; } 00178 00179 unsigned int count_parameter_space_in_y_point() const 00180 { return m_counters[PARAMETER_SPACE_IN_Y_POINT_OP]; } 00181 00182 unsigned int count_compare_x_near_boundary_point_curve_end() const 00183 { return m_counters[COMPARE_X_NEAR_BOUNDARY_POINT_CURVE_END_OP]; } 00184 00185 unsigned int count_compare_x_near_boundary_curve_ends() const 00186 { return m_counters[COMPARE_X_NEAR_BOUNDARY_CURVE_ENDS_OP]; } 00187 00188 unsigned int count_compare_x_on_boundary() const 00189 { return m_counters[COMPARE_X_ON_BOUNDARY_OP]; } 00190 00192 00193 00194 // Traits types: 00195 typedef typename Base::Has_left_category Has_left_category; 00196 typedef typename Base::Has_merge_category Has_merge_category; 00197 00198 typedef typename CGALi::Arr_complete_left_side_tag< Base >::Tag 00199 Arr_left_side_tag; 00200 typedef typename CGALi::Arr_complete_bottom_side_tag< Base >::Tag 00201 Arr_bottom_side_tag; 00202 typedef typename CGALi::Arr_complete_top_side_tag< Base >::Tag 00203 Arr_top_side_tag; 00204 typedef typename CGALi::Arr_complete_right_side_tag< Base >::Tag 00205 Arr_right_side_tag; 00206 00207 typedef typename Base::Point_2 Point_2; 00208 typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; 00209 typedef typename Base::Curve_2 Curve_2; 00210 00212 class Compare_x_2 { 00213 private: 00214 typename Base::Compare_x_2 m_object; 00215 unsigned int & m_counter; 00216 00217 public: 00219 Compare_x_2(const Base * base, unsigned int & counter) : 00220 m_object(base->compare_x_2_object()), m_counter(counter) {} 00221 00223 Comparison_result operator()(const Point_2 & p1, const Point_2 & p2) const 00224 { ++m_counter; return m_object(p1, p2); } 00225 }; 00226 00228 class Compare_xy_2 { 00229 private: 00230 typename Base::Compare_xy_2 m_object; 00231 mutable unsigned int & m_counter; 00232 00233 public: 00235 Compare_xy_2(const Base * base, unsigned int & counter) : 00236 m_object(base->compare_xy_2_object()), m_counter(counter) {} 00237 00239 Comparison_result operator()(const Point_2 & p1, const Point_2 & p2) const 00240 { ++m_counter; return m_object(p1, p2); } 00241 }; 00242 00244 class Construct_min_vertex_2 { 00245 private: 00246 typename Base::Construct_min_vertex_2 m_object; 00247 unsigned int & m_counter; 00248 00249 public: 00251 Construct_min_vertex_2(const Base * base, unsigned int & counter) : 00252 m_object(base->construct_min_vertex_2_object()), m_counter(counter) {} 00253 00255 const Point_2 operator()(const X_monotone_curve_2 & xc) const 00256 { ++m_counter; return m_object(xc); } 00257 }; 00258 00260 class Construct_max_vertex_2 { 00261 private: 00262 typename Base::Construct_max_vertex_2 m_object; 00263 unsigned int & m_counter; 00264 00265 public: 00267 Construct_max_vertex_2(const Base * base, unsigned int & counter) : 00268 m_object(base->construct_max_vertex_2_object()), m_counter(counter) {} 00269 00271 const Point_2 operator()(const X_monotone_curve_2 & xc) const 00272 { ++m_counter; return m_object(xc); } 00273 }; 00274 00276 class Is_vertical_2 { 00277 private: 00278 typename Base::Is_vertical_2 m_object; 00279 unsigned int & m_counter; 00280 00281 public: 00283 Is_vertical_2(const Base * base, unsigned int & counter) : 00284 m_object(base->is_vertical_2_object()), m_counter(counter) {} 00285 00287 bool operator()(const X_monotone_curve_2 & xc) const 00288 { ++m_counter; return m_object(xc); } 00289 }; 00290 00294 class Compare_y_at_x_2 { 00295 private: 00296 typename Base::Compare_y_at_x_2 m_object; 00297 unsigned int & m_counter; 00298 00299 public: 00301 Compare_y_at_x_2(const Base * base, unsigned int & counter) : 00302 m_object(base->compare_y_at_x_2_object()), m_counter(counter) {} 00303 00305 Comparison_result operator()(const Point_2 & p, 00306 const X_monotone_curve_2 & xc) const 00307 { ++m_counter; return m_object(p, xc); } 00308 }; 00309 00313 class Equal_2 { 00314 private: 00315 typename Base::Equal_2 m_object; 00316 unsigned int & m_counter1; 00317 unsigned int & m_counter2; 00318 00319 public: 00321 Equal_2(const Base * base, 00322 unsigned int & counter1, unsigned int & counter2) : 00323 m_object(base->equal_2_object()), 00324 m_counter1(counter1), m_counter2(counter2) 00325 {} 00326 00328 bool operator()(const X_monotone_curve_2 & xc1, 00329 const X_monotone_curve_2 & xc2) const 00330 { ++m_counter1; return m_object(xc1, xc2); } 00331 00333 bool operator()(const Point_2 & p1, const Point_2 & p2) const 00334 { ++m_counter2; return m_object(p1, p2); } 00335 }; 00336 00340 class Compare_y_at_x_left_2 { 00341 private: 00342 typename Base::Compare_y_at_x_left_2 m_object; 00343 unsigned int & m_counter; 00344 00345 public: 00347 Compare_y_at_x_left_2(const Base * base, unsigned int & counter) : 00348 m_object(base->compare_y_at_x_left_2_object()), m_counter(counter) {} 00349 00351 Comparison_result operator()(const X_monotone_curve_2 & xc1, 00352 const X_monotone_curve_2 & xc2, 00353 const Point_2 & p) const 00354 { ++m_counter; return m_object(xc1, xc2, p); } 00355 }; 00356 00360 class Compare_y_at_x_right_2 { 00361 private: 00362 typename Base::Compare_y_at_x_right_2 m_object; 00363 unsigned int & m_counter; 00364 00365 public: 00367 Compare_y_at_x_right_2(const Base * base, unsigned int & counter) : 00368 m_object(base->compare_y_at_x_right_2_object()), m_counter(counter) {} 00369 00371 Comparison_result operator()(const X_monotone_curve_2 & xc1, 00372 const X_monotone_curve_2 & xc2, 00373 const Point_2 & p) const 00374 { ++m_counter; return m_object(xc1, xc2, p); } 00375 }; 00376 00378 class Make_x_monotone_2 { 00379 private: 00380 typename Base::Make_x_monotone_2 m_object; 00381 unsigned int & m_counter; 00382 00383 public: 00385 Make_x_monotone_2(const Base * base, unsigned int & counter) : 00386 m_object(base->make_x_monotone_2_object()), m_counter(counter) {} 00387 00389 template<class OutputIterator> 00390 OutputIterator operator()(const Curve_2 & cv, OutputIterator oi) const 00391 { ++m_counter; return m_object(cv, oi); } 00392 }; 00393 00395 class Split_2 { 00396 private: 00397 typename Base::Split_2 m_object; 00398 unsigned int & m_counter; 00399 00400 public: 00402 Split_2(const Base * base, unsigned int & counter) : 00403 m_object(base->split_2_object()), m_counter(counter) {} 00404 00406 void operator()(const X_monotone_curve_2 & xc, const Point_2 & p, 00407 X_monotone_curve_2 & xc1, X_monotone_curve_2 & xc2) const 00408 { ++m_counter; m_object(xc, p, xc1, xc2); } 00409 }; 00410 00412 class Intersect_2 { 00413 private: 00414 typename Base::Intersect_2 m_object; 00415 unsigned int & m_counter; 00416 00417 public: 00419 Intersect_2(const Base * base, unsigned int & counter) : 00420 m_object(base->intersect_2_object()), m_counter(counter) {} 00421 00423 template<class OutputIterator> 00424 OutputIterator operator()(const X_monotone_curve_2 & xc1, 00425 const X_monotone_curve_2 & xc2, 00426 OutputIterator oi) const 00427 { ++m_counter; return m_object(xc1, xc2, oi); } 00428 }; 00429 00431 class Are_mergeable_2 { 00432 private: 00433 typename Base::Are_mergeable_2 m_object; 00434 unsigned int & m_counter; 00435 00436 public: 00438 Are_mergeable_2(const Base * base, unsigned int & counter) : 00439 m_object(base->are_mergeable_2_object()), m_counter(counter) {} 00440 00442 bool operator()(const X_monotone_curve_2 & xc1, 00443 const X_monotone_curve_2 & xc2) const 00444 { ++m_counter; return m_object(xc1, xc2); } 00445 }; 00446 00448 class Merge_2 { 00449 private: 00450 typename Base::Merge_2 m_object; 00451 unsigned int & m_counter; 00452 00453 public: 00455 Merge_2(const Base * base, unsigned int & counter) : 00456 m_object(base->merge_2_object()), m_counter(counter) {} 00457 00459 void operator()(const X_monotone_curve_2 & xc1, 00460 const X_monotone_curve_2 & xc2, 00461 X_monotone_curve_2 & xc) const 00462 { ++m_counter; m_object(xc1, xc2, xc); } 00463 }; 00464 00466 class Construct_opposite_2 { 00467 private: 00468 typename Base::Construct_opposite_2 m_object; 00469 unsigned int & m_counter; 00470 00471 public: 00473 Construct_opposite_2(const Base * base, unsigned int & counter) : 00474 m_object(base->construct_opposite_2_object()), m_counter(counter) {} 00475 00477 X_monotone_curve_2 operator()(const X_monotone_curve_2 & xc) 00478 { ++m_counter; return m_object(xc); } 00479 }; 00480 00484 class Compare_endpoints_xy_2 { 00485 private: 00486 typename Base::Compare_endpoints_xy_2 m_object; 00487 unsigned int & m_counter; 00488 00489 public: 00491 Compare_endpoints_xy_2(const Base * base, unsigned int & counter) : 00492 m_object(base->compare_endpoints_xy_2_object()), m_counter(counter) {} 00493 00495 Comparison_result operator()(const X_monotone_curve_2 & xc) 00496 { ++m_counter; return m_object(xc); } 00497 }; 00498 00499 // left-right 00500 00504 class Parameter_space_in_x_2 { 00505 private: 00506 typename Base::Parameter_space_in_x_2 m_object; 00507 mutable unsigned int & m_counter1; 00508 mutable unsigned int & m_counter2; 00509 mutable unsigned int & m_counter3; 00510 00511 public: 00513 Parameter_space_in_x_2(const Base * base, 00514 unsigned int & counter1, 00515 unsigned int & counter2, 00516 unsigned int & counter3) : 00517 m_object(base->parameter_space_in_x_2_object()), 00518 m_counter1(counter1), 00519 m_counter2(counter2), 00520 m_counter3(counter3) {} 00521 00523 Arr_parameter_space operator()(const X_monotone_curve_2 & xc, 00524 Arr_curve_end ce) const 00525 { ++m_counter1; return m_object(xc, ce); } 00526 00527 00529 Arr_parameter_space operator()(const Point_2 & p) const 00530 { ++m_counter2; return m_object(p); } 00531 00532 00534 Arr_parameter_space operator()(const X_monotone_curve_2 & xc) const 00535 { ++m_counter3; return m_object(xc); } 00536 00537 }; 00538 00542 class Compare_y_near_boundary_2 { 00543 private: 00544 typename Base::Compare_y_near_boundary_2 m_object; 00545 unsigned int & m_counter; 00546 00547 public: 00549 Compare_y_near_boundary_2(const Base * base, unsigned int & counter) : 00550 m_object(base->compare_y_near_boundary_2_object()), m_counter(counter) {} 00551 00553 Comparison_result operator()(const X_monotone_curve_2 & xc1, 00554 const X_monotone_curve_2 & xc2, 00555 Arr_curve_end ce) const 00556 { ++m_counter; return m_object(xc1, xc2, ce); } 00557 }; 00558 00562 class Compare_y_on_boundary_2 { 00563 private: 00564 typename Base::Compare_y_on_boundary_2 m_object; 00565 unsigned int & m_counter; 00566 00567 public: 00569 Compare_y_on_boundary_2(const Base * base, unsigned int & counter) : 00570 m_object(base->compare_y_on_boundary_2_object()), 00571 m_counter(counter) 00572 {} 00573 00575 Comparison_result operator()(const Point_2 & p1, 00576 const Point_2 & p2) const 00577 { ++m_counter; return m_object(p1, p2); } 00578 }; 00579 00580 // TODO Is_on_x_identification_2 00581 00582 // bottom-top 00583 00584 00588 class Parameter_space_in_y_2 { 00589 private: 00590 typename Base::Parameter_space_in_y_2 m_object; 00591 mutable unsigned int & m_counter1; 00592 mutable unsigned int & m_counter2; 00593 mutable unsigned int & m_counter3; 00594 00595 public: 00597 Parameter_space_in_y_2(const Base * base, 00598 unsigned int & counter1, 00599 unsigned int & counter2, 00600 unsigned int & counter3) : 00601 m_object(base->parameter_space_in_y_2_object()), 00602 m_counter1(counter1), 00603 m_counter2(counter2), 00604 m_counter3(counter3) {} 00605 00607 Arr_parameter_space operator()(const X_monotone_curve_2 & xc, 00608 Arr_curve_end ce) const 00609 { ++m_counter1; return m_object(xc, ce); } 00610 00612 Arr_parameter_space operator()(const Point_2 & p) const 00613 { ++m_counter2; return m_object(p); } 00614 00616 Arr_parameter_space operator()(const X_monotone_curve_2 & xc) const 00617 { ++m_counter3; return m_object(xc); } 00618 00619 }; 00620 00624 class Compare_x_near_boundary_2 { 00625 private: 00626 typename Base::Compare_x_near_boundary_2 m_object; 00627 unsigned int & m_counter1; 00628 unsigned int & m_counter2; 00629 00630 public: 00632 Compare_x_near_boundary_2(const Base * base, 00633 unsigned int & counter1, 00634 unsigned int & counter2) : 00635 m_object(base->compare_x_near_boundary_2_object()), 00636 m_counter1(counter1), 00637 m_counter2(counter2) {} 00638 00640 Comparison_result operator()(const Point_2 & p, 00641 const X_monotone_curve_2 & xc, 00642 Arr_curve_end ce) const 00643 { ++m_counter1; return m_object(p, xc, ce); } 00644 00646 Comparison_result operator()(const X_monotone_curve_2 & xc1, 00647 Arr_curve_end ce1, 00648 const X_monotone_curve_2 & xc2, 00649 Arr_curve_end ce2) const 00650 { ++m_counter2; return m_object(xc1, ce1, xc2, ce2); } 00651 }; 00652 00653 00657 class Compare_x_on_boundary_2 { 00658 private: 00659 typename Base::Compare_x_on_boundary_2 m_object; 00660 unsigned int & m_counter; 00661 00662 public: 00664 Compare_x_on_boundary_2(const Base * base, unsigned int & counter) : 00665 m_object(base->compare_x_on_boundary_2_object()), 00666 m_counter(counter) 00667 {} 00668 00670 Comparison_result operator()(const Point_2 & p1, 00671 const Point_2 & p2) const 00672 { ++m_counter; return m_object(p1, p2); } 00673 }; 00674 00675 00676 // TODO Is_on_y_identification_2 00677 00679 00680 00681 00683 00684 00685 Compare_x_2 compare_x_2_object() const 00686 { return Compare_x_2(this, m_counters[COMPARE_X_OP]); } 00687 00688 Compare_xy_2 compare_xy_2_object() const 00689 { return Compare_xy_2(this, m_counters[COMPARE_XY_OP]); } 00690 00691 Construct_min_vertex_2 construct_min_vertex_2_object() const 00692 { return Construct_min_vertex_2(this, m_counters[CONSTRUCT_MIN_VERTEX_OP]); } 00693 00694 Construct_max_vertex_2 construct_max_vertex_2_object() const 00695 { return Construct_max_vertex_2(this, m_counters[CONSTRUCT_MAX_VERTEX_OP]); } 00696 00697 Is_vertical_2 is_vertical_2_object() const 00698 { return Is_vertical_2(this, m_counters[IS_VERTICAL_OP]); } 00699 00700 Compare_y_at_x_2 compare_y_at_x_2_object() const 00701 { return Compare_y_at_x_2(this, m_counters[COMPARE_Y_AT_X_OP]); } 00702 00703 Equal_2 equal_2_object() const 00704 { 00705 return Equal_2(this, m_counters[EQUAL_POINTS_OP], 00706 m_counters[EQUAL_CURVES_OP]); 00707 } 00708 00709 Compare_y_at_x_left_2 compare_y_at_x_left_2_object() const 00710 { return Compare_y_at_x_left_2(this, m_counters[COMPARE_Y_AT_X_LEFT_OP]); } 00711 00712 Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const 00713 { return Compare_y_at_x_right_2(this, m_counters[COMPARE_Y_AT_X_RIGHT_OP]); } 00714 00715 Make_x_monotone_2 make_x_monotone_2_object() const 00716 { return Make_x_monotone_2(this, m_counters[MAKE_X_MONOTONE_OP]); } 00717 00718 Split_2 split_2_object() const 00719 { return Split_2(this, m_counters[SPLIT_OP]); } 00720 00721 Intersect_2 intersect_2_object() const 00722 { return Intersect_2(this, m_counters[INTERSECT_OP]); } 00723 00724 Are_mergeable_2 are_mergeable_2_object() const 00725 { return Are_mergeable_2(this, m_counters[ARE_MERGEABLE_OP]); } 00726 00727 Merge_2 merge_2_object() const 00728 { return Merge_2(this, m_counters[MERGE_OP]); } 00729 00730 Construct_opposite_2 construct_opposite_2_object() const 00731 { return Construct_opposite_2(this, m_counters[CONSTRUCT_OPPOSITE_OP]); } 00732 00733 Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const 00734 { return Compare_endpoints_xy_2(this, m_counters[COMPARE_ENDPOINTS_XY_OP]); } 00735 00736 // left-right 00737 Parameter_space_in_x_2 parameter_space_in_x_2_object() const 00738 { return Parameter_space_in_x_2( 00739 this, 00740 m_counters[PARAMETER_SPACE_IN_X_CURVE_END_OP], 00741 m_counters[PARAMETER_SPACE_IN_X_POINT_OP], 00742 m_counters[PARAMETER_SPACE_IN_X_CURVE_OP] 00743 ); 00744 } 00745 00746 // bottom-top 00747 Parameter_space_in_y_2 parameter_space_in_y_2_object() const 00748 { return Parameter_space_in_y_2( 00749 this, 00750 m_counters[PARAMETER_SPACE_IN_Y_CURVE_END_OP], 00751 m_counters[PARAMETER_SPACE_IN_Y_POINT_OP], 00752 m_counters[PARAMETER_SPACE_IN_Y_CURVE_OP] 00753 ); 00754 } 00755 00756 00758 00763 static unsigned int increment(bool doit = true) 00764 { 00765 static unsigned int counter = 0; 00766 if (doit) ++counter; 00767 return counter; 00768 } 00769 00771 void clear_counters() 00772 { memset(m_counters, 0, sizeof(m_counters)); } 00773 00774 private: 00776 mutable unsigned int m_counters[NUMBER_OF_OPERATIONS]; 00777 }; 00778 00779 template <class Out_stream, class Base_traits> 00780 inline 00781 Out_stream & operator<<(Out_stream & os, 00782 const Arr_counting_traits_2<Base_traits> & traits) 00783 { 00784 typedef Arr_counting_traits_2<Base_traits> Traits; 00785 unsigned int sum = 0; 00786 unsigned int i; 00787 for (i = 0; i < Traits::NUMBER_OF_OPERATIONS; ++i) 00788 sum += traits.count(static_cast<typename Traits::Operation_id>(i)); 00789 os << "# of COMPARE_X operation = " 00790 << traits.count_compare_x() << std::endl 00791 << "# of COMPARE_XY operation = " 00792 << traits.count_compare_xy() << std::endl 00793 << "# of CONSTRUCT_MIN_VERTEX operation = " 00794 << traits.count_construct_min_vertex() << std::endl 00795 << "# of CONSTRUCT_MAX_VERTEX operation = " 00796 << traits.count_construct_max_vertex() << std::endl 00797 << "# of IS_VERTICAL operation = " 00798 << traits.count_is_vertical() << std::endl 00799 << "# of COMPARE_Y_AT_X operation = " 00800 << traits.count_compare_y_at_x() << std::endl 00801 << "# of EQUAL_POINTS operation = " 00802 << traits.count_equal_points() << std::endl 00803 << "# of EQUAL_CURVES operation = " 00804 << traits.count_equal_curves() << std::endl 00805 << "# of COMPARE_Y_AT_X_LEFT operation = " 00806 << traits.count_compare_y_at_x_left() << std::endl 00807 << "# of COMPARE_Y_AT_X_RIGHT operation = " 00808 << traits.count_compare_y_at_x_right() << std::endl 00809 << "# of MAKE_X_MONOTONE operation = " 00810 << traits.count_make_x_monotone() << std::endl 00811 << "# of SPLIT operation = " 00812 << traits.count_split() << std::endl 00813 << "# of INTERSECT operation = " 00814 << traits.count_intersect() << std::endl 00815 << "# of ARE_MERGEABLE operation = " 00816 << traits.count_are_mergeable() << std::endl 00817 << "# of MERGE operation = " 00818 << traits.count_merge() << std::endl 00819 << "# of CONSTRUCT_OPPOSITE operation = " 00820 << traits.count_construct_opposite() << std::endl 00821 << "# of COMPARE_ENDPOINTS_XY operation = " 00822 << traits.count_compare_endpoints_xy() << std::endl 00823 // left-right 00824 << "# of PARAMETER_SPACE_IN_X curve-end operation = " 00825 << traits.count_parameter_space_in_x_curve_end() << std::endl 00826 << "# of PARAMETER_SPACE_IN_X point operation = " 00827 << traits.count_parameter_space_in_x_point() << std::endl 00828 << "# of PARAMETER_SPACE_IN_X curve operation = " 00829 << traits.count_parameter_space_in_x_curve() << std::endl 00830 << "# of COMPARE_Y_NEAR_BOUNDARY operation = " 00831 << traits.count_compare_y_near_boundary() << std::endl 00832 << "# of COMPARE_Y_ON_BOUNDARY operation = " 00833 << traits.count_compare_y_on_boundary() << std::endl 00834 // bottom-top 00835 << "# of PARAMETER_SPACE_IN_Y curve-end operation = " 00836 << traits.count_parameter_space_in_y_curve_end() << std::endl 00837 << "# of PARAMETER_SPACE_IN_Y point operation = " 00838 << traits.count_parameter_space_in_y_point() << std::endl 00839 << "# of PARAMETER_SPACE_IN_Y curve operation = " 00840 << traits.count_parameter_space_in_y_curve() << std::endl 00841 << "# of COMPARE_X_NEAR_BOUNDARY point/curve-end operation = " 00842 << traits.count_compare_x_near_boundary_point_curve_end() << std::endl 00843 << "# of COMPARE_X_NEAR_BOUNDARY curve-ends operation = " 00844 << traits.count_compare_x_near_boundary_curve_ends() << std::endl 00845 << "# of COMPARE_X_ON_BOUNDARY operation = " 00846 << traits.count_compare_x_on_boundary() << std::endl 00847 00848 << "total # = " << sum << std::endl 00849 << "# of traits constructed = " << Traits::increment(false) 00850 << std::endl; 00851 return os; 00852 } 00853 00854 CGAL_END_NAMESPACE 00855 00856 #endif