Param1FunctionInt.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 _PAR1FUNCINT_H
00034 #define _PAR1FUNCINT_H
00035 
00036 
00037 #include "ParamFunctionInt.h"
00038 #include "ParamCurve.h"
00039 
00040 
00041 namespace Go {
00044 
00045 
00046 
00049 
00050 class Param1FunctionInt : public ParamFunctionInt {
00051 public:
00055     explicit Param1FunctionInt(boost::shared_ptr<ParamCurve> curve);
00056 
00062     explicit Param1FunctionInt(boost::shared_ptr<ParamCurve> curve, 
00063                                ParamFunctionInt *parent);
00064 
00066     virtual ~Param1FunctionInt();
00067 
00072     virtual void point(Point& res, const double *par) const
00073     { curve_->point(res, par[0]); }
00074 
00081     virtual void point(std::vector<Point>& res, double par, int der)
00082     { curve_->point(res, par, der); }
00083 
00095     virtual void point(std::vector<Point>& pt, 
00096                        const double* tpar, 
00097                        int derivs,  
00098                        const bool* from_right = 0,
00099                        double resolution = 1.0e-12) const
00100     {
00101         bool fr = (from_right != 0) ? from_right[0] : true;
00102         pt = curve_->point(*tpar, derivs, fr);
00103     }
00104 
00106     virtual Param1FunctionInt* getParam1FunctionInt();
00107 
00109     boost::shared_ptr<ParamCurve> getParamCurve();
00111     boost::shared_ptr<const ParamCurve> getParamCurve() const;
00112 
00117     boost::shared_ptr<ParamCurve> getParentParamCurve(double& start,
00118                                                       double& end);
00123     boost::shared_ptr<ParamCurve> getParentParamCurve();
00124 
00129     virtual boost::shared_ptr<Param1FunctionInt> 
00130     makeIntFunction(boost::shared_ptr<ParamCurve> curve);
00131     
00133     virtual int numParams() const;
00134 
00142     virtual void getLengthAndWiggle(double *length, double *wiggle);
00143 
00148     virtual bool hasInnerKnots(int pardir) const;
00149 
00154     virtual bool hasCriticalVals(int pardir) const;
00155 
00160     virtual bool hasCriticalValsOrKnots(int pardir) const;
00161 
00165     virtual bool canDivide(int pardir);
00166 
00171     virtual std::vector<double> getCriticalVals(int pardir) const;
00172 
00177     virtual std::vector<double> getInnerKnotVals(int pardir,
00178                                                  bool sort = false) const;
00179 
00184     virtual std::vector<double> getCriticalValsAndKnots(int pardir) const;
00185 
00190     virtual int getMeshSize(int dir);
00191 
00197     virtual double paramFromMesh(int dir, int idx);
00198 
00200     virtual std::vector<double>::iterator getMesh();
00201 
00205     virtual double startParam(int pardir) const
00206     { return curve_->startparam(); }
00207 
00211     virtual double endParam(int pardir) const
00212     { return curve_->endparam(); }
00213 
00219     virtual bool boundaryPoint(const double* par, double eps) const;
00220 
00230     virtual void subdivide(int pardir, double par, 
00231                            std::vector<boost::
00232                            shared_ptr<ParamFunctionInt> >& subdiv_objs,
00233                            std::vector<boost::
00234                            shared_ptr<ParamFunctionInt> >& bd_objs);
00235 
00236     // Accepts non-strict monotonicity, as long as sf is not totally
00237     // flat.
00243     virtual bool monotone(Point& dir, double tol=1.0e-15) const; // = 0;
00244 
00246     virtual CompositeBox compositeBox() const;
00247 
00250     virtual void 
00251     getBoundaryObjects(std::vector<boost::
00252                        shared_ptr<BoundaryFunctionInt> >& bd_objs);
00253 
00255     int dimension()
00256     { return dim_; }
00257 
00259     double startparam() const
00260     { return curve_->startparam(); }
00262     double endparam() const
00263     { return curve_->endparam(); }
00264 
00265     // Functions used from coincidence checking
00266 
00271     void assureInRange(double& t);
00272  
00278     virtual int knotIntervalFuzzy(double& t, double tol) const;
00279     
00285     virtual double nextSegmentVal(double par, bool forward) const;
00286 
00293     virtual bool isDegenerate(double epsge, int dir, double *par);
00294 
00295 protected:
00296 
00297     // Data members
00298     // The curve defining the parameter domain.
00299     // However it need not be 1d, could be part of a composite
00300     // function.
00301     // Other parts of the curve (as well as evaluators) will then lie
00302     // in a subclass.
00303     boost::shared_ptr<ParamCurve> curve_; // Our param curve (R->R).
00304 
00305     int dim_; // Space dimension. 1.
00306 
00307     Param1FunctionInt *parentcurve_; // @@sbr Or surface ... Currently cv.
00308 
00309     std::vector<std::pair<double, int> > segment_;
00310 
00311     // Approximating polygon
00312     mutable std::vector<double> mesh_;
00313 
00314     double deg_tol_; // Object should not be subdivided if it is
00315                      // already degenerate.
00316 
00317 private:
00318     // Make approximating polygon
00319     void makeMesh(int size);
00320 
00321 };
00322 
00323 
00325 } // namespace Go
00326 
00327 
00328 #endif // _PAR1FUNCINT_H
00329 
00330 

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