1 // Created on: 1994-03-23
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2dAPI_ProjectPointOnCurve_HeaderFile
18 #define _Geom2dAPI_ProjectPointOnCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Extrema_ExtPC2d.hxx>
26 #include <Geom2dAdaptor_Curve.hxx>
32 //! This class implements methods for computing all the orthogonal
33 //! projections of a 2D point onto a 2D curve.
34 class Geom2dAPI_ProjectPointOnCurve
41 //! Constructs an empty projector algorithm. Use an Init
42 //! function to define the point and the curve on which it is going to work.
43 Standard_EXPORT Geom2dAPI_ProjectPointOnCurve();
45 //! Create the projection of a point <P> on a curve
47 Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve);
49 //! Create the projection of a point <P> on a curve
50 //! <Curve> limited by the two points of parameter Umin and Usup.
52 //! Use the function NbPoints to obtain the number of solutions. If
53 //! projection fails, NbPoints returns 0.
54 Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
56 //! Initializes this algorithm with the given arguments, and
57 //! computes the orthogonal projections of a point <P> on a curve <Curve>
58 Standard_EXPORT void Init (const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve);
60 //! Initializes this algorithm with the given arguments, and
61 //! computes the orthogonal projections of the point P onto the portion
62 //! of the curve Curve limited by the two points of parameter Umin and Usup.
63 Standard_EXPORT void Init (const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
65 //! return the number of of computed
66 //! orthogonal projectionn points.
67 Standard_EXPORT Standard_Integer NbPoints() const;
68 Standard_EXPORT operator Standard_Integer() const;
70 //! Returns the orthogonal projection
71 //! on the curve. Index is a number of a computed point.
73 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
74 //! NbPoints is the number of solution points.
75 Standard_EXPORT gp_Pnt2d Point (const Standard_Integer Index) const;
77 //! Returns the parameter on the curve
78 //! of a point which is the orthogonal projection. Index is a number of a
79 //! computed projected point.
81 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
82 //! NbPoints is the number of solution points.
83 Standard_EXPORT Standard_Real Parameter (const Standard_Integer Index) const;
85 //! Returns the parameter on the curve
86 //! of a point which is the orthogonal projection. Index is a number of a
87 //! computed projected point.
89 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
90 //! NbPoints is the number of solution points
91 Standard_EXPORT void Parameter (const Standard_Integer Index, Standard_Real& U) const;
93 //! Computes the distance between the
94 //! point and its computed orthogonal projection on the curve. Index is a
95 //! number of computed projected point.
97 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
98 //! NbPoints is the number of solution points.
99 Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
101 //! Returns the nearest orthogonal projection of the point on the curve.
103 //! StdFail_NotDone if this algorithm fails.
104 Standard_EXPORT gp_Pnt2d NearestPoint() const;
105 Standard_EXPORT operator gp_Pnt2d() const;
107 //! Returns the parameter on the curve
108 //! of the nearest orthogonal projection of the point.
110 //! StdFail_NotDone if this algorithm fails.
111 Standard_EXPORT Standard_Real LowerDistanceParameter() const;
113 //! Computes the distance between the
114 //! point and its nearest orthogonal projection on the curve.
116 //! StdFail_NotDone if this algorithm fails.
117 Standard_EXPORT Standard_Real LowerDistance() const;
118 Standard_EXPORT operator Standard_Real() const;
120 //! return the algorithmic object from Extrema
121 const Extrema_ExtPC2d& Extrema() const;
125 Standard_Boolean myIsDone;
126 Standard_Integer myIndex;
127 Extrema_ExtPC2d myExtPC;
128 Geom2dAdaptor_Curve myC;
134 #include <Geom2dAPI_ProjectPointOnCurve.lxx>
140 #endif // _Geom2dAPI_ProjectPointOnCurve_HeaderFile