00001 //=========================================================================== 00002 // GoTools - SINTEF Geometry Tools version 1.1 00003 // 00004 // GoTools module: CORE 00005 // 00006 // Copyright (C) 2000-2007 SINTEF ICT, Applied Mathematics, Norway. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation version 2 of the License. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 00020 // 59 Temple Place - Suite 330, 00021 // Boston, MA 02111-1307, USA. 00022 // 00023 // Contact information: E-mail: tor.dokken@sintef.no 00024 // SINTEF ICT, Department of Applied Mathematics, 00025 // P.O. Box 124 Blindern, 00026 // 0314 Oslo, Norway. 00027 // 00028 // Other licenses are also available for this software, notably licenses 00029 // for: 00030 // - Building commercial software. 00031 // - Building software whose source code you wish to keep private. 00032 //=========================================================================== 00033 #ifndef _GOSMOOTHSURF_H_ 00034 #define _GOSMOOTHSURF_H_ 00035 00036 00037 // ----------------------------------------------------------------------- 00038 // Interface file for class SmoothSurf 00039 // ----------------------------------------------------------------------- 00040 // 00041 // Used to modify a tensor product B-spline surface with respect 00042 // to conditions on smoothness, editing constraints and boundary 00043 // conditions. 00044 // 00045 // Implementation of the member functions are given in the 00046 // following files: 00047 // 00048 // 1. SmoothSurf.C 00049 // 00050 // ----------------------------------------------------------------------- 00051 // Written by: Vibeke Skytt 08-11.1993. 00052 // Revised by: Vibeke Skytt 09.1995 00053 // Revised by: Vibeke Skytt 04.1998 00054 // ----------------------------------------------------------------------- 00055 00056 #include "SplineSurface.h" 00057 #include "ConstraintDefinitions.h" 00058 00059 #include <vector> 00060 00061 00062 namespace Go 00063 { 00066 00067 00070 class SmoothSurf 00071 { 00072 00073 public: 00075 SmoothSurf(); 00076 00079 SmoothSurf(bool copy_coefs); 00080 00082 virtual 00083 ~SmoothSurf(); 00084 00095 void attach(boost::shared_ptr<SplineSurface>& insf, int seem[], int coef_known[], 00096 int num_side_constraints = 0, int has_normal_cond = 0); 00097 00102 virtual 00103 void setOptimize(const double weight1, const double weight2, 00104 const double weight3); 00105 00115 void setLeastSquares(std::vector<double>& pnts, 00116 std::vector<double>& param_pnts, 00117 std::vector<double>& pnt_weights, 00118 const double weight); 00119 00130 int setNormalCond(std::vector<double>& pnts, 00131 std::vector<double>& param_pnts, 00132 std::vector<double>& pnt_weights, 00133 const double weight); 00134 00139 void approxOrig(double weight); 00140 00146 virtual 00147 void setPeriodicity(int pardir, 00148 int cont, 00149 double weight1, 00150 double weight2); 00151 00152 00155 void setSideConstraints(std::vector<sideConstraint>& constraints); 00156 00161 int equationSolve(boost::shared_ptr<SplineSurface>& surf); 00162 00163 00164 protected: 00165 int kdim_; // If the problem has normal-conditions: 3, otherwise: 1 00166 int idim_; // Dimension of geomtry space. 00167 int idim1_; // Dimension of projective space (for rationals). 00168 int ider_; // Maximum derivative involved in the computations. 00169 bool integralset_; // 00170 00171 int cont_seem_[2]; // Number of rows affected by continuity at a seem 00172 // for each parameter direction. 00173 int kncond_; // Size of matrix system (# unknown coefficents + # side constraints) 00174 int knconstraint_; // Number of side constraints. 00175 const int kpointer_; // If coefknown_[ki] >= kpointer_, the coefficients indexed by 00176 // ki & coefknown_[ki] - kpointer_ should be equal. 00177 00178 int *coefknown_; // Array indicating the status of coefficients, i.e. 00179 // free, fixed, not involved, equal to a given coefficients. 00180 // 0: not known, 1: known, 2: not of interest (i.e. assumed known). 00181 // >= kpointer_: the coefficients indexed by 00182 // ki & coefknown_[ki] - kpointer_ should be equal. 00183 std::vector<int> pivot_; // Array giving the position of the free coefficients 00184 // in the equation system. 00185 00186 // Parameters defining the spline space. 00187 boost::shared_ptr<SplineSurface> srf_; // Pointer to input surface. 00188 int kk1_, kk2_; // Order of surface in both parameter directions. 00189 int kn1_, kn2_; // Number of coefficients of surface. 00190 std::vector<double>::const_iterator st1_; // Pointer to knot vector of 00191 // surface in 1. par. dir. 00192 std::vector<double>::const_iterator st2_; // Pointer to knot vector of 00193 // surface in 2. par. dir. 00194 00195 const bool copy_coefs_; 00196 00198 std::vector<double> coef_array_; // Only used if copy_coefs_ == true 00199 std::vector<double>::iterator scoef_; // Pointer to surface coefficients. 00200 00202 std::vector<double> gmat_; // Matrix at left side of equation system. 00203 std::vector<double> gright_; // Right side of equation system. 00204 00206 virtual 00207 void releaseScratch(); 00208 00210 virtual 00211 void prepareIntegral(); 00212 00224 virtual 00225 void getBasis(const double *sb1, const double *sb2, int kleft1, int kleft2, 00226 int ider, double *sbasis); 00227 00231 void preparePeriodicity(int seem[]); 00232 00235 void setC1AtSeem(int pardir, double weight); 00236 00239 void setC2AtSeem(int pardir, double weight); 00240 00243 virtual 00244 int adjustAtSeem(); 00245 00246 00247 private: 00248 00249 // Parameters used in integration 00250 std::vector<double> vec1_, vec2_; 00251 double ***integral1_; // Array used to store integrals of inner product 00252 // of derivatives of B-splines in 1. par. dir. 00253 double ***integral2_; // Array used to store integrals of inner product 00254 // of derivatives of B-splines in 2. par. dir. 00255 00256 00257 }; // end of class SmoothSurf 00258 00259 00261 } // end of namespace Go 00262 00263 #endif 00264