Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:11

0001 // Created on: 1992-04-03
0002 // Created by: Isabelle GRIGNON
0003 // Copyright (c) 1992-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 _IntWalk_PWalking_HeaderFile
0018 #define _IntWalk_PWalking_HeaderFile
0019 
0020 #include <Adaptor3d_Surface.hxx>
0021 #include <gp_Dir.hxx>
0022 #include <IntImp_ConstIsoparametric.hxx>
0023 #include <IntSurf_PntOn2S.hxx>
0024 #include <gp_Dir2d.hxx>
0025 #include <IntWalk_TheInt2S.hxx>
0026 #include <TColStd_Array1OfReal.hxx>
0027 #include <IntWalk_StatusDeflection.hxx>
0028 
0029 class gp_Pnt;
0030 
0031 //! This class implements an algorithm to determine the
0032 //! intersection between 2 parametrized surfaces, marching from
0033 //! a starting point. The intersection line
0034 //! starts and ends on the natural surface's  boundaries .
0035 class IntWalk_PWalking 
0036 {
0037 public:
0038 
0039   DEFINE_STANDARD_ALLOC
0040 
0041   
0042   //! Constructor used to set the data to compute intersection
0043   //! lines between Caro1 and Caro2.
0044   //! Deflection is the maximum deflection admitted between two
0045   //! consecutive points on the resulting polyline.
0046   //! TolTangency is the tolerance to find a tangent point.
0047   //! Func is the criterion which has to be evaluated at each
0048   //! solution point (each point of the line).
0049   //! It is necessary to call the Perform method to compute
0050   //! the intersection lines.
0051   //! The line found starts at a point on or in 2 natural domains
0052   //! of surfaces. It can be closed in the
0053   //! standard case if it is open it stops and begins at the
0054   //! border of one of the domains. If an open line
0055   //! stops at the middle of a domain, one stops at the tangent point.
0056   //! Epsilon is SquareTolerance of points confusion.
0057   Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_Surface)& Caro1,
0058                                    const Handle(Adaptor3d_Surface)& Caro2,
0059                                    const Standard_Real TolTangency,
0060                                    const Standard_Real Epsilon,
0061                                    const Standard_Real Deflection,
0062                                    const Standard_Real Increment);
0063   
0064   //! Returns the intersection line containing the exact
0065   //! point Poin. This line is a polygonal line.
0066   //! Deflection is the maximum deflection admitted between two
0067   //! consecutive points on the resulting polyline.
0068   //! TolTangency is the tolerance to find a tangent point.
0069   //! Func is the criterion which has to be evaluated at each
0070   //! solution point (each point of the line).
0071   //! The line found starts at a point on or in 2 natural domains
0072   //! of surfaces. It can be closed in the
0073   //! standard case if it is open it stops and begins at the
0074   //! border of one of the domains. If an open line
0075   //! stops at the middle of a domain, one stops at the tangent point.
0076   //! Epsilon is SquareTolerance of points confusion.
0077   Standard_EXPORT IntWalk_PWalking(const Handle(Adaptor3d_Surface)& Caro1,
0078                                    const Handle(Adaptor3d_Surface)& Caro2,
0079                                    const Standard_Real TolTangency,
0080                                    const Standard_Real Epsilon,
0081                                    const Standard_Real Deflection,
0082                                    const Standard_Real Increment,
0083                                    const Standard_Real U1,
0084                                    const Standard_Real V1,
0085                                    const Standard_Real U2,
0086                                    const Standard_Real V2);
0087   
0088   //! calculate the line of intersection
0089   Standard_EXPORT void Perform (const TColStd_Array1OfReal& ParDep);
0090   
0091   //! calculate the line of intersection. The regulation
0092   //! of steps is done using min and max values on u and
0093   //! v.  (if this data is not presented as in the
0094   //! previous method, the initial steps are calculated
0095   //! starting from min and max uv of faces).
0096   Standard_EXPORT void Perform (const TColStd_Array1OfReal& ParDep,
0097                                 const Standard_Real u1min,
0098                                 const Standard_Real v1min,
0099                                 const Standard_Real u2min,
0100                                 const Standard_Real v2min,
0101                                 const Standard_Real u1max,
0102                                 const Standard_Real v1max,
0103                                 const Standard_Real u2max,
0104                                 const Standard_Real v2max);
0105   
0106   //! calculate the first point of a line of intersection
0107   Standard_EXPORT Standard_Boolean PerformFirstPoint (const TColStd_Array1OfReal& ParDep,
0108                                                       IntSurf_PntOn2S& FirstPoint);
0109   
0110   //! Returns true if the calculus was successful.
0111     Standard_Boolean IsDone() const;
0112   
0113   //! Returns the number of points of the resulting polyline.
0114   //! An exception is raised if IsDone returns False.
0115     Standard_Integer NbPoints() const;
0116   
0117   //! Returns the point of range Index on the polyline.
0118   //! An exception is raised if IsDone returns False.
0119   //! An exception is raised if Index<=0 or Index>NbPoints.
0120     const IntSurf_PntOn2S& Value (const Standard_Integer Index) const;
0121   
0122     const Handle(IntSurf_LineOn2S)& Line() const;
0123   
0124   //! Returns True if the surface are tangent at the first point
0125   //! of the line.
0126   //! An exception is raised if IsDone returns False.
0127     Standard_Boolean TangentAtFirst() const;
0128   
0129   //! Returns true if the surface are tangent at the last point
0130   //! of the line.
0131   //! An exception is raised if IsDone returns False.
0132     Standard_Boolean TangentAtLast() const;
0133   
0134   //! Returns True if the line is closed.
0135   //! An exception is raised if IsDone returns False.
0136     Standard_Boolean IsClosed() const;
0137   
0138     const gp_Dir& TangentAtLine (Standard_Integer& Index) const;
0139   
0140   Standard_EXPORT   IntWalk_StatusDeflection TestDeflection (const IntImp_ConstIsoparametric ChoixIso,
0141                                                              const IntWalk_StatusDeflection  theStatus);
0142   
0143   Standard_EXPORT Standard_Boolean TestArret (const Standard_Boolean DejaReparti,
0144                                               TColStd_Array1OfReal& Param,
0145                                               IntImp_ConstIsoparametric& ChoixIso);
0146   
0147   Standard_EXPORT void RepartirOuDiviser (Standard_Boolean& DejaReparti,
0148                                           IntImp_ConstIsoparametric& ChoixIso,
0149                                           Standard_Boolean& Arrive);
0150   
0151   //! Inserts thePOn2S in the end of line
0152   void AddAPoint (const IntSurf_PntOn2S& thePOn2S);
0153 
0154   //! Removes point with index theIndex from line.
0155   //! If theIndex is greater than the number of points in line
0156   //! then the last point will be removed.
0157   //! theIndex must be started with 1.
0158   void RemoveAPoint(const Standard_Integer theIndex)
0159   {
0160     const Standard_Integer anIdx = Min(theIndex, line->NbPoints());
0161     
0162     if (anIdx < 1)
0163       return;
0164 
0165     if (anIdx <= myTangentIdx)
0166     {
0167       myTangentIdx--;
0168 
0169       if (myTangentIdx < 1)
0170         myTangentIdx = 1;
0171     }
0172 
0173     line->RemovePoint(anIdx);
0174   }
0175   
0176   Standard_EXPORT Standard_Boolean PutToBoundary (const Handle(Adaptor3d_Surface)& theASurf1,
0177                                                   const Handle(Adaptor3d_Surface)& theASurf2);
0178   
0179   Standard_EXPORT Standard_Boolean SeekAdditionalPoints (const Handle(Adaptor3d_Surface)& theASurf1,
0180                                                          const Handle(Adaptor3d_Surface)& theASurf2,
0181                                                          const Standard_Integer theMinNbPoints);
0182 
0183   Standard_Real MaxStep(Standard_Integer theIndex)
0184   {
0185     Standard_OutOfRange_Raise_if ((theIndex < 0) || (theIndex > 3),
0186                                   "IntWalk_PWalking::MaxStep() - index is out of range");
0187     return pasInit[theIndex];
0188   }
0189 
0190 
0191 
0192 protected:
0193   Standard_EXPORT void ComputePasInit(const Standard_Real theDeltaU1,
0194                                       const Standard_Real theDeltaV1,
0195                                       const Standard_Real theDeltaU2,
0196                                       const Standard_Real theDeltaV2);
0197 
0198   //! Uses Gradient method in order to find intersection point between the given surfaces
0199   //! Arrays theInit (initial point to be precise) and theStep0 (steps-array) must contain
0200   //! four items and must be filled strictly in following order:
0201   //! {U-parameter on S1, V-parameter on S1, U-parameter on S2, V-parameter on S2}
0202   Standard_EXPORT Standard_Boolean DistanceMinimizeByGradient(const Handle(Adaptor3d_Surface)& theASurf1,
0203                                                               const Handle(Adaptor3d_Surface)& theASurf2,
0204                                                               TColStd_Array1OfReal& theInit,
0205                                                               const Standard_Real* theStep0 = 0);
0206   
0207   //! Finds the point on theASurf which is the nearest point to theP0.
0208   //! theU0 and theV0 must be initialized (before calling the method) by initial
0209   //! parameters on theASurf. Their values are changed while algorithm being launched.
0210   //! Array theStep0 (steps-array) must contain two items and must be filled strictly in following order:
0211   //! {U-parameter, V-parameter}
0212   Standard_EXPORT Standard_Boolean DistanceMinimizeByExtrema (const Handle(Adaptor3d_Surface)& theASurf,
0213                                                               const gp_Pnt& theP0,                                                              
0214                                                               Standard_Real& theU0,
0215                                                               Standard_Real& theV0,
0216                                                               const Standard_Real* theStep0 = 0);
0217   
0218   //! Searches an intersection point which lies on the some surface boundary.
0219   //! Found point (in case of successful result) is added in the line.
0220   //! theU1, theV1, theU2 and theV2 parameters are initial parameters in
0221   //! for used numeric algorithms. If isTheFirst == TRUE then
0222   //! a point on theASurf1 is searched. Otherwise, the point on theASurf2 is searched.
0223   //!
0224   //! ATTENTION!!!
0225   //!   This method can delete some points from the curve if it is necessary
0226   //!   (in order to obtain correct result after insertion).
0227   //!   Returns TRUE in case of success adding (i.e. can return FALSE even after
0228   //!   removing some points).
0229   Standard_EXPORT Standard_Boolean SeekPointOnBoundary (const Handle(Adaptor3d_Surface)& theASurf1,
0230                                                         const Handle(Adaptor3d_Surface)& theASurf2,
0231                                                         const Standard_Real theU1,
0232                                                         const Standard_Real theV1,
0233                                                         const Standard_Real theU2,
0234                                                         const Standard_Real theV2,
0235                                                         const Standard_Boolean isTheFirst);
0236 
0237 
0238   // Method to handle single singular point. Sub-method in SeekPointOnBoundary.
0239   Standard_EXPORT Standard_Boolean HandleSingleSingularPoint(const Handle(Adaptor3d_Surface) &theASurf1,
0240                                                              const Handle(Adaptor3d_Surface) &theASurf2,
0241                                                              const Standard_Real the3DTol,
0242                                                              TColStd_Array1OfReal &thePnt);
0243   
0244   Standard_EXPORT Standard_Boolean ExtendLineInCommonZone (const IntImp_ConstIsoparametric theChoixIso,
0245                                                            const Standard_Boolean theDirectionFlag);
0246 
0247 private:
0248   Standard_Boolean done;
0249   Handle(IntSurf_LineOn2S) line;
0250   Standard_Boolean close;
0251   Standard_Boolean tgfirst;
0252   Standard_Boolean tglast;
0253 
0254   //! Index of point on the surface boundary.
0255   //! It is used for transition computation
0256   Standard_Integer myTangentIdx;
0257 
0258   //! Tangent to WLine in the point with index myTangentIdx
0259   gp_Dir tgdir;
0260 
0261   Standard_Real fleche;
0262   Standard_Real pasMax;
0263   Standard_Real tolconf;
0264   Standard_Real myTolTang;
0265   Standard_Real pasuv[4];
0266   Standard_Real myStepMin[4];
0267   Standard_Real pasSav[4];
0268   Standard_Real pasInit[4];
0269   Standard_Real Um1;
0270   Standard_Real UM1;
0271   Standard_Real Vm1;
0272   Standard_Real VM1;
0273   Standard_Real Um2;
0274   Standard_Real UM2;
0275   Standard_Real Vm2;
0276   Standard_Real VM2;
0277   Standard_Real ResoU1;
0278   Standard_Real ResoU2;
0279   Standard_Real ResoV1;
0280   Standard_Real ResoV2;
0281   Standard_Integer sensCheminement;
0282   IntImp_ConstIsoparametric choixIsoSav;
0283   IntSurf_PntOn2S previousPoint;
0284   Standard_Boolean previoustg;
0285   gp_Dir previousd;
0286   gp_Dir2d previousd1;
0287   gp_Dir2d previousd2;
0288   gp_Dir2d firstd1;
0289   gp_Dir2d firstd2;
0290   IntWalk_TheInt2S myIntersectionOn2S;
0291   Standard_Integer STATIC_BLOCAGE_SUR_PAS_TROP_GRAND;
0292   Standard_Integer STATIC_PRECEDENT_INFLEXION;
0293 
0294 
0295 };
0296 
0297 
0298 #include <IntWalk_PWalking.lxx>
0299 
0300 
0301 
0302 
0303 
0304 #endif // _IntWalk_PWalking_HeaderFile