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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _GeomAPI_ProjectPointOnCurve_HeaderFile
18 #define _GeomAPI_ProjectPointOnCurve_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Extrema_ExtPC.hxx>
27 #include <GeomAdaptor_Curve.hxx>
28 class gp_Pnt;
29 class Geom_Curve;
30 
31 
32 
33 //! This class implements methods for  computing all the orthogonal
34 //! projections of a 3D point onto a  3D curve.
35 class GeomAPI_ProjectPointOnCurve
36 {
37 public:
38 
39   DEFINE_STANDARD_ALLOC
40 
41 
42   //! Creates an empty object. Use an
43   //! Init function for further initialization.
44   Standard_EXPORT GeomAPI_ProjectPointOnCurve();
45 
46   //! Create the projection  of a  point  <P> on a curve
47   //! <Curve>
48   Standard_EXPORT GeomAPI_ProjectPointOnCurve(const gp_Pnt& P, const Handle(Geom_Curve)& Curve);
49 
50   //! Create  the projection  of a point <P>  on a curve
51   //! <Curve> limited by the two points of parameter Umin and Usup.
52   Standard_EXPORT GeomAPI_ProjectPointOnCurve(const gp_Pnt& P, const Handle(Geom_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
53 
54   //! Init the projection  of a  point  <P> on a curve
55   //! <Curve>
56   Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Curve)& Curve);
57 
58   //! Init  the  projection  of a  point <P>  on a curve
59   //! <Curve> limited by the two points of parameter Umin and Usup.
60   Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
61 
62   //! Init  the  projection  of a  point <P>  on a curve
63   //! <Curve> limited by the two points of parameter Umin and Usup.
64   Standard_EXPORT void Init (const Handle(Geom_Curve)& Curve, const Standard_Real Umin, const Standard_Real Usup);
65 
66   //! Performs the projection of a point on the current curve.
67   Standard_EXPORT void Perform (const gp_Pnt& P);
68 
69   //! Returns the number of computed
70   //! orthogonal projection points.
71   //! Note: if this algorithm fails, NbPoints returns 0.
72   Standard_EXPORT Standard_Integer NbPoints() const;
73 Standard_EXPORT operator Standard_Integer() const;
74 
75   //! Returns the orthogonal projection
76   //! on the curve. Index is a number of a computed point.
77   //! Exceptions
78   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
79   //! NbPoints is the number of solution points.
80   Standard_EXPORT gp_Pnt Point (const Standard_Integer Index) const;
81 
82   //! Returns the parameter on the curve
83   //! of the point, which is the orthogonal projection. Index is a
84   //! number of a computed point.
85   //! Exceptions
86   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
87   //! NbPoints is the number of solution points.
88   Standard_EXPORT Standard_Real Parameter (const Standard_Integer Index) const;
89 
90   //! Returns the parameter on the curve
91   //! of the point, which is the orthogonal projection. Index is a
92   //! number of a computed point.
93   //! Exceptions
94   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
95   //! NbPoints is the number of solution points.-
96   Standard_EXPORT void Parameter (const Standard_Integer Index, Standard_Real& U) const;
97 
98   //! Computes the distance between the
99   //! point and its orthogonal projection on the curve. Index is a number of a computed point.
100   //! Exceptions
101   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
102   //! NbPoints is the number of solution points.
103   Standard_EXPORT Standard_Real Distance (const Standard_Integer Index) const;
104 
105   //! Returns the nearest orthogonal
106   //! projection of the point on the curve.
107   //! Exceptions: StdFail_NotDone if this algorithm fails.
108   Standard_EXPORT gp_Pnt NearestPoint() const;
109 Standard_EXPORT operator gp_Pnt() const;
110 
111   //! Returns the parameter on the curve
112   //! of the nearest orthogonal projection of the point.
113   //! Exceptions: StdFail_NotDone if this algorithm fails.
114   Standard_EXPORT Standard_Real LowerDistanceParameter() const;
115 
116   //! Computes the distance between the
117   //! point and its nearest orthogonal projection on the curve.
118   //! Exceptions: StdFail_NotDone if this algorithm fails.
119   Standard_EXPORT Standard_Real LowerDistance() const;
120 Standard_EXPORT operator Standard_Real() const;
121 
122   //! return the algorithmic object from Extrema
123     const Extrema_ExtPC& Extrema() const;
124 
125 private:
126 
127   Standard_Boolean myIsDone;
128   Standard_Integer myIndex;
129   Extrema_ExtPC myExtPC;
130   GeomAdaptor_Curve myC;
131 
132 };
133 
134 
135 #include <GeomAPI_ProjectPointOnCurve.lxx>
136 
137 
138 
139 
140 
141 #endif // _GeomAPI_ProjectPointOnCurve_HeaderFile
142