Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-13 08:43:38

0001 // Created on: 1994-03-17
0002 // Created by: Bruno DUMORTIER
0003 // Copyright (c) 1994-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _GeomAPI_ProjectPointOnSurf_HeaderFile
0018 #define _GeomAPI_ProjectPointOnSurf_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <Extrema_ExtPS.hxx>
0026 #include <GeomAdaptor_Surface.hxx>
0027 #include <Extrema_ExtAlgo.hxx>
0028 #include <Extrema_ExtFlag.hxx>
0029 class gp_Pnt;
0030 class Geom_Surface;
0031 
0032 //! This class implements methods for  computing all the orthogonal
0033 //! projections of a point onto a  surface.
0034 class GeomAPI_ProjectPointOnSurf
0035 {
0036 public:
0037   DEFINE_STANDARD_ALLOC
0038 
0039   //! Creates an empty object. Use the
0040   //! Init function for further initialization.
0041   Standard_EXPORT GeomAPI_ProjectPointOnSurf();
0042 
0043   //! Create the projection  of a point <P> on a surface
0044   //! <Surface>
0045   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt&               P,
0046                                              const Handle(Geom_Surface)& Surface,
0047                                              const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
0048 
0049   //! Create the projection  of a point <P> on a surface
0050   //! <Surface>
0051   //! Create the projection of a point <P>  on a surface
0052   //! <Surface>. The solution are computed in the domain
0053   //! [Umin,Usup] [Vmin,Vsup] of the surface.
0054   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt&               P,
0055                                              const Handle(Geom_Surface)& Surface,
0056                                              const Standard_Real         Tolerance,
0057                                              const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
0058 
0059   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt&               P,
0060                                              const Handle(Geom_Surface)& Surface,
0061                                              const Standard_Real         Umin,
0062                                              const Standard_Real         Usup,
0063                                              const Standard_Real         Vmin,
0064                                              const Standard_Real         Vsup,
0065                                              const Standard_Real         Tolerance,
0066                                              const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
0067 
0068   //! Init the projection  of a point <P> on a surface
0069   //! <Surface>
0070   Standard_EXPORT GeomAPI_ProjectPointOnSurf(const gp_Pnt&               P,
0071                                              const Handle(Geom_Surface)& Surface,
0072                                              const Standard_Real         Umin,
0073                                              const Standard_Real         Usup,
0074                                              const Standard_Real         Vmin,
0075                                              const Standard_Real         Vsup,
0076                                              const Extrema_ExtAlgo Algo = Extrema_ExtAlgo_Grad);
0077 
0078   Standard_EXPORT void Init(const gp_Pnt&               P,
0079                             const Handle(Geom_Surface)& Surface,
0080                             const Standard_Real         Tolerance,
0081                             const Extrema_ExtAlgo       Algo = Extrema_ExtAlgo_Grad);
0082 
0083   //! Init the projection of a point <P>  on a surface
0084   //! <Surface>. The solution are computed in the domain
0085   //! [Umin,Usup] [Vmin,Vsup] of the surface.
0086   Standard_EXPORT void Init(const gp_Pnt&               P,
0087                             const Handle(Geom_Surface)& Surface,
0088                             const Extrema_ExtAlgo       Algo = Extrema_ExtAlgo_Grad);
0089 
0090   Standard_EXPORT void Init(const gp_Pnt&               P,
0091                             const Handle(Geom_Surface)& Surface,
0092                             const Standard_Real         Umin,
0093                             const Standard_Real         Usup,
0094                             const Standard_Real         Vmin,
0095                             const Standard_Real         Vsup,
0096                             const Standard_Real         Tolerance,
0097                             const Extrema_ExtAlgo       Algo = Extrema_ExtAlgo_Grad);
0098 
0099   //! Init the projection for many points on a surface
0100   //! <Surface>. The solutions will be computed in the domain
0101   //! [Umin,Usup] [Vmin,Vsup] of the surface.
0102   Standard_EXPORT void Init(const gp_Pnt&               P,
0103                             const Handle(Geom_Surface)& Surface,
0104                             const Standard_Real         Umin,
0105                             const Standard_Real         Usup,
0106                             const Standard_Real         Vmin,
0107                             const Standard_Real         Vsup,
0108                             const Extrema_ExtAlgo       Algo = Extrema_ExtAlgo_Grad);
0109 
0110   Standard_EXPORT void Init(const Handle(Geom_Surface)& Surface,
0111                             const Standard_Real         Umin,
0112                             const Standard_Real         Usup,
0113                             const Standard_Real         Vmin,
0114                             const Standard_Real         Vsup,
0115                             const Standard_Real         Tolerance,
0116                             const Extrema_ExtAlgo       Algo = Extrema_ExtAlgo_Grad);
0117 
0118   Standard_EXPORT void Init(const Handle(Geom_Surface)& Surface,
0119                             const Standard_Real         Umin,
0120                             const Standard_Real         Usup,
0121                             const Standard_Real         Vmin,
0122                             const Standard_Real         Vsup,
0123                             const Extrema_ExtAlgo       Algo = Extrema_ExtAlgo_Grad);
0124 
0125   //! Sets the Extrema search algorithm - Grad or Tree. <br>
0126   //! By default the Extrema is initialized with Grad algorithm.
0127   void SetExtremaAlgo(const Extrema_ExtAlgo theAlgo) { myExtPS.SetAlgo(theAlgo); }
0128 
0129   //! Sets the Extrema search flag - MIN or MAX or MINMAX.<br>
0130   //! By default the Extrema is set to search the MinMax solutions.
0131   void SetExtremaFlag(const Extrema_ExtFlag theExtFlag) { myExtPS.SetFlag(theExtFlag); }
0132 
0133   //! Performs the projection of a point on the current surface.
0134   Standard_EXPORT void Perform(const gp_Pnt& P);
0135 
0136   Standard_EXPORT Standard_Boolean IsDone() const;
0137 
0138   //! Returns the number of computed orthogonal projection points.
0139   //! Note: if projection fails, NbPoints returns 0.
0140   Standard_EXPORT Standard_Integer NbPoints() const;
0141   Standard_EXPORT                  operator Standard_Integer() const;
0142 
0143   //! Returns the orthogonal projection
0144   //! on the surface. Index is a number of a computed point.
0145   //! Exceptions
0146   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0147   //! NbPoints is the number of solution points.
0148   Standard_EXPORT gp_Pnt Point(const Standard_Integer Index) const;
0149 
0150   //! Returns the parameters (U,V) on the
0151   //! surface of the orthogonal projection. Index is a number of a
0152   //! computed point.
0153   //! Exceptions
0154   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0155   //! NbPoints is the number of solution points.
0156   Standard_EXPORT void Parameters(const Standard_Integer Index,
0157                                   Standard_Real&         U,
0158                                   Standard_Real&         V) const;
0159 
0160   //! Computes the distance between the
0161   //! point and its orthogonal projection on the surface. Index is a number
0162   //! of a computed point.
0163   //! Exceptions
0164   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0165   //! NbPoints is the number of solution points.
0166   Standard_EXPORT Standard_Real Distance(const Standard_Integer Index) const;
0167 
0168   //! Returns the nearest orthogonal projection of the point
0169   //! on the surface.
0170   //! Exceptions
0171   //! StdFail_NotDone if projection fails.
0172   Standard_EXPORT gp_Pnt NearestPoint() const;
0173   Standard_EXPORT        operator gp_Pnt() const;
0174 
0175   //! Returns the parameters (U,V) on the
0176   //! surface of the nearest computed orthogonal projection of the point.
0177   //! Exceptions
0178   //! StdFail_NotDone if projection fails.
0179   Standard_EXPORT void LowerDistanceParameters(Standard_Real& U, Standard_Real& V) const;
0180 
0181   //! Computes the distance between the
0182   //! point and its nearest orthogonal projection on the surface.
0183   //! Exceptions
0184   //! StdFail_NotDone if projection fails.
0185   Standard_EXPORT Standard_Real LowerDistance() const;
0186   Standard_EXPORT               operator Standard_Real() const;
0187 
0188   //! return the algorithmic object from Extrema
0189   const Extrema_ExtPS& Extrema() const;
0190 
0191 private:
0192   Standard_EXPORT void Init();
0193 
0194   Standard_Boolean    myIsDone;
0195   Standard_Integer    myIndex;
0196   Extrema_ExtPS       myExtPS;
0197   GeomAdaptor_Surface myGeomAdaptor;
0198 };
0199 
0200 #include <GeomAPI_ProjectPointOnSurf.lxx>
0201 
0202 #endif // _GeomAPI_ProjectPointOnSurf_HeaderFile