Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-03 09:16:06

0001 // Created on: 2003-03-18
0002 // Created by: Oleg FEDYAEV
0003 // Copyright (c) 2003-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _GeomLib_Tool_HeaderFile
0017 #define _GeomLib_Tool_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <Standard_Boolean.hxx>
0024 #include <Standard_Real.hxx>
0025 
0026 class Geom_Curve;
0027 class Geom_Surface;
0028 class Geom2d_Curve;
0029 class Geom2dAdaptor_Curve;
0030 class gp_Lin2d;
0031 class gp_Pnt;
0032 class gp_Pnt2d;
0033 class gp_Vec2d;
0034 
0035 //! Provides various methods with Geom2d and Geom curves and surfaces.
0036 //! The methods of this class compute the parameter(s) of a given point on a
0037 //! curve or a surface. To get the valid result the point must be located rather close
0038 //! to the curve (surface) or at least to allow getting unambiguous result
0039 //! (do not put point at center of circle...),
0040 //! but choice of "trust" distance between curve/surface and point is
0041 //! responsibility of user (parameter MaxDist).
0042 //! Return FALSE if the point is beyond the MaxDist
0043 //! limit or if computation fails.
0044 class GeomLib_Tool
0045 {
0046 public:
0047   DEFINE_STANDARD_ALLOC
0048 
0049   //! Extracts the parameter of a 3D point lying on a 3D curve
0050   //! or at a distance less than the MaxDist value.
0051   Standard_EXPORT static bool Parameter(const occ::handle<Geom_Curve>& Curve,
0052                                         const gp_Pnt&                  Point,
0053                                         const double                   MaxDist,
0054                                         double&                        U);
0055 
0056   //! Extracts the parameter of a 3D point lying on a surface
0057   //! or at a distance less than the MaxDist value.
0058   Standard_EXPORT static bool Parameters(const occ::handle<Geom_Surface>& Surface,
0059                                          const gp_Pnt&                    Point,
0060                                          const double                     MaxDist,
0061                                          double&                          U,
0062                                          double&                          V);
0063 
0064   //! Extracts the parameter of a 2D point lying on a 2D curve
0065   //! or at a distance less than the MaxDist value.
0066   Standard_EXPORT static bool Parameter(const occ::handle<Geom2d_Curve>& Curve,
0067                                         const gp_Pnt2d&                  Point,
0068                                         const double                     MaxDist,
0069                                         double&                          U);
0070 
0071   //! Computes parameter in theCurve (*thePrmOnCurve) where maximal deviation
0072   //! between theCurve and the linear segment joining its points with
0073   //! the parameters theFPar and theLPar is obtained.
0074   //! Returns the (positive) value of deviation. Returns negative value if
0075   //! the deviation cannot be computed.
0076   //! The returned parameter (in case of successful) will always be in
0077   //! the range [theFPar, theLPar].
0078   //! Iterative method is used for computation. So, theStartParameter is
0079   //! needed to be set. Recommend value of theStartParameter can be found with
0080   //! the overloaded method.
0081   //! Additionally, following values can be returned (optionally):
0082   //! @param thePtOnCurve - the point on curve where maximal deviation is achieved;
0083   //! @param thePrmOnCurve - the parameter of thePtOnCurve;
0084   //! @param theVecCurvLine - the vector along which is computed (this vector is always
0085   //!                         perpendicular theLine);
0086   //! @param theLine - the linear segment joining the point of theCurve having parameters
0087   //!                  theFPar and theLPar.
0088   Standard_EXPORT static double ComputeDeviation(const Geom2dAdaptor_Curve& theCurve,
0089                                                  const double               theFPar,
0090                                                  const double               theLPar,
0091                                                  const double               theStartParameter,
0092                                                  const int                  theNbIters    = 100,
0093                                                  double* const              thePrmOnCurve = nullptr,
0094                                                  gp_Pnt2d* const            thePtOnCurve  = nullptr,
0095                                                  gp_Vec2d* const theVecCurvLine           = nullptr,
0096                                                  gp_Lin2d* const theLine = nullptr);
0097 
0098   //! Computes parameter in theCurve (*thePrmOnCurve) where maximal deviation
0099   //! between theCurve and the linear segment joining its points with
0100   //! the parameters theFPar and theLPar is obtained.
0101   //! Returns the (positive) value of deviation. Returns negative value if
0102   //! the deviation cannot be computed.
0103   //! The returned parameter (in case of successful) will always be in
0104   //! the range [theFPar, theLPar].
0105   //! theNbSubIntervals defines discretization of the given interval [theFPar, theLPar]
0106   //! to provide better search condition. This value should be chosen taking into
0107   //! account complexity of the curve in considered interval. E.g. if there are many
0108   //! oscillations of the curve in the interval then theNbSubIntervals mus be
0109   //! great number. However, the greater value of theNbSubIntervals the slower the
0110   //! algorithm will compute.
0111   //! theNbIters sets number of iterations.
0112   //!   ATTENTION!!!
0113   //! This algorithm cannot compute deviation precisely (so, there is no point in
0114   //! setting big value of theNbIters). But it can give some start point for
0115   //! the overloaded method.
0116   Standard_EXPORT static double ComputeDeviation(const Geom2dAdaptor_Curve& theCurve,
0117                                                  const double               theFPar,
0118                                                  const double               theLPar,
0119                                                  const int                  theNbSubIntervals,
0120                                                  const int                  theNbIters = 10,
0121                                                  double* const thePrmOnCurve           = nullptr);
0122 };
0123 
0124 #endif // _GeomLib_Tool_HeaderFile