Point Cloud Library (PCL)  1.9.1-dev
bspline_data.h
1 /*
2 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
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 BSPLINE_DATA_INCLUDED
30 #define BSPLINE_DATA_INCLUDED
31 
32 
33 #include "ppolynomial.h"
34 
35 namespace pcl
36 {
37  namespace poisson
38  {
39 
40 
41  template< int Degree , class Real >
43  {
44  bool useDotRatios;
45  bool reflectBoundary;
46  public:
48  {
50  Polynomial< Degree >& operator[] ( int idx ) { return polys[idx]; }
51  const Polynomial< Degree >& operator[] ( int idx ) const { return polys[idx]; }
52  void printnl( void ) const { for( int d=0 ; d<=Degree ; d++ ) polys[d].printnl(); }
53  BSplineComponents scale( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].scale(s) ; return b; }
54  BSplineComponents shift( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].shift(s) ; return b; }
55  };
56  const static int VV_DOT_FLAG = 1;
57  const static int DV_DOT_FLAG = 2;
58  const static int DD_DOT_FLAG = 4;
59  const static int VALUE_FLAG = 1;
60  const static int D_VALUE_FLAG = 2;
61 
67  BSplineComponents baseBSpline, leftBSpline , rightBSpline;
69  BSplineComponents* baseBSplines;
70 
71  BSplineData(void);
72  ~BSplineData(void);
73 
74  virtual void setDotTables( int flags );
75  virtual void clearDotTables( int flags );
76 
77  virtual void setValueTables( int flags,double smooth=0);
78  virtual void setValueTables( int flags,double valueSmooth,double normalSmooth);
79  virtual void clearValueTables(void);
80 
81  void setSampleSpan( int idx , int& start , int& end , double smooth=0 ) const;
82 
83  /********************************************************
84  * Sets the translates and scales of the basis function
85  * up to the prescribed depth
86  * <maxDepth> the maximum depth
87  * <useDotRatios> specifies if dot-products of derivatives
88  * should be pre-divided by function integrals
89  * <reflectBoundary> spcifies if function space should be
90  * forced to be reflectively symmetric across the boundary
91  ********************************************************/
92  void set( int maxDepth , bool useDotRatios=true , bool reflectBoundary=false );
93 
94  inline int Index( int i1 , int i2 ) const;
95  static inline int SymmetricIndex( int i1 , int i2 );
96  static inline int SymmetricIndex( int i1 , int i2 , int& index );
97  };
98 
99  template< int Degree >
101  {
102  int coeffs[Degree+1];
103  BSplineElementCoefficients( void ) { memset( coeffs , 0 , sizeof( int ) * ( Degree+1 ) ); }
104  int& operator[]( int idx ){ return coeffs[idx]; }
105  const int& operator[]( int idx ) const { return coeffs[idx]; }
106  };
107  template< int Degree >
108  struct BSplineElements : public std::vector< BSplineElementCoefficients< Degree > >
109  {
110  static const int _off = (Degree+1)/2;
111  void _addLeft ( int offset , int boundary );
112  void _addRight( int offset , int boundary );
113  public:
114  enum
115  {
116  NONE = 0,
117  DIRICHLET = -1,
118  NEUMANN = 1
119  };
120  // Coefficients are ordered as "/" "-" "\"
122 
123  BSplineElements( void ) { denominator = 1; }
124  BSplineElements( int res , int offset , int boundary=NONE );
125 
126  void upSample( BSplineElements& high ) const;
127  void differentiate( BSplineElements< Degree-1 >& d ) const;
128 
129  void print( FILE* fp=stdout ) const
130  {
131  for( int i=0 ; i<this->size() ; i++ )
132  {
133  printf( "%d]" , i );
134  for( int j=0 ; j<=Degree ; j++ ) printf( " %d" , (*this)[i][j] );
135  printf( " (%d)\n" , denominator );
136  }
137  }
138  };
139  template< int Degree1 , int Degree2 > void SetBSplineElementIntegrals( double integrals[Degree1+1][Degree2+1] );
140 
141 
142  }
143 }
144 
145 
146 #include "bspline_data.hpp"
147 
148 #endif // BSPLINE_DATA_INCLUDED
virtual void clearDotTables(int flags)
PPolynomial< Degree-1 > dBaseFunction
Definition: bspline_data.h:66
PPolynomial< Degree-1 > dRightBaseFunction
Definition: bspline_data.h:66
BSplineComponents shift(double s) const
Definition: bspline_data.h:54
BSplineComponents leftBSpline
Definition: bspline_data.h:67
PPolynomial< Degree-1 > dLeftBaseFunction
Definition: bspline_data.h:66
PPolynomial< Degree > rightBaseFunction
Definition: bspline_data.h:65
static const int D_VALUE_FLAG
Definition: bspline_data.h:60
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
static int SymmetricIndex(int i1, int i2)
void print(FILE *fp=stdout) const
Definition: bspline_data.h:129
BSplineComponents scale(double s) const
Definition: bspline_data.h:53
PPolynomial< Degree > baseFunction
Definition: bspline_data.h:65
static const int DV_DOT_FLAG
Definition: bspline_data.h:57
PPolynomial< Degree > * baseFunctions
Definition: bspline_data.h:68
virtual void setValueTables(int flags, double smooth=0)
static const int VV_DOT_FLAG
Definition: bspline_data.h:56
virtual void clearValueTables(void)
const int & operator[](int idx) const
Definition: bspline_data.h:105
BSplineComponents baseBSpline
Definition: bspline_data.h:67
Polynomial< Degree > & operator[](int idx)
Definition: bspline_data.h:50
int Index(int i1, int i2) const
virtual void setDotTables(int flags)
static const int DD_DOT_FLAG
Definition: bspline_data.h:58
Polynomial< Degree > polys[Degree+1]
Definition: bspline_data.h:49
void SetBSplineElementIntegrals(double integrals[Degree1+1][Degree2+1])
BSplineComponents * baseBSplines
Definition: bspline_data.h:69
void setSampleSpan(int idx, int &start, int &end, double smooth=0) const
BSplineComponents rightBSpline
Definition: bspline_data.h:67
PPolynomial< Degree > leftBaseFunction
Definition: bspline_data.h:65
static const int VALUE_FLAG
Definition: bspline_data.h:59