Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:17:45

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_CommonPrt.hxx>
0030 #include <NCollection_Sequence.hxx>
0031 #include <IntTools_Range.hxx>
0032 class IntTools_Context;
0033 class gp_Pnt;
0034 class IntTools_CommonPrt;
0035 
0036 //! The class provides Edge/Face intersection algorithm to determine
0037 //! common parts between edge and face in 3-d space.
0038 //! Common parts between Edge and Face can be:
0039 //! - Vertices - in case of intersection or touching;
0040 //! - Edge - in case of full coincidence of the edge with the face.
0041 class IntTools_EdgeFace
0042 {
0043 public:
0044   DEFINE_STANDARD_ALLOC
0045 
0046 public: //! @name Constructors
0047   //! Empty Constructor
0048   Standard_EXPORT IntTools_EdgeFace();
0049 
0050 public: //! @name Setters/Getters
0051   //! Sets the edge for intersection
0052   void SetEdge(const TopoDS_Edge& theEdge) { myEdge = theEdge; }
0053 
0054   //! Returns the edge
0055   const TopoDS_Edge& Edge() const { return myEdge; }
0056 
0057   //! Sets the face for intersection
0058   void SetFace(const TopoDS_Face& theFace) { myFace = theFace; }
0059 
0060   //! Returns the face
0061   const TopoDS_Face& Face() const { return myFace; }
0062 
0063   //! Sets the boundaries for the edge.
0064   //! The algorithm processes edge inside these boundaries.
0065   void SetRange(const IntTools_Range& theRange) { myRange = theRange; }
0066 
0067   //! Sets the boundaries for the edge.
0068   //! The algorithm processes edge inside these boundaries.
0069   void SetRange(const double theFirst, const double theLast)
0070   {
0071     myRange.SetFirst(theFirst);
0072     myRange.SetLast(theLast);
0073   }
0074 
0075   //! Returns intersection range of the edge
0076   const IntTools_Range& Range() const { return myRange; }
0077 
0078   //! Sets the intersection context
0079   void SetContext(const occ::handle<IntTools_Context>& theContext) { myContext = theContext; }
0080 
0081   //! Returns the intersection context
0082   const occ::handle<IntTools_Context>& Context() const { return myContext; }
0083 
0084   //! Sets the Fuzzy value
0085   void SetFuzzyValue(const double theFuzz)
0086   {
0087     myFuzzyValue = (std::max)(theFuzz, Precision::Confusion());
0088   }
0089 
0090   //! Returns the Fuzzy value
0091   double FuzzyValue() const { return myFuzzyValue; }
0092 
0093   //! Sets the flag for quick coincidence check.
0094   //! It is safe to use the quick check for coincidence only if both
0095   //! of the following conditions are met:
0096   //! - The vertices of edge are lying on the face;
0097   //! - The edge does not intersect the boundaries of the face on the given range.
0098   void UseQuickCoincidenceCheck(const bool theFlag) { myQuickCoincidenceCheck = theFlag; }
0099 
0100   //! Returns the flag myQuickCoincidenceCheck
0101   bool IsCoincidenceCheckedQuickly() { return myQuickCoincidenceCheck; }
0102 
0103 public: //! @name Performing the operation
0104   //! Launches the process
0105   Standard_EXPORT void Perform();
0106 
0107 public: //! @name Checking validity of the intersection
0108   //! Returns TRUE if computation was successful.
0109   //! Otherwise returns FALSE.
0110   bool IsDone() const { return myIsDone; }
0111 
0112   //! Returns the code of completion:
0113   //! 0 - means successful completion;
0114   //! 1 - the process was not started;
0115   //! 2,3 - invalid source data for the algorithm;
0116   //! 4 - projection failed.
0117   int ErrorStatus() const { return myErrorStatus; }
0118 
0119 public: //! @name Obtaining results
0120   //! Returns resulting common parts
0121   const NCollection_Sequence<IntTools_CommonPrt>& CommonParts() const { return mySeqOfCommonPrts; }
0122 
0123   //! Returns the minimal distance found between edge and face
0124   double MinimalDistance() const { return myMinDistance; }
0125 
0126 protected: //! @name Protected methods performing the intersection
0127   Standard_EXPORT static bool IsEqDistance(const gp_Pnt&              aP,
0128                                            const BRepAdaptor_Surface& aS,
0129                                            const double               aT,
0130                                            double&                    aD);
0131   Standard_EXPORT void        CheckData();
0132 
0133   Standard_EXPORT bool IsProjectable(const double t) const;
0134 
0135   Standard_EXPORT double DistanceFunction(const double t);
0136 
0137   Standard_EXPORT int MakeType(IntTools_CommonPrt& aCP);
0138 
0139   Standard_EXPORT bool CheckTouch(const IntTools_CommonPrt& aCP, double& aTX);
0140 
0141   Standard_EXPORT bool CheckTouchVertex(const IntTools_CommonPrt& aCP, double& aTX);
0142 
0143   //! Checks if the edge is in the face really.
0144   Standard_EXPORT bool IsCoincident();
0145 
0146 protected:
0147   TopoDS_Edge                              myEdge;
0148   TopoDS_Face                              myFace;
0149   double                                   myFuzzyValue;
0150   BRepAdaptor_Curve                        myC;
0151   BRepAdaptor_Surface                      myS;
0152   double                                   myCriteria;
0153   bool                                     myIsDone;
0154   int                                      myErrorStatus;
0155   occ::handle<IntTools_Context>            myContext;
0156   NCollection_Sequence<IntTools_CommonPrt> mySeqOfCommonPrts;
0157   IntTools_Range                           myRange;
0158   bool                                     myQuickCoincidenceCheck;
0159   double                                   myMinDistance; //!< Minimal distance found
0160 };
0161 
0162 #endif // _IntTools_EdgeFace_HeaderFile