1 // Created on: 1994-03-17
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 _GeomAPI_ProjectPointOnCurve_HeaderFile
18 #define _GeomAPI_ProjectPointOnCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Extrema_ExtPC.hxx>
27 #include <GeomAdaptor_Curve.hxx>
28 class Standard_OutOfRange;
29 class StdFail_NotDone;
36 //! This class implements methods for computing all the orthogonal
37 //! projections of a 3D point onto a 3D curve.
38 class GeomAPI_ProjectPointOnCurve
45 //! Creates an empty object. Use an
46 //! Init function for further initialization.
47 Standard_EXPORT GeomAPI_ProjectPointOnCurve();
49 //! Create the projection of a point <P> on a curve
51 Standard_EXPORT GeomAPI_ProjectPointOnCurve(const gp_Pnt& P, const Handle(Geom_Curve)& Curve);
53 //! Create the projection of a point <P> on a curve
54 //! <Curve> limited by the two points of parameter Umin and Usup.
55 Standard_EXPORT GeomAPI_ProjectPointOnCurve(const gp_Pnt& P, const Handle(Geom_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
57 //! Init the projection of a point <P> on a curve
59 Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Curve)& Curve);
61 //! Init the projection of a point <P> on a curve
62 //! <Curve> limited by the two points of parameter Umin and Usup.
63 Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
65 //! Init the projection of a point <P> on a curve
66 //! <Curve> limited by the two points of parameter Umin and Usup.
67 Standard_EXPORT void Init (const Handle(Geom_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
69 //! Performs the projection of a point on the current curve.
70 Standard_EXPORT void Perform (const gp_Pnt& P);
72 //! Returns the number of computed
73 //! orthogonal projection points.
74 //! Note: if this algorithm fails, NbPoints returns 0.
75 Standard_EXPORT Standard_Integer NbPoints() const;
76 Standard_EXPORT operator Standard_Integer() const;
78 //! Returns the orthogonal projection
79 //! on the curve. Index is a number of a computed 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 gp_Pnt Point (const Standard_Integer Index) const;
85 //! Returns the parameter on the curve
86 //! of the point, which is the orthogonal projection. Index is a
87 //! number of a computed 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 Standard_Real Parameter (const Standard_Integer Index) const;
93 //! Returns the parameter on the curve
94 //! of the point, which is the orthogonal projection. Index is a
95 //! number of a computed 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 void Parameter (const Standard_Integer Index, Standard_Real& U) const;
101 //! Computes the distance between the
102 //! point and its orthogonal projection on the curve. Index is a number of a computed point.
104 //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
105 //! NbPoints is the number of solution points.
106 Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
108 //! Returns the nearest orthogonal
109 //! projection of the point on the curve.
110 //! Exceptions: StdFail_NotDone if this algorithm fails.
111 Standard_EXPORT gp_Pnt NearestPoint() const;
112 Standard_EXPORT operator gp_Pnt() const;
114 //! Returns the parameter on the curve
115 //! of the nearest orthogonal projection of the point.
116 //! Exceptions: StdFail_NotDone if this algorithm fails.
117 Standard_EXPORT Standard_Real LowerDistanceParameter() const;
119 //! Computes the distance between the
120 //! point and its nearest orthogonal projection on the curve.
121 //! Exceptions: StdFail_NotDone if this algorithm fails.
122 Standard_EXPORT Standard_Real LowerDistance() const;
123 Standard_EXPORT operator Standard_Real() const;
125 //! return the algorithmic object from Extrema
126 const Extrema_ExtPC& Extrema() const;
130 Standard_Boolean myIsDone;
131 Standard_Integer myIndex;
132 Extrema_ExtPC myExtPC;
133 GeomAdaptor_Curve myC;
138 #include <GeomAPI_ProjectPointOnCurve.lxx>
144 #endif // _GeomAPI_ProjectPointOnCurve_HeaderFile