Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:28

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