| 1 |
/* |
| 2 |
Copyright (c) 2023, Michael Kazhdan |
| 3 |
All rights reserved. |
| 4 |
|
| 5 |
Redistribution and use in source and binary forms, with or without modification, |
| 6 |
are permitted provided that the following conditions are met: |
| 7 |
|
| 8 |
Redistributions of source code must retain the above copyright notice, this list of |
| 9 |
conditions and the following disclaimer. Redistributions in binary form must reproduce |
| 10 |
the above copyright notice, this list of conditions and the following disclaimer |
| 11 |
in the documentation and/or other materials provided with the distribution. |
| 12 |
|
| 13 |
Neither the name of the Johns Hopkins University nor the names of its contributors |
| 14 |
may be used to endorse or promote products derived from this software without specific |
| 15 |
prior written permission. |
| 16 |
|
| 17 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 18 |
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES |
| 19 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
| 20 |
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 |
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 22 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 |
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 25 |
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 26 |
DAMAGE. |
| 27 |
*/ |
| 28 |
|
| 29 |
#ifndef POINT_EXTENT_INCLUDED |
| 30 |
#define POINT_EXTENT_INCLUDED |
| 31 |
|
| 32 |
#include <ostream> |
| 33 |
#include "Geometry.h" |
| 34 |
#include "DataStream.h" |
| 35 |
|
| 36 |
namespace PoissonRecon |
| 37 |
{ |
| 38 |
namespace PointExtent |
| 39 |
{ |
| 40 |
template< typename Real , unsigned int Dim , bool ExtendedAxes > |
| 41 |
struct Frame |
| 42 |
{ |
| 43 |
static const unsigned int DirectionN = ExtendedAxes ? ( Dim==2 ? 4 : 9 ) : Dim; |
| 44 |
Point< Real , Dim > directions[ DirectionN ]; |
| 45 |
unsigned int frames[DirectionN][Dim]; |
| 46 |
Frame( void ); |
| 47 |
}; |
| 48 |
|
| 49 |
template< typename Real , unsigned int Dim , bool ExtendedAxes=true > |
| 50 |
struct Extent |
| 51 |
{ |
| 52 |
static const unsigned int DirectionN = Frame< Real , Dim , ExtendedAxes >::DirectionN; |
| 53 |
static Point< Real , Dim > Direction( unsigned int d ){ return _Frame.directions[d]; } |
| 54 |
static const unsigned int *Frame( unsigned int d ){ return _Frame.frames[d]; } |
| 55 |
|
| 56 |
std::pair< Real , Real > extents[ DirectionN ]; |
| 57 |
std::pair< Real , Real > &operator[]( unsigned int d ){ return extents[d]; } |
| 58 |
const std::pair< Real , Real > &operator[]( unsigned int d ) const { return extents[d]; } |
| 59 |
|
| 60 |
Extent( void ); |
| 61 |
void add( Point< Real , Dim > p ); |
| 62 |
Extent operator + ( const Extent &e ) const; |
| 63 |
protected: |
| 64 |
static const PointExtent::Frame< Real , Dim , ExtendedAxes > _Frame; |
| 65 |
|
| 66 |
template< typename _Real , unsigned int _Dim , bool _ExtendedAxes > |
| 67 |
friend std::ostream &operator << ( std::ostream & , const Extent< _Real , _Dim , _ExtendedAxes > & ); |
| 68 |
}; |
| 69 |
|
| 70 |
template< typename Real , unsigned int Dim , bool ExtendedAxes > |
| 71 |
const Frame< Real , Dim , ExtendedAxes > Extent< Real , Dim , ExtendedAxes >::_Frame; |
| 72 |
|
| 73 |
template< class Real , unsigned int Dim , bool ExtendedAxes , typename ... Data > |
| 74 |
Extent< Real , Dim , ExtendedAxes > GetExtent( InputDataStream< Point< Real , Dim > , Data ... > &stream , Data ... data ); |
| 75 |
|
| 76 |
template< class Real , unsigned int Dim > |
| 77 |
XForm< Real , Dim+1 > GetXForm( Point< Real , Dim > min , Point< Real , Dim > max , Real scaleFactor , bool rotate=true ); |
| 78 |
|
| 79 |
template< class Real , unsigned int Dim , bool ExtendedAxes > |
| 80 |
XForm< Real , Dim+1 > GetXForm( const Extent< Real , Dim , ExtendedAxes > &extent , Real scaleFactor , unsigned int dir ); |
| 81 |
|
| 82 |
template< class Real , unsigned int Dim , bool ExtendedAxes , typename ... Data > |
| 83 |
XForm< Real , Dim+1 > GetXForm( InputDataStream< Point< Real , Dim > , Data ... > &stream , Data ... data , Real scaleFactor , unsigned int dir ); |
| 84 |
|
| 85 |
#include "PointExtent.inl" |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
#endif // POINT_EXTENT_INCLUDED |