Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:15:43

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_ProjectPointOnCurve_HeaderFile
0018 #define _Geom2dAPI_ProjectPointOnCurve_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_ExtPC2d.hxx>
0026 #include <Geom2dAdaptor_Curve.hxx>
0027 class gp_Pnt2d;
0028 class Geom2d_Curve;
0029 
0030 //! This class implements methods for computing all the orthogonal
0031 //! projections of a 2D point onto a 2D curve.
0032 class Geom2dAPI_ProjectPointOnCurve
0033 {
0034 public:
0035   DEFINE_STANDARD_ALLOC
0036 
0037   //! Constructs an empty projector algorithm. Use an Init
0038   //! function to define the point and the curve on which it is going to work.
0039   Standard_EXPORT Geom2dAPI_ProjectPointOnCurve();
0040 
0041   //! Create the projection of a point <P> on a curve
0042   //! <Curve>
0043   Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d&                  P,
0044                                                 const occ::handle<Geom2d_Curve>& Curve);
0045 
0046   //! Create the projection of a point <P> on a curve
0047   //! <Curve> limited by the two points of parameter Umin and Usup.
0048   //! Warning
0049   //! Use the function NbPoints to obtain the number of solutions. If
0050   //! projection fails, NbPoints returns 0.
0051   Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d&                  P,
0052                                                 const occ::handle<Geom2d_Curve>& Curve,
0053                                                 const double                     Umin,
0054                                                 const double                     Usup);
0055 
0056   //! Initializes this algorithm with the given arguments, and
0057   //! computes the orthogonal projections of a point <P> on a curve <Curve>
0058   Standard_EXPORT void Init(const gp_Pnt2d& P, const occ::handle<Geom2d_Curve>& Curve);
0059 
0060   //! Initializes this algorithm with the given arguments, and
0061   //! computes the orthogonal projections of the point P onto the portion
0062   //! of the curve Curve limited by the two points of parameter Umin and Usup.
0063   Standard_EXPORT void Init(const gp_Pnt2d&                  P,
0064                             const occ::handle<Geom2d_Curve>& Curve,
0065                             const double                     Umin,
0066                             const double                     Usup);
0067 
0068   //! return the number of of computed
0069   //! orthogonal projectionn points.
0070   Standard_EXPORT int NbPoints() const;
0071   Standard_EXPORT     operator int() const;
0072 
0073   //! Returns the orthogonal projection
0074   //! on the curve. Index is a number of a computed point.
0075   //! Exceptions
0076   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0077   //! NbPoints is the number of solution points.
0078   Standard_EXPORT gp_Pnt2d Point(const int Index) const;
0079 
0080   //! Returns the parameter on the curve
0081   //! of a point which is the orthogonal projection. Index is a number of a
0082   //! computed projected point.
0083   //! Exceptions
0084   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0085   //! NbPoints is the number of solution points.
0086   Standard_EXPORT double Parameter(const int Index) const;
0087 
0088   //! Returns the parameter on the curve
0089   //! of a point which is the orthogonal projection. Index is a number of a
0090   //! computed projected point.
0091   //! Exceptions
0092   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0093   //! NbPoints is the number of solution points
0094   Standard_EXPORT void Parameter(const int Index, double& U) const;
0095 
0096   //! Computes the distance between the
0097   //! point and its computed orthogonal projection on the curve. Index is a
0098   //! number of computed projected point.
0099   //! Exceptions
0100   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0101   //! NbPoints is the number of solution points.
0102   Standard_EXPORT double Distance(const int Index) const;
0103 
0104   //! Returns the nearest orthogonal projection of the point on the curve.
0105   //! Exceptions
0106   //! StdFail_NotDone if this algorithm fails.
0107   Standard_EXPORT gp_Pnt2d NearestPoint() const;
0108   Standard_EXPORT          operator gp_Pnt2d() const;
0109 
0110   //! Returns the parameter on the curve
0111   //! of the nearest orthogonal projection of the point.
0112   //! Exceptions
0113   //! StdFail_NotDone if this algorithm fails.
0114   Standard_EXPORT double LowerDistanceParameter() const;
0115 
0116   //! Computes the distance between the
0117   //! point and its nearest orthogonal projection on the curve.
0118   //! Exceptions
0119   //! StdFail_NotDone if this algorithm fails.
0120   Standard_EXPORT double LowerDistance() const;
0121   Standard_EXPORT        operator double() const;
0122 
0123   //! return the algorithmic object from Extrema
0124   const Extrema_ExtPC2d& Extrema() const;
0125 
0126 private:
0127   bool                myIsDone;
0128   int                 myIndex;
0129   Extrema_ExtPC2d     myExtPC;
0130   Geom2dAdaptor_Curve myC;
0131 };
0132 
0133 #include <Geom2dAPI_ProjectPointOnCurve.lxx>
0134 
0135 #endif // _Geom2dAPI_ProjectPointOnCurve_HeaderFile