BWAPI
|
00001 // Copyright (c) 1997-2001 Freie Universitaet Berlin (Germany). 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/Min_ellipse_2/include/CGAL/Min_ellipse_2/Min_ellipse_2_impl.h $ 00015 // $Id: Min_ellipse_2_impl.h 32391 2006-07-11 12:17:08Z gaertner $ 00016 // 00017 // 00018 // Author(s) : Sven Schoenherr <sven@inf.ethz.ch>, Bernd Gaertner 00019 00020 #include <iterator> 00021 00022 CGAL_BEGIN_NAMESPACE 00023 00024 // Class implementation (continued) 00025 // ================================ 00026 // I/O 00027 // --- 00028 template < class Traits_ > 00029 std::ostream& 00030 operator << ( std::ostream& os, 00031 const Min_ellipse_2<Traits_>& min_ellipse) 00032 { 00033 using namespace std; 00034 00035 typedef typename Min_ellipse_2<Traits_>::Point Point; 00036 typedef ostream_iterator<Point> Os_it; 00037 00038 switch ( CGAL::get_mode( os)) { 00039 00040 case CGAL::IO::PRETTY: 00041 os << endl; 00042 os << "CGAL::Min_ellipse_2( |P| = "<<min_ellipse.number_of_points() 00043 << ", |S| = " << min_ellipse.number_of_support_points() << endl; 00044 os << " P = {" << endl; 00045 os << " "; 00046 copy( min_ellipse.points_begin(), min_ellipse.points_end(), 00047 Os_it( os, ",\n ")); 00048 os << "}" << endl; 00049 os << " S = {" << endl; 00050 os << " "; 00051 copy( min_ellipse.support_points_begin(), 00052 min_ellipse.support_points_end(), 00053 Os_it( os, ",\n ")); 00054 os << "}" << endl; 00055 os << " ellipse = " << min_ellipse.ellipse() << endl; 00056 os << ")" << endl; 00057 break; 00058 00059 case CGAL::IO::ASCII: 00060 copy( min_ellipse.points_begin(), min_ellipse.points_end(), 00061 Os_it( os, "\n")); 00062 break; 00063 00064 case CGAL::IO::BINARY: 00065 copy( min_ellipse.points_begin(), min_ellipse.points_end(), 00066 Os_it( os)); 00067 break; 00068 00069 default: 00070 CGAL_optimisation_assertion_msg( false, 00071 "CGAL::get_mode( os) invalid!"); 00072 break; } 00073 00074 return( os); 00075 } 00076 00077 template < class Traits_ > 00078 std::istream& 00079 operator >> ( std::istream& is, CGAL::Min_ellipse_2<Traits_>& min_ellipse) 00080 { 00081 using namespace std; 00082 00083 switch ( CGAL::get_mode( is)) { 00084 00085 case CGAL::IO::PRETTY: 00086 cerr << endl; 00087 cerr << "Stream must be in ascii or binary mode" << endl; 00088 break; 00089 00090 case CGAL::IO::ASCII: 00091 case CGAL::IO::BINARY: 00092 typedef typename Min_ellipse_2<Traits_>::Point Point; 00093 typedef istream_iterator<Point> Is_it; 00094 min_ellipse.clear(); 00095 min_ellipse.insert( Is_it( is), Is_it()); 00096 break; 00097 00098 default: 00099 CGAL_optimisation_assertion_msg( false, "CGAL::IO::mode invalid!"); 00100 break; } 00101 00102 return( is); 00103 } 00104 00105 CGAL_END_NAMESPACE 00106 00107 // ===== EOF ==================================================================