BWAPI
|
00001 // Copyright (c) 2008 INRIA Sophia-Antipolis (France). 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/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h $ 00015 // $Id: Circular_arc_point_3.h 50731 2009-07-21 09:08:07Z sloriot $ 00016 // 00017 // Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado, 00018 // Sebastien Loriot, Julien Hazebrouck, Damien Leroy 00019 00020 // Partially supported by the IST Programme of the EU as a 00021 // STREP (FET Open) Project under Contract No IST-006413 00022 // (ACS -- Algorithms for Complex Shapes) 00023 00024 #ifndef CGAL_SPHERICAL_KERNEL_CIRCULAR_ARC_POINT_3_H 00025 #define CGAL_SPHERICAL_KERNEL_CIRCULAR_ARC_POINT_3_H 00026 00027 #include <iostream> 00028 00029 //#include <CGAL/global_functions_on_roots_and_polynomials_2_2.h> 00030 // fixme, devrait 00031 // appeler fonction de global_functions_on_circular_arcs 00032 00033 namespace CGAL { 00034 namespace CGALi { 00035 00036 template <class SK > 00037 class Circular_arc_point_3 00038 { 00039 typedef typename SK::FT FT; 00040 typedef typename SK::Root_of_2 Root_of_2; 00041 typedef typename SK::Point_3 Point_3; 00042 typedef typename SK::Algebraic_kernel Algebraic_kernel; 00043 typedef typename Algebraic_kernel::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; 00044 typedef typename Algebraic_kernel::Polynomial_1_3 Polynomial_1_3; 00045 typedef typename Algebraic_kernel::Polynomials_for_line_3 Polynomials_for_line_3; 00046 typedef typename SK::Line_3 Line_3; 00047 typedef typename SK::Plane_3 Plane_3; 00048 typedef typename SK::Sphere_3 Sphere_3; 00049 typedef typename SK::Circle_3 Circle_3; 00050 typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; 00051 00052 typedef Root_for_spheres_2_3 Rep__; 00053 typedef typename SK::template Handle<Rep__>::type Base; 00054 00055 Base base; 00056 00057 public: 00058 00059 Circular_arc_point_3() {} 00060 00061 Circular_arc_point_3(const Root_of_2 & x, 00062 const Root_of_2 & y, 00063 const Root_of_2 & z) 00064 : base(x,y,z){} 00065 00066 Circular_arc_point_3(const Root_for_spheres_2_3 & np) 00067 : base(np){} 00068 00069 Circular_arc_point_3(const Point_3 & p) 00070 : base(p.x(),p.y(),p.z()){} 00071 00072 Circular_arc_point_3(const Sphere_3 &s1, 00073 const Sphere_3 &s2, 00074 const Sphere_3 &s3, 00075 const bool less_xyz = true) { 00076 std::vector<Object> sols; 00077 SK().intersect_3_object()(s1, s2, s3, std::back_inserter(sols)); 00078 // s1,s2,s3 must intersect 00079 CGAL_kernel_precondition(sols.size() != 0); 00080 if(sols.size() == 1) { 00081 // the intersection must be a point 00082 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00083 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]); 00084 CGAL_kernel_precondition(pair!=NULL); 00085 *this = pair->first.rep(); 00086 } else { 00087 // the intersections must be a point 00088 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00089 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]); 00090 CGAL_kernel_precondition(pair!=NULL); 00091 *this = pair->first.rep(); 00092 } 00093 } 00094 00095 Circular_arc_point_3(const Plane_3 &p, 00096 const Sphere_3 &s1, 00097 const Sphere_3 &s2, 00098 const bool less_xyz = true) { 00099 std::vector<Object> sols; 00100 SK().intersect_3_object()(p, s1, s2, std::back_inserter(sols)); 00101 // s1,s2,s3 must intersect 00102 CGAL_kernel_precondition(sols.size() != 0); 00103 if(sols.size() == 1) { 00104 // the intersection must be a point 00105 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00106 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]); 00107 CGAL_kernel_precondition(pair!=NULL); 00108 *this = pair->first.rep(); 00109 } else { 00110 // the intersections must be a point 00111 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00112 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]); 00113 CGAL_kernel_precondition(pair!=NULL); 00114 *this = pair->first.rep(); 00115 } 00116 } 00117 00118 Circular_arc_point_3(const Plane_3 &p1, 00119 const Plane_3 &p2, 00120 const Sphere_3 &s, 00121 const bool less_xyz = true) { 00122 std::vector<Object> sols; 00123 SK().intersect_3_object()(p1, p2, s, std::back_inserter(sols)); 00124 // s1,s2,s3 must intersect 00125 CGAL_kernel_precondition(sols.size() != 0); 00126 if(sols.size() == 1) { 00127 // the intersection must be a point 00128 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00129 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]); 00130 CGAL_kernel_precondition(pair!=NULL); 00131 *this = pair->first.rep(); 00132 } else { 00133 // the intersections must be a point 00134 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00135 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]); 00136 CGAL_kernel_precondition(pair!=NULL); 00137 *this = pair->first.rep(); 00138 } 00139 } 00140 00141 Circular_arc_point_3(const Line_3 &l, 00142 const Sphere_3 &s, 00143 const bool less_xyz = true) { 00144 std::vector<Object> sols; 00145 SK().intersect_3_object()(l, s, std::back_inserter(sols)); 00146 // s1,s2,s3 must intersect 00147 CGAL_kernel_precondition(sols.size() != 0); 00148 if(sols.size() == 1) { 00149 // the intersection must be a point 00150 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00151 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]); 00152 CGAL_kernel_precondition(pair!=NULL); 00153 *this = pair->first.rep(); 00154 } else { 00155 // the intersections must be a point 00156 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00157 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]); 00158 CGAL_kernel_precondition(pair!=NULL); 00159 *this = pair->first.rep(); 00160 } 00161 } 00162 00163 Circular_arc_point_3(const Circle_3 &c, 00164 const Plane_3 &p, 00165 const bool less_xyz = true) { 00166 std::vector<Object> sols; 00167 SK().intersect_3_object()(c, p, std::back_inserter(sols)); 00168 // s1,s2,s3 must intersect 00169 CGAL_kernel_precondition(sols.size() != 0); 00170 if(sols.size() == 1) { 00171 // the intersection must be a point 00172 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00173 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]); 00174 CGAL_kernel_precondition(pair!=NULL); 00175 *this = pair->first.rep(); 00176 } else { 00177 // the intersections must be a point 00178 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00179 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]); 00180 CGAL_kernel_precondition(pair!=NULL); 00181 *this = pair->first.rep(); 00182 } 00183 } 00184 00185 Circular_arc_point_3(const Circle_3 &c, 00186 const Sphere_3 &s, 00187 const bool less_xyz = true) { 00188 std::vector<Object> sols; 00189 SK().intersect_3_object()(c, s, std::back_inserter(sols)); 00190 // s1,s2,s3 must intersect 00191 CGAL_kernel_precondition(sols.size() != 0); 00192 if(sols.size() == 1) { 00193 // the intersection must be a point 00194 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00195 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]); 00196 CGAL_kernel_precondition(pair!=NULL); 00197 *this = pair->first.rep(); 00198 } else { 00199 // the intersections must be a point 00200 const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair= 00201 object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]); 00202 CGAL_kernel_precondition(pair!=NULL); 00203 *this = pair->first.rep(); 00204 } 00205 } 00206 00207 const Root_of_2 & x() const { return get(base).x(); } 00208 const Root_of_2 & y() const { return get(base).y(); } 00209 const Root_of_2 & z() const { return get(base).z(); } 00210 00211 const Root_for_spheres_2_3 & coordinates() const { return get(base); } 00212 00213 const CGAL::Bbox_3 bbox() const { 00214 return get(base).bbox(); 00215 } 00216 00217 bool operator==(const Circular_arc_point_3 &) const; 00218 bool operator!=(const Circular_arc_point_3 &) const; 00219 00220 }; 00221 00222 template < class SK > 00223 CGAL_KERNEL_INLINE 00224 bool 00225 Circular_arc_point_3<SK>::operator==(const Circular_arc_point_3<SK> &t) const 00226 { 00227 if (CGAL::identical(base, t.base)) 00228 return true; 00229 return x() == t.x() && 00230 y() == t.y() && 00231 z() == t.z(); 00232 } 00233 00234 template < class SK > 00235 CGAL_KERNEL_INLINE 00236 bool 00237 Circular_arc_point_3<SK>::operator!=(const Circular_arc_point_3<SK> &t) const 00238 { 00239 return !(*this == t); 00240 } 00241 00242 template < typename SK > 00243 std::ostream & 00244 print(std::ostream & os, const Circular_arc_point_3<SK> &p) 00245 { 00246 return os << "CirclArcEndPoint_3(" << p.x() << ", " << p.y() << ')' << std::endl; 00247 } 00248 00249 } // namespace CGALi 00250 } // namespace CGAL 00251 00252 #endif // CGAL_SPHERICAL_KERNEL_CIRCULAR_ARC_POINT_3_H