BoundedSurface.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 _GOBOUNDEDSURFACE_H
00034 #define _GOBOUNDEDSURFACE_H
00035 
00036 #include "ParamSurface.h"
00037 #include "CurveOnSurface.h"
00038 #include "CurveBoundedDomain.h"
00039 
00040 using boost::shared_ptr;
00041 using std::vector;
00042 
00043 namespace Go
00044 {
00047 
00048 
00050 class BoundedSurface : public ParamSurface
00051 {
00052 public:
00053 
00055     BoundedSurface();
00056 
00067     BoundedSurface(shared_ptr<ParamSurface> surf,
00068                      vector<shared_ptr<CurveOnSurface> > loop,
00069                      double space_epsilon);
00070 
00071 
00085     BoundedSurface(shared_ptr<ParamSurface> surf,
00086                      vector<vector<shared_ptr<CurveOnSurface> > > loops,
00087                      double space_epsilon);
00088 
00090     virtual ~BoundedSurface();
00091 
00092 
00093     // From Streamable
00094 
00095     // @afr: These should not be called!
00097     virtual void read (std::istream& is);
00099     virtual void write (std::ostream& os) const;
00100 
00101     // From GeomObject
00102 
00104     virtual BoundingBox boundingBox() const;
00105 
00107     virtual int dimension() const;
00108 
00110     virtual ClassType instanceType() const;
00111 
00113     static ClassType classType()
00114     { return Class_BoundedSurface; }
00115 
00117     virtual BoundedSurface* clone() const
00118     { return new BoundedSurface(*this); }
00119 
00120     // From ParamSurface
00121 
00125     virtual DirectionCone normalCone() const;
00126 
00134     virtual DirectionCone tangentCone(bool pardir_is_u) const;
00135 
00141     virtual const CurveBoundedDomain& parameterDomain() const;
00142 
00148     virtual RectDomain containingDomain() const;
00149 
00150 
00156     virtual CurveLoop outerBoundaryLoop(double degenerate_epsilon
00157                                           = DEFAULT_SPACE_EPSILON) const;
00158 
00167     virtual std::vector<CurveLoop> allBoundaryLoops(double degenerate_epsilon
00168                                                       = DEFAULT_SPACE_EPSILON) const;
00169 
00177     std::vector<CurveLoop> absolutelyAllBoundaryLoops() const;
00178 
00179 
00184     virtual void point(Point& pt, double upar, double vpar) const;
00185 
00186 
00210     virtual void point(std::vector<Point>& pts, 
00211                        double upar, double vpar,
00212                        int derivs,
00213                        bool u_from_right = true,
00214                        bool v_from_right = true,
00215                        double resolution = 1.0e-12) const;
00216 
00231     virtual void point(std::vector<Point>& pts, 
00232                        double upar, double vpar,
00233                        int derivs) const;
00234 
00235     //    using ParamSurface::point;
00240     virtual void normal(Point& n, double upar, double vpar) const;
00241 
00252     virtual std::vector<boost::shared_ptr<ParamCurve> >
00253     constParamCurves(double parameter, bool pardir_is_u) const;
00254 
00268     virtual std::vector<boost::shared_ptr<ParamSurface> >
00269     subSurfaces(double from_upar, double from_vpar,
00270                 double to_upar, double to_vpar,
00271                 double fuzzy = DEFAULT_PARAMETER_EPSILON) const;
00272 
00291     virtual double nextSegmentVal(int dir, double par, bool forward, double tol) const;
00292 
00305     virtual void closestPoint(const Point& pt,
00306                               double&        clo_u,
00307                               double&        clo_v, 
00308                               Point&       clo_pt,
00309                               double&        clo_dist,
00310                               double         epsilon,
00311                               const RectDomain* domain_of_interest = NULL,
00312                               double   *seed = 0) const;
00313 
00314 
00317     virtual void closestBoundaryPoint(const Point& pt,
00318                                       double&        clo_u,
00319                                       double&        clo_v, 
00320                                       Point&       clo_pt,
00321                                       double&        clo_dist,
00322                                       double epsilon,
00323                                       const RectDomain* domain_of_interest = NULL,
00324                                       double *seed = 0) const;
00325 
00348     virtual void getBoundaryInfo(Point& pt1, Point& pt2, 
00349                                  double epsilon, SplineCurve*& cv,
00350                                  SplineCurve*& crosscv, double knot_tol = 1e-05) const;
00351 
00352 
00361     void getBoundaryInfo(Point& pt1, Point& pt2,
00362                          vector<shared_ptr<CurveOnSurface> >& bd_cvs) const;
00363 
00365     virtual void turnOrientation();
00366 
00371     virtual void reverseParameterDirection(bool direction_is_u);
00372 
00373     // If a segment in a loop in boundary_loops_ is not G1, curve is split.
00374     // Function to be called prior to a topology builder relying on smooth segments.
00375 
00381     void makeBoundaryCurvesG1(double kink);
00382 
00384     virtual void swapParameterDirection();
00385 
00392     void setParameterDomain(double u1, double u2, double v1, double v2);
00393 
00394     // If a boundary loop is represented as a single curve, it is split into 3 parts.
00395     // Handy tue to current limitations in topology analysator.
00396 
00400     void splitSingleLoops();
00401 
00402     // Access functions
00403 
00406     shared_ptr<ParamSurface> underlyingSurface()
00407     { return surface_; }
00408 
00411     shared_ptr<const ParamSurface> underlyingSurface() const
00412     { return surface_; }
00413 
00415     int numberOfLoops()
00416       { return boundary_loops_.size(); }
00417 
00419     shared_ptr<CurveLoop> loop(int idx)
00420       { return boundary_loops_[idx]; }
00421 
00431     SplineCurve* constParamCurve(double parameter, bool direction_is_u) const;
00432 
00444     virtual bool isDegenerate(bool& b, bool& r,
00445                               bool& t, bool& l, double tolerance) const;
00446 
00447 
00448 private:
00450     shared_ptr<ParamSurface> surface_;
00451 
00454     vector<shared_ptr<CurveLoop> > boundary_loops_;
00455 
00456     mutable CurveBoundedDomain domain_;
00457 
00460     void orderBoundaryLoops(double degenerate_epsilon = DEFAULT_SPACE_EPSILON);
00461 
00462     // We want the boundary curve to be at least c1. To be called from public function.
00463     vector<shared_ptr<CurveOnSurface> >
00464     splitIntoC1Curves(shared_ptr<CurveOnSurface>& curve, double space_epsilon, double kink);
00465 
00466     // Run through the bounday loops, returning the smallest epsgeo.
00467     double getEpsGeo() const;
00468 
00469 };
00470 
00471 
00473 } // namespace Go
00474 
00475 
00476 #endif // _GOBOUNDEDSURFACE_H
00477 
00478 

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