Point Cloud Library (PCL) 1.12.0
bspline_data.h
1/*
2Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without modification,
6are permitted provided that the following conditions are met:
7
8Redistributions of source code must retain the above copyright notice, this list of
9conditions and the following disclaimer. Redistributions in binary form must reproduce
10the above copyright notice, this list of conditions and the following disclaimer
11in the documentation and/or other materials provided with the distribution.
12
13Neither the name of the Johns Hopkins University nor the names of its contributors
14may be used to endorse or promote products derived from this software without specific
15prior written permission.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26DAMAGE.
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
38namespace 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( void ) 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(void);
75 ~BSplineData(void);
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(void);
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];
106 BSplineElementCoefficients( void ) { memset( coeffs , 0 , sizeof( int ) * ( 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,
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
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
virtual void clearValueTables(void)
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 > & operator[](int idx)
Definition: bspline_data.h:53
Polynomial< Degree > polys[Degree+1]
Definition: bspline_data.h:52
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