//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //===========================================================================

SmoothSurfSet.h

Go to the documentation of this file.
00001 #ifndef _SMOOTHSURFSET_H_
00002 #define _SMOOTHSURFSET_H_
00003 
00004 
00005 //   -----------------------------------------------------------------------
00006 //      Interface file for class SmoothSurfSET
00007 //   -----------------------------------------------------------------------
00008 //
00009 //       Used to modify a tensor product B-spline surface with respect
00010 //       to conditions on smoothness, editing constraints and boundary
00011 //       conditions.
00012 //
00013 //       Implementation of the member functions are given in the
00014 //       following files:
00015 //
00016 //          1. SmoothSurfSet.C
00017 //
00018 //   -----------------------------------------------------------------------
00019 //    Written by: Vibeke Skytt                            04.2002.
00020 //   -----------------------------------------------------------------------
00021 
00022 #include "GoTools/geometry/SplineSurface.h"
00023 #include "GoTools/creators/ConstraintDefinitions.h"
00024 #include <vector>
00025 
00026 namespace Go
00027 {
00028 
00031 class SmoothSurfSet
00032 {
00033 
00034 
00035 public:
00037     SmoothSurfSet();
00038 
00041     SmoothSurfSet(bool copy_coefs);
00042 
00044     virtual
00045     ~SmoothSurfSet();
00046 
00057     void attach(std::vector<boost::shared_ptr<SplineSurface> >& insf, 
00058                 std::vector<std::vector<int> >& coef_known,
00059                 int num_side_constraints = 0, 
00060                 int has_normal_cond = 0);
00061 
00062     // @@@ VSK. Can it be relevant to use different weights for 
00063     // different surfaces, and how to define the weights in that case?
00069     virtual
00070     void setOptimize(double weight1, double weight2, double weight3);
00071 
00082     void setLeastSquares(std::vector<std::vector<double> >& pnts,
00083                          std::vector<std::vector<double> >& param_pnts,
00084                          std::vector<std::vector<double> >& pnt_weights,
00085                          double weight);
00086 
00097     int setNormalCond(std::vector<std::vector<double> >& pnts,
00098                       std::vector<std::vector<double> >& param_pnts,
00099                       std::vector<std::vector<double> >& pnt_weights,
00100                       double weight);
00101 
00106     void approxOrig(double weight);
00107 
00110     void setSideConstraints(std::vector<sideConstraintSet>& constraints);
00111 
00112     // We may have side constraints which are not suitable for exact equality as
00113     // spline solution space may not be large enough. We therefore allow using least
00114     // squares to minimize the error.
00115     // This applies in particular to constraint involving higher order derivatives.
00116     // @@ Currently function uses newmat. As matrix is sparce we may do it another way.
00118     void setApproxSideConstraints(std::vector<sideConstraintSet>& constraints,
00119                                   double weight);
00120 
00125     int equationSolve(std::vector<boost::shared_ptr<SplineSurface> >& surfaces);
00126 
00127 
00128 protected:
00129     int kdim_;             // 3 if normal conditions are included, otherwise 1.
00130     int idim_;             // Dimension of geometry space. 
00131     int idim1_;            // Dimension of projective space.
00132     int ider_;             // Maximum derivative involved in the computations. 
00133 
00134     int kncond_;           // Number of unknown coefficents + number of constraints.
00135     int knconstraint_;     // Number of side constraints.
00136 
00137     std::vector<std::vector<int>::iterator> coef_known_;
00138     // Array indicating the status of coefficients, i.e.
00139     // free, fixed, not involved, equal to a given
00140     // coefficients.
00141     std::vector<std::vector<int> > pivot_; // Array giving the position of the
00142     // free coefficients in the equation system.
00143 
00144     // Parameters defining the spline space.
00145     std::vector<boost::shared_ptr<SplineSurface> > srfs_;   // Pointer to input surfaces.
00146 
00147     const int copy_coefs_; // Whether we are to copy the coefs from input surfaces
00148                            // (or work directly on coefficients in input surfaces).
00149 
00150     // Parameters used to define the specific input spline surfaces.
00151     std::vector<std::vector<double> > coef_array_;
00152 
00153     //    std::vector<double>::iterator  scoef;   // Pointer to surface coefficients.      
00154 
00155     // Storage of the equation system.
00156     std::vector<double> gmat_;       // Matrix at left side of equation system.
00157     std::vector<double> gright_;     // Right side of equation system.      
00158 
00172     virtual
00173     void getBasis(double *sb1, double *sb2, int kk1, int kk2, 
00174                   int kleft1, int kleft2, int ider, double *sbasis);
00175 
00176 
00177 private:
00178 
00180     typedef struct integralInfo
00181     {
00182         // Parameters used in integration
00183         std::vector<double> vec1, vec2;
00184         double ***integral1;  // Array used to store integrals of inner product
00185         // of derivatives of B-splines in 1. par. dir.
00186         // The 1st index runs over the derivatives, the 2nd & 3rd in u- and v-dir.
00187         double ***integral2;  // Array used to store integrals of inner product
00188         // of derivatives of B-splines in 2. par. dir.
00189         // The 1st index runs over the derivatives, the 2nd & 3rd in u- and v-dir.
00190         bool integralset; // Whether integral1 & integral2 have been computed.
00191         int der; // The number of derivatives to compute.
00192       
00194         integralInfo() 
00195         { integral1 = 0; integral2 = 0; integralset = false; der = -1; }
00196 
00198         ~integralInfo()
00199         { erase(); }
00200 
00205         void resize(int ider, int in1, int in2)
00206         {
00207             int ki, kj;
00208             vec1.resize((ider+1)*in1*in1);
00209             vec2.resize((ider+1)*in2*in2);
00210             std::fill(vec1.begin(), vec1.end(), 0.0);
00211             std::fill(vec2.begin(), vec2.end(), 0.0);
00212 
00213             integral1 = new double**[ider+1];
00214             integral2 = new double**[ider+1];
00215 
00216             for (ki=0; ki<=ider; ki++)
00217                 {
00218                     integral1[ki] = new double*[in1];
00219                     integral2[ki] = new double*[in2];
00220 
00221                     for (kj=0; kj<in1; kj++)
00222                         integral1[ki][kj] = &vec1[(ki*in1+kj)*in1];
00223 
00224                     for (kj=0; kj<in2; kj++)
00225                         integral2[ki][kj] = &vec2[(ki*in2+kj)*in2];
00226                 }
00227 
00228             integralset = 0;
00229             der = ider;
00230         }
00231 
00233         void erase()
00234         {
00235             int ki;
00236             for (ki=0; ki<=der; ki++)
00237                 {
00238                     delete [] integral1[ki];
00239                     delete [] integral2[ki];
00240                 }
00241             delete [] integral1;
00242             delete [] integral2;
00243             integralset = false;
00244         }
00245     } integralInfo;
00246 
00247     std::vector<integralInfo> surf_integral_; // Integral calculations for the surfaces.
00248 
00253     void removeKnownCoefs(std::vector<sideConstraintSet>& constraints) const;
00254 
00255 };
00256 
00257 }
00258 
00259 #endif //
Generated on Tue Sep 21 15:44:16 2010 for GoTools Core by  doxygen 1.6.3