CurveBoundedDomain.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 _GOCURVEBOUNDEDDOMAIN_H
00034 #define _GOCURVEBOUNDEDDOMAIN_H
00035 
00036 #include "Domain.h"
00037 #include "RectDomain.h"
00038 #include "CurveLoop.h"
00039 #include "SplineSurface.h"
00040 #include "CurveOnSurface.h"
00041 
00042 using std::vector;
00043 using std::pair;
00044 using boost::shared_ptr;
00045 
00046 namespace Go
00047 {
00050 
00051 
00054 class CurveBoundedDomain : public Domain
00055 {
00056 public:
00058     CurveBoundedDomain()
00059     {}
00060 
00064 
00065 
00072     CurveBoundedDomain(vector<shared_ptr<CurveLoop> > loops);
00073 
00078     CurveBoundedDomain(shared_ptr<CurveLoop> ccw_loop);
00079 
00081     virtual ~CurveBoundedDomain();
00082 
00083     // virtual DomainType domainType() const;
00084     // @@ Seems that direction of bd cv is not used. Fine by me.
00085 
00094     virtual bool isInDomain(const Array<double, 2>& point, 
00095                             double tolerance) const;
00096 
00104     virtual bool isOnBoundary(const Array<double, 2>& point, 
00105                               double tolerance) const;
00106 
00115     virtual void closestInDomain(const Array<double, 2>& point,
00116                                  Array<double, 2>& clo_pt,
00117                                  double tolerance) const;
00118 
00128     virtual void closestOnBoundary(const Array<double, 2>& point,
00129                                    Array<double, 2>& clo_bd_pt,
00130                                    double tolerance) const;
00131 
00139     RectDomain containingDomain() const;
00140 
00156     void clipWithDomain(int pardir, double parval, 
00157                         double tolerance, shared_ptr<SplineSurface> srf,
00158                         vector<shared_ptr<CurveOnSurface> >& trim_pieces) const;
00159 
00160     // Determine which intervals of a 2D spline curve lies inside the bounded
00161     // domain.  The start and end parameter values for the inside intervals are
00162     // found in the vector 'params_start_end_interval'.  Even entries in this 
00163     // vector marks the start of an inside interval, odd entries marks the end.
00164 
00165 
00178     void findPcurveInsideSegments(const SplineCurve& curve,
00179                                   double tolerance,
00180                                   vector<double>& params_start_end_interval) const;
00181 
00182 private:
00183     typedef struct intersection_point {
00184         double par1, par2;
00185         int pretop;
00186         
00187         intersection_point(double p1, double p2, int top)
00188         { par1 = p1; par2 = p2; pretop = top;}
00189         
00190     } intersection_point;
00191     
00192     // Comparisement function to use in std::sort
00193     static bool par1_compare(const intersection_point& el1,
00194                              const intersection_point& el2)
00195     {
00196         if (el1.par1 < el2.par1)
00197             return true;
00198         else
00199             return false;
00200     }
00201     
00202 
00203     // We store a set of curve loops
00204     vector<shared_ptr<CurveLoop> > loops_;
00205 
00206     // Fetch all intervals in one parameter direction
00207     // going through a specific point lying inside the 
00208     // bounded domain.
00209     void getInsideIntervals(int pardir, double parval, double tolerance,
00210                             vector<pair<double, double> >& insideInts) const;
00211 
00212     // We return a pointer to a parameter curve defining boundary. If loops_
00213     // consists of CoCurveOnSurface's, the parameter domain curve is returned.
00214     // Otherwise we make sure that dimension really is 2.
00215     shared_ptr<ParamCurve> getParameterCurve(int loop_nmb, int curve_nmb) const;
00216 
00217     // Determine which intervals of a 2D spline curve lies inside the bounded 
00218     // domain.  The start and end parameter values for the inside intervals are 
00219     // found in the intersection_points in the 'intpt' vector.  Those
00220     // intersection_points with even indexes marks the start of such an interval,
00221     // each following (odd-indexed) intersection_point mark the end of that interval.
00222     void findPcurveInsideSegments(const SplineCurve& curve,
00223                                   double tolerance, 
00224                                   vector<intersection_point>& intpt) const;
00225 
00226 };
00227 
00228 
00230 } // namespace Go
00231 
00232 #endif // _GOCURVEBOUNDEDDOMAIN_H
00233 
00234 

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