Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:14:13

0001 // Created on: 1995-07-18
0002 // Created by: Modelistation
0003 // Copyright (c) 1995-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 _Extrema_GenExtPS_HeaderFile
0018 #define _Extrema_GenExtPS_HeaderFile
0019 
0020 #include <Bnd_Sphere.hxx>
0021 #include <NCollection_Array1.hxx>
0022 #include <NCollection_HArray1.hxx>
0023 #include <Extrema_POnSurfParams.hxx>
0024 #include <NCollection_Array2.hxx>
0025 #include <NCollection_UBTreeFiller.hxx>
0026 #include <NCollection_Handle.hxx>
0027 #include <Extrema_FuncPSNorm.hxx>
0028 #include <Extrema_ExtFlag.hxx>
0029 #include <Extrema_ExtAlgo.hxx>
0030 
0031 class Adaptor3d_Surface;
0032 
0033 //! It calculates all the extremum distances
0034 //! between a point and a surface.
0035 //! These distances can be minimum or maximum.
0036 class Extrema_GenExtPS
0037 {
0038 public:
0039   DEFINE_STANDARD_ALLOC
0040 
0041   //! Empty constructor.
0042   Standard_EXPORT Extrema_GenExtPS();
0043 
0044   //! Destructor.
0045   Standard_EXPORT ~Extrema_GenExtPS();
0046 
0047   //! It calculates all the distances.
0048   //! The function F(u,v)=distance(P,S(u,v)) has an
0049   //! extremum when gradient(F)=0. The algorithm searches
0050   //! all the zeros inside the definition ranges of the
0051   //! surface.
0052   //! NbU and NbV are used to locate the close points
0053   //! to find the zeros. They must be great enough
0054   //! such that if there is N extrema, there will
0055   //! be N extrema between P and the grid.
0056   //! TolU et TolV are used to determine the conditions
0057   //! to stop the iterations; at the iteration number n:
0058   //! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
0059   Standard_EXPORT Extrema_GenExtPS(const gp_Pnt&            P,
0060                                    const Adaptor3d_Surface& S,
0061                                    const int                NbU,
0062                                    const int                NbV,
0063                                    const double             TolU,
0064                                    const double             TolV,
0065                                    const Extrema_ExtFlag    F = Extrema_ExtFlag_MINMAX,
0066                                    const Extrema_ExtAlgo    A = Extrema_ExtAlgo_Grad);
0067 
0068   //! It calculates all the distances.
0069   //! The function F(u,v)=distance(P,S(u,v)) has an
0070   //! extremum when gradient(F)=0. The algorithm searches
0071   //! all the zeros inside the definition ranges of the
0072   //! surface.
0073   //! NbU and NbV are used to locate the close points
0074   //! to find the zeros. They must be great enough
0075   //! such that if there is N extrema, there will
0076   //! be N extrema between P and the grid.
0077   //! TolU et TolV are used to determine the conditions
0078   //! to stop the iterations; at the iteration number n:
0079   //! (Un - Un-1) < TolU and (Vn - Vn-1) < TolV .
0080   Standard_EXPORT Extrema_GenExtPS(const gp_Pnt&            P,
0081                                    const Adaptor3d_Surface& S,
0082                                    const int                NbU,
0083                                    const int                NbV,
0084                                    const double             Umin,
0085                                    const double             Usup,
0086                                    const double             Vmin,
0087                                    const double             Vsup,
0088                                    const double             TolU,
0089                                    const double             TolV,
0090                                    const Extrema_ExtFlag    F = Extrema_ExtFlag_MINMAX,
0091                                    const Extrema_ExtAlgo    A = Extrema_ExtAlgo_Grad);
0092 
0093   Standard_EXPORT void Initialize(const Adaptor3d_Surface& S,
0094                                   const int                NbU,
0095                                   const int                NbV,
0096                                   const double             TolU,
0097                                   const double             TolV);
0098 
0099   Standard_EXPORT void Initialize(const Adaptor3d_Surface& S,
0100                                   const int                NbU,
0101                                   const int                NbV,
0102                                   const double             Umin,
0103                                   const double             Usup,
0104                                   const double             Vmin,
0105                                   const double             Vsup,
0106                                   const double             TolU,
0107                                   const double             TolV);
0108 
0109   //! the algorithm is done with the point P.
0110   //! An exception is raised if the fields have not
0111   //! been initialized.
0112   Standard_EXPORT void Perform(const gp_Pnt& P);
0113 
0114   Standard_EXPORT void SetFlag(const Extrema_ExtFlag F);
0115 
0116   Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A);
0117 
0118   //! Returns True if the distances are found.
0119   Standard_EXPORT bool IsDone() const;
0120 
0121   //! Returns the number of extremum distances.
0122   Standard_EXPORT int NbExt() const;
0123 
0124   //! Returns the value of the Nth resulting square distance.
0125   Standard_EXPORT double SquareDistance(const int N) const;
0126 
0127   //! Returns the point of the Nth resulting distance.
0128   Standard_EXPORT const Extrema_POnSurf& Point(const int N) const;
0129 
0130 private:
0131   Standard_EXPORT void BuildTree();
0132 
0133   Standard_EXPORT void FindSolution(const gp_Pnt& P, const Extrema_POnSurfParams& theParams);
0134 
0135   //! Selection of points to build grid, depending on the type of surface
0136   Standard_EXPORT void GetGridPoints(const Adaptor3d_Surface& theSurf);
0137 
0138   //! Creation of grid of parametric points
0139   Standard_EXPORT void BuildGrid(const gp_Pnt& thePoint);
0140 
0141   //! Compute new edge parameters.
0142   Standard_EXPORT const Extrema_POnSurfParams& ComputeEdgeParameters(
0143     const bool                   IsUEdge,
0144     const Extrema_POnSurfParams& theParam0,
0145     const Extrema_POnSurfParams& theParam1,
0146     const gp_Pnt&                thePoints,
0147     const double                 theDiffTol);
0148 
0149 private:
0150   // disallow copies
0151   Extrema_GenExtPS(const Extrema_GenExtPS&)            = delete;
0152   Extrema_GenExtPS& operator=(const Extrema_GenExtPS&) = delete;
0153 
0154 private:
0155   bool   myDone;
0156   bool   myInit;
0157   double myumin;
0158   double myusup;
0159   double myvmin;
0160   double myvsup;
0161   int    myusample;
0162   int    myvsample;
0163   double mytolu;
0164   double mytolv;
0165 
0166   NCollection_Array2<Extrema_POnSurfParams>               myPoints;
0167   NCollection_Handle<NCollection_UBTree<int, Bnd_Sphere>> mySphereUBTree;
0168   occ::handle<NCollection_HArray1<Bnd_Sphere>>            mySphereArray;
0169   Extrema_FuncPSNorm                                      myF;
0170   const Adaptor3d_Surface*                                myS;
0171   Extrema_ExtFlag                                         myFlag;
0172   Extrema_ExtAlgo                                         myAlgo;
0173   occ::handle<NCollection_HArray1<double>>                myUParams;
0174   occ::handle<NCollection_HArray1<double>>                myVParams;
0175   NCollection_Array2<Extrema_POnSurfParams>               myFacePntParams;
0176   NCollection_Array2<Extrema_POnSurfParams>               myUEdgePntParams;
0177   NCollection_Array2<Extrema_POnSurfParams>               myVEdgePntParams;
0178   Extrema_POnSurfParams                                   myGridParam;
0179 };
0180 
0181 #endif // _Extrema_GenExtPS_HeaderFile