Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:57:54

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_ProjectPointOnCurve_HeaderFile
0018 #define _GeomAPI_ProjectPointOnCurve_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_ExtPC.hxx>
0026 #include <GeomAdaptor_Curve.hxx>
0027 class gp_Pnt;
0028 class Geom_Curve;
0029 
0030 //! This class implements methods for computing all the orthogonal
0031 //! projections of a 3D point onto a 3D curve.
0032 class GeomAPI_ProjectPointOnCurve
0033 {
0034 public:
0035   DEFINE_STANDARD_ALLOC
0036 
0037   //! Creates an empty object. Use an
0038   //! Init function for further initialization.
0039   Standard_EXPORT GeomAPI_ProjectPointOnCurve();
0040 
0041   //! Create the projection of a point <P> on a curve
0042   //! <Curve>
0043   Standard_EXPORT GeomAPI_ProjectPointOnCurve(const gp_Pnt&                  P,
0044                                               const occ::handle<Geom_Curve>& Curve);
0045 
0046   //! Create the projection of a point <P> on a curve
0047   //! <Curve> limited by the two points of parameter Umin and Usup.
0048   Standard_EXPORT GeomAPI_ProjectPointOnCurve(const gp_Pnt&                  P,
0049                                               const occ::handle<Geom_Curve>& Curve,
0050                                               const double                   Umin,
0051                                               const double                   Usup);
0052 
0053   //! Init the projection of a point <P> on a curve
0054   //! <Curve>
0055   Standard_EXPORT void Init(const gp_Pnt& P, const occ::handle<Geom_Curve>& Curve);
0056 
0057   //! Init the projection of a point <P> on a curve
0058   //! <Curve> limited by the two points of parameter Umin and Usup.
0059   Standard_EXPORT void Init(const gp_Pnt&                  P,
0060                             const occ::handle<Geom_Curve>& Curve,
0061                             const double                   Umin,
0062                             const double                   Usup);
0063 
0064   //! Init the projection of a point <P> on a curve
0065   //! <Curve> limited by the two points of parameter Umin and Usup.
0066   Standard_EXPORT void Init(const occ::handle<Geom_Curve>& Curve,
0067                             const double                   Umin,
0068                             const double                   Usup);
0069 
0070   //! Performs the projection of a point on the current curve.
0071   Standard_EXPORT void Perform(const gp_Pnt& P);
0072 
0073   //! Returns the number of computed
0074   //! orthogonal projection points.
0075   //! Note: if this algorithm fails, NbPoints returns 0.
0076   Standard_EXPORT int NbPoints() const;
0077   Standard_EXPORT     operator int() const;
0078 
0079   //! Returns the orthogonal projection
0080   //! on the curve. Index is a number of a computed point.
0081   //! Exceptions
0082   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0083   //! NbPoints is the number of solution points.
0084   Standard_EXPORT gp_Pnt Point(const int Index) const;
0085 
0086   //! Returns the parameter on the curve
0087   //! of the point, which is the orthogonal projection. Index is a
0088   //! number of a computed point.
0089   //! Exceptions
0090   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0091   //! NbPoints is the number of solution points.
0092   Standard_EXPORT double Parameter(const int Index) const;
0093 
0094   //! Returns the parameter on the curve
0095   //! of the point, which is the orthogonal projection. Index is a
0096   //! number of a computed point.
0097   //! Exceptions
0098   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0099   //! NbPoints is the number of solution points.-
0100   Standard_EXPORT void Parameter(const int Index, double& U) const;
0101 
0102   //! Computes the distance between the
0103   //! point and its orthogonal projection on the curve. Index is a number of a computed point.
0104   //! Exceptions
0105   //! Standard_OutOfRange if Index is not in the range [ 1,NbPoints ], where
0106   //! NbPoints is the number of solution points.
0107   Standard_EXPORT double Distance(const int Index) const;
0108 
0109   //! Returns the nearest orthogonal
0110   //! projection of the point on the curve.
0111   //! Exceptions: StdFail_NotDone if this algorithm fails.
0112   Standard_EXPORT gp_Pnt NearestPoint() const;
0113   Standard_EXPORT        operator gp_Pnt() const;
0114 
0115   //! Returns the parameter on the curve
0116   //! of the nearest orthogonal projection of the point.
0117   //! Exceptions: StdFail_NotDone if this algorithm fails.
0118   Standard_EXPORT double LowerDistanceParameter() const;
0119 
0120   //! Computes the distance between the
0121   //! point and its nearest orthogonal projection on the curve.
0122   //! Exceptions: StdFail_NotDone if this algorithm fails.
0123   Standard_EXPORT double LowerDistance() const;
0124   Standard_EXPORT        operator double() const;
0125 
0126   //! return the algorithmic object from Extrema
0127   const Extrema_ExtPC& Extrema() const;
0128 
0129 private:
0130   bool              myIsDone;
0131   int               myIndex;
0132   Extrema_ExtPC     myExtPC;
0133   GeomAdaptor_Curve myC;
0134 };
0135 
0136 #include <GeomAPI_ProjectPointOnCurve.lxx>
0137 
0138 #endif // _GeomAPI_ProjectPointOnCurve_HeaderFile