42cf5bc1 |
1 | // Created on: 2006-08-10 |
2 | // Created by: Galina KULIKOVA |
3 | // Copyright (c) 2006-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 _ShapeUpgrade_RemoveInternalWires_HeaderFile |
17 | #define _ShapeUpgrade_RemoveInternalWires_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
22 | #include <TopoDS_Shape.hxx> |
23 | #include <Standard_Real.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> |
26 | #include <TopTools_DataMapOfShapeListOfShape.hxx> |
27 | #include <TopTools_SequenceOfShape.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | #include <ShapeUpgrade_Tool.hxx> |
30 | #include <ShapeExtend_Status.hxx> |
42cf5bc1 |
31 | |
9fd2d2c3 |
32 | // resolve name collisions with X11 headers |
33 | #ifdef Status |
34 | #undef Status |
35 | #endif |
42cf5bc1 |
36 | |
37 | class ShapeUpgrade_RemoveInternalWires; |
38 | DEFINE_STANDARD_HANDLE(ShapeUpgrade_RemoveInternalWires, ShapeUpgrade_Tool) |
39 | |
40 | //! Removes all internal wires having area less than specified min area |
41 | class ShapeUpgrade_RemoveInternalWires : public ShapeUpgrade_Tool |
42 | { |
43 | |
44 | public: |
45 | |
46 | |
47 | //! Creates empty constructor. |
48 | Standard_EXPORT ShapeUpgrade_RemoveInternalWires(); |
49 | |
50 | Standard_EXPORT ShapeUpgrade_RemoveInternalWires(const TopoDS_Shape& theShape); |
51 | |
52 | //! Initialize by a Shape. |
53 | Standard_EXPORT void Init (const TopoDS_Shape& theShape); |
54 | |
55 | //! Removes all internal wires having area less than area specified as minimal allowed area |
56 | Standard_EXPORT Standard_Boolean Perform(); |
57 | |
58 | //! If specified sequence of shape contains - |
59 | //! 1.wires then these wires will be removed if they have area less than allowed min area. |
60 | //! 2.faces than internal wires from these faces will be removed if they have area less than allowed min area. |
61 | Standard_EXPORT Standard_Boolean Perform (const TopTools_SequenceOfShape& theSeqShapes); |
62 | |
63 | //! Get result shape |
64 | TopoDS_Shape GetResult() const; |
65 | |
66 | //! Set min area allowed for holes( all holes having area less than mi area will be removed) |
67 | Standard_Real& MinArea(); |
68 | |
69 | //! Set mode which manage removing faces which have outer wires consisting only from edges |
70 | //! belonginig to removed internal wires. |
71 | //! By default it is equal to true. |
72 | Standard_Boolean& RemoveFaceMode(); |
73 | |
74 | //! Returns sequence of removed faces. |
75 | const TopTools_SequenceOfShape& RemovedFaces() const; |
76 | |
77 | //! Returns sequence of removed faces. |
78 | const TopTools_SequenceOfShape& RemovedWires() const; |
79 | |
80 | //! Queries status of last call to Perform() |
81 | //! : OK - nothing was done |
82 | //! :DONE1 - internal wires were removed |
83 | //! :DONE2 - small faces were removed. |
84 | //! :FAIL1 - initial shape is not specified |
85 | //! :FAIL2 - specified sub-shape is not belonged to inotial shape. |
86 | Standard_Boolean Status (const ShapeExtend_Status theStatus) const; |
87 | |
88 | |
89 | |
90 | |
92efcf78 |
91 | DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_RemoveInternalWires,ShapeUpgrade_Tool) |
42cf5bc1 |
92 | |
93 | protected: |
94 | |
95 | |
96 | //! Clear all sequences and temporary map; |
97 | Standard_EXPORT void Clear(); |
98 | |
99 | Standard_Integer myStatus; |
100 | |
101 | |
102 | private: |
103 | |
104 | |
105 | //! Removes internal wires having area of contour less than specified MinArea |
106 | Standard_EXPORT void removeSmallWire (const TopoDS_Shape& theFace, const TopoDS_Shape& theWire); |
107 | |
108 | //! Removes faces having outer wire consisting |
109 | //! from removed edges(belonging small internal wires) |
110 | Standard_EXPORT void removeSmallFaces(); |
111 | |
112 | TopoDS_Shape myShape; |
113 | TopoDS_Shape myResult; |
114 | Standard_Real myMinArea; |
115 | Standard_Boolean myRemoveFacesMode; |
116 | TopTools_IndexedDataMapOfShapeListOfShape myEdgeFaces; |
117 | TopTools_DataMapOfShapeListOfShape myRemoveEdges; |
118 | TopTools_SequenceOfShape myRemovedFaces; |
119 | TopTools_SequenceOfShape myRemoveWires; |
120 | |
121 | |
122 | }; |
123 | |
124 | |
125 | #include <ShapeUpgrade_RemoveInternalWires.lxx> |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | #endif // _ShapeUpgrade_RemoveInternalWires_HeaderFile |