Back to home page

EIC code displayed by LXR

 
 

    


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

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