Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move << and >> overloads from Min_circle_2_impl.h to Min_circle_2.h #8716

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Bounding_volumes/examples/Min_circle_2/min_circle_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <CGAL/Random.h>

#include <iostream>

#include <vector>
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Min_sphere_of_points_d_traits_2<K,double> Traits;
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_circle;
Expand All @@ -14,14 +14,14 @@ int
main( int, char**)
{
const int n = 100;
Point P[n];
std::vector<Point> P(n);
CGAL::Random r; // random number generator

for ( int i = 0; i < n; ++i){
P[ i] = Point(r.get_double(), r.get_double());
P.at(i) = Point(r.get_double(), r.get_double());
}

Min_circle mc( P, P+n);
Min_circle mc( P.begin(), P.begin() + n);

Min_circle::Cartesian_const_iterator ccib = mc.center_cartesian_begin(), ccie = mc.center_cartesian_end();
std::cout << "center:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <CGAL/Simple_homogeneous.h>
#include <CGAL/Min_circle_2.h>
#include <CGAL/Min_circle_2_traits_2.h>

#include <vector>
#include <iostream>

// typedefs
Expand All @@ -16,15 +16,15 @@ int
main( int, char**)
{
const int n = 100;
Point P[n];
std::vector<Point> P(n);

for ( int i = 0; i < n; ++i){
P[i] = Point( (i%2 == 0 ? i : -i), 0, 1);
P.at(i) = Point( (i%2 == 0 ? i : -i), 0, 1);
// (0,0), (-1,0), (2,0), (-3,0), ...
}

Min_circle mc1( P, P+n, false); // very slow
Min_circle mc2( P, P+n, true); // fast
Min_circle mc1( P.begin(), P.begin() + n, false); // very slow
Min_circle mc2( P.begin(), P.begin() +n, true); // fast

CGAL::IO::set_pretty_mode( std::cout);
std::cout << mc2;
Expand Down
75 changes: 72 additions & 3 deletions Bounding_volumes/include/CGAL/Min_circle_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,84 @@ class Min_circle_2 {
// ---
template < class Traits_ >
std::ostream&
operator << ( std::ostream& os, const Min_circle_2<Traits_>& mc);
operator << ( std::ostream& os,
const Min_circle_2<Traits_>& min_circle)
{
using namespace std;

typedef typename Min_circle_2<Traits_>::Point Point;
typedef ostream_iterator<Point> Os_it;

switch ( CGAL::IO::get_mode( os)) {

case CGAL::IO::PRETTY:
os << endl;
os << "CGAL::Min_circle_2( |P| = " << min_circle.number_of_points()
<< ", |S| = " << min_circle.number_of_support_points() << endl;
os << " P = {" << endl;
os << " ";
copy( min_circle.points_begin(), min_circle.points_end(),
Os_it( os, ",\n "));
os << "}" << endl;
os << " S = {" << endl;
os << " ";
copy( min_circle.support_points_begin(),
min_circle.support_points_end(),
Os_it( os, ",\n "));
os << "}" << endl;
os << " circle = " << min_circle.circle() << endl;
os << ")" << endl;
break;

case CGAL::IO::ASCII:
copy( min_circle.points_begin(), min_circle.points_end(),
Os_it( os, "\n"));
break;

case CGAL::IO::BINARY:
copy( min_circle.points_begin(), min_circle.points_end(),
Os_it( os));
break;

default:
CGAL_assertion_msg( false,
"CGAL::IO::get_mode( os) invalid!");
break; }

return( os);
}

template < class Traits_ >
std::istream&
operator >> ( std::istream& is, Min_circle_2<Traits_>& mc);
operator >> ( std::istream& is, CGAL::Min_circle_2<Traits_>& min_circle)
{
using namespace std;

switch ( CGAL::IO::get_mode( is)) {

case CGAL::IO::PRETTY:
cerr << endl;
cerr << "Stream must be in ASCII or binary mode" << endl;
break;

case CGAL::IO::ASCII:
case CGAL::IO::BINARY:
typedef typename CGAL::Min_circle_2<Traits_>::Point Point;
typedef istream_iterator<Point> Is_it;
min_circle.clear();
min_circle.insert( Is_it( is), Is_it());
break;

default:
CGAL_assertion_msg( false, "CGAL::IO::mode invalid!");
break; }

return( is);
}

} //namespace CGAL

#include <CGAL/Min_circle_2/Min_circle_2_impl.h>
// #include <CGAL/Min_circle_2/Min_circle_2_impl.h>

#endif // CGAL_MIN_CIRCLE_2_H

Expand Down
214 changes: 107 additions & 107 deletions Bounding_volumes/include/CGAL/Min_circle_2/Min_circle_2_impl.h
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
// Copyright (c) 1997-2001
// ETH Zurich (Switzerland). All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Sven Schoenherr <[email protected]>, Bernd Gaertner

#ifndef CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H
#define CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H

#include <CGAL/license/Bounding_volumes.h>

#include <iterator>

namespace CGAL {

// Class implementation (continued)
// ================================
// I/O
// ---
template < class Traits_ >
std::ostream&
operator << ( std::ostream& os,
const Min_circle_2<Traits_>& min_circle)
{
using namespace std;

typedef typename Min_circle_2<Traits_>::Point Point;
typedef ostream_iterator<Point> Os_it;

switch ( CGAL::IO::get_mode( os)) {

case CGAL::IO::PRETTY:
os << endl;
os << "CGAL::Min_circle_2( |P| = " << min_circle.number_of_points()
<< ", |S| = " << min_circle.number_of_support_points() << endl;
os << " P = {" << endl;
os << " ";
copy( min_circle.points_begin(), min_circle.points_end(),
Os_it( os, ",\n "));
os << "}" << endl;
os << " S = {" << endl;
os << " ";
copy( min_circle.support_points_begin(),
min_circle.support_points_end(),
Os_it( os, ",\n "));
os << "}" << endl;
os << " circle = " << min_circle.circle() << endl;
os << ")" << endl;
break;

case CGAL::IO::ASCII:
copy( min_circle.points_begin(), min_circle.points_end(),
Os_it( os, "\n"));
break;

case CGAL::IO::BINARY:
copy( min_circle.points_begin(), min_circle.points_end(),
Os_it( os));
break;

default:
CGAL_assertion_msg( false,
"CGAL::IO::get_mode( os) invalid!");
break; }

return( os);
}

template < class Traits_ >
std::istream&
operator >> ( std::istream& is, CGAL::Min_circle_2<Traits_>& min_circle)
{
using namespace std;

switch ( CGAL::IO::get_mode( is)) {

case CGAL::IO::PRETTY:
cerr << endl;
cerr << "Stream must be in ASCII or binary mode" << endl;
break;

case CGAL::IO::ASCII:
case CGAL::IO::BINARY:
typedef typename CGAL::Min_circle_2<Traits_>::Point Point;
typedef istream_iterator<Point> Is_it;
min_circle.clear();
min_circle.insert( Is_it( is), Is_it());
break;

default:
CGAL_assertion_msg( false, "CGAL::IO::mode invalid!");
break; }

return( is);
}

} //namespace CGAL

// ===== EOF ==================================================================

#endif // CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H
// // Copyright (c) 1997-2001
// // ETH Zurich (Switzerland). All rights reserved.
// //
// // This file is part of CGAL (www.cgal.org).
// //
// // $URL$
// // $Id$
// // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// // Author(s) : Sven Schoenherr <[email protected]>, Bernd Gaertner

// #ifndef CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H
// #define CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H

// #include <CGAL/license/Bounding_volumes.h>

// #include <iterator>

// namespace CGAL {

// // Class implementation (continued)
// // ================================
// // I/O
// // ---
// template < class Traits_ >
// std::ostream&
// operator << ( std::ostream& os,
// const Min_circle_2<Traits_>& min_circle)
// {
// using namespace std;

// typedef typename Min_circle_2<Traits_>::Point Point;
// typedef ostream_iterator<Point> Os_it;

// switch ( CGAL::IO::get_mode( os)) {

// case CGAL::IO::PRETTY:
// os << endl;
// os << "CGAL::Min_circle_2( |P| = " << min_circle.number_of_points()
// << ", |S| = " << min_circle.number_of_support_points() << endl;
// os << " P = {" << endl;
// os << " ";
// copy( min_circle.points_begin(), min_circle.points_end(),
// Os_it( os, ",\n "));
// os << "}" << endl;
// os << " S = {" << endl;
// os << " ";
// copy( min_circle.support_points_begin(),
// min_circle.support_points_end(),
// Os_it( os, ",\n "));
// os << "}" << endl;
// os << " circle = " << min_circle.circle() << endl;
// os << ")" << endl;
// break;

// case CGAL::IO::ASCII:
// copy( min_circle.points_begin(), min_circle.points_end(),
// Os_it( os, "\n"));
// break;

// case CGAL::IO::BINARY:
// copy( min_circle.points_begin(), min_circle.points_end(),
// Os_it( os));
// break;

// default:
// CGAL_assertion_msg( false,
// "CGAL::IO::get_mode( os) invalid!");
// break; }

// return( os);
// }

// template < class Traits_ >
// std::istream&
// operator >> ( std::istream& is, CGAL::Min_circle_2<Traits_>& min_circle)
// {
// using namespace std;

// switch ( CGAL::IO::get_mode( is)) {

// case CGAL::IO::PRETTY:
// cerr << endl;
// cerr << "Stream must be in ASCII or binary mode" << endl;
// break;

// case CGAL::IO::ASCII:
// case CGAL::IO::BINARY:
// typedef typename CGAL::Min_circle_2<Traits_>::Point Point;
// typedef istream_iterator<Point> Is_it;
// min_circle.clear();
// min_circle.insert( Is_it( is), Is_it());
// break;

// default:
// CGAL_assertion_msg( false, "CGAL::IO::mode invalid!");
// break; }

// return( is);
// }

// } //namespace CGAL

// // ===== EOF ==================================================================

// #endif // CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <CGAL/assertions.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <CGAL/boost/graph/copy_face_graph.h>
#include <CGAL/Container_helper.h>
Expand All @@ -37,6 +38,7 @@
#include <CGAL/iterator.h>
#include <CGAL/tuple.h>

#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>

namespace CGAL {
Expand Down
Loading
Loading