Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:41

0001 // Created on: 1995-10-20
0002 // Created by: Yves FRICAUD
0003 // Copyright (c) 1995-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 _BRepOffset_Analyse_HeaderFile
0018 #define _BRepOffset_Analyse_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <TopoDS_Shape.hxx>
0024 #include <BRepOffset_Interval.hxx>
0025 #include <NCollection_List.hxx>
0026 #include <TopTools_ShapeMapHasher.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <NCollection_IndexedDataMap.hxx>
0029 #include <ChFiDS_TypeOfConcavity.hxx>
0030 #include <NCollection_Map.hxx>
0031 
0032 #include <Message_ProgressRange.hxx>
0033 
0034 class TopoDS_Edge;
0035 class TopoDS_Vertex;
0036 class TopoDS_Face;
0037 class TopoDS_Compound;
0038 
0039 //! Analyses the shape to find the parts of edges
0040 //! connecting the convex, concave or tangent faces.
0041 class BRepOffset_Analyse
0042 {
0043 public:
0044   DEFINE_STANDARD_ALLOC
0045 
0046 public: //! @name Constructors
0047   //! Empty c-tor
0048   Standard_EXPORT BRepOffset_Analyse();
0049 
0050   //! C-tor performing the job inside
0051   Standard_EXPORT BRepOffset_Analyse(const TopoDS_Shape& theS, const double theAngle);
0052 
0053 public: //! @name Performing analysis
0054   //! Performs the analysis
0055   Standard_EXPORT void Perform(const TopoDS_Shape&          theS,
0056                                const double                 theAngle,
0057                                const Message_ProgressRange& theRange = Message_ProgressRange());
0058 
0059 public: //! @name Results
0060   //! Returns status of the algorithm
0061   bool IsDone() const { return myDone; }
0062 
0063   //! Returns the connectivity type of the edge
0064   Standard_EXPORT const NCollection_List<BRepOffset_Interval>& Type(const TopoDS_Edge& theE) const;
0065 
0066   //! Stores in <L> all the edges of Type <T>
0067   //! on the vertex <V>.
0068   Standard_EXPORT void Edges(const TopoDS_Vertex&            theV,
0069                              const ChFiDS_TypeOfConcavity    theType,
0070                              NCollection_List<TopoDS_Shape>& theL) const;
0071 
0072   //! Stores in <L> all the edges of Type <T>
0073   //! on the face <F>.
0074   Standard_EXPORT void Edges(const TopoDS_Face&              theF,
0075                              const ChFiDS_TypeOfConcavity    theType,
0076                              NCollection_List<TopoDS_Shape>& theL) const;
0077 
0078   //! set in <Edges> all the Edges of <Shape> which are
0079   //! tangent to <Edge> at the vertex <Vertex>.
0080   Standard_EXPORT void TangentEdges(const TopoDS_Edge&              theEdge,
0081                                     const TopoDS_Vertex&            theVertex,
0082                                     NCollection_List<TopoDS_Shape>& theEdges) const;
0083 
0084   //! Checks if the given shape has ancestors
0085   bool HasAncestor(const TopoDS_Shape& theS) const { return myAncestors.Contains(theS); }
0086 
0087   //! Returns ancestors for the shape
0088   const NCollection_List<TopoDS_Shape>& Ancestors(const TopoDS_Shape& theS) const
0089   {
0090     return myAncestors.FindFromKey(theS);
0091   }
0092 
0093   //! Explode in compounds of faces where
0094   //! all the connex edges are of type <Side>
0095   Standard_EXPORT void Explode(NCollection_List<TopoDS_Shape>& theL,
0096                                const ChFiDS_TypeOfConcavity    theType) const;
0097 
0098   //! Explode in compounds of faces where
0099   //! all the connex edges are of type <Side1> or <Side2>
0100   Standard_EXPORT void Explode(NCollection_List<TopoDS_Shape>& theL,
0101                                const ChFiDS_TypeOfConcavity    theType1,
0102                                const ChFiDS_TypeOfConcavity    theType2) const;
0103 
0104   //! Add in <CO> the faces of the shell containing <Face>
0105   //! where all the connex edges are of type <Side>.
0106   Standard_EXPORT void AddFaces(const TopoDS_Face&                                      theFace,
0107                                 TopoDS_Compound&                                        theCo,
0108                                 NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& theMap,
0109                                 const ChFiDS_TypeOfConcavity theType) const;
0110 
0111   //! Add in <CO> the faces of the shell containing <Face>
0112   //! where all the connex edges are of type <Side1> or <Side2>.
0113   Standard_EXPORT void AddFaces(const TopoDS_Face&                                      theFace,
0114                                 TopoDS_Compound&                                        theCo,
0115                                 NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher>& theMap,
0116                                 const ChFiDS_TypeOfConcavity                            theType1,
0117                                 const ChFiDS_TypeOfConcavity theType2) const;
0118 
0119   void SetOffsetValue(const double theOffset) { myOffset = theOffset; }
0120 
0121   //! Sets the face-offset data map to analyze tangential cases
0122   void SetFaceOffsetMap(
0123     const NCollection_DataMap<TopoDS_Shape, double, TopTools_ShapeMapHasher>& theMap)
0124   {
0125     myFaceOffsetMap = theMap;
0126   }
0127 
0128   //! Returns the new faces constructed between tangent faces
0129   //! having different offset values on the shape
0130   const NCollection_List<TopoDS_Shape>& NewFaces() const { return myNewFaces; }
0131 
0132   //! Returns the new face constructed for the edge connecting
0133   //! the two tangent faces having different offset values
0134   Standard_EXPORT TopoDS_Shape Generated(const TopoDS_Shape& theS) const;
0135 
0136   //! Checks if the edge has generated a new face.
0137   bool HasGenerated(const TopoDS_Shape& theS) const { return myGenerated.Seek(theS) != nullptr; }
0138 
0139   //! Returns the replacement of the edge in the face.
0140   //! If no replacement exists, returns the edge
0141   Standard_EXPORT const TopoDS_Edge& EdgeReplacement(const TopoDS_Face& theFace,
0142                                                      const TopoDS_Edge& theEdge) const;
0143 
0144   //! Returns the shape descendants.
0145   Standard_EXPORT const NCollection_List<TopoDS_Shape>* Descendants(
0146     const TopoDS_Shape& theS,
0147     const bool          theUpdate = false) const;
0148 
0149 public: //! @name Clearing the content
0150   //! Clears the content of the algorithm
0151   Standard_EXPORT void Clear();
0152 
0153 private: //! @name Treatment of tangential cases
0154   //! Treatment of the tangential cases.
0155   //! @param theEdges List of edges connecting tangent faces
0156   Standard_EXPORT void TreatTangentFaces(const NCollection_List<TopoDS_Shape>& theEdges,
0157                                          const Message_ProgressRange&          theRange);
0158 
0159 private: //! @name Fields
0160   // Inputs
0161   TopoDS_Shape myShape; //!< Input shape to analyze
0162   double       myAngle; //!< Criteria angle to check tangency
0163 
0164   double myOffset; //!< Offset value
0165   NCollection_DataMap<TopoDS_Shape, double, TopTools_ShapeMapHasher>
0166     myFaceOffsetMap; //!< Map to store offset values for the faces.
0167                      //!  Should be set by the calling algorithm.
0168 
0169   // Results
0170   bool myDone; //!< Status of the algorithm
0171 
0172   // clang-format off
0173   NCollection_DataMap<TopoDS_Shape, NCollection_List<BRepOffset_Interval>, TopTools_ShapeMapHasher> myMapEdgeType; //!< Map containing the list of intervals on the edge
0174   NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> myAncestors; //!< Ancestors map
0175   NCollection_DataMap<TopoDS_Shape,
0176                       NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher>,
0177                       TopTools_ShapeMapHasher> myReplacement; //!< Replacement of an edge in the face
0178   mutable NCollection_DataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> myDescendants; //!< Map of shapes descendants built on the base of
0179                                                             //!< Ancestors map. Filled on the first query.
0180 
0181   NCollection_List<TopoDS_Shape> myNewFaces; //!< New faces generated to close the gaps between adjacent
0182                                    //!  tangential faces having different offset values
0183   NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_ShapeMapHasher> myGenerated; //!< Binding between edge and face generated from the edge
0184   // clang-format on
0185 };
0186 
0187 #endif // _BRepOffset_Analyse_HeaderFile