Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-24 09:13:38

0001 // Created on: 1994-07-06
0002 // Created by: Laurent PAINNOT
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 _Extrema_ExtCC_HeaderFile
0018 #define _Extrema_ExtCC_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <Extrema_ECC.hxx>
0024 #include <Extrema_POnCurv.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <gp_Pnt.hxx>
0027 
0028 class Adaptor3d_Curve;
0029 class Extrema_POnCurv;
0030 class Extrema_ExtElC;
0031 
0032 //! It calculates all the distance between two curves.
0033 //! These distances can be maximum or minimum.
0034 class Extrema_ExtCC
0035 {
0036 public:
0037   DEFINE_STANDARD_ALLOC
0038 
0039   Standard_EXPORT Extrema_ExtCC(const double TolC1 = 1.0e-10, const double TolC2 = 1.0e-10);
0040 
0041   //! It calculates all the distances.
0042   Standard_EXPORT Extrema_ExtCC(const Adaptor3d_Curve& C1,
0043                                 const Adaptor3d_Curve& C2,
0044                                 const double           TolC1 = 1.0e-10,
0045                                 const double           TolC2 = 1.0e-10);
0046 
0047   //! It calculates all the distances.
0048   Standard_EXPORT Extrema_ExtCC(const Adaptor3d_Curve& C1,
0049                                 const Adaptor3d_Curve& C2,
0050                                 const double           U1,
0051                                 const double           U2,
0052                                 const double           V1,
0053                                 const double           V2,
0054                                 const double           TolC1 = 1.0e-10,
0055                                 const double           TolC2 = 1.0e-10);
0056 
0057   //! Initializes but does not perform algorithm.
0058   Standard_EXPORT void Initialize(const Adaptor3d_Curve& C1,
0059                                   const Adaptor3d_Curve& C2,
0060                                   const double           TolC1 = 1.0e-10,
0061                                   const double           TolC2 = 1.0e-10);
0062 
0063   //! Initializes but does not perform algorithm.
0064   Standard_EXPORT void Initialize(const Adaptor3d_Curve& C1,
0065                                   const Adaptor3d_Curve& C2,
0066                                   const double           U1,
0067                                   const double           U2,
0068                                   const double           V1,
0069                                   const double           V2,
0070                                   const double           TolC1 = 1.0e-10,
0071                                   const double           TolC2 = 1.0e-10);
0072 
0073   Standard_EXPORT void SetCurve(const int theRank, const Adaptor3d_Curve& C);
0074 
0075   Standard_EXPORT void SetCurve(const int              theRank,
0076                                 const Adaptor3d_Curve& C,
0077                                 const double           Uinf,
0078                                 const double           Usup);
0079 
0080   Standard_EXPORT void SetRange(const int theRank, const double Uinf, const double Usup);
0081 
0082   Standard_EXPORT void SetTolerance(const int theRank, const double Tol);
0083 
0084   Standard_EXPORT void Perform();
0085 
0086   //! Returns True if the distances are found.
0087   Standard_EXPORT bool IsDone() const;
0088 
0089   //! Returns the number of extremum distances.
0090   Standard_EXPORT int NbExt() const;
0091 
0092   //! Returns True if the two curves are parallel.
0093   Standard_EXPORT bool IsParallel() const;
0094 
0095   //! Returns the value of the Nth extremum square distance.
0096   Standard_EXPORT double SquareDistance(const int N = 1) const;
0097 
0098   //! Returns the points of the Nth extremum distance.
0099   //! P1 is on the first curve, P2 on the second one.
0100   Standard_EXPORT void Points(const int N, Extrema_POnCurv& P1, Extrema_POnCurv& P2) const;
0101 
0102   //! if the curve is a trimmed curve,
0103   //! dist11 is a square distance between the point on C1
0104   //! of parameter FirstParameter and the point of
0105   //! parameter FirstParameter on C2.
0106   Standard_EXPORT void TrimmedSquareDistances(double& dist11,
0107                                               double& distP12,
0108                                               double& distP21,
0109                                               double& distP22,
0110                                               gp_Pnt& P11,
0111                                               gp_Pnt& P12,
0112                                               gp_Pnt& P21,
0113                                               gp_Pnt& P22) const;
0114 
0115   //! Set flag for single extrema computation. Works on parametric solver only.
0116   Standard_EXPORT void SetSingleSolutionFlag(const bool theSingleSolutionFlag);
0117 
0118   //! Get flag for single extrema computation. Works on parametric solver only.
0119   Standard_EXPORT bool GetSingleSolutionFlag() const;
0120 
0121 protected:
0122   //! Prepares the extrema result(s) for analytical cases (line, circle, ellipsis etc.)
0123   Standard_EXPORT void PrepareResults(const Extrema_ExtElC& AlgExt,
0124                                       const bool            theIsInverse,
0125                                       const double          Ut11,
0126                                       const double          Ut12,
0127                                       const double          Ut21,
0128                                       const double          Ut22);
0129 
0130   //! Prepares the extrema result(s) for general cases (e.g. with B-spline curves).
0131   Standard_EXPORT void PrepareResults(const Extrema_ECC& AlgExt,
0132                                       const double       Ut11,
0133                                       const double       Ut12,
0134                                       const double       Ut21,
0135                                       const double       Ut22);
0136 
0137   //! Prepares the extrema result(s) in case when the given curves are parallel.
0138   Standard_EXPORT void PrepareParallelResult(const double theUt11,
0139                                              const double theUt12,
0140                                              const double theUt21,
0141                                              const double theUt22,
0142                                              const double theSqDist);
0143 
0144   // Clears all found extremas.
0145   // This method does not change any flags (e.g. Done or IsParallel)
0146   void ClearSolutions()
0147   {
0148     mySqDist.Clear();
0149     mypoints.Clear();
0150   }
0151 
0152 private:
0153   // disallow copies
0154   Extrema_ExtCC(Extrema_ExtCC&)            = delete;
0155   Extrema_ExtCC& operator=(Extrema_ExtCC&) = delete;
0156 
0157 private:
0158   bool                                  myIsFindSingleSolution; // Default value is false.
0159   Extrema_ECC                           myECC;
0160   bool                                  myDone;
0161   bool                                  myIsParallel;
0162   NCollection_Sequence<Extrema_POnCurv> mypoints;
0163   NCollection_Sequence<double>          mySqDist;
0164   const Adaptor3d_Curve*                myC[2];
0165   double                                myInf[2];
0166   double                                mySup[2];
0167   double                                myTol[2];
0168   gp_Pnt                                myP1f;
0169   gp_Pnt                                myP1l;
0170   gp_Pnt                                myP2f;
0171   gp_Pnt                                myP2l;
0172   double                                mydist11;
0173   double                                mydist12;
0174   double                                mydist21;
0175   double                                mydist22;
0176 };
0177 
0178 #endif // _Extrema_ExtCC_HeaderFile