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: 00015 // $Id: General_polygon_set_2.h 47919 2009-02-05 15:39:55Z guyzucke $ $Date: 2009-02-05 17:39:55 +0200 (Thu, 05 Feb 2009) $ 00016 // 00017 // 00018 // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> 00019 // Efi Fogel <efif@post.tau.ac.il> 00020 // Ophir Setter <ophir.setter@cs.tau.ac.il> 00021 00022 #ifndef CGAL_GENERAL_POLYGON_SET_ON_SURFACE_2_H 00023 #define CGAL_GENERAL_POLYGON_SET_ON_SURFACE_2_H 00024 00025 #include <CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h> 00026 #include <CGAL/Boolean_set_operations_2/Gps_polygon_validation.h> 00027 00028 CGAL_BEGIN_NAMESPACE 00029 00030 00031 namespace Boolean_set_operation_2_internal 00032 { 00033 struct PreconditionValidationPolicy 00034 { 00041 template <class Polygon, class Traits> 00042 inline static void is_valid(const Polygon& p, Traits& t) 00043 { 00044 CGAL_precondition(is_valid_unknown_polygon(p, t)); 00045 } 00046 }; 00047 } 00048 00049 00050 // General_polygon_set_on_surface_2 00051 /* 00052 This class is derived from Gps_on_surface_base_2. 00053 It enforces the validation conditions for general polygons, and is therefore 00054 the basic implementation that should be used by the user 00055 */ 00056 template <class Traits_, class TopTraits_> 00057 class General_polygon_set_on_surface_2 : 00058 public Gps_on_surface_base_2<Traits_, TopTraits_, 00059 Boolean_set_operation_2_internal::PreconditionValidationPolicy> 00060 { 00061 protected: 00062 typedef Traits_ Traits_2; 00063 typedef General_polygon_set_on_surface_2<Traits_2, TopTraits_> Self; 00064 typedef Gps_on_surface_base_2<Traits_2, TopTraits_, 00065 Boolean_set_operation_2_internal::PreconditionValidationPolicy> Base; 00066 00067 public: 00068 typedef typename Base::Polygon_2 Polygon_2; 00069 typedef typename Base::Polygon_with_holes_2 00070 Polygon_with_holes_2; 00071 typedef typename Base::Arrangement_on_surface_2 00072 Arrangement_on_surface_2; 00073 00074 public: 00075 00076 // default costructor 00077 General_polygon_set_on_surface_2() : Base() 00078 {} 00079 00080 00081 // constructor with traits object 00082 General_polygon_set_on_surface_2(Traits_2& tr) : Base(tr) 00083 {} 00084 00085 00086 General_polygon_set_on_surface_2(const Self& ps) : Base(ps) 00087 {} 00088 00089 00090 General_polygon_set_on_surface_2& operator=(const Self& ps) 00091 { 00092 Base::operator=(ps); 00093 return (*this); 00094 } 00095 00096 00097 explicit General_polygon_set_on_surface_2(const Polygon_2& pgn) : Base(pgn) 00098 { } 00099 00100 explicit General_polygon_set_on_surface_2( 00101 const Polygon_with_holes_2& pgn_with_holes) : Base(pgn_with_holes) 00102 { } 00103 00104 protected: 00105 General_polygon_set_on_surface_2(Arrangement_on_surface_2* arr) : Base(arr) 00106 {} 00107 00108 public: 00109 //destructor 00110 virtual ~General_polygon_set_on_surface_2() 00111 { } 00112 00113 void intersection(const Self& gps1, const Self& gps2) 00114 { 00115 Base::intersection(gps1.base(), gps2.base()); 00116 } 00117 00118 void join(const Self& gps1, const Self& gps2) 00119 { 00120 Base::join(gps1.base(), gps2.base()); 00121 } 00122 00123 void symmetric_difference(const Self& gps1, const Self& gps2) 00124 { 00125 Base::symmetric_difference(gps1.base(), gps2.base()); 00126 } 00127 00128 00129 // For some reason the below functions (the ones that we call "using" for) 00130 // are hidden by the function in this class and are not found in the parent's 00131 // class (General_polygon_set_on_surface_2) when they are called on an 00132 // object of type General_polygon_set_2. 00133 // Check in the Vandervoorde / Stroustrup books what is the exact reason. 00134 // (There may be a better and more correct solution.) 00135 using Base::intersection; 00136 using Base::join; 00137 using Base::symmetric_difference; 00138 00139 private: 00140 const Base& base() const 00141 { 00142 return static_cast<const Base&> (*this); 00143 } 00144 00145 Base& base() 00146 { 00147 return static_cast<Base&> (*this); 00148 } 00149 00150 }; 00151 00152 CGAL_END_NAMESPACE 00153 00154 #endif // CGAL_GENERAL_POLYGON_SET_ON_SURFACE_2_H