Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, 00006 are permitted provided that the following conditions are met: 00007 00008 Redistributions of source code must retain the above copyright notice, this list of 00009 conditions and the following disclaimer. Redistributions in binary form must reproduce 00010 the above copyright notice, this list of conditions and the following disclaimer 00011 in the documentation and/or other materials provided with the distribution. 00012 00013 Neither the name of the Johns Hopkins University nor the names of its contributors 00014 may be used to endorse or promote products derived from this software without specific 00015 prior written permission. 00016 00017 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00018 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 00019 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00020 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00022 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00023 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00024 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00025 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00026 DAMAGE. 00027 */ 00028 00029 #ifndef BSPLINE_DATA_INCLUDED 00030 #define BSPLINE_DATA_INCLUDED 00031 00032 00033 #include "ppolynomial.h" 00034 00035 namespace pcl 00036 { 00037 namespace poisson 00038 { 00039 00040 00041 template< int Degree , class Real > 00042 class BSplineData 00043 { 00044 bool useDotRatios; 00045 bool reflectBoundary; 00046 public: 00047 struct BSplineComponents 00048 { 00049 Polynomial< Degree > polys[Degree+1]; 00050 Polynomial< Degree >& operator[] ( int idx ) { return polys[idx]; } 00051 const Polynomial< Degree >& operator[] ( int idx ) const { return polys[idx]; } 00052 void printnl( void ) const { for( int d=0 ; d<=Degree ; d++ ) polys[d].printnl(); } 00053 BSplineComponents scale( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].scale(s) ; return b; } 00054 BSplineComponents shift( double s ) const { BSplineComponents b ; for( int d=0 ; d<=Degree ; d++ ) b[d] = polys[d].shift(s) ; return b; } 00055 }; 00056 const static int VV_DOT_FLAG = 1; 00057 const static int DV_DOT_FLAG = 2; 00058 const static int DD_DOT_FLAG = 4; 00059 const static int VALUE_FLAG = 1; 00060 const static int D_VALUE_FLAG = 2; 00061 00062 int depth , functionCount , sampleCount; 00063 Real *vvDotTable , *dvDotTable , *ddDotTable; 00064 Real *valueTables , *dValueTables; 00065 PPolynomial< Degree > baseFunction , leftBaseFunction , rightBaseFunction; 00066 PPolynomial< Degree-1 > dBaseFunction , dLeftBaseFunction , dRightBaseFunction; 00067 BSplineComponents baseBSpline, leftBSpline , rightBSpline; 00068 PPolynomial<Degree>* baseFunctions; 00069 BSplineComponents* baseBSplines; 00070 00071 BSplineData(void); 00072 ~BSplineData(void); 00073 00074 virtual void setDotTables( int flags ); 00075 virtual void clearDotTables( int flags ); 00076 00077 virtual void setValueTables( int flags,double smooth=0); 00078 virtual void setValueTables( int flags,double valueSmooth,double normalSmooth); 00079 virtual void clearValueTables(void); 00080 00081 void setSampleSpan( int idx , int& start , int& end , double smooth=0 ) const; 00082 00083 /******************************************************** 00084 * Sets the translates and scales of the basis function 00085 * up to the prescribed depth 00086 * <maxDepth> the maximum depth 00087 * <useDotRatios> specifies if dot-products of derivatives 00088 * should be pre-divided by function integrals 00089 * <reflectBoundary> spcifies if function space should be 00090 * forced to be reflectively symmetric across the boundary 00091 ********************************************************/ 00092 void set( int maxDepth , bool useDotRatios=true , bool reflectBoundary=false ); 00093 00094 inline int Index( int i1 , int i2 ) const; 00095 static inline int SymmetricIndex( int i1 , int i2 ); 00096 static inline int SymmetricIndex( int i1 , int i2 , int& index ); 00097 }; 00098 00099 template< int Degree > 00100 struct BSplineElementCoefficients 00101 { 00102 int coeffs[Degree+1]; 00103 BSplineElementCoefficients( void ) { memset( coeffs , 0 , sizeof( int ) * ( Degree+1 ) ); } 00104 int& operator[]( int idx ){ return coeffs[idx]; } 00105 const int& operator[]( int idx ) const { return coeffs[idx]; } 00106 }; 00107 template< int Degree > 00108 struct BSplineElements : public std::vector< BSplineElementCoefficients< Degree > > 00109 { 00110 static const int _off = (Degree+1)/2; 00111 void _addLeft ( int offset , int boundary ); 00112 void _addRight( int offset , int boundary ); 00113 public: 00114 enum 00115 { 00116 NONE = 0, 00117 DIRICHLET = -1, 00118 NEUMANN = 1 00119 }; 00120 // Coefficients are ordered as "/" "-" "\" 00121 int denominator; 00122 00123 BSplineElements( void ) { denominator = 1; } 00124 BSplineElements( int res , int offset , int boundary=NONE ); 00125 00126 void upSample( BSplineElements& high ) const; 00127 void differentiate( BSplineElements< Degree-1 >& d ) const; 00128 00129 void print( FILE* fp=stdout ) const 00130 { 00131 for( int i=0 ; i<this->size() ; i++ ) 00132 { 00133 printf( "%d]" , i ); 00134 for( int j=0 ; j<=Degree ; j++ ) printf( " %d" , (*this)[i][j] ); 00135 printf( " (%d)\n" , denominator ); 00136 } 00137 } 00138 }; 00139 template< int Degree1 , int Degree2 > void SetBSplineElementIntegrals( double integrals[Degree1+1][Degree2+1] ); 00140 00141 00142 } 00143 } 00144 00145 00146 #include "bspline_data.hpp" 00147 00148 #endif // BSPLINE_DATA_INCLUDED