Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:37

0001 // Created on: 1994-03-18
0002 // Created by: Bruno DUMORTIER
0003 // Copyright (c) 1994-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _GeomAPI_ExtremaCurveCurve_HeaderFile
0018 #define _GeomAPI_ExtremaCurveCurve_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <Extrema_ExtCC.hxx>
0026 #include <GeomAdaptor_Curve.hxx>
0027 #include <gp_Pnt.hxx>
0028 class Geom_Curve;
0029 
0030 
0031 //! Describes functions for computing all the extrema
0032 //! between two 3D curves.
0033 //! An ExtremaCurveCurve algorithm minimizes or
0034 //! maximizes the distance between a point on the first
0035 //! curve and a point on the second curve. Thus, it
0036 //! computes start and end points of perpendiculars
0037 //! common to the two curves (an intersection point is
0038 //! not an extremum unless the two curves are tangential at this point).
0039 //! Solutions consist of pairs of points, and an extremum
0040 //! is considered to be a segment joining the two points of a solution.
0041 //! An ExtremaCurveCurve object provides a framework for:
0042 //! -   defining the construction of the extrema,
0043 //! -   implementing the construction algorithm, and
0044 //! -   consulting the results.
0045 //! Warning
0046 //! In some cases, the nearest points between two
0047 //! curves do not correspond to one of the computed
0048 //! extrema. Instead, they may be given by:
0049 //! -   a limit point of one curve and one of the following:
0050 //! -   its orthogonal projection on the other curve,
0051 //! -   a limit point of the other curve; or
0052 //! -   an intersection point between the two curves.
0053 class GeomAPI_ExtremaCurveCurve 
0054 {
0055 public:
0056 
0057   DEFINE_STANDARD_ALLOC
0058 
0059   
0060   //! Constructs an empty algorithm for computing
0061   //! extrema between two curves. Use an Init function
0062   //! to define the curves on which it is going to work.
0063   Standard_EXPORT GeomAPI_ExtremaCurveCurve();
0064   
0065   //! Computes the extrema between the curves C1 and C2.
0066   Standard_EXPORT GeomAPI_ExtremaCurveCurve(const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2);
0067   
0068   //! Computes   the portion of the curve C1 limited by the two
0069   //! points of parameter (U1min,U1max), and
0070   //! -   the portion of the curve C2 limited by the two
0071   //! points of parameter (U2min,U2max).
0072   //! Warning
0073   //! Use the function NbExtrema to obtain the number
0074   //! of solutions. If this algorithm fails, NbExtrema returns 0.
0075   Standard_EXPORT GeomAPI_ExtremaCurveCurve(const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2, const Standard_Real U1min, const Standard_Real U1max, const Standard_Real U2min, const Standard_Real U2max);
0076   
0077   //! Initializes this algorithm with the given arguments
0078   //! and computes the extrema between the curves C1 and C2
0079   Standard_EXPORT void Init (const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2);
0080   
0081   //! Initializes this algorithm with the given arguments
0082   //! and computes the extrema between :
0083   //! -   the portion of the curve C1 limited by the two
0084   //! points of parameter (U1min,U1max), and
0085   //! -   the portion of the curve C2 limited by the two
0086   //! points of parameter (U2min,U2max).
0087   //! Warning
0088   //! Use the function NbExtrema to obtain the number
0089   //! of solutions. If this algorithm fails, NbExtrema returns 0.
0090   Standard_EXPORT void Init (const Handle(Geom_Curve)& C1, const Handle(Geom_Curve)& C2, const Standard_Real U1min, const Standard_Real U1max, const Standard_Real U2min, const Standard_Real U2max);
0091   
0092   //! Returns the number of extrema computed by this algorithm.
0093   //! Note: if this algorithm fails, NbExtrema returns 0.
0094   Standard_EXPORT Standard_Integer NbExtrema() const;
0095 Standard_EXPORT operator Standard_Integer() const;
0096   
0097   //! Returns the points P1 on the first curve and P2 on
0098   //! the second curve, which are the ends of the
0099   //! extremum of index Index computed by this algorithm.
0100   //! Exceptions
0101   //! Standard_OutOfRange if Index is not in the range [
0102   //! 1,NbExtrema ], where NbExtrema is the
0103   //! number of extrema computed by this algorithm.
0104   Standard_EXPORT void Points (const Standard_Integer Index, gp_Pnt& P1, gp_Pnt& P2) const;
0105   
0106   //! Returns the parameters U1 of the point on the first
0107   //! curve and U2 of the point on the second curve, which
0108   //! are the ends of the extremum of index Index computed by this algorithm.
0109   //! Exceptions
0110   //! Standard_OutOfRange if Index is not in the range [
0111   //! 1,NbExtrema ], where NbExtrema is the
0112   //! number of extrema computed by this algorithm.
0113   Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& U1, Standard_Real& U2) const;
0114   
0115   //! Computes the distance between the end points of the
0116   //! extremum of index Index computed by this algorithm.
0117   //! Exceptions
0118   //! Standard_OutOfRange if Index is not in the range [
0119   //! 1,NbExtrema ], where NbExtrema is the
0120   //! number of extrema computed by this algorithm.
0121   Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
0122 
0123   //! Returns True if the two curves are parallel.
0124   Standard_Boolean IsParallel() const
0125   {
0126     return myExtCC.IsParallel();
0127   }
0128   
0129   //! Returns the points P1 on the first curve and P2 on
0130   //! the second curve, which are the ends of the shortest
0131   //! extremum computed by this algorithm.
0132   //! Exceptions StdFail_NotDone if this algorithm fails.
0133   Standard_EXPORT void NearestPoints (gp_Pnt& P1, gp_Pnt& P2) const;
0134   
0135   //! Returns the parameters U1 of the point on the first
0136   //! curve and U2 of the point on the second curve, which
0137   //! are the ends of the shortest extremum computed by this algorithm.
0138   //! Exceptions StdFail_NotDone if this algorithm fails.
0139   Standard_EXPORT void LowerDistanceParameters (Standard_Real& U1, Standard_Real& U2) const;
0140   
0141   //! Computes the distance between the end points of the
0142   //! shortest extremum computed by this algorithm.
0143   //! Exceptions StdFail_NotDone if this algorithm fails.
0144   Standard_EXPORT Standard_Real LowerDistance() const;
0145 Standard_EXPORT operator Standard_Real() const;
0146   
0147   //! return the algorithmic object from Extrema
0148     const Extrema_ExtCC& Extrema() const;
0149   
0150   //! set  in  <P1>  and <P2> the couple solution points
0151   //! such a the distance [P1,P2] is the minimum. taking  in  account
0152   //! extremity  points  of  curves.
0153   Standard_EXPORT Standard_Boolean TotalNearestPoints (gp_Pnt& P1, gp_Pnt& P2);
0154   
0155   //! set  in <U1> and <U2> the parameters of the couple
0156   //! solution   points  which  represents  the  total  nearest
0157   //! solution.
0158   Standard_EXPORT Standard_Boolean TotalLowerDistanceParameters (Standard_Real& U1, Standard_Real& U2);
0159   
0160   //! return the distance of the total  nearest couple solution
0161   //! point.
0162   //! if <myExtCC> is not done
0163   Standard_EXPORT Standard_Real TotalLowerDistance();
0164 
0165 private:
0166   
0167   Standard_EXPORT void TotalPerform();
0168 
0169 
0170   Standard_Boolean myIsDone;
0171   Standard_Integer myIndex;
0172   Extrema_ExtCC myExtCC;
0173   GeomAdaptor_Curve myC1;
0174   GeomAdaptor_Curve myC2;
0175   Standard_Boolean myTotalExt;
0176   Standard_Boolean myIsInfinite;
0177   Standard_Real myTotalDist;
0178   gp_Pnt myTotalPoints[2];
0179   Standard_Real myTotalPars[2];
0180 
0181 
0182 };
0183 
0184 
0185 #include <GeomAPI_ExtremaCurveCurve.lxx>
0186 
0187 
0188 
0189 
0190 
0191 #endif // _GeomAPI_ExtremaCurveCurve_HeaderFile