SmoothTransition.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 _GOSMOOTHTRANSITION_H_
00034 #define _GOSMOOTHTRANSITION_H_
00035 
00036 #include <boost/smart_ptr.hpp>
00037 
00038 #include "Point.h"
00039 #include "EvalCurveSet.h"
00040 #include "SplineCurve.h"
00041 #include "SplineSurface.h"
00042 #include "SISLconversion.h"
00043 
00044 namespace Go
00045 {
00048 
00049 
00056 
00057 class SmoothTransition : public EvalCurveSet
00058 {
00059 public:
00060 
00062     SmoothTransition(boost::shared_ptr<const SplineCurve>& inters_crv,
00063                      boost::shared_ptr<const SplineCurve>& p_crv1,
00064                      boost::shared_ptr<const SplineCurve>& p_crv2,
00065                      boost::shared_ptr<const ParamSurface> surf1,
00066                      boost::shared_ptr<const ParamSurface> surf2,
00067                      double offset_dist1, double offset_dist2,
00068                      double epsgeo);
00069 
00070     // Inherited from EvalCurve
00071 
00073     virtual ~SmoothTransition();
00074     virtual std::vector<Point> eval( double t); // offset1, offset1p, offset1_cross_tan,
00075     // offset2, offset2p, offset2_cross_tan
00076     virtual void eval(double t, int n, std::vector<std::vector<Point> >& der); // Exact value.
00077     virtual double start();
00078     virtual double end();
00079     virtual int dim(); // Dimension of space, i.e. 3.
00080     virtual bool approximationOK(double par, const std::vector<Point>& approxpos,
00081                                  double tol1, double tol2);
00082     virtual int nmbCvs()
00083     { return 6; }
00084 
00085 private:
00086     boost::shared_ptr<const SplineCurve> inters_crv_;
00087     // Param curves serve as seed generators for closest point eval.
00088     boost::shared_ptr<const SplineCurve> p_crv1_;
00089     boost::shared_ptr<const SplineCurve> p_crv2_;
00090     boost::shared_ptr<const ParamSurface> surf1_;
00091     boost::shared_ptr<const ParamSurface> surf2_;
00092     boost::shared_ptr<const SplineSurface> under_surf1_;
00093     boost::shared_ptr<const SplineSurface> under_surf2_;
00094     double offset_dist1_; // In direction normal to surf1_.
00095     double offset_dist2_; // In direction normal to surf2_.
00096     const double epsgeo_;
00097     const double kinktol_;
00098     std::vector<double> tangent_lengths_; // We set required lengths on the tangents (0, 1, 3, 4).
00099 
00100     // Given space point, we project onto surface, returning parameter values.
00101     // If seed has size two, value is used in closest point evaluation.
00102     Point projectPoint(const Point& space_pt, const ParamSurface& surf,
00103                        std::vector<double>& seed, bool boundary_pt,
00104                        double epsgeo, double& dist);
00105 
00106     // Given input we compute the point and tangent std::vector of the cross tangent curve.
00107     // space_pt must be of size 2, local_pt of size derivs+1 (derivs not larger than 1).
00108     std::vector<Point> computeCrosstangentValues(std::vector<Point>& space_pt,
00109                                                  std::vector<Point>& local_pt, int derivs);
00110 
00111     // We try to guess parameter values of intersection between sf1 & sf2 & plane defined by
00112     // inters_cv_pt and it's tangent. Tangent is not needed as it is defined by normal in sfs.
00113     void guessParameterPoints(const Point& inters_cv_pt, double t,
00114                               const SplineCurve& inters_cv,
00115                               const ParamSurface& sf1, const ParamSurface& sf2,
00116                               const SplineCurve& p_inters_cv1, const SplineCurve& p_inters_cv2,
00117                               double offset_dist1, double offset_dist2,
00118                               Point& guess_pt1, Point& guess_pt2);
00119 
00120     // param_cv may be parametrized in the opposite direction, as given by pcv_turned.
00121     std::vector<double>
00122     getSuggestedSurfaceParameter(const SplineCurve& space_cv, double t,
00123                                  const SplineCurve& param_cv,
00124                                  bool pcv_turned);
00125 
00126     // Given a point in space, close to input surface point, we use partial derivatives in input
00127     // point to make a guess on parameter values of projection of space point.
00128     // surf_par_pt is of dimension 2, while space_pt shares dimension with surf.
00129     std::vector<double> getSuggestedSurfaceParameter(Point& surf_par_pt, const ParamSurface& surf,
00130                                                      Point& space_pt, double tolerance);
00131 
00132     void offsetIntersectionPoints(std::vector<Point>& ep, std::vector<Point>& eq,
00133                                   std::vector<Point>& eoffp, std::vector<Point>& eoffq,
00134                                   Point& eparp, Point& eparq,
00135                                   std::vector<Point>& espine, std::vector<Point>& egeobb1,
00136                                   std::vector<Point>& egeobb2, std::vector<Point>& ecrtan1,
00137                                   std::vector<Point>& ecrtan2, std::vector<Point>& egeop,
00138                                   std::vector<Point>& egeoq, std::vector<double>& curv_radis);
00139 
00140     void offsetIntersectionIterate(double arad1, double arad2, std::vector<Point>& epoint,
00141                                    std::vector<Point>& epnt1, std::vector<Point>& epnt2,
00142                                    Point& epar1, Point& epar2,
00143                                    const SplineSurface& psurf1, const SplineSurface& psurf2,
00144                                    double astep, double aepsge, std::vector<Point>& gpnt1,
00145                                    std::vector<Point>& gpnt2, std::vector<Point>& goffpnt1,
00146                                    std::vector<Point>& goffpnt2, Point& gpar1,
00147                                    Point& gpar2p);
00148 
00149     void blend_s1421(const SplineSurface* ps, double aoffset, int ider,
00150                      const Point& epar, int& ilfs, int& ilft,
00151                      std::vector<Point>& eoffpnt, std::vector<Point>& epnt, int* jstat);
00152 
00153 
00154 };
00155 
00157 } // namespace Go
00158 
00159 #endif // _GOSMOOTHTRANSITION_H_
00160 

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