42cf5bc1 |
1 | // Created on: 2007-09-10 |
2 | // Created by: Igor FEOKTISTOV |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _BRepLib_FuseEdges_HeaderFile |
17 | #define _BRepLib_FuseEdges_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_DefineAlloc.hxx> |
21 | #include <Standard_Handle.hxx> |
22 | |
23 | #include <TopoDS_Shape.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> |
26 | #include <TopTools_DataMapOfIntegerListOfShape.hxx> |
27 | #include <TopTools_DataMapOfIntegerShape.hxx> |
28 | #include <TopTools_DataMapOfShapeShape.hxx> |
29 | #include <Standard_Integer.hxx> |
30 | #include <TopTools_IndexedMapOfShape.hxx> |
31 | #include <TopAbs_ShapeEnum.hxx> |
32 | #include <TopTools_MapOfShape.hxx> |
33 | #include <TopTools_ListOfShape.hxx> |
34 | class Standard_ConstructionError; |
35 | class Standard_NullObject; |
36 | class TopoDS_Shape; |
37 | class TopoDS_Vertex; |
38 | class TopoDS_Edge; |
39 | |
40 | |
41 | //! This class can detect vertices in a face that can |
42 | //! be considered useless and then perform the fuse of |
43 | //! the edges and remove the useless vertices. By |
44 | //! useles vertices, we mean : |
45 | //! * vertices that have exactly two connex edges |
46 | //! * the edges connex to the vertex must have |
47 | //! exactly the same 2 connex faces . |
48 | //! * The edges connex to the vertex must have the |
49 | //! same geometric support. |
50 | class BRepLib_FuseEdges |
51 | { |
52 | public: |
53 | |
54 | DEFINE_STANDARD_ALLOC |
55 | |
56 | |
57 | //! Initialise members and build construction of map |
58 | //! of ancestors. |
59 | Standard_EXPORT BRepLib_FuseEdges(const TopoDS_Shape& theShape, const Standard_Boolean PerformNow = Standard_False); |
60 | |
61 | //! set edges to avoid being fused |
62 | Standard_EXPORT void AvoidEdges (const TopTools_IndexedMapOfShape& theMapEdg); |
63 | |
64 | //! set mode to enable concatenation G1 BSpline edges in one |
65 | //! End Modified by IFV 19.04.07 |
66 | Standard_EXPORT void SetConcatBSpl (const Standard_Boolean theConcatBSpl = Standard_True); |
67 | |
68 | //! returns all the list of edges to be fused |
69 | //! each list of the map represent a set of connex edges |
70 | //! that can be fused. |
71 | Standard_EXPORT void Edges (TopTools_DataMapOfIntegerListOfShape& theMapLstEdg); |
72 | |
73 | //! returns all the fused edges. each integer entry in |
74 | //! the map corresponds to the integer in the |
75 | //! DataMapOfIntegerListOfShape we get in method |
76 | //! Edges. That is to say, to the list of edges in |
77 | //! theMapLstEdg(i) corresponds the resulting edge theMapEdge(i) |
78 | Standard_EXPORT void ResultEdges (TopTools_DataMapOfIntegerShape& theMapEdg); |
79 | |
80 | //! returns the map of modified faces. |
81 | Standard_EXPORT void Faces (TopTools_DataMapOfShapeShape& theMapFac); |
82 | |
83 | //! returns myShape modified with the list of internal |
84 | //! edges removed from it. |
85 | Standard_EXPORT TopoDS_Shape& Shape(); |
86 | |
87 | //! returns the number of vertices candidate to be removed |
487bf1ce |
88 | Standard_EXPORT Standard_Integer NbVertices(); |
42cf5bc1 |
89 | |
90 | //! Using map of list of connex edges, fuse each list to |
91 | //! one edge and then update myShape |
92 | Standard_EXPORT void Perform(); |
93 | |
94 | |
95 | |
96 | |
97 | protected: |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | private: |
104 | |
105 | |
106 | //! build a map of shapes and ancestors, like |
107 | //! TopExp.MapShapesAndAncestors, but we remove duplicate |
108 | //! shapes in list of shapes. |
109 | Standard_EXPORT void BuildAncestors (const TopoDS_Shape& S, const TopAbs_ShapeEnum TS, const TopAbs_ShapeEnum TA, TopTools_IndexedDataMapOfShapeListOfShape& M) const; |
110 | |
111 | //! Build the all the lists of edges that are to be fused |
112 | Standard_EXPORT void BuildListEdges(); |
113 | |
114 | //! Build result fused edges according to the list |
115 | //! builtin BuildLisEdges |
116 | Standard_EXPORT void BuildListResultEdges(); |
117 | |
118 | Standard_EXPORT void BuildListConnexEdge (const TopoDS_Shape& theEdge, TopTools_MapOfShape& theMapUniq, TopTools_ListOfShape& theLstEdg); |
119 | |
120 | Standard_EXPORT Standard_Boolean NextConnexEdge (const TopoDS_Vertex& theVertex, const TopoDS_Shape& theEdge, TopoDS_Shape& theEdgeConnex) const; |
121 | |
122 | Standard_EXPORT Standard_Boolean SameSupport (const TopoDS_Edge& E1, const TopoDS_Edge& E2) const; |
123 | |
124 | Standard_EXPORT Standard_Boolean UpdatePCurve (const TopoDS_Edge& theOldEdge, TopoDS_Edge& theNewEdge, const TopTools_ListOfShape& theLstEdg) const; |
125 | |
126 | |
127 | TopoDS_Shape myShape; |
128 | Standard_Boolean myShapeDone; |
129 | Standard_Boolean myEdgesDone; |
130 | Standard_Boolean myResultEdgesDone; |
131 | TopTools_IndexedDataMapOfShapeListOfShape myMapVerLstEdg; |
132 | TopTools_IndexedDataMapOfShapeListOfShape myMapEdgLstFac; |
133 | TopTools_DataMapOfIntegerListOfShape myMapLstEdg; |
134 | TopTools_DataMapOfIntegerShape myMapEdg; |
135 | TopTools_DataMapOfShapeShape myMapFaces; |
136 | Standard_Integer myNbConnexEdge; |
137 | TopTools_IndexedMapOfShape myAvoidEdg; |
138 | Standard_Boolean myConcatBSpl; |
139 | |
140 | |
141 | }; |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | #endif // _BRepLib_FuseEdges_HeaderFile |