Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CGAL/include/CGAL/Bbox_2.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1999 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 //
33 // release : CGAL-2.2
34 // release_date : 2000, September 30
35 //
36 // source : Bbox_2.fw
37 // file : include/CGAL/Bbox_2.h
38 // package : _2 (3.6)
39 // revision : 3.6
40 // revision_date : 30 Jul 2000
41 // author(s) : Andreas Fabri
42 //
43 // coordinator : MPI, Saarbruecken (<Stefan.Schirra>)
44 // email : contact@cgal.org
45 // www : http://www.cgal.org
46 //
47 // ======================================================================
48 
49 
50 #ifndef CGAL_BBOX_2_H
51 #define CGAL_BBOX_2_H
52 
53 #ifndef CGAL_BASIC_H
54 #include <CGAL/basic.h>
55 #endif // CGAL_BASIC_H
56 #ifndef CGAL_CARTESIAN_CLASSES_H
57 #include <CGAL/cartesian_classes.h>
58 #endif // CGAL_CARTESIAN_CLASSES_H
59 #ifndef FOURTUPLE_H
60 #include <CGAL/Fourtuple.h>
61 #endif // FOURTUPLE_H
62 
64 
65 class Bbox_2 : public Handle_for< Fourtuple<double> >
66 {
67 public:
68  Bbox_2();
69  Bbox_2(double x_min, double y_min,
70  double x_max, double y_max);
71 
72  bool operator==(const Bbox_2 &b) const;
73  bool operator!=(const Bbox_2 &b) const;
74 
75  int dimension() const;
76  double xmin() const;
77  double ymin() const;
78  double xmax() const;
79  double ymax() const;
80 
81  double max(int i) const;
82  double min(int i) const;
83 
84  Bbox_2 operator+(const Bbox_2 &b) const;
85 
86 };
87 
88 
89 inline
90 int
92 { return 2; }
93 
94 inline
95 double
96 Bbox_2::xmin() const
97 { return ptr->e0; }
98 
99 inline
100 double
102 { return ptr->e1; }
103 
104 inline
105 double
107 { return ptr->e2; }
108 
109 inline
110 double
112 { return ptr->e3; }
113 
114 inline
115 double
116 Bbox_2::min(int i) const
117 {
118  CGAL_kernel_precondition( (i == 0 ) || ( i == 1 ) );
119  if(i == 0) { return xmin(); }
120  return ymin();
121 }
122 
123 inline
124 double
125 Bbox_2::max(int i) const
126 {
127  CGAL_kernel_precondition( (i == 0 ) || ( i == 1 ) );
128  if(i == 0) { return xmax(); }
129  return ymax();
130 }
131 inline Bbox_2 Bbox_2::operator+(const Bbox_2 &b) const
132 {
133  return Bbox_2(std::min(xmin(), b.xmin()),
134  std::min(ymin(), b.ymin()),
135  std::max(xmax(), b.xmax()),
136  std::max(ymax(), b.ymax()));
137 }
138 inline bool do_overlap(const Bbox_2 &bb1, const Bbox_2 &bb2)
139 {
140  // check for emptiness ??
141  if (bb1.xmax() < bb2.xmin() || bb2.xmax() < bb1.xmin())
142  return false;
143  if (bb1.ymax() < bb2.ymin() || bb2.ymax() < bb1.ymin())
144  return false;
145  return true;
146 }
147 
148 #ifndef NO_OSTREAM_INSERT_BBOX_2
149 inline
150 std::ostream&
151 operator<<(std::ostream &os, const Bbox_2 &b)
152 {
153  switch(os.iword(IO::mode)) {
154  case IO::ASCII :
155  os << b.xmin() << ' ' << b.ymin() << ' '
156  << b.xmax() << ' ' << b.ymax();
157  break;
158  case IO::BINARY :
159  write(os, b.xmin());
160  write(os, b.ymin());
161  write(os, b.xmax());
162  write(os, b.ymax());
163  break;
164  default:
165  os << "Bbox_2(" << b.xmin() << ", " << b.ymin() << ", "
166  << b.xmax() << ", " << b.ymax() << ")";
167  break;
168  }
169  return os;
170 }
171 #endif // NO_OSTREAM_INSERT_BBOX_2
172 
173 
174 
175 #ifndef NO_ISTREAM_EXTRACT_BBOX_2
176 inline
177 std::istream&
178 operator>>(std::istream &is, Bbox_2 &b)
179 {
180  double xmin, ymin, xmax, ymax;
181 
182  switch(is.iword(IO::mode)) {
183  case IO::ASCII :
184  is >> xmin >> ymin >> xmax >> ymax;
185  break;
186  case IO::BINARY :
187  read(is, xmin);
188  read(is, ymin);
189  read(is, xmax);
190  read(is, ymax);
191  break;
192  }
193  b = Bbox_2(xmin, ymin, xmax, ymax);
194  return is;
195 }
196 #endif // NO_ISTREAM_EXTRACT_BBOX_2
197 
198 
200 
201 
202 #endif // CGAL_BBOX_2_H
double ymin() const
double xmax() const
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double xmin() const
Bbox_2 operator+(const Bbox_2 &b) const
int dimension() const
Definition: io.h:64
Bbox_2()
Definition: Bbox_2.C:56
void write(std::ostream &os, const T &t, const io_Read_write &)
Definition: io.h:96
bool operator==(const Bbox_2 &b) const
Definition: Bbox_2.C:66
double min(int i) const
double max(int i) const
blockLoc i
Definition: read.cpp:79
static int mode
Definition: io.h:63
Definition: io.h:64
double ymax() const
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
bool operator!=(const Bbox_2 &b) const
Definition: Bbox_2.C:72
bool do_overlap(const Bbox_2 &bb1, const Bbox_2 &bb2)
void read(std::istream &is, T &t, const io_Read_write &)
Definition: io.h:132
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
std::ostream & operator<<(std::ostream &os, const COM_exception &ex)
Print out a given exception.
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
#define CGAL_kernel_precondition(EX)