Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CGAL/include/CGAL/Bbox_3.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_3.fw
37 // file : include/CGAL/Bbox_3.h
38 // package : _3 (3.7)
39 // revision : 3.7
40 // revision_date : 16 Aug 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_3_H
51 #define CGAL_BBOX_3_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 SIXTUPLE_H
60 #include <CGAL/Sixtuple.h>
61 #endif // SIXTUPLE_H
62 
64 
65 class Bbox_3 : public Handle_for< Sixtuple<double> >
66 {
67 public:
68  Bbox_3();
69  Bbox_3(double x_min, double y_min, double zmin,
70  double x_max, double y_max, double z_max);
71 
72  double xmin() const;
73  double ymin() const;
74  double zmin() const;
75  double xmax() const;
76  double ymax() const;
77  double zmax() const;
78 
79  Bbox_3 operator+(const Bbox_3& b) const;
80 };
81 
82 inline
84 { new ( static_cast< void*>(ptr)) Sixtuple<double>(); }
85 
86 inline
87 Bbox_3::Bbox_3(double x_min, double y_min, double z_min,
88  double x_max, double y_max, double z_max)
89 {
90  new ( static_cast< void*>(ptr)) Sixtuple<double>(x_min, y_min, z_min,
91  x_max, y_max, z_max);
92 }
93 
94 inline
95 double
96 Bbox_3::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
117 { return ptr->e4; }
118 
119 inline
120 double
122 { return ptr->e5; }
123 inline Bbox_3 Bbox_3::operator+(const Bbox_3& b) const
124 {
125  return Bbox_3(std::min(xmin(), b.xmin()),
126  std::min(ymin(), b.ymin()),
127  std::min(zmin(), b.zmin()),
128  std::max(xmax(), b.xmax()),
129  std::max(ymax(), b.ymax()),
130  std::max(zmax(), b.zmax()));
131 }
132 inline bool do_overlap(const Bbox_3& bb1, const Bbox_3& bb2)
133 {
134  // check for emptiness ??
135  if (bb1.xmax() < bb2.xmin() || bb2.xmax() < bb1.xmin())
136  return false;
137  if (bb1.ymax() < bb2.ymin() || bb2.ymax() < bb1.ymin())
138  return false;
139  if (bb1.zmax() < bb2.zmin() || bb2.zmax() < bb1.zmin())
140  return false;
141  return true;
142 }
143 #ifndef NO_OSTREAM_INSERT_BBOX_3
144 inline
145 std::ostream&
146 operator<<(std::ostream &os, const Bbox_3& b)
147 {
148  switch(os.iword(IO::mode))
149  {
150  case IO::ASCII :
151  return os << b.xmin() << ' ' << b.ymin() << ' ' << b.zmin();
152  case IO::BINARY :
153  write(os, b.xmin());
154  write(os, b.ymin());
155  write(os, b.zmin());
156  write(os, b.xmax());
157  write(os, b.ymax());
158  write(os, b.zmax());
159  return os;
160  default:
161  os << "Bbox_3((" << b.xmin()
162  << ", " << b.ymin()
163  << ", " << b.zmin() << "), (";
164  os << b.xmax()
165  << ", " << b.ymax()
166  << ", " << b.zmax() << "))";
167  return os;
168  }
169 }
170 #endif // NO_OSTREAM_INSERT_BBOX_3
171 
172 
173 
174 #ifndef NO_ISTREAM_EXTRACT_BBOX_3
175 inline
176 std::istream&
177 operator>>(std::istream &is, Bbox_3& b)
178 {
179  double xmin, ymin, zmin, xmax, ymax, zmax;
180 
181  switch(is.iword(IO::mode))
182  {
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, zmin);
190  read(is, xmax);
191  read(is, ymax);
192  read(is, zmax);
193  break;
194  }
195  b = Bbox_3(xmin, ymin, zmin, xmax, ymax, zmax);
196  return is;
197 }
198 
199 #endif // NO_ISTREAM_EXTRACT_BBOX_3
200 
201 
203 
204 
205 #endif // CGAL_BBOX_3_H
double xmax() const
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double xmin() const
double zmin() const
Definition: io.h:64
double ymax() const
void write(std::ostream &os, const T &t, const io_Read_write &)
Definition: io.h:96
double zmax() const
static int mode
Definition: io.h:63
Definition: io.h:64
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
double ymin() const
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
Bbox_3 operator+(const Bbox_3 &b) const