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