Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1994-03-23
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 _Geom2dAPI_ExtremaCurveCurve_HeaderFile
0018 #define _Geom2dAPI_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_ExtCC2d.hxx>
0026 #include <Geom2dAdaptor_Curve.hxx>
0027 class Geom2d_Curve;
0028 class gp_Pnt2d;
0029 
0030 
0031 //! Describes functions for computing all the extrema
0032 //! between two 2D 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 the start point and end point of
0037 //! perpendiculars common to the two curves (an
0038 //! intersection point is not an extremum except where
0039 //! the two curves are tangential at this point).
0040 //! Solutions consist of pairs of points, and an extremum
0041 //! is considered to be a segment joining the two points of a solution.
0042 //! An ExtremaCurveCurve object provides a framework for:
0043 //! -   defining the construction of the extrema,
0044 //! -   implementing the construction algorithm, and
0045 //! -   consulting the results.
0046 //! Warning
0047 //! In some cases, the nearest points between two
0048 //! curves do not correspond to one of the computed
0049 //! extrema. Instead, they may be given by:
0050 //! -   a limit point of one curve and one of the following:
0051 //! -   its orthogonal projection on the other curve,
0052 //! -   a limit point of the other curve; or
0053 //! -   an intersection point between the two curves.
0054 class Geom2dAPI_ExtremaCurveCurve 
0055 {
0056 public:
0057 
0058   DEFINE_STANDARD_ALLOC
0059 
0060   
0061   //! Computes the extrema between
0062   //! -   the portion of the curve C1 limited by the two
0063   //! points of parameter (U1min,U1max), and
0064   //! -   the portion of the curve C2 limited by the two
0065   //! points of parameter (U2min,U2max).
0066   //! Warning
0067   //! Use the function NbExtrema to obtain the number
0068   //! of solutions. If this algorithm fails, NbExtrema returns 0.
0069   Standard_EXPORT Geom2dAPI_ExtremaCurveCurve(const Handle(Geom2d_Curve)& C1, const Handle(Geom2d_Curve)& C2, const Standard_Real U1min, const Standard_Real U1max, const Standard_Real U2min, const Standard_Real U2max);
0070   
0071   //! Returns the number of extrema computed by this algorithm.
0072   //! Note: if this algorithm fails, NbExtrema returns 0.
0073   Standard_EXPORT Standard_Integer NbExtrema() const;
0074 Standard_EXPORT operator Standard_Integer() const;
0075   
0076   //! Returns the points P1 on the first curve and P2 on
0077   //! the second curve, which are the ends of the
0078   //! extremum of index Index computed by this algorithm.
0079   //! Exceptions
0080   //! Standard_OutOfRange if Index is not in the range [
0081   //! 1,NbExtrema ], where NbExtrema is the
0082   //! number of extrema computed by this algorithm.
0083   Standard_EXPORT void Points (const Standard_Integer Index, gp_Pnt2d& P1, gp_Pnt2d& P2) const;
0084   
0085   //! Returns the parameters U1 of the point on the first
0086   //! curve and U2 of the point on the second curve, which
0087   //! are the ends of the extremum of index Index
0088   //! computed by this algorithm.
0089   //! Exceptions
0090   //! Standard_OutOfRange if Index is not in the range [
0091   //! 1,NbExtrema ], where NbExtrema is the
0092   //! number of extrema computed by this algorithm.
0093   Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& U1, Standard_Real& U2) const;
0094   
0095   //! Computes the distance between the end points of the
0096   //! extremum of index Index computed by this algorithm.
0097   //! Exceptions
0098   //! Standard_OutOfRange if Index is not in the range [
0099   //! 1,NbExtrema ], where NbExtrema is the
0100   //! number of extrema computed by this algorithm.
0101   Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
0102   
0103   //! Returns the points P1 on the first curve and P2 on
0104   //! the second curve, which are the ends of the shortest
0105   //! extremum computed by this algorithm.
0106   //! Exceptions StdFail_NotDone if this algorithm fails.
0107   Standard_EXPORT void NearestPoints (gp_Pnt2d& P1, gp_Pnt2d& P2) const;
0108   
0109   //! Returns the parameters U1 of the point on the first
0110   //! curve and U2 of the point on the second curve, which
0111   //! are the ends of the shortest extremum computed by this algorithm.
0112   //! Exceptions
0113   //! StdFail_NotDone if this algorithm fails.
0114   Standard_EXPORT void LowerDistanceParameters (Standard_Real& U1, Standard_Real& U2) const;
0115   
0116   //! Computes the distance between the end points of the
0117   //! shortest extremum computed by this algorithm.
0118   //! Exceptions - StdFail_NotDone if this algorithm fails.
0119   Standard_EXPORT Standard_Real LowerDistance() const;
0120 Standard_EXPORT operator Standard_Real() const;
0121   
0122     const Extrema_ExtCC2d& Extrema() const;
0123 
0124 
0125 
0126 
0127 protected:
0128 
0129 
0130 
0131 
0132 
0133 private:
0134 
0135 
0136 
0137   Standard_Boolean myIsDone;
0138   Standard_Integer myIndex;
0139   Extrema_ExtCC2d myExtCC;
0140   Geom2dAdaptor_Curve myC1;
0141   Geom2dAdaptor_Curve myC2;
0142 
0143 
0144 };
0145 
0146 
0147 #include <Geom2dAPI_ExtremaCurveCurve.lxx>
0148 
0149 
0150 
0151 
0152 
0153 #endif // _Geom2dAPI_ExtremaCurveCurve_HeaderFile