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_ProjectPointOnSurf_HeaderFile
18 #define _GeomAPI_ProjectPointOnSurf_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_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;
41 //! This class implements methods for computing all the orthogonal
42 //! projections of a point onto a surface.
43 class GeomAPI_ProjectPointOnSurf
50 //! Creates an empty object. Use the
51 //! Init function for further initialization.
52 Standard_EXPORT GeomAPI_ProjectPointOnSurf();
54 //! Create the projection of a point <P> on a surface
56 Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt& P, const Handle(Geom_Surface)& Surface, const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
58 //! Create the projection of a point <P> on a 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);
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);
67 //! Init the projection of a point <P> on a 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);
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);
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);
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);
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);
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);
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);
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)
93 myExtPS.SetAlgo(theAlgo);
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)
100 myExtPS.SetFlag(theExtFlag);
103 //! Performs the projection of a point on the current surface.
104 Standard_EXPORT void Perform (const gp_Pnt& P);
106 Standard_EXPORT Standard_Boolean IsDone() const;
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;
113 //! Returns the orthogonal projection
114 //! on the surface. Index is a number of a computed point.
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;
120 //! Returns the parameters (U,V) on the
121 //! surface of the orthogonal projection. Index is a number of a
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;
128 //! Computes the distance between the
129 //! point and its orthogonal projection on the surface. Index is a number
130 //! of a computed point.
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;
136 //! Returns the nearest orthogonal projection of the point
139 //! StdFail_NotDone if projection fails.
140 Standard_EXPORT gp_Pnt NearestPoint() const;
141 Standard_EXPORT operator gp_Pnt() const;
143 //! Returns the parameters (U,V) on the
144 //! surface of the nearest computed orthogonal projection of the point.
146 //! StdFail_NotDone if projection fails.
147 Standard_EXPORT void LowerDistanceParameters (Quantity_Parameter& U, Quantity_Parameter& V) const;
149 //! Computes the distance between the
150 //! point and its nearest orthogonal projection on the surface.
152 //! StdFail_NotDone if projection fails.
153 Standard_EXPORT Quantity_Length LowerDistance() const;
154 Standard_EXPORT operator Standard_Real() const;
156 //! return the algorithmic object from Extrema
157 const Extrema_ExtPS& Extrema() const;
171 Standard_EXPORT void Init();
174 Standard_Boolean myIsDone;
175 Standard_Integer myIndex;
176 Extrema_ExtPS myExtPS;
177 GeomAdaptor_Surface myGeomAdaptor;
183 #include <GeomAPI_ProjectPointOnSurf.lxx>
189 #endif // _GeomAPI_ProjectPointOnSurf_HeaderFile