Loading...
Searching...
No Matches
bspline_data.h
/*
Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer. Redistributions in binary form must reproduce
the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
Neither the name of the Johns Hopkins University nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*/
#ifndef BSPLINE_DATA_INCLUDED
#define BSPLINE_DATA_INCLUDED
#include "ppolynomial.h"
#include <cstdio>
#include <cstring>
namespace pcl
{
namespace poisson
{
template< int Degree , class Real >
class BSplineData
{
bool useDotRatios;
bool reflectBoundary;
public:
struct BSplineComponents
{
Polynomial< Degree > polys[Degree+1];
Polynomial< Degree >& operator[] ( int idx ) { return polys[idx]; }
const Polynomial< Degree >& operator[] ( int idx ) const { return polys[idx]; }
void printnl( ) const { for( int d=0 ; d<=Degree ; d++ ) polys[d].printnl(); }
BSplineComponents scale( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].scale(s) ; return b; }
BSplineComponents shift( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].shift(s) ; return b; }
};
const static int VV_DOT_FLAG = 1;
const static int DV_DOT_FLAG = 2;
const static int DD_DOT_FLAG = 4;
const static int VALUE_FLAG = 1;
const static int D_VALUE_FLAG = 2;
int depth , functionCount , sampleCount;
Real *vvDotTable , *dvDotTable , *ddDotTable;
Real *valueTables , *dValueTables;
PPolynomial< Degree > baseFunction , leftBaseFunction , rightBaseFunction;
PPolynomial< Degree-1 > dBaseFunction , dLeftBaseFunction , dRightBaseFunction;
BSplineComponents baseBSpline, leftBSpline , rightBSpline;
PPolynomial<Degree>* baseFunctions;
BSplineComponents* baseBSplines;
BSplineData();
virtual ~BSplineData();
virtual void setDotTables( int flags );
virtual void clearDotTables( int flags );
virtual void setValueTables( int flags,double smooth=0);
virtual void setValueTables( int flags,double valueSmooth,double normalSmooth);
virtual void clearValueTables();
void setSampleSpan( int idx , int& start , int& end , double smooth=0 ) const;
/********************************************************
* Sets the translates and scales of the basis function
* up to the prescribed depth
* <maxDepth> the maximum depth
* <useDotRatios> specifies if dot-products of derivatives
* should be pre-divided by function integrals
* <reflectBoundary> spcifies if function space should be
* forced to be reflectively symmetric across the boundary
********************************************************/
void set( int maxDepth , bool useDotRatios=true , bool reflectBoundary=false );
inline int Index( int i1 , int i2 ) const;
static inline int SymmetricIndex( int i1 , int i2 );
static inline int SymmetricIndex( int i1 , int i2 , int& index );
};
template< int Degree >
struct BSplineElementCoefficients
{
int coeffs[Degree+1] = {};
BSplineElementCoefficients( ) = default;
int& operator[]( int idx ){ return coeffs[idx]; }
const int& operator[]( int idx ) const { return coeffs[idx]; }
};
template< int Degree >
struct BSplineElements : public std::vector< BSplineElementCoefficients< Degree > >
{
static const int _off = (Degree+1)/2;
void _addLeft ( int offset , int boundary );
void _addRight( int offset , int boundary );
public:
enum
{
NONE = 0,
DIRICHLET = -1,
NEUMANN = 1
};
// Coefficients are ordered as "/" "-" "\"
int denominator;
BSplineElements( ) { denominator = 1; }
BSplineElements( int res , int offset , int boundary=NONE );
void upSample( BSplineElements& high ) const;
void differentiate( BSplineElements< Degree-1 >& d ) const;
void print( FILE* ) const
{
for( int i=0 ; i<this->size() ; i++ )
{
printf( "%d]" , i );
for( int j=0 ; j<=Degree ; j++ ) printf( " %d" , (*this)[i][j] );
printf( " (%d)\n" , denominator );
}
}
};
template< int Degree1 , int Degree2 > void SetBSplineElementIntegrals( double integrals[Degree1+1][Degree2+1] );
}
}
#include "bspline_data.hpp"
#endif // BSPLINE_DATA_INCLUDED
pcl::poisson::BSplineData::baseFunction
PPolynomial< Degree > baseFunction
Definition bspline_data.h:68
pcl::poisson::BSplineData::DD_DOT_FLAG
static const int DD_DOT_FLAG
Definition bspline_data.h:61
pcl::poisson::BSplineData::dRightBaseFunction
PPolynomial< Degree-1 > dRightBaseFunction
Definition bspline_data.h:69
pcl::poisson::BSplineData::VV_DOT_FLAG
static const int VV_DOT_FLAG
Definition bspline_data.h:59
pcl::poisson::BSplineData::~BSplineData
virtual ~BSplineData()
Definition bspline_data.hpp:94
pcl::poisson::BSplineData::baseBSplines
BSplineComponents * baseBSplines
Definition bspline_data.h:72
pcl::poisson::BSplineData::functionCount
int functionCount
Definition bspline_data.h:65
pcl::poisson::BSplineData::dvDotTable
Real * dvDotTable
Definition bspline_data.h:66
pcl::poisson::BSplineData::set
void set(int maxDepth, bool useDotRatios=true, bool reflectBoundary=false)
Definition bspline_data.hpp:116
pcl::poisson::BSplineData::SymmetricIndex
static int SymmetricIndex(int i1, int i2)
Definition bspline_data.hpp:381
pcl::poisson::BSplineData::depth
int depth
Definition bspline_data.h:65
pcl::poisson::BSplineData::D_VALUE_FLAG
static const int D_VALUE_FLAG
Definition bspline_data.h:63
pcl::poisson::BSplineData::setValueTables
virtual void setValueTables(int flags, double smooth=0)
Definition bspline_data.hpp:322
pcl::poisson::BSplineData::dBaseFunction
PPolynomial< Degree-1 > dBaseFunction
Definition bspline_data.h:69
pcl::poisson::BSplineData::clearDotTables
virtual void clearDotTables(int flags)
Definition bspline_data.hpp:290
pcl::poisson::BSplineData::rightBaseFunction
PPolynomial< Degree > rightBaseFunction
Definition bspline_data.h:68
pcl::poisson::BSplineData::clearValueTables
virtual void clearValueTables()
Definition bspline_data.hpp:372
pcl::poisson::BSplineData::DV_DOT_FLAG
static const int DV_DOT_FLAG
Definition bspline_data.h:60
pcl::poisson::BSplineData::setDotTables
virtual void setDotTables(int flags)
Definition bspline_data.hpp:175
pcl::poisson::BSplineData::ddDotTable
Real * ddDotTable
Definition bspline_data.h:66
pcl::poisson::BSplineData::dLeftBaseFunction
PPolynomial< Degree-1 > dLeftBaseFunction
Definition bspline_data.h:69
pcl::poisson::BSplineData::leftBaseFunction
PPolynomial< Degree > leftBaseFunction
Definition bspline_data.h:68
pcl::poisson::BSplineData::sampleCount
int sampleCount
Definition bspline_data.h:65
pcl::poisson::BSplineData::baseFunctions
PPolynomial< Degree > * baseFunctions
Definition bspline_data.h:71
pcl::poisson::BSplineData::setSampleSpan
void setSampleSpan(int idx, int &start, int &end, double smooth=0) const
Definition bspline_data.hpp:303
pcl::poisson::BSplineData::Index
int Index(int i1, int i2) const
Definition bspline_data.hpp:379
pcl::poisson::BSplineData::valueTables
Real * valueTables
Definition bspline_data.h:67
pcl::poisson::BSplineData::rightBSpline
BSplineComponents rightBSpline
Definition bspline_data.h:70
pcl::poisson::BSplineData::baseBSpline
BSplineComponents baseBSpline
Definition bspline_data.h:70
pcl::poisson::BSplineData::VALUE_FLAG
static const int VALUE_FLAG
Definition bspline_data.h:62
pcl::poisson::BSplineData::vvDotTable
Real * vvDotTable
Definition bspline_data.h:66
pcl::poisson::BSplineData::BSplineData
BSplineData()
Definition bspline_data.hpp:84
pcl::poisson::BSplineData::leftBSpline
BSplineComponents leftBSpline
Definition bspline_data.h:70
pcl::poisson::BSplineData::dValueTables
Real * dValueTables
Definition bspline_data.h:67
pcl::poisson::PPolynomial
Definition ppolynomial.h:59
pcl::poisson::Polynomial
Definition polynomial.h:40
pcl::poisson
Definition allocator.h:36
pcl::poisson::Real
float Real
Definition multi_grid_octree_data.h:85
pcl::poisson::SetBSplineElementIntegrals
void SetBSplineElementIntegrals(double integrals[Degree1+1][Degree2+1])
Definition bspline_data.hpp:473
pcl
Definition convolution.h:46
pcl::poisson::BSplineData::BSplineComponents
Definition bspline_data.h:51
pcl::poisson::BSplineData::BSplineComponents::operator[]
Polynomial< Degree > & operator[](int idx)
Definition bspline_data.h:53
pcl::poisson::BSplineData::BSplineComponents::polys
Polynomial< Degree > polys[Degree+1]
Definition bspline_data.h:52
pcl::poisson::BSplineData::BSplineComponents::shift
BSplineComponents shift(double s) const
Definition bspline_data.h:57
pcl::poisson::BSplineData::BSplineComponents::printnl
void printnl() const
Definition bspline_data.h:55
pcl::poisson::BSplineData::BSplineComponents::scale
BSplineComponents scale(double s) const
Definition bspline_data.h:56
pcl::poisson::BSplineElementCoefficients::operator[]
int & operator[](int idx)
Definition bspline_data.h:107
pcl::poisson::BSplineElementCoefficients::BSplineElementCoefficients
BSplineElementCoefficients()=default
pcl::poisson::BSplineElementCoefficients::operator[]
const int & operator[](int idx) const
Definition bspline_data.h:108
pcl::poisson::BSplineElementCoefficients::coeffs
int coeffs[Degree+1]
Definition bspline_data.h:105
pcl::poisson::BSplineElements
Definition bspline_data.h:112
pcl::poisson::BSplineElements::_off
static const int _off
Definition bspline_data.h:113
pcl::poisson::BSplineElements::differentiate
void differentiate(BSplineElements< Degree-1 > &d) const
Definition bspline_data.hpp:459
pcl::poisson::BSplineElements::NONE
@ NONE
Definition bspline_data.h:119
pcl::poisson::BSplineElements::DIRICHLET
@ DIRICHLET
Definition bspline_data.h:120
pcl::poisson::BSplineElements::NEUMANN
@ NEUMANN
Definition bspline_data.h:121
pcl::poisson::BSplineElements::BSplineElements
BSplineElements()
Definition bspline_data.h:126
pcl::poisson::BSplineElements::_addRight
void _addRight(int offset, int boundary)
Definition bspline_data.hpp:436
pcl::poisson::BSplineElements::print
void print(FILE *) const
Definition bspline_data.h:132
pcl::poisson::BSplineElements::_addLeft
void _addLeft(int offset, int boundary)
Definition bspline_data.hpp:424
pcl::poisson::BSplineElements::denominator
int denominator
Definition bspline_data.h:124
pcl::poisson::BSplineElements::upSample
void upSample(BSplineElements &high) const
Definition bspline_data.hpp:448