Param2FunctionInt.h

00001 //===========================================================================
00002 // GoTools - SINTEF Geometry Tools
00003 //
00004 // GoTools module: Intersections, version 1.0
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 _PARAM2FUNCTIONINT_H
00034 #define _PARAM2FUNCTIONINT_H
00035 
00036 
00037 #include "ParamFunctionInt.h"
00038 #include "ParamSurface.h"
00039 
00040 
00041 namespace Go {
00044 
00045 
00046 
00047 class SplineSurface;
00048 
00049 
00052 
00053 class Param2FunctionInt : public ParamFunctionInt {
00054 public:
00058     explicit Param2FunctionInt(boost::shared_ptr<ParamSurface> surf);
00059 
00064     explicit Param2FunctionInt(boost::shared_ptr<ParamSurface> surf,
00065                                Param2FunctionInt *parent);
00066 
00068     virtual ~Param2FunctionInt() {};
00069 
00074     virtual void point(Point& res, const double *par) const
00075     { surf_->point(res, par[0], par[1]); }
00076 
00088     virtual void point(std::vector<Point>& pt, 
00089                        const double* tpar, 
00090                        int der,
00091                        const bool* from_right = 0,
00092                        double resolution = 1.0e-12) const
00093     {
00094         if (from_right == 0) { // User did not specify direction of
00095                                // differentiation
00096             surf_->point(pt, tpar[0], tpar[1], der, true, true);
00097         } else {
00098             surf_->point(pt, tpar[0], tpar[1], der,
00099                          from_right[0], from_right[1], resolution);
00100         } 
00101     }
00102 
00104     virtual Param2FunctionInt* getParam2FunctionInt();
00105 
00107     boost::shared_ptr<ParamSurface> getParamSurface();
00109     boost::shared_ptr<const ParamSurface> getParamSurface() const;
00110 
00115     boost::shared_ptr<ParamSurface>
00116     getParentParamSurface(RectDomain& domain);
00121     boost::shared_ptr<ParamSurface> getParentParamSurface();
00122 
00127     virtual boost::shared_ptr<Param2FunctionInt> 
00128     makeIntFunction(boost::shared_ptr<ParamSurface> surf);
00129     
00131     virtual int numParams() const;
00132 
00141     boost::shared_ptr<ParamCurve> 
00142     getIsoCurve(double param_start, double param_end,
00143                 double isoval, bool pardir_is_u) const;
00144 
00147     boost::shared_ptr<ParamCurve>
00148         getConstantParameterCurve(int dir, double par);
00149 
00157     virtual void getLengthAndWiggle(double *length, double *wiggle);
00158 
00163     virtual bool hasInnerKnots(int pardir) const;
00164 
00169     virtual bool hasCriticalVals(int pardir) const;
00170 
00175     virtual bool hasCriticalValsOrKnots(int pardir) const;
00176 
00180     virtual bool canDivide(int pardir);
00181 
00186     virtual std::vector<double> getCriticalVals(int pardir) const;
00187 
00192     virtual std::vector<double> getInnerKnotVals(int pardir,
00193                                                  bool sort = false) const;
00194 
00199     virtual std::vector<double> getCriticalValsAndKnots(int pardir) const;
00200 
00205     virtual int getMeshSize(int dir);
00206 
00212     virtual double paramFromMesh(int dir, int idx);
00213 
00215     virtual std::vector<double>::iterator getMesh();
00216 
00217     // @@sbr A trimmed sf need not have a startparam/endparam ...
00221     virtual double startParam(int pardir) const;
00222 
00226     virtual double endParam(int pardir) const;
00227 
00233     virtual bool boundaryPoint(const double* par, double eps) const;
00234 
00238     std::vector<double> getMima() const;
00239 
00249     virtual void subdivide(int pardir, double par, 
00250                            std::vector<boost::
00251                            shared_ptr<ParamFunctionInt> >& subdiv_objs,
00252                            std::vector<boost::
00253                            shared_ptr<ParamFunctionInt> >& bd_objs);
00254 
00255     // We want to know if there exists par direction in which the
00256     // function is monotone (guarantees at most one solution for a
00257     // continuous function).  We also would like to know in what
00258     // direction the function is monotone (will then move in
00259     // orthogonal direction).
00264     virtual bool monotone(Point& dir, double tol=1.0e-15) const;
00265 
00268     virtual CompositeBox compositeBox() const;
00269 
00272     virtual void 
00273     getBoundaryObjects(std::vector<boost::
00274                        shared_ptr<BoundaryFunctionInt> >& bd_objs);
00275 
00277     int dimension()
00278     { return dim_; }
00279     
00288     double isolateDegPar(int dir, int deg_edge, double threshold);
00289 
00290     // Functions used from coincidence checking
00291 
00298     void assureInRange(int pardir, double& t);
00299  
00300     // Find the interval in which t lies, if t is within tol of an
00301     // existing knot, t will be changed to that knot.
00302 
00310     virtual int knotIntervalFuzzy(int pardir, double& t, double tol) const;
00311     
00319     virtual double nextSegmentVal(int pardir, double par, bool forward) const;
00320 
00325     bool isDegenerate(double epsge, int pardir);
00326 
00333     virtual bool isDegenerate(double epsge, int pardir, double* par);
00334 
00337     boost::shared_ptr<ParamSurface> getSurface()
00338     { return surf_; }
00339 
00342     boost::shared_ptr<const ParamSurface> getSurface() const
00343     { return surf_;}
00344 
00350     void derivs(double u, double v,
00351                 Point& deriv_u, Point& deriv_v) const
00352     {
00353         surf_->point(temp_point_array_, u, v, 1);
00354         deriv_u = temp_point_array_[1];
00355         deriv_v = temp_point_array_[2];
00356     }
00357 
00358 protected:
00359     // Data members
00360 
00361     boost::shared_ptr<ParamSurface> surf_; // Our 2D-parametric 1D
00362                                            // function (R^2->R).
00363 
00364     int dim_; // Space dimension. 1.
00365 
00366     Param2FunctionInt *parentfunction_; // Probably undivided sf, to
00367                                         // avoid num error.
00368 
00369     std::vector<std::pair<double, int> > segment_[2];
00370 
00371     // pardir (0 || 1) is that opposite bdidx (i.e. dir of constant
00372     // parameter tpar along edge given by bdidx).
00373     Go::SplineCurve* extractBdCurve(const Go::SplineSurface&, int bdidx,
00374                                     int& pardir, double& tpar) const;
00375 
00376     // Generated data
00377     // @@sbr Possibly include more of the computed datas. For instance
00378     // structure conc monotonicity.
00379     bool bd_deg_[4];  // Degeneracy, sequence left, right, bottom, top
00380     double deg_tol_;
00381     RectDomain domain_;
00382     // Approximating mesh
00383     mutable int nmesh_[2];
00384     mutable std::vector<double> mesh_;
00385 
00386     mutable std::vector<Point> temp_point_array_;
00387 
00388 };
00389 
00390 
00392 } // namespace Go
00393 
00394 
00395 #endif // _PARAM2FUNCTIONINT_H
00396 
00397 

Generated on Fri Nov 23 12:24:33 2007 for GoTools Intersections Library by  doxygen 1.5.1