0028574: Get rid of the TestTopOpe* packages
[occt.git] / src / GeomAPI / GeomAPI_ProjectPointOnSurf.hxx
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_ProjectPointOnSurf_HeaderFile
18 #define _GeomAPI_ProjectPointOnSurf_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_ExtPS.hxx>
27 #include <GeomAdaptor_Surface.hxx>
28 #include <Extrema_ExtAlgo.hxx>
29 #include <Extrema_ExtFlag.hxx>
30 #include <Standard_Real.hxx>
31 #include <Quantity_Parameter.hxx>
32 #include <Quantity_Length.hxx>
33 class Standard_OutOfRange;
34 class StdFail_NotDone;
35 class gp_Pnt;
36 class Geom_Surface;
37 class Extrema_ExtPS;
38
39
40
41 //! This class implements methods for  computing all the orthogonal
42 //! projections of a point onto a  surface.
43 class GeomAPI_ProjectPointOnSurf 
44 {
45 public:
46
47   DEFINE_STANDARD_ALLOC
48
49   
50   //! Creates an empty object. Use the
51   //! Init function for further initialization.
52   Standard_EXPORT GeomAPI_ProjectPointOnSurf();
53   
54   //! Create the projection  of a point <P> on a surface
55   //! <Surface>
56   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
57   
58   //! Create the projection  of a point <P> on a surface
59   //! <Surface>
60   //! Create the projection of a point <P>  on a surface
61   //! <Surface>. The solution are computed in the domain
62   //! [Umin,Usup] [Vmin,Vsup] of the surface.
63   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
64   
65   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Quantity_Parameter Umin, const Quantity_Parameter Usup, const Quantity_Parameter Vmin, const Quantity_Parameter Vsup, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
66   
67   //! Init the projection  of a point <P> on a surface
68   //! <Surface>
69   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Quantity_Parameter Umin, const Quantity_Parameter Usup, const Quantity_Parameter Vmin, const Quantity_Parameter Vsup, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
70   
71   Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
72   
73   //! Init the projection of a point <P>  on a surface
74   //! <Surface>. The solution are computed in the domain
75   //! [Umin,Usup] [Vmin,Vsup] of the surface.
76   Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
77   
78   Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Quantity_Parameter Umin, const Quantity_Parameter Usup, const Quantity_Parameter Vmin, const Quantity_Parameter Vsup, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
79   
80   //! Init the projection for many points on a surface
81   //! <Surface>. The solutions will be computed in the domain
82   //! [Umin,Usup] [Vmin,Vsup] of the surface.
83   Standard_EXPORT void Init (const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Quantity_Parameter Umin, const Quantity_Parameter Usup, const Quantity_Parameter Vmin, const Quantity_Parameter Vsup, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
84   
85   Standard_EXPORT void Init (const Handle(Geom_Surface)& Surface, const Quantity_Parameter Umin, const Quantity_Parameter Usup, const Quantity_Parameter Vmin, const Quantity_Parameter Vsup, const Standard_Real Tolerance, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
86   
87   Standard_EXPORT void Init (const Handle(Geom_Surface)& Surface, const Quantity_Parameter Umin, const Quantity_Parameter Usup, const Quantity_Parameter Vmin, const Quantity_Parameter Vsup, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
88
89   //! Sets the Extrema search algorithm - Grad or Tree. <br>
90   //! By default the Extrema is initialized with Grad algorithm.
91   void SetExtremaAlgo(const Extrema_ExtAlgo theAlgo)
92   {
93     myExtPS.SetAlgo(theAlgo);
94   }
95
96   //! Sets the Extrema search flag - MIN or MAX or MINMAX.<br>
97   //! By default the Extrema is set to search the MinMax solutions.
98   void SetExtremaFlag(const Extrema_ExtFlag theExtFlag)
99   {
100     myExtPS.SetFlag(theExtFlag);
101   }
102
103   //! Performs the projection of a point on the current surface.
104   Standard_EXPORT void Perform (const gp_Pnt& P);
105   
106   Standard_EXPORT Standard_Boolean IsDone() const;
107   
108   //! Returns the number of computed orthogonal projection points.
109   //! Note: if projection fails, NbPoints returns 0.
110   Standard_EXPORT Standard_Integer NbPoints() const;
111 Standard_EXPORT operator Standard_Integer() const;
112   
113   //! Returns the orthogonal projection
114   //! on the surface. Index is a number of a computed point.
115   //! Exceptions
116   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
117   //! NbPoints is the number of solution points.
118   Standard_EXPORT gp_Pnt Point (const Standard_Integer Index) const;
119   
120   //! Returns the parameters (U,V) on the
121   //! surface of the orthogonal projection. Index is a number of a
122   //! computed point.
123   //! Exceptions
124   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
125   //! NbPoints is the number of solution points.
126   Standard_EXPORT void Parameters (const Standard_Integer Index, Quantity_Parameter& U, Quantity_Parameter& V) const;
127   
128   //! Computes the distance between the
129   //! point and its orthogonal projection on the surface. Index is a number
130   //! of a computed point.
131   //! Exceptions
132   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
133   //! NbPoints is the number of solution points.
134   Standard_EXPORT Quantity_Length Distance (const Standard_Integer Index) const;
135   
136   //! Returns the nearest orthogonal projection of the point
137   //! on the surface.
138   //! Exceptions
139   //! StdFail_NotDone if projection fails.
140   Standard_EXPORT gp_Pnt NearestPoint() const;
141 Standard_EXPORT operator gp_Pnt() const;
142   
143   //! Returns the parameters (U,V) on the
144   //! surface of the nearest computed orthogonal projection of the point.
145   //! Exceptions
146   //! StdFail_NotDone if projection fails.
147   Standard_EXPORT void LowerDistanceParameters (Quantity_Parameter& U, Quantity_Parameter& V) const;
148   
149   //! Computes the distance between the
150   //! point and its nearest orthogonal projection on the surface.
151   //! Exceptions
152   //! StdFail_NotDone if projection fails.
153   Standard_EXPORT Quantity_Length LowerDistance() const;
154 Standard_EXPORT operator Standard_Real() const;
155   
156   //! return the algorithmic object from Extrema
157     const Extrema_ExtPS& Extrema() const;
158
159
160
161
162 protected:
163
164
165
166
167
168 private:
169
170   
171   Standard_EXPORT void Init();
172
173
174   Standard_Boolean myIsDone;
175   Standard_Integer myIndex;
176   Extrema_ExtPS myExtPS;
177   GeomAdaptor_Surface myGeomAdaptor;
178
179
180 };
181
182
183 #include <GeomAPI_ProjectPointOnSurf.lxx>
184
185
186
187
188
189 #endif // _GeomAPI_ProjectPointOnSurf_HeaderFile