//=========================================================================== // 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. //===========================================================================

ApproxSurf.h

Go to the documentation of this file.
00001 #ifndef _APPROXSURF_H_
00002 #define _APPROXSURF_H_
00003 
00004 //   -----------------------------------------------------------------------
00005 //      Interface file for class ApproxSurf
00006 //   -----------------------------------------------------------------------
00007 //
00008 //       Approximate a set of points by a B-spline curve to
00009 //       satisfy a given accuracy
00010 //
00011 //       Implementation of the member functions are given in the
00012 //       following files:
00013 //
00014 //          1. ApproxSurf.C
00015 //
00016 //   -----------------------------------------------------------------------
00017 //    Written by: Vibeke Skytt                           04-00
00018 //   -----------------------------------------------------------------------
00019 
00020 #include "GoTools/geometry/SplineSurface.h"
00021 #include "GoTools/geometry/SplineCurve.h"
00022 #include <vector>
00023 
00024 
00025 
00026 class SmoothSurf;
00027 
00028 namespace Go
00029 {
00032 class ApproxSurf
00033 {
00034  public:
00063     ApproxSurf(std::vector<boost::shared_ptr<SplineCurve> > & crvs,
00064                const std::vector<double>& points, 
00065                const std::vector<double>& parvals,
00066                double domain[],
00067                int dim, 
00068                double aepsge,
00069                int constdir = 0,
00070                bool repar=true);
00071 
00097     ApproxSurf(boost::shared_ptr<SplineSurface>& srf,
00098                const std::vector<double>& points, 
00099                const std::vector<double>& parvals,
00100                int dim, double aepsge, int constdir = 0,
00101                bool approx_orig = false,
00102                bool close_belt = false,
00103                int nmb_stabil = 0,
00104                bool repar=true);
00105 
00106 
00108     ~ApproxSurf();
00109 
00113     void setSmoothingWeight(double smooth)
00114         {
00115             ASSERT(smoothweight_ >= 0.0 && smoothweight_ <= 1.0);
00116             smoothweight_ = smooth;
00117         }
00118 
00125     void setFixBoundary(bool fix_boundary)
00126         {
00127             int fix = (fix_boundary) ? 1 : 0;
00128             edge_derivs_[0] = edge_derivs_[1] = edge_derivs_[2] = edge_derivs_[3] = fix;
00129         }
00130 
00142     void edgeFix(int edge_fix[])  // CCV
00143         {
00144             for (int ki=0; ki<4; ki++)
00145                 edge_derivs_[ki] = edge_fix[ki];
00146         }
00147 
00154     void setNormalConditions(const std::vector<double>& points, 
00155                              const std::vector<double>& parvals,
00156                              int nmb_stabil = 0)
00157         {
00158             use_normals_ = true;
00159             norm_points_ = points;
00160             norm_parvals_ = parvals;
00161             norm_stabil_ = nmb_stabil;
00162         }
00163 
00165 
00178     boost::shared_ptr<SplineSurface> getApproxSurf(double& maxdist, 
00179                                                    double& avdist,
00180                                                    int& nmb_out_eps, 
00181                                                    int max_iter=4,
00182                                                    int keep_init=0);
00183 
00186     int reParam();
00187 
00188     bool getDoRefine()
00189     {
00190       return refine_;
00191     }
00192 
00193     void setDoRefine(bool refine)
00194     {
00195       refine_ = refine;
00196     }
00197 
00198 
00199  protected:
00201     ApproxSurf();
00202 
00203  private:
00204     boost::shared_ptr<SplineSurface> curr_srf_;
00205     boost::shared_ptr<SplineSurface> init_srf_;
00206     boost::shared_ptr<SplineSurface> prev_srf_;
00207     std::vector<int> coef_known_;
00208     double prevdist_;
00209     double prevav_;
00210     double maxdist_;
00211     double avdist_;
00212     int outsideeps_;
00213     double aepsge_;
00214     double smoothweight_;
00215     double smoothfac_;
00216     bool use_normals_;
00217     int edge_derivs_[4];
00218     bool close_belt_;
00219     bool repar_;
00220     bool refine_;
00221 
00222     int dim_;
00223     std::vector<double> points_;
00224     std::vector<double> parvals_;
00225     int pts_stabil_;
00226     std::vector<double> norm_points_;
00227     std::vector<double> norm_parvals_;
00228     int norm_stabil_;
00229     int constdir_;
00230     bool orig_;
00231 
00233     int makeInitSurf(std::vector<boost::shared_ptr<SplineCurve> > &crvs, 
00234                      double domain[]);
00235 
00236     void
00237       spline_space_cont(boost::shared_ptr<SplineSurface> sf, 
00238                         int& nmbc1, int& nmbc2);
00239 
00240     int get_min_deriv(boost::shared_ptr<SplineSurface> sf, double support_mult);
00241 
00243     int makeSmoothSurf();
00244 
00246     int checkAccuracy(std::vector<double>& acc_outside_u,
00247                       std::vector<int>& nmb_outside_u,
00248                       std::vector<double>& acc_outside_v,
00249                       std::vector<int>& nmb_outside_v);
00250 
00252     int doApprox(int max_iter, int keep_init);
00253 
00255     int refineSplineSpace(std::vector<double>& acc_outside_u,
00256                           std::vector<int>& nmb_outside_u,
00257                           std::vector<double>& acc_outside_v,
00258                           std::vector<int>& nmb_outside_v);
00259 
00261     void coefKnownFromPoints();
00262     void setCoefKnown();
00263 };
00264 
00265 }  // namespace Go
00266 
00267 #endif
00268 
00269 
00270 
00271 
00272 
00273 
Generated on Tue Sep 21 15:44:16 2010 for GoTools Core by  doxygen 1.6.3