BWAPI
|
00001 // Copyright (c) 1999 Utrecht University (The Netherlands), 00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), 00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg 00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), 00005 // and Tel-Aviv University (Israel). All rights reserved. 00006 // 00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00008 // modify it under the terms of the GNU Lesser General Public License as 00009 // published by the Free Software Foundation; version 2.1 of the License. 00010 // See the file LICENSE.LGPL distributed with CGAL. 00011 // 00012 // Licensees holding a valid commercial license may use this file in 00013 // accordance with the commercial license agreement provided with the software. 00014 // 00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 // 00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Kernel_23/include/CGAL/Line_3.h $ 00019 // $Id: Line_3.h 49257 2009-05-09 16:08:19Z spion $ 00020 // 00021 // 00022 // Author(s) : Andreas Fabri 00023 // Stefan Schirra 00024 00025 #ifndef CGAL_LINE_3_H 00026 #define CGAL_LINE_3_H 00027 00028 #include <boost/static_assert.hpp> 00029 #include <boost/type_traits.hpp> 00030 #include <CGAL/Kernel/Return_base_tag.h> 00031 #include <CGAL/Dimension.h> 00032 00033 CGAL_BEGIN_NAMESPACE 00034 00035 template <class R_> 00036 class Line_3 : public R_::Kernel_base::Line_3 00037 { 00038 typedef typename R_::RT RT; 00039 typedef typename R_::Point_3 Point_3; 00040 typedef typename R_::Ray_3 Ray_3; 00041 typedef typename R_::Segment_3 Segment_3; 00042 typedef typename R_::Direction_3 Direction_3; 00043 typedef typename R_::Vector_3 Vector_3; 00044 typedef typename R_::Plane_3 Plane_3; 00045 typedef typename R_::Aff_transformation_3 Aff_transformation_3; 00046 00047 typedef Line_3 Self; 00048 BOOST_STATIC_ASSERT((boost::is_same<Self, typename R_::Line_3>::value)); 00049 00050 public: 00051 00052 typedef Dimension_tag<3> Ambient_dimension; 00053 typedef Dimension_tag<1> Feature_dimension; 00054 00055 typedef typename R_::Kernel_base::Line_3 Rep; 00056 00057 const Rep& rep() const 00058 { 00059 return *this; 00060 } 00061 00062 Rep& rep() 00063 { 00064 return *this; 00065 } 00066 00067 typedef R_ R; 00068 00069 Line_3() {} 00070 00071 // conversion impl -> interface class 00072 Line_3(const Rep& l) 00073 : Rep(l) {} 00074 00075 Line_3(const Point_3 & p, const Point_3 & q) 00076 : Rep(typename R::Construct_line_3()(Return_base_tag(), p, q)) {} 00077 00078 explicit Line_3(const Segment_3 & s) 00079 : Rep(typename R::Construct_line_3()(Return_base_tag(), s)) {} 00080 00081 explicit Line_3(const Ray_3 & r) 00082 : Rep(typename R::Construct_line_3()(Return_base_tag(), r)) {} 00083 00084 Line_3(const Point_3 & p, const Direction_3 & d) 00085 : Rep(typename R::Construct_line_3()(Return_base_tag(), p, d)) {} 00086 00087 Line_3(const Point_3 & p, const Vector_3 & v) 00088 : Rep(typename R::Construct_line_3()(Return_base_tag(), p, v)) {} 00089 00090 Line_3 transform(const Aff_transformation_3 &t) const 00091 { 00092 return Line_3(t.transform(this->point()), t.transform(this->direction())); 00093 } 00094 00095 Vector_3 to_vector() const 00096 { 00097 return R().construct_vector_3_object()(*this); 00098 } 00099 00100 Direction_3 direction() const 00101 { 00102 return R().construct_direction_3_object()(*this); 00103 } 00104 00105 bool has_on(const Point_3 &p) const 00106 { 00107 return R().has_on_3_object()(*this, p); 00108 //return has_on_boundary(p); 00109 } 00110 00111 Point_3 point() const 00112 { 00113 return R().construct_point_on_3_object()(*this, 0); 00114 } 00115 00116 Point_3 point(int i) const 00117 { 00118 return R().construct_point_on_3_object()(*this, i); 00119 } 00120 00121 Line_3 opposite() const 00122 { 00123 return R().construct_opposite_line_3_object()(*this); 00124 } 00125 00126 Plane_3 perpendicular_plane(const Point_3 &p) const 00127 { 00128 return R().construct_perpendicular_plane_3_object()(*this, p); 00129 } 00130 00131 Point_3 projection(const Point_3 &p) const 00132 { 00133 return R().construct_projected_point_3_object()(*this, p); 00134 } 00135 00136 bool is_degenerate() const 00137 { 00138 return R().is_degenerate_3_object()(*this); 00139 } 00140 00141 }; 00142 00143 template < class R > 00144 std::ostream & 00145 operator<<(std::ostream &os, const Line_3<R> &l) 00146 { 00147 switch(os.iword(IO::mode)) { 00148 case IO::ASCII : 00149 return os << l.point(0) << ' ' << l.point(1); 00150 case IO::BINARY : 00151 return os << l.point(0) << l.point(1); 00152 default: 00153 return os << "Line_3(" << l.point(0) << ", " << l.point(1) << ")"; 00154 } 00155 } 00156 00157 template < class R > 00158 std::istream & 00159 operator>>(std::istream &is, Line_3<R> &l) 00160 { 00161 typename R::Point_3 p, q; 00162 is >> p >> q; 00163 if (is) 00164 l = Line_3<R>(p, q); 00165 return is; 00166 } 00167 00168 CGAL_END_NAMESPACE 00169 00170 #endif // CGAL_LINE_3_H