Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2001-02-26
0002 // Created by: Peter KURNEV
0003 // Copyright (c) 2001-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 _IntTools_EdgeFace_HeaderFile
0017 #define _IntTools_EdgeFace_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <TopoDS_Edge.hxx>
0024 #include <Standard_Real.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <BRepAdaptor_Curve.hxx>
0027 #include <BRepAdaptor_Surface.hxx>
0028 #include <Standard_Boolean.hxx>
0029 #include <IntTools_SequenceOfCommonPrts.hxx>
0030 #include <IntTools_Range.hxx>
0031 class IntTools_Context;
0032 class gp_Pnt;
0033 class IntTools_CommonPrt;
0034 
0035 //! The class provides Edge/Face intersection algorithm to determine
0036 //! common parts between edge and face in 3-d space.
0037 //! Common parts between Edge and Face can be:
0038 //! - Vertices - in case of intersection or touching;
0039 //! - Edge - in case of full coincidence of the edge with the face.
0040 class IntTools_EdgeFace 
0041 {
0042 public:
0043 
0044   DEFINE_STANDARD_ALLOC
0045 
0046 public: //! @name Constructors
0047 
0048   //! Empty Constructor
0049   Standard_EXPORT IntTools_EdgeFace();
0050 
0051 public: //! @name Setters/Getters
0052 
0053   //! Sets the edge for intersection
0054   void SetEdge(const TopoDS_Edge& theEdge)
0055   {
0056     myEdge = theEdge;
0057   }
0058 
0059   //! Returns the edge
0060   const TopoDS_Edge& Edge() const
0061   {
0062     return myEdge;
0063   }
0064 
0065   //! Sets the face for intersection
0066   void SetFace(const TopoDS_Face& theFace)
0067   {
0068     myFace = theFace;
0069   }
0070 
0071   //! Returns the face
0072   const TopoDS_Face& Face() const
0073   {
0074     return myFace;
0075   }
0076 
0077   //! Sets the boundaries for the edge.
0078   //! The algorithm processes edge inside these boundaries.
0079   void SetRange(const IntTools_Range& theRange)
0080   {
0081     myRange = theRange;
0082   }
0083 
0084   //! Sets the boundaries for the edge.
0085   //! The algorithm processes edge inside these boundaries.
0086   void SetRange(const Standard_Real theFirst, const Standard_Real theLast)
0087   {
0088     myRange.SetFirst(theFirst);
0089     myRange.SetLast(theLast);
0090   }
0091 
0092   //! Returns intersection range of the edge
0093   const IntTools_Range& Range() const
0094   {
0095     return myRange;
0096   }
0097 
0098   //! Sets the intersection context
0099   void SetContext(const Handle(IntTools_Context)& theContext)
0100   {
0101     myContext = theContext;
0102   }
0103 
0104   //! Returns the intersection context
0105   const Handle(IntTools_Context)& Context() const
0106   {
0107     return myContext;
0108   }
0109 
0110   //! Sets the Fuzzy value
0111   void SetFuzzyValue(const Standard_Real theFuzz)
0112   {
0113     myFuzzyValue = Max(theFuzz, Precision::Confusion());
0114   }
0115 
0116   //! Returns the Fuzzy value
0117   Standard_Real FuzzyValue() const
0118   {
0119     return myFuzzyValue;
0120   }
0121 
0122   //! Sets the flag for quick coincidence check.
0123   //! It is safe to use the quick check for coincidence only if both
0124   //! of the following conditions are met:
0125   //! - The vertices of edge are lying on the face;
0126   //! - The edge does not intersect the boundaries of the face on the given range.
0127   void UseQuickCoincidenceCheck(const Standard_Boolean theFlag)
0128   {
0129     myQuickCoincidenceCheck = theFlag;
0130   }
0131 
0132   //! Returns the flag myQuickCoincidenceCheck
0133   Standard_Boolean IsCoincidenceCheckedQuickly()
0134   {
0135     return myQuickCoincidenceCheck;
0136   }
0137 
0138 
0139 
0140 public: //! @name Performing the operation
0141 
0142   //! Launches the process
0143   Standard_EXPORT void Perform();
0144 
0145 
0146 public: //! @name Checking validity of the intersection
0147 
0148   //! Returns TRUE if computation was successful.
0149   //! Otherwise returns FALSE.
0150   Standard_Boolean IsDone() const
0151   {
0152     return myIsDone;
0153   }
0154 
0155   //! Returns the code of completion:
0156   //! 0 - means successful completion;
0157   //! 1 - the process was not started;
0158   //! 2,3 - invalid source data for the algorithm;
0159   //! 4 - projection failed.
0160   Standard_Integer ErrorStatus() const
0161   {
0162     return myErrorStatus;
0163   }
0164 
0165 
0166 public: //! @name Obtaining results
0167 
0168   //! Returns resulting common parts
0169   const IntTools_SequenceOfCommonPrts& CommonParts() const
0170   {
0171     return mySeqOfCommonPrts;
0172   }
0173 
0174   //! Returns the minimal distance found between edge and face
0175   Standard_Real MinimalDistance() const
0176   {
0177     return myMinDistance;
0178   }
0179 
0180 protected: //! @name Protected methods performing the intersection
0181 
0182   Standard_EXPORT static Standard_Boolean IsEqDistance (const gp_Pnt& aP, const BRepAdaptor_Surface& aS, const Standard_Real aT, Standard_Real& aD);
0183   Standard_EXPORT void CheckData();
0184   
0185   Standard_EXPORT Standard_Boolean IsProjectable (const Standard_Real t) const;
0186   
0187   Standard_EXPORT Standard_Real DistanceFunction (const Standard_Real t);
0188   
0189   Standard_EXPORT Standard_Integer MakeType (IntTools_CommonPrt& aCP);
0190    
0191   Standard_EXPORT Standard_Boolean CheckTouch (const IntTools_CommonPrt& aCP, Standard_Real& aTX);
0192   
0193   Standard_EXPORT Standard_Boolean CheckTouchVertex (const IntTools_CommonPrt& aCP, Standard_Real& aTX);
0194 
0195   //! Checks if the edge is in the face really.
0196   Standard_EXPORT Standard_Boolean IsCoincident();
0197 
0198 protected:
0199 
0200   TopoDS_Edge myEdge;
0201   TopoDS_Face myFace;
0202   Standard_Real myFuzzyValue;
0203   BRepAdaptor_Curve myC;
0204   BRepAdaptor_Surface myS;
0205   Standard_Real myCriteria;
0206   Standard_Boolean myIsDone;
0207   Standard_Integer myErrorStatus;
0208   Handle(IntTools_Context) myContext;
0209   IntTools_SequenceOfCommonPrts mySeqOfCommonPrts;
0210   IntTools_Range myRange;
0211   Standard_Boolean myQuickCoincidenceCheck;
0212   Standard_Real myMinDistance; //!< Minimal distance found
0213 };
0214 
0215 #endif // _IntTools_EdgeFace_HeaderFile