42cf5bc1 |
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 |
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 _Geom2dAPI_ProjectPointOnCurve_HeaderFile |
18 | #define _Geom2dAPI_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_ExtPC2d.hxx> |
27 | #include <Geom2dAdaptor_Curve.hxx> |
28 | #include <Quantity_Parameter.hxx> |
29 | #include <Quantity_Length.hxx> |
30 | class Standard_OutOfRange; |
31 | class StdFail_NotDone; |
32 | class gp_Pnt2d; |
33 | class Geom2d_Curve; |
34 | class Extrema_ExtPC2d; |
35 | |
36 | |
37 | |
38 | //! This class implements methods for computing all the orthogonal |
39 | //! projections of a 2D point onto a 2D curve. |
40 | class Geom2dAPI_ProjectPointOnCurve |
41 | { |
42 | public: |
43 | |
44 | DEFINE_STANDARD_ALLOC |
45 | |
46 | |
47 | //! Constructs an empty projector algorithm. Use an Init |
48 | //! function to define the point and the curve on which it is going to work. |
49 | Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(); |
50 | |
51 | //! Create the projection of a point <P> on a curve |
52 | //! <Curve> |
53 | Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve); |
54 | |
55 | //! Create the projection of a point <P> on a curve |
56 | //! <Curve> limited by the two points of parameter Umin and Usup. |
57 | //! Warning |
58 | //! Use the function NbPoints to obtain the number of solutions. If |
59 | //! projection fails, NbPoints returns 0. |
60 | Standard_EXPORT Geom2dAPI_ProjectPointOnCurve(const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve, const Quantity_Parameter Umin, const Quantity_Parameter Usup); |
61 | |
62 | //! Initializes this algorithm with the given arguments, and |
63 | //! computes the orthogonal projections of a point <P> on a curve <Curve> |
64 | Standard_EXPORT void Init (const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve); |
65 | |
66 | //! Initializes this algorithm with the given arguments, and |
67 | //! computes the orthogonal projections of the point P onto the portion |
68 | //! of the curve Curve limited by the two points of parameter Umin and Usup. |
69 | Standard_EXPORT void Init (const gp_Pnt2d& P, const Handle(Geom2d_Curve)& Curve, const Quantity_Parameter Umin, const Quantity_Parameter Usup); |
70 | |
71 | //! return the number of of computed |
72 | //! orthogonal projectionn points. |
73 | Standard_EXPORT Standard_Integer NbPoints() const; |
74 | Standard_EXPORT operator Standard_Integer() const; |
75 | |
76 | //! Returns the orthogonal projection |
77 | //! on the curve. Index is a number of a computed point. |
78 | //! Exceptions |
79 | //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where |
80 | //! NbPoints is the number of solution points. |
81 | Standard_EXPORT gp_Pnt2d Point (const Standard_Integer Index) const; |
82 | |
83 | //! Returns the parameter on the curve |
84 | //! of a point which is the orthogonal projection. Index is a number of a |
85 | //! computed projected point. |
86 | //! Exceptions |
87 | //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where |
88 | //! NbPoints is the number of solution points. |
89 | Standard_EXPORT Quantity_Parameter Parameter (const Standard_Integer Index) const; |
90 | |
91 | //! Returns the parameter on the curve |
92 | //! of a point which is the orthogonal projection. Index is a number of a |
93 | //! computed projected point. |
94 | //! Exceptions |
95 | //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where |
96 | //! NbPoints is the number of solution points |
97 | Standard_EXPORT void Parameter (const Standard_Integer Index, Quantity_Parameter& U) const; |
98 | |
99 | //! Computes the distance between the |
100 | //! point and its computed orthogonal projection on the curve. Index is a |
101 | //! number of computed projected point. |
102 | //! Exceptions |
103 | //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where |
104 | //! NbPoints is the number of solution points. |
105 | Standard_EXPORT Quantity_Length Distance (const Standard_Integer Index) const; |
106 | |
107 | //! Returns the nearest orthogonal projection of the point on the curve. |
108 | //! Exceptions |
109 | //! StdFail_NotDone if this algorithm fails. |
110 | Standard_EXPORT gp_Pnt2d NearestPoint() const; |
111 | Standard_EXPORT operator gp_Pnt2d() const; |
112 | |
113 | //! Returns the parameter on the curve |
114 | //! of the nearest orthogonal projection of the point. |
115 | //! Exceptions |
116 | //! StdFail_NotDone if this algorithm fails. |
117 | Standard_EXPORT Quantity_Parameter LowerDistanceParameter() const; |
118 | |
119 | //! Computes the distance between the |
120 | //! point and its nearest orthogonal projection on the curve. |
121 | //! Exceptions |
122 | //! StdFail_NotDone if this algorithm fails. |
123 | Standard_EXPORT Quantity_Length LowerDistance() const; |
124 | Standard_EXPORT operator Standard_Real() const; |
125 | |
126 | //! return the algorithmic object from Extrema |
127 | const Extrema_ExtPC2d& Extrema() const; |
128 | |
129 | |
130 | |
131 | |
132 | protected: |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | private: |
139 | |
140 | |
141 | |
142 | Standard_Boolean myIsDone; |
143 | Standard_Integer myIndex; |
144 | Extrema_ExtPC2d myExtPC; |
145 | Geom2dAdaptor_Curve myC; |
146 | |
147 | |
148 | }; |
149 | |
150 | |
151 | #include <Geom2dAPI_ProjectPointOnCurve.lxx> |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | #endif // _Geom2dAPI_ProjectPointOnCurve_HeaderFile |