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

AdaptCurve.h

Go to the documentation of this file.
00001 #ifndef _ADAPTCURVE_H_
00002 #define _ADAPTCURVE_H_
00003 
00004 //   -----------------------------------------------------------------------
00005 //      Interface file for class AdaptCurve
00006 //   -----------------------------------------------------------------------
00007 //
00008 //       Approximate an evaluator based curve 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. AdaptCurve.C
00015 //
00016 //   -----------------------------------------------------------------------
00017 //    Written by: Vibeke Skytt                           November 2009
00018 //   -----------------------------------------------------------------------
00019 
00020 #include "GoTools/geometry/SplineCurve.h"
00021 #include <vector>
00022 #include "GoTools/creators/SmoothCurve.h"
00023 #include "GoTools/creators/EvalCurve.h"
00024 
00025 namespace Go
00026 {
00029 class AdaptCurve
00030 {
00031 public:
00037   AdaptCurve(const EvalCurve *evalcrv, double aepsge);
00038 
00045   AdaptCurve(const EvalCurve *evalcrv, double aepsge, int in, int ik);
00046 
00054   AdaptCurve(const EvalCurve *evalcrv, double aepsge, int in, int ik,
00055              std::vector<double>& knots);
00056 
00062   AdaptCurve(const EvalCurve *evalcrv, double aepsge, 
00063              boost::shared_ptr<SplineCurve> curve);
00064 
00066   ~AdaptCurve();
00067 
00070   void setSmooth(double w);
00071 
00072 
00074   void unsetSmooth();
00075     
00078 
00087   void setEndPoints(const std::vector<Point>& start_point, 
00088                     const std::vector<Point>& end_point);
00089 
00092   int approximate(int max_iter = 5);
00093 
00101   boost::shared_ptr<SplineCurve> getAdaptCurve(double& maxdist, 
00102                                                double& avdist,
00103                                                int max_iter = 5);
00104  protected:
00106     AdaptCurve();
00107 
00108 private:
00109   boost::shared_ptr<SplineCurve> prev_crv_;
00110   boost::shared_ptr<SplineCurve> curr_crv_;
00111   double prev_maxdist_;
00112   double prev_avdist_;
00113   double maxdist_;
00114   double avdist_;
00115   double aepsge_;
00116   double smoothweight_;
00117   double smoothfac_;
00118 
00119   const EvalCurve *evalcrv_;
00120 
00121   int dim_;
00122   std::vector<double> points_;
00123   std::vector<double> parvals_;
00124   std::vector<double> pt_weight_;
00125   std::vector<Point> start_pt_; // Pt, der. May be empty.
00126   std::vector<Point> end_pt_; // Pt, der. May be empty.
00127 
00128   int cont_;     // Continuity of approximation
00129   int order_;    // Order of approximating curve
00130 
00131   int fix_[2];   // Number of coefficients to fix in the endpoints
00132   int init_sample_;  // Initial number of sample points
00133   double min_sample_par_;  // Parameter of first sample point
00134   double max_sample_par_;  // Parameter of last sample point
00135 
00137   void makeInitCurve();
00138 
00139   void makeInitCurve(int in, int ik, std::vector<double> knots);
00140 
00141   void makeInitCurve(int in, int ik);
00142   
00144   void initSamples();
00145 
00148   void adjustSmoothWeight();
00149 
00151   void makeSmoothCurve();
00152 
00154   void checkAccuracy(std::vector<double>& newknots, int uniform=1);
00155 
00156   void getConstraints(std::vector<sideConstraint>& pt_constraints,
00157                       std::vector<sideConstraint>& tangent_constraints);
00158 
00159 };
00160 }
00161 
00162 #endif
00163 
Generated on Tue Sep 21 15:44:16 2010 for GoTools Core by  doxygen 1.6.3