1 // Created on: 1995-10-20 2 // Created by: Yves FRICAUD 3 // Copyright (c) 1995-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 8 // This library is free software; you can redistribute it and/or modify it under 9 // the terms of the GNU Lesser General Public License version 2.1 as published 10 // by the Free Software Foundation, with special exception defined in the file 11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 12 // distribution for complete text of the license and disclaimer of any warranty. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _BRepOffset_Analyse_HeaderFile 18 #define _BRepOffset_Analyse_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_DefineAlloc.hxx> 22 #include <Standard_Handle.hxx> 23 24 #include <Standard_Boolean.hxx> 25 #include <TopoDS_Shape.hxx> 26 #include <BRepOffset_DataMapOfShapeListOfInterval.hxx> 27 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> 28 #include <Standard_Real.hxx> 29 #include <BRepOffset_ListOfInterval.hxx> 30 #include <ChFiDS_TypeOfConcavity.hxx> 31 #include <TopTools_DataMapOfShapeListOfShape.hxx> 32 #include <TopTools_DataMapOfShapeReal.hxx> 33 #include <TopTools_DataMapOfShapeShape.hxx> 34 #include <TopTools_ListOfShape.hxx> 35 #include <TopTools_MapOfShape.hxx> 36 37 #include <Message_ProgressRange.hxx> 38 39 class TopoDS_Edge; 40 class TopoDS_Vertex; 41 class TopoDS_Face; 42 class TopoDS_Compound; 43 44 //! Analyses the shape to find the parts of edges 45 //! connecting the convex, concave or tangent faces. 46 class BRepOffset_Analyse 47 { 48 public: 49 DEFINE_STANDARD_ALLOC 50 51 public: //! @name Constructors 52 53 //! Empty c-tor 54 Standard_EXPORT BRepOffset_Analyse(); 55 56 //! C-tor performing the job inside 57 Standard_EXPORT BRepOffset_Analyse (const TopoDS_Shape& theS, 58 const Standard_Real theAngle); 59 60 public: //! @name Performing analysis 61 62 //! Performs the analysis 63 Standard_EXPORT void Perform (const TopoDS_Shape& theS, 64 const Standard_Real theAngle, 65 const Message_ProgressRange& theRange = Message_ProgressRange()); 66 67 public: //! @name Results 68 69 //! Returns status of the algorithm IsDone() const70 Standard_Boolean IsDone() const 71 { 72 return myDone; 73 } 74 75 //! Returns the connectivity type of the edge 76 Standard_EXPORT const BRepOffset_ListOfInterval& Type (const TopoDS_Edge& theE) const; 77 78 //! Stores in <L> all the edges of Type <T> 79 //! on the vertex <V>. 80 Standard_EXPORT void Edges (const TopoDS_Vertex& theV, 81 const ChFiDS_TypeOfConcavity theType, 82 TopTools_ListOfShape& theL) const; 83 84 //! Stores in <L> all the edges of Type <T> 85 //! on the face <F>. 86 Standard_EXPORT void Edges (const TopoDS_Face& theF, 87 const ChFiDS_TypeOfConcavity theType, 88 TopTools_ListOfShape& theL) const; 89 90 //! set in <Edges> all the Edges of <Shape> which are 91 //! tangent to <Edge> at the vertex <Vertex>. 92 Standard_EXPORT void TangentEdges (const TopoDS_Edge& theEdge, 93 const TopoDS_Vertex& theVertex, 94 TopTools_ListOfShape& theEdges) const; 95 96 //! Checks if the given shape has ancestors HasAncestor(const TopoDS_Shape & theS) const97 Standard_Boolean HasAncestor (const TopoDS_Shape& theS) const 98 { 99 return myAncestors.Contains (theS); 100 } 101 102 //! Returns ancestors for the shape Ancestors(const TopoDS_Shape & theS) const103 const TopTools_ListOfShape& Ancestors (const TopoDS_Shape& theS) const 104 { 105 return myAncestors.FindFromKey (theS); 106 } 107 108 //! Explode in compounds of faces where 109 //! all the connex edges are of type <Side> 110 Standard_EXPORT void Explode (TopTools_ListOfShape& theL, 111 const ChFiDS_TypeOfConcavity theType) const; 112 113 //! Explode in compounds of faces where 114 //! all the connex edges are of type <Side1> or <Side2> 115 Standard_EXPORT void Explode (TopTools_ListOfShape& theL, 116 const ChFiDS_TypeOfConcavity theType1, 117 const ChFiDS_TypeOfConcavity theType2) const; 118 119 //! Add in <CO> the faces of the shell containing <Face> 120 //! where all the connex edges are of type <Side>. 121 Standard_EXPORT void AddFaces (const TopoDS_Face& theFace, 122 TopoDS_Compound& theCo, 123 TopTools_MapOfShape& theMap, 124 const ChFiDS_TypeOfConcavity theType) const; 125 126 //! Add in <CO> the faces of the shell containing <Face> 127 //! where all the connex edges are of type <Side1> or <Side2>. 128 Standard_EXPORT void AddFaces (const TopoDS_Face& theFace, 129 TopoDS_Compound& theCo, 130 TopTools_MapOfShape& theMap, 131 const ChFiDS_TypeOfConcavity theType1, 132 const ChFiDS_TypeOfConcavity theType2) const; 133 SetOffsetValue(const Standard_Real theOffset)134 void SetOffsetValue (const Standard_Real theOffset) 135 { 136 myOffset = theOffset; 137 } 138 139 //! Sets the face-offset data map to analyze tangential cases SetFaceOffsetMap(const TopTools_DataMapOfShapeReal & theMap)140 void SetFaceOffsetMap (const TopTools_DataMapOfShapeReal& theMap) 141 { 142 myFaceOffsetMap = theMap; 143 } 144 145 //! Returns the new faces constructed between tangent faces 146 //! having different offset values on the shape NewFaces() const147 const TopTools_ListOfShape& NewFaces() const { return myNewFaces; } 148 149 //! Returns the new face constructed for the edge connecting 150 //! the two tangent faces having different offset values 151 Standard_EXPORT TopoDS_Shape Generated (const TopoDS_Shape& theS) const; 152 153 //! Checks if the edge has generated a new face. HasGenerated(const TopoDS_Shape & theS) const154 Standard_Boolean HasGenerated (const TopoDS_Shape& theS) const 155 { 156 return myGenerated.Seek (theS) != NULL; 157 } 158 159 //! Returns the replacement of the edge in the face. 160 //! If no replacement exists, returns the edge 161 Standard_EXPORT const TopoDS_Edge& EdgeReplacement (const TopoDS_Face& theFace, 162 const TopoDS_Edge& theEdge) const; 163 164 //! Returns the shape descendants. 165 Standard_EXPORT const TopTools_ListOfShape* Descendants (const TopoDS_Shape& theS, 166 const Standard_Boolean theUpdate = Standard_False) const; 167 168 public: //! @name Clearing the content 169 170 //! Clears the content of the algorithm 171 Standard_EXPORT void Clear(); 172 173 private: //! @name Treatment of tangential cases 174 175 //! Treatment of the tangential cases. 176 //! @param theEdges List of edges connecting tangent faces 177 Standard_EXPORT void TreatTangentFaces (const TopTools_ListOfShape& theEdges, const Message_ProgressRange& theRange); 178 179 private: //! @name Fields 180 181 // Inputs 182 TopoDS_Shape myShape; //!< Input shape to analyze 183 Standard_Real myAngle; //!< Criteria angle to check tangency 184 185 Standard_Real myOffset; //!< Offset value 186 TopTools_DataMapOfShapeReal myFaceOffsetMap; //!< Map to store offset values for the faces. 187 //! Should be set by the calling algorithm. 188 189 // Results 190 Standard_Boolean myDone; //!< Status of the algorithm 191 192 BRepOffset_DataMapOfShapeListOfInterval myMapEdgeType; //!< Map containing the list of intervals on the edge 193 TopTools_IndexedDataMapOfShapeListOfShape myAncestors; //!< Ancestors map 194 NCollection_DataMap<TopoDS_Shape, 195 TopTools_DataMapOfShapeShape, 196 TopTools_ShapeMapHasher> myReplacement; //!< Replacement of an edge in the face 197 mutable TopTools_DataMapOfShapeListOfShape myDescendants; //!< Map of shapes descendants built on the base of 198 //!< Ancestors map. Filled on the first query. 199 200 TopTools_ListOfShape myNewFaces; //!< New faces generated to close the gaps between adjacent 201 //! tangential faces having different offset values 202 TopTools_DataMapOfShapeShape myGenerated; //!< Binding between edge and face generated from the edge 203 }; 204 205 #endif // _BRepOffset_Analyse_HeaderFile 206