/usr/include/CGAL/Bbox_3.h is in libcgal-dev 4.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | // Copyright (c) 1999,2004
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
// Author(s) : Andreas Fabri
#ifndef CGAL_BBOX_3_H
#define CGAL_BBOX_3_H
#include <CGAL/basic.h>
#include <CGAL/IO/io.h>
#include <CGAL/Dimension.h>
#include <CGAL/array.h>
namespace CGAL {
template < typename T >
struct Simple_cartesian;
class Bbox_3
{
cpp11::array<double, 6> rep;
public:
typedef Dimension_tag<3> Ambient_dimension;
typedef Dimension_tag<3> Feature_dimension;
typedef Simple_cartesian<double> R;
Bbox_3() {}
Bbox_3(double x_min, double y_min, double z_min,
double x_max, double y_max, double z_max)
: rep(CGAL::make_array(x_min, y_min, z_min, x_max, y_max, z_max)) {}
inline bool operator==(const Bbox_3 &b) const;
inline bool operator!=(const Bbox_3 &b) const;
inline int dimension() const;
double xmin() const;
double ymin() const;
double zmin() const;
double xmax() const;
double ymax() const;
double zmax() const;
inline double min BOOST_PREVENT_MACRO_SUBSTITUTION (int i) const;
inline double max BOOST_PREVENT_MACRO_SUBSTITUTION (int i) const;
Bbox_3 operator+(const Bbox_3& b) const;
Bbox_3& operator+=(const Bbox_3& b);
};
inline
double
Bbox_3::xmin() const
{ return rep[0]; }
inline
double
Bbox_3::ymin() const
{ return rep[1]; }
inline
double
Bbox_3::zmin() const
{ return rep[2]; }
inline
double
Bbox_3::xmax() const
{ return rep[3]; }
inline
double
Bbox_3::ymax() const
{ return rep[4]; }
inline
double
Bbox_3::zmax() const
{ return rep[5]; }
inline
bool
Bbox_3::operator==(const Bbox_3 &b) const
{
return xmin() == b.xmin() && xmax() == b.xmax()
&& ymin() == b.ymin() && ymax() == b.ymax()
&& zmin() == b.zmin() && zmax() == b.zmax();
}
inline
bool
Bbox_3::operator!=(const Bbox_3 &b) const
{
return ! (b == *this);
}
inline
int
Bbox_3::dimension() const
{ return 3; }
inline
double
Bbox_3::min BOOST_PREVENT_MACRO_SUBSTITUTION (int i) const
{
CGAL_kernel_precondition( (i == 0 ) || ( i == 1 ) || ( i == 2) );
if (i == 0) { return xmin(); }
if (i == 1) { return ymin(); }
return zmin();
}
inline
double
Bbox_3::max BOOST_PREVENT_MACRO_SUBSTITUTION (int i) const
{
CGAL_kernel_precondition( (i == 0 ) || ( i == 1 ) || ( i == 2 ) );
if (i == 0) { return xmax(); }
if (i == 1) { return ymax(); }
return zmax();
}
inline
Bbox_3
Bbox_3::operator+(const Bbox_3& b) const
{
return Bbox_3((std::min)(xmin(), b.xmin()),
(std::min)(ymin(), b.ymin()),
(std::min)(zmin(), b.zmin()),
(std::max)(xmax(), b.xmax()),
(std::max)(ymax(), b.ymax()),
(std::max)(zmax(), b.zmax()));
}
inline
Bbox_3&
Bbox_3::operator+=(const Bbox_3& b)
{
rep[0] = (std::min)(xmin(), b.xmin());
rep[1] = (std::min)(ymin(), b.ymin());
rep[2] = (std::min)(zmin(), b.zmin());
rep[3] = (std::max)(xmax(), b.xmax());
rep[4] = (std::max)(ymax(), b.ymax());
rep[5] = (std::max)(zmax(), b.zmax());
return *this;
}
inline
bool
do_overlap(const Bbox_3& bb1, const Bbox_3& bb2)
{
// check for emptiness ??
if (bb1.xmax() < bb2.xmin() || bb2.xmax() < bb1.xmin())
return false;
if (bb1.ymax() < bb2.ymin() || bb2.ymax() < bb1.ymin())
return false;
if (bb1.zmax() < bb2.zmin() || bb2.zmax() < bb1.zmin())
return false;
return true;
}
inline
std::ostream&
operator<<(std::ostream &os, const Bbox_3& b)
{
switch(os.iword(IO::mode))
{
case IO::ASCII :
return os << b.xmin() << ' ' << b.ymin() << ' ' << b.zmin()
<< ' ' << b.xmax() << ' ' << b.ymax() << ' ' << b.zmax();
case IO::BINARY :
write(os, b.xmin());
write(os, b.ymin());
write(os, b.zmin());
write(os, b.xmax());
write(os, b.ymax());
write(os, b.zmax());
return os;
default:
os << "Bbox_3((" << b.xmin()
<< ", " << b.ymin()
<< ", " << b.zmin() << "), (";
os << b.xmax()
<< ", " << b.ymax()
<< ", " << b.zmax() << "))";
return os;
}
}
inline
std::istream&
operator>>(std::istream &is, Bbox_3& b)
{
double xmin, ymin, zmin, xmax, ymax, zmax;
switch(is.iword(IO::mode))
{
case IO::ASCII :
is >> xmin >> ymin >> zmin >> xmax >> ymax >> zmax;
break;
case IO::BINARY :
read(is, xmin);
read(is, ymin);
read(is, zmin);
read(is, xmax);
read(is, ymax);
read(is, zmax);
break;
}
if (is)
b = Bbox_3(xmin, ymin, zmin, xmax, ymax, zmax);
return is;
}
template <class Input_iterator, class Traits>
Bbox_3 bbox_3(Input_iterator begin, Input_iterator end, const Traits& traits)
{
if (begin==end) return Bbox_3();
typename Traits::Construct_bbox_3 get_bbox = traits.construct_bbox_3_object();
Bbox_3 res = get_bbox( *begin );
for (++begin; begin!=end; ++begin)
res += get_bbox( *begin );
return res;
}
template <class Input_iterator>
Bbox_3 bbox_3(Input_iterator begin, Input_iterator end)
{
if (begin==end) return Bbox_3();
Bbox_3 res = begin->bbox();
for (++begin; begin!=end; ++begin)
res += begin->bbox();
return res;
}
} //namespace CGAL
#endif // CGAL_BBOX_3_H
|