ApproxSurf.h

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 _GOAPPROXSURF_H_
00034 #define _GOAPPROXSURF_H_
00035 
00036 //   -----------------------------------------------------------------------
00037 //      Interface file for class ApproxSurf
00038 //   -----------------------------------------------------------------------
00039 //
00040 //       Approximate a set of points by a B-spline curve to
00041 //       satisfy a given accuracy
00042 //
00043 //       Implementation of the member functions are given in the
00044 //       following files:
00045 //
00046 //          1. ApproxSurf.C
00047 //
00048 //   -----------------------------------------------------------------------
00049 //    Written by: Vibeke Skytt                           04-00
00050 //   -----------------------------------------------------------------------
00051 
00052 #include "SplineSurface.h"
00053 #include "SplineCurve.h"
00054 #include <vector>
00055 
00056 
00057 
00058 class SmoothSurf;
00059 
00060 namespace Go
00061 {
00064 
00067 class ApproxSurf
00068 {
00069  public:
00098     ApproxSurf(std::vector<boost::shared_ptr<SplineCurve> > & crvs,
00099                  const std::vector<double>& points, 
00100                  const std::vector<double>& parvals,
00101                  double domain[],
00102                  int dim, 
00103                  double aepsge,
00104                  int constdir = 0);
00105 
00129     ApproxSurf(boost::shared_ptr<SplineSurface>& srf,
00130                  const std::vector<double>& points, 
00131                  const std::vector<double>& parvals,
00132                  int dim, double aepsge, int constdir = 0);
00133 
00134 
00136     ~ApproxSurf();
00137 
00141     void setSmoothingWeight(double smooth)
00142         {
00143             ASSERT(smoothweight_ >= 0.0 && smoothweight_ <= 1.0);
00144             smoothweight_ = smooth;
00145         }
00146 
00153     void setFixBoundary(bool fix_boundary)
00154         {
00155             int fix = (fix_boundary) ? 1 : 0;
00156             edge_derivs_[0] = edge_derivs_[1] = edge_derivs_[2] = edge_derivs_[3] = fix;
00157         }
00158 
00170     void edgeFix(int edge_fix[])  // CCV
00171         {
00172             for (int ki=0; ki<4; ki++)
00173                 edge_derivs_[ki] = edge_fix[ki];
00174         }
00175 
00182     void setNormalConditions(const std::vector<double>& points, 
00183                              const std::vector<double>& parvals)
00184         {
00185             use_normals_ = true;
00186             norm_points_ = points;
00187             norm_parvals_ = parvals;
00188         }
00189 
00191 
00204     boost::shared_ptr<SplineSurface> getApproxSurf(double& maxdist, 
00205                                                    double& avdist,
00206                                                    int& nmb_out_eps, 
00207                                                    int max_iter=4);
00208 
00211     int reParam();
00212 
00213 
00214  protected:
00216     ApproxSurf();
00217 
00218  private:
00219     boost::shared_ptr<SplineSurface> curr_srf_;
00220     double maxdist_;
00221     double avdist_;
00222     int outsideeps_;
00223     double aepsge_;
00224     double smoothweight_;
00225     double smoothfac_;
00226     bool use_normals_;
00227     int edge_derivs_[4];
00228 
00229     int dim_;
00230     std::vector<double> points_;
00231     std::vector<double> parvals_;
00232     std::vector<double> norm_points_;
00233     std::vector<double> norm_parvals_;
00234     int constdir_;
00235 
00237     int makeInitSurf(std::vector<boost::shared_ptr<SplineCurve> > &crvs, 
00238                      double domain[]);
00239 
00241     int makeSmoothSurf();
00242 
00244     int checkAccuracy();
00245 
00247     int doApprox(int max_iter);
00248 
00249 
00250 };
00251 
00253 }  // namespace Go
00254 
00255 #endif
00256 
00257 
00258 
00259 
00260 
00261 
00262 

Generated on Mon Jun 11 14:48:18 2007 for GoTools Core Library by  doxygen 1.5.1