b311480e |
1 | // Created on: 1997-01-24 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <TNaming_Iterator.hxx> |
19 | #include <TNaming_IteratorOnShapesSet.hxx> |
20 | #include <TNaming_ShapesSet.hxx> |
7fd59977 |
21 | #include <TopExp_Explorer.hxx> |
42cf5bc1 |
22 | #include <TopoDS_Iterator.hxx> |
23 | #include <TopoDS_Shape.hxx> |
7fd59977 |
24 | |
7fd59977 |
25 | //#define MDTV_DEB_INT |
26 | //======================================================================= |
27 | //function : TNaming_ShapesSet |
28 | //purpose : |
29 | //======================================================================= |
7fd59977 |
30 | TNaming_ShapesSet::TNaming_ShapesSet (const TopoDS_Shape& CS, |
31 | const TopAbs_ShapeEnum Type) |
32 | { |
33 | if (CS.IsNull()) return; |
0797d9d3 |
34 | #ifdef OCCT_DEBUG_INT |
7fd59977 |
35 | cout << "ShapeSet: CS TShape = " <<CS.TShape() << " Type = " << Type <<endl; |
36 | #endif |
37 | if (Type == TopAbs_SHAPE) { |
38 | if (CS.ShapeType() == TopAbs_SOLID || |
39 | CS.ShapeType() == TopAbs_FACE || |
40 | CS.ShapeType() == TopAbs_EDGE || |
41 | CS.ShapeType() == TopAbs_VERTEX ) { |
42 | Add(CS); |
43 | } |
44 | else { |
45 | for (TopoDS_Iterator it(CS) ; it.More(); it.Next()) { |
46 | Add(it.Value()); |
47 | } |
48 | } |
49 | } |
50 | else { |
51 | |
7fd59977 |
52 | // corrected by vro 13.09.00: |
53 | if (Type > CS.ShapeType()) { |
54 | for (TopExp_Explorer exp(CS,Type) ; exp.More(); exp.Next()) { |
55 | Add(exp.Current()); |
0797d9d3 |
56 | #ifdef OCCT_DEBUG_INT |
7fd59977 |
57 | cout << "ShapeSet: sub-shape TShape = " <<exp.Current().TShape() <<endl; |
58 | #endif |
59 | } |
60 | } else { |
61 | // for (TopoDS_Iterator it(CS) ; it.More(); it.Next()) { |
62 | // Add(it.Value()); |
63 | // } |
64 | Add(CS); |
65 | } |
66 | // end of correction by vro. |
7fd59977 |
67 | } |
68 | } |
69 | |
70 | |
71 | //======================================================================= |
72 | //function : Add |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | void TNaming_ShapesSet::Add(const TNaming_ShapesSet& Shapes) |
77 | { |
78 | TNaming_IteratorOnShapesSet it(Shapes); |
79 | for (; it.More(); it.Next()) { |
80 | myMap.Add(it.Value()); |
81 | } |
82 | } |
83 | |
84 | |
85 | //======================================================================= |
86 | //function : Filter |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | void TNaming_ShapesSet::Filter(const TNaming_ShapesSet& Shapes) |
91 | { |
92 | |
93 | TNaming_ShapesSet ToRemove; |
94 | TNaming_IteratorOnShapesSet it(*this); |
95 | for (; it.More(); it.Next()) { |
96 | const TopoDS_Shape& S = it.Value(); |
97 | if (!Shapes.Contains(S)) { |
98 | ToRemove.Add(S); |
99 | } |
100 | } |
101 | Remove(ToRemove); |
102 | } |
103 | |
104 | //======================================================================= |
105 | //function : Remove |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | void TNaming_ShapesSet::Remove(const TNaming_ShapesSet& Shapes) |
110 | { |
111 | TNaming_IteratorOnShapesSet it(Shapes); |
112 | for (; it.More(); it.Next()) { |
113 | myMap.Remove(it.Value()); |
114 | } |
115 | } |
116 | |
117 | |