ParamSurfaceInt.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 _PARAMSURFACEINT_H
00034 #define _PARAMSURFACEINT_H
00035 
00036 
00037 #include "ParamGeomInt.h"
00038 #include "ParamSurface.h"
00039 
00040 
00041 namespace Go {
00044 
00045 
00046 
00047 class AlgObj3DInt;
00048 class ImplicitizeSurfaceAlgo;
00049 class RotatedBox;
00050 
00051 
00054 
00055 class ParamSurfaceInt : public ParamGeomInt {
00056 public:
00061     explicit ParamSurfaceInt(boost::shared_ptr<ParamSurface> surf,
00062                              ParamGeomInt* parent = 0);
00063     
00065     virtual ~ParamSurfaceInt();
00066     
00071     virtual void point(Point& pt, const double* tpar) const 
00072     { surf_->point(pt, tpar[0], tpar[1]); }
00073 
00085     virtual void point(std::vector<Point>& pt, 
00086                        const double* tpar, 
00087                        int derivs,
00088                        const bool* from_right = 0,
00089                        double resolution = 1.0e-12) const 
00090     {
00091         if (from_right) {
00092             surf_->point(pt, tpar[0], tpar[1], derivs, from_right[0], 
00093                          from_right[1], resolution);
00094         } else {
00095             surf_->point(pt, tpar[0], tpar[1], derivs, true, true,
00096                          resolution);
00097         }
00098     }
00099 
00102     virtual ParamSurfaceInt* getParamSurfaceInt();
00103 
00104 //     boost::shared_ptr<ParamSurface> getSurface()
00105 //     { return surf_; }
00106 //     boost::shared_ptr<const ParamSurface> getSurface() const
00107 //     { return surf_;}
00108 
00112     boost::shared_ptr<ParamSurface> getParamSurface()
00113     { return surf_; }
00114 
00118     boost::shared_ptr<const ParamSurface> getParamSurface() const
00119     { return surf_;}
00120 
00127     boost::shared_ptr<ParamSurface> getParentParamSurface(RectDomain& domain);
00128 
00133     boost::shared_ptr<ParamSurface> getParentParamSurface();
00134 
00139     virtual boost::shared_ptr<ParamSurfaceInt>
00140     makeIntObject(boost::shared_ptr<ParamSurface> surf);
00141 
00147     virtual boost::shared_ptr<ParamCurveInt> 
00148     makeIntCurve(boost::shared_ptr<ParamCurve> crv, ParamGeomInt* parent);
00149 
00151     virtual int numParams() const
00152     { return 2;}
00153 
00154 //     int checkCoincidence(double start, double end,
00155 //                       ParamSurfaceInt *other,
00156 //                       double other_start, double other_end);
00157 
00166     boost::shared_ptr<ParamCurve> 
00167     getIsoCurve(double param_start, double param_end,
00168                 double isoval, bool pardir_is_u) const;
00169 
00175     boost::shared_ptr<ParamCurve>
00176     getConstantParameterCurve(int dir, double par);
00177 
00178     boost::shared_ptr<ParamCurve>
00179     getConstantParameterCurve(int dir, double par, double tmin, double tmax);
00180 
00181     void 
00182         minimumAlongCurve(int dir, double par, double tmin, double tmax,
00183                           Point& pnt, double& minpar, Point& minval, 
00184                           double& mindist);
00185 
00193     virtual void getLengthAndWiggle(double *length, double *wiggle);
00194 
00199     virtual bool hasInnerKnots(int pardir) const;
00200 
00205     virtual bool hasCriticalVals(int pardir) const;
00206 
00211     virtual bool hasCriticalValsOrKnots(int pardir) const;
00212 
00216     virtual bool canDivide(int pardir);
00217 
00218     virtual bool canDivideTinyTriang(int pardir);
00219 
00224     virtual std::vector<double> getCriticalVals(int pardir) const;
00225 
00230     virtual std::vector<double> getInnerKnotVals(int pardir,
00231                                                  bool sort = false) const; 
00232 
00237     virtual std::vector<double> getCriticalValsAndKnots(int pardir) const;
00238 
00243     virtual int getMeshSize(int dir);
00244 
00250     virtual double paramFromMesh(int dir, int idx);
00251 
00253     virtual std::vector<double>::iterator getMesh();
00254 
00258     virtual double startParam(int pardir) const;
00259 
00263     virtual double endParam(int pardir) const;
00264 
00270     virtual bool boundaryPoint(const double* par, double eps) const;
00271 
00275     std::vector<double> getMima() const;
00276 
00282     virtual bool inCorner(const double *par, double epspar) const;
00283 
00284     bool atDegenerateBd(const double *par, double epsge, double epspar);
00285 
00295     virtual void
00296     subdivide(int pardir, double par, 
00297               std::vector<boost::shared_ptr<ParamGeomInt> >& subdiv_objs,
00298               std::vector<boost::shared_ptr<ParamGeomInt> >& bd_objs);
00299 
00313     virtual std::vector<boost::shared_ptr<ParamSurfaceInt> >
00314     subSurfaces(double from_upar, double from_vpar,
00315                 double to_upar, double to_vpar,
00316                 double fuzzy);
00317 
00320     virtual CompositeBox compositeBox() const;
00321 
00324     virtual DirectionCone directionCone() const;
00325 
00328     virtual void 
00329     getBoundaryObjects(std::vector<boost::
00330                        shared_ptr<BoundaryGeomInt> >& bd_objs);
00331 
00343     virtual int checkPeriodicity(int pardir) const;
00344 
00346     virtual int dimension() const
00347     { return dim_; }
00348 
00351     virtual const RectDomain& getDomain() const
00352     { return domain_;}
00353 
00357     const RectDomain& getDegDomain(double epsge);
00358 
00363     virtual bool isSimple();
00364 
00367     virtual bool isSpline();
00368 
00371     virtual bool isIsoParametric(ParamCurveInt *curve, int dir, double par,
00372                                  double ptol, double tol)
00373         { return false; }  // Default behaviour
00374 
00382     virtual double getOptimizedConeAngle(Point& axis1, Point& axis2);
00383 
00392     virtual void knotIntervalFuzzy(double& u, double&v,
00393                                    double utol, double vtol) const; 
00394 
00404     virtual double nextSegmentVal(int dir, double par,
00405                                   bool forward, double tol) const;
00406 
00407     // Degeneracy
00410     bool isDegenerate(double epsge);
00411 
00416     virtual int isDegenerate(double epsge, int dir);
00417 
00424     virtual bool isDegenerate(double epsge, int dir, double *par);
00425 
00434     double isolateDegPar(int dir, int deg_edge, double threshold, double *deg_factor=NULL);
00435 
00438     void setDegTriang()
00439     { deg_triang_ = true; }
00440 
00443     bool getDegTriang()
00444     { return deg_triang_; }
00445     
00453     double getParOffBd(int dir, bool atstart, double tol) const;
00454 
00467     void  first_fund_form(double u, 
00468                           double v, 
00469                           bool u_from_right, 
00470                           bool v_from_right, 
00471                           double& E, 
00472                           double& F, 
00473                           double& G) const
00474     {
00475         // Getting first derivatives
00476         surf_->point(temp_point_array_, u, v, 1,
00477                      u_from_right, v_from_right); 
00478         
00479         E = temp_point_array_[1] * temp_point_array_[1];
00480         F = temp_point_array_[1] * temp_point_array_[2];
00481         G = temp_point_array_[2] * temp_point_array_[2];
00482     }
00483 
00498     void second_fund_form(double u, 
00499                           double v, 
00500                           bool u_from_right,
00501                           bool v_from_right,
00502                           double& L, 
00503                           double& M, 
00504                           double& N) const
00505     {
00506         // Getting second derivatives
00507         surf_->point(temp_point_array_, u, v, 2,
00508                      u_from_right, v_from_right); 
00509         // Getting normal (we suppose that the surface contains a
00510         // continuous first derivative...)
00511         surf_->normal(temp_point_array_[0], u, v); // Setting first
00512                                                    // point to normal
00513                                                    // vec
00514 
00515         L = temp_point_array_[3] * temp_point_array_[0];  // d2r/du2 . N
00516         M = temp_point_array_[4] * temp_point_array_[0];  // d2r/dudv . N
00517         N = temp_point_array_[5] * temp_point_array_[0];  // d2r/dv2 . N
00518     }
00519 
00531     void derivs(double u, 
00532                 double v, 
00533                 Point& deriv_u, 
00534                 Point& deriv_v,
00535                 bool from_right_1 = true,
00536                 bool from_right_2 = true) const
00537     {
00538         surf_->point(temp_point_array_, u, v, 1,
00539                      from_right_1, from_right_2);
00540         deriv_u = temp_point_array_[1];
00541         deriv_v = temp_point_array_[2];
00542     }
00543 
00554     void normal(double u, 
00555                 double v, 
00556                 Point& normal,
00557                 bool from_right_1 = true,
00558                 bool from_right_2 = true) const
00559     {
00560         surf_->point(temp_point_array_, u, v, 1,
00561                      from_right_1, from_right_2);
00562         normal = temp_point_array_[1] % temp_point_array_[2];
00563     }
00564 
00571     virtual RotatedBox getRotatedBox(std::vector<Point>& axis) const;
00572 
00573 //     virtual void dumpToStream(std::ostream& os) const
00574 //     {
00575 //      surf_->writeStandardHeader(os);
00576 //      surf_->write(os);
00577 //     }
00578 
00582     void axisFromCorners(Point& axis1, Point& axis2) const;
00583 
00588     virtual void splitAtG0(double angtol,
00589                            std::vector<boost::
00590                            shared_ptr<ParamSurfaceInt> >& subG1);
00591 
00599     void getSingularity(double eps, double sing_par[], Point& sing_pt,
00600                         double& sing_val, double *seed);
00601 
00605     bool canSelfIntersect(double epsge) const;
00606 
00610     virtual boost::shared_ptr<ParamSurfaceInt> getNormalSurface() const
00611     {
00612         boost::shared_ptr<ParamSurfaceInt> dummy;
00613         return dummy;
00614     }
00615 
00619     virtual bool canImplicitize()
00620     { return false; }
00621 
00625     virtual bool implicitize(double tol)
00626     { return false; }
00627 
00637     // @@sbr Todo (tol2)!!!
00638     virtual bool getImplicit(double tol, double& tol2,
00639                              AlgObj3DInt& alg_obj_3d_int)
00640     { return false; }
00641 
00642 //     /// Find the maximum curvature in a number of isocurves.
00643 //     /// \param dir_is_u the direction of the isocurves.
00644 //     /// \param nmb_params the number of isocurves to check.
00645 //     /// \param iso_from start parameter of domain of interest in the
00646 //     /// isocurves.
00647 //     /// \param iso_to end parameter of domain of interest in the
00648 //     /// isocurves.
00649 //     /// \param guess_param initial guess for the parameter value with
00650 //     /// the highest curvature.
00651 //     /// \param max_curv_params the parameter values for the maximum
00652 //     /// curvature in each isocurve.
00653 //     /// \param max_curvatures the maximum curvature in each isocurve,
00654 //     /// corresponding the parameters in max_curv_params.
00655      void maxCurvatures(bool dir_is_u, int nmb_params, double iso_from,
00656                        double iso_to, double guess_param,
00657                        std::vector<double>& max_curv_params,
00658                        std::vector<double>& max_curvatures);
00659 
00660 
00661 protected:
00662     // Data members
00663     boost::shared_ptr<ParamSurface> surf_;
00664     int dim_; // Space dimension.
00665     double deg_tol_;
00666     bool deg_triang_;
00667 
00668     std::vector<std::pair<double, int> > segment_[2];
00669 
00670    // Generated data
00671     bool bd_deg_[4];  // Degeneracy, sequence left, right, bottom, top
00672     RectDomain domain_;
00673     RectDomain deg_domain_;   // Reduced domain for degenerate surfaces used in closest
00674                               // point computations
00675     // Approximating mesh
00676     mutable int nmesh_[2];
00677     mutable std::vector<double> mesh_;
00678 
00679     mutable DirectionCone cone_;
00680 
00681     mutable bool lw_set_;
00682     mutable double length_[2], wiggle_[2];
00683 
00684 //     const static int nder_ = 2; // Order of derivatives to be
00685 //                              // calulated.
00686 //     double delta_;
00687 //     std::vector<Point> ft_;     // Partial derivatives up to order
00688 //                              // nder
00689 //     std::vector<Point> gs_;     // Partial derivatives up to order
00690 //                              // nder
00691     mutable std::vector<Point> temp_point_array_;
00692 
00693     // Implicit objects
00694     boost::shared_ptr<ImplicitizeSurfaceAlgo> impl_sf_algo_;
00695     double implicit_tol_; // Error tolerance used when creating
00696                           // impl_sf_algo_.
00697     int impl_deg_;
00698     boost::shared_ptr<AlgObj3DInt> implicit_obj_;
00699     double implicit_err_;
00700  
00701     
00702  private:
00703     void makeMesh(int size1, int size2) const;
00704 
00705     void computeDegDomain(double aepsge);
00706 
00707 };
00708 
00709 
00711 } // namespace Go
00712 
00713 
00714 #endif // _PARAMSURFACEINT_H
00715 

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