/usr/include/SFCGAL/Envelope.h is in libsfcgal-dev 1.2.2-1.
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 | /**
* SFCGAL
*
* Copyright (C) 2012-2013 Oslandia <infos@oslandia.com>
* Copyright (C) 2012-2013 IGN (http://www.ign.fr)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SFCGAL_ENVELOPE_H_
#define _SFCGAL_ENVELOPE_H_
#include <memory>
#include <boost/assert.hpp>
#include <CGAL/Bbox_2.h>
#include <CGAL/Bbox_3.h>
#include <SFCGAL/config.h>
#include <SFCGAL/detail/Interval.h>
#include <SFCGAL/Coordinate.h>
namespace SFCGAL {
class LineString ;
class Polygon ;
class Solid ;
class PolyhedralSurface ;
/**
* Represents a bounding box
* @todo add asText instead of "print"?
* @todo add basic operations (especialy intersects/intersects3D)
*/
class SFCGAL_API Envelope {
public:
/**
* default constructor (empty bounding box)
*/
Envelope() ;
/**
* 2D box constructor with min,max values
*/
Envelope(
const double& xmin, const double& xmax,
const double& ymin, const double& ymax
) ;
/**
* 3D box constructor with min,max values
*/
Envelope(
const double& xmin, const double& xmax,
const double& ymin, const double& ymax,
const double& zmin, const double& zmax
) ;
/**
* default constructor (empty bounding box)
*/
Envelope( const Coordinate& p ) ;
/**
* default constructor (empty bounding box)
*/
Envelope( const Coordinate& p1, const Coordinate& p2 ) ;
/**
* copy constructor
*/
Envelope( const Envelope& other ) ;
/**
* assign operator
*/
Envelope& operator = ( const Envelope& other ) ;
/**
* destructor
*/
~Envelope() ;
/**
* indicates if the bounding box is empty
*/
bool isEmpty() const ;
/**
* indicates if the bounding box has a 3D component
*/
bool is3D() const ;
/**
* expand the box to include coordinate
*/
void expandToInclude( const Coordinate& coordinate ) ;
inline const double& xMin() const {
return _bounds[0].lower();
}
inline const double& yMin() const {
return _bounds[1].lower();
}
inline const double& zMin() const {
return _bounds[2].lower();
}
inline const double& xMax() const {
return _bounds[0].upper();
}
inline const double& yMax() const {
return _bounds[1].upper();
}
inline const double& zMax() const {
return _bounds[2].upper();
}
/**
* returns the n-th bound
*/
inline detail::Interval& boundsN( const size_t& n ) {
BOOST_ASSERT( n < 3 );
return _bounds[n] ;
}
/**
* returns the n-th bound
*/
inline const detail::Interval& boundsN( const size_t& n ) const {
BOOST_ASSERT( n < 3 );
return _bounds[n] ;
}
/**
* Convenience function. Convert to CGAL::BBox_2
*/
inline CGAL::Bbox_2 toBbox_2() const {
BOOST_ASSERT( ! isEmpty() );
return CGAL::Bbox_2(
_bounds[0].lower(), _bounds[1].lower(),
_bounds[0].upper(), _bounds[1].upper()
);
}
/**
* Convenience function. Convert to CGAL::BBox_3
*/
inline CGAL::Bbox_3 toBbox_3() const {
if ( is3D() ) {
return CGAL::Bbox_3(
_bounds[0].lower(), _bounds[1].lower(), _bounds[2].lower(),
_bounds[0].upper(), _bounds[1].upper(), _bounds[2].upper()
);
}
return CGAL::Bbox_3(
_bounds[0].lower(), _bounds[1].lower(), 0.0,
_bounds[0].upper(), _bounds[1].upper(), 0.0
);
}
/**
* Global binary operator on Envelopes. Test if A's bounding box contains B's
* FIXME: consider moving that outside of the class
*/
static bool contains( const Envelope& a, const Envelope& b );
/**
* Global binary operator on Envelopes. Test if A's bounding box overlaps B's
*/
static bool overlaps( const Envelope& a, const Envelope& b );
//-- helpers
/**
* @brief convenience method to convert to 2D Polygon ring
* @warning empty LineString for empty Envelope, may be X or Y collapsed
*/
std::auto_ptr< LineString > toRing() const ;
/**
* @brief convenience method to convert to 2D Polygon
* @warning empty Polygon for empty Envelope, may be X or Y collapsed
*/
std::auto_ptr< Polygon > toPolygon() const ;
/**
* @brief convenience method to convert to 3D Shell
* @warning empty Solid for empty or non 3D Envelope, may be X, Y or Z collapsed
*/
std::auto_ptr< PolyhedralSurface > toShell() const ;
/**
* @brief convenience method to convert to 3D Solid
* @warning empty Solid for empty or non 3D Envelope, may be X, Y or Z collapsed
*/
std::auto_ptr< Solid > toSolid() const ;
/*
* Display method
*/
std::ostream& print( std::ostream& ) const;
private:
/**
* bounds of the interval ((xmin,xmax),(ymin,ymax),(zmin,zmax))
*/
detail::Interval _bounds[3] ;
};
/**
* Global comparison operator on Envelope
*/
SFCGAL_API bool operator==( const Envelope&, const Envelope& );
}//SFCGAL
#endif
|