BWAPI
|
00001 // Copyright (c) 1997-2000 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_d/include/CGAL/Kernel_d/Pair_d.h $ 00019 // $Id: Pair_d.h 40851 2007-11-09 15:27:44Z ameyer $ 00020 // 00021 // 00022 // Author(s) : Michael Seel <seel@mpi-sb.mpg.de> 00023 #ifndef CGAL_PAIR_D_H 00024 #define CGAL_PAIR_D_H 00025 00026 #include <CGAL/basic.h> 00027 #include <CGAL/Handle_for.h> 00028 00029 CGAL_BEGIN_NAMESPACE 00030 00031 template <class R> class Segment_d; 00032 template <class R> class Ray_d; 00033 template <class R> class Line_d; 00034 00035 template <class R> 00036 class Pair_d 00037 { 00038 typedef Pair_d<R> Self; 00039 typedef typename R::Point_d Point_d; 00040 typedef typename R::Vector_d Vector_d; 00041 typedef typename R::Direction_d Direction_d; 00042 Point_d _p[2]; 00043 00044 friend class Line_d<R>; 00045 friend class Ray_d<R>; 00046 friend class Segment_d<R>; 00047 00048 /* Any line object in $d$ - space is defined by two points |_p1| and |_p2| 00049 respectively. There exists an orientation from _p1 to _p2. */ 00050 00051 public: 00052 Pair_d(int d = 0) { _p[0]=_p[1]=Point_d(d); } 00053 00054 Pair_d(const Point_d& p, const Point_d& q) 00055 { CGAL_assertion_msg((p.dimension() == q.dimension()), 00056 "Pair_d::constructor: source and target must have the same dimension."); 00057 _p[0]=p; _p[1]=q; 00058 } 00059 00060 bool is_degenerate() const 00061 { return (_p[0] == _p[1]); } 00062 00063 Vector_d vector() const 00064 { return (_p[1] - _p[0]); } 00065 00066 Direction_d direction() const 00067 { return vector().direction(); } 00068 00069 void read(std::istream& is) 00070 { 00071 switch( is.iword(CGAL::IO::mode) ) { 00072 case CGAL::IO::ASCII : 00073 is >> _p[0] >> _p[1]; break; 00074 case CGAL::IO::BINARY : 00075 CGAL::read(is, _p[0]); CGAL::read(is, _p[1]); break; 00076 default: 00077 CGAL_error_msg("\nStream must be in ascii or binary mode\n"); 00078 } 00079 } 00080 00081 void print(std::ostream& os, const char* _name) const 00082 { 00083 switch( os.iword(CGAL::IO::mode) ) { 00084 case CGAL::IO::ASCII : 00085 os << _p[0] << " " << _p[1]; break; 00086 case CGAL::IO::BINARY : 00087 CGAL::write(os, _p[0]); CGAL::write(os, _p[1]); break; 00088 default : 00089 os << _name << "(" << _p[0] << ", " << _p[1] << ")"; break; 00090 } 00091 } 00092 00093 }; // Pair_d<R> 00094 00095 CGAL_END_NAMESPACE 00096 #endif //CGAL_PAIR_D_H 00097