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 _GOSMOOTHCURVE_H_ 00034 #define _GOSMOOTHCURVE_H_ 00035 00036 00037 // ----------------------------------------------------------------------- 00038 // Interface file for class SmoothCurve 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. SmoothCurve.C 00049 // a. SmoothCurve() 00050 // b. ~SmoothCurve() 00051 // c. attach() 00052 // d. setOptim() 00053 // e. setLeastSquares() 00054 // f. equationSolve() 00055 // 00056 // ----------------------------------------------------------------------- 00057 // Written by: Vibeke Skytt 28-04.1998. 00058 // ----------------------------------------------------------------------- 00059 00060 #include "SplineCurve.h" 00061 #include "ConstraintDefinitions.h" 00062 //#include "newmat.h" 00063 #include <boost/smart_ptr.hpp> 00064 00065 #include <vector> 00066 00067 00068 namespace Go 00069 { 00072 00073 00083 class SmoothCurve 00084 { 00085 00086 public: 00087 00091 SmoothCurve(int dim = 3); 00092 00094 ~SmoothCurve(); 00095 00097 00106 int attach(const boost::shared_ptr<SplineCurve>& incurve, 00107 int coef_known[], 00108 int numSideConstraints = 0); 00109 00115 void setOptim(const double weight1, const double weight2, 00116 const double weight3); 00117 00126 void setLeastSquares(std::vector<double>& pnts, 00127 std::vector<double>& param_pnts, 00128 std::vector<double>& pnt_weights, 00129 double weight); 00130 00135 void setPeriodicity(int cont, double weight); 00136 00141 void setSideConstraints(std::vector<sideConstraint>& constraints); 00142 00145 void equationSolve(boost::shared_ptr<SplineCurve>& curve); 00146 00147 00148 private: 00149 int idim_; // Dimension of geometry space. 00150 int ider_; // Maximum derivative involved in the computations. 00151 // int cont_bound[2]; // Fixed continuity at each endpoint, i.e. the number 00152 // // of coefficients not to be changed. 00153 int cont_seam_; // Number of rows affected by continuity at the seam 00154 int kcond_; // Number of unknowns in equation system (# of coefs + kconstraint). 00155 int kconstraint_; // # of constraints. 00156 00157 int *coefknown_; // Array indicating the status of coefficients, i.e. 00158 // free, fixed, not involved, equal to a given 00159 // coefficients. 00160 std::vector<int> pivot_; // Array giving the position of the free coefficients 00161 // in the equation system. 00162 00163 // The input curve 00164 boost::shared_ptr<SplineCurve> qcurve_; 00165 00166 // Parameters defining the spline space. 00167 int kk_; // Order of curve. 00168 int kn_; // Number of coefficients of curve. 00169 std::vector<double>::const_iterator st_; // Pointer to knot of curve. 00170 00171 // Parameters used to define the specific input spline curve. 00172 std::vector<double>::iterator scoef_; // Pointer to coefficients. 00173 00174 // Parameters used in integration 00175 double ***integral_; // Array used to store integrals of inner product 00176 00177 // Storage of the equation system. 00178 //Matrix gmat_; // Matrix at left side of equation system. 00179 //ColumnVector gright_; // Right side of equation system. 00180 std::vector<std::vector<double> > gmat_; // Matrix at left side of equation system 00181 std::vector<double> gright_; // Right side of equation system 00182 00184 // \return return value 0 = OK, negative return value = failure. 00185 int prepareIntegral(); 00186 00188 void releaseScratch(); 00189 00191 void adjustAtSeam(); 00192 00195 void setC0AtSeam(double weight); 00196 00199 void setC1AtSeam(double weight); 00200 }; 00201 00203 }// end namespace Go 00204 00205 #endif 00206