0024624: Lost word in license statement in source files
[occt.git] / src / TNaming / TNaming_ShapesSet.cxx
1 // Created on: 1997-01-24
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1997-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 #include <TNaming_ShapesSet.ixx>
18 #include <TNaming_IteratorOnShapesSet.hxx>
19 #include <TNaming_Iterator.hxx>
20
21 #include <TopoDS_Shape.hxx>
22 #include <TopoDS_Iterator.hxx>
23 #include <TopExp_Explorer.hxx>
24
25 #define BUC60862
26 //#define MDTV_DEB_INT
27 //=======================================================================
28 //function : TNaming_ShapesSet
29 //purpose  : 
30 //=======================================================================
31
32 TNaming_ShapesSet::TNaming_ShapesSet (const TopoDS_Shape&    CS,
33                                       const TopAbs_ShapeEnum Type)
34 {
35   if (CS.IsNull()) return;
36 #ifdef MDTV_DEB_INT
37   cout << "ShapeSet: CS TShape = " <<CS.TShape() << " Type = " << Type <<endl;
38 #endif  
39   if (Type == TopAbs_SHAPE) { 
40     if (CS.ShapeType() == TopAbs_SOLID ||
41         CS.ShapeType() == TopAbs_FACE  ||
42         CS.ShapeType() == TopAbs_EDGE  ||
43         CS.ShapeType() == TopAbs_VERTEX ) {
44       Add(CS);
45     }
46     else {
47       for (TopoDS_Iterator it(CS) ; it.More(); it.Next()) {
48         Add(it.Value());
49       }
50     }
51   }
52   else {
53
54 #ifdef BUC60862
55 // corrected by vro 13.09.00:
56     if (Type > CS.ShapeType()) {
57       for (TopExp_Explorer exp(CS,Type) ; exp.More(); exp.Next()) {
58         Add(exp.Current());
59 #ifdef MDTV_DEB_INT
60         cout << "ShapeSet: sub-shape TShape = " <<exp.Current().TShape() <<endl;
61 #endif  
62       }
63     } else {
64 //      for (TopoDS_Iterator it(CS) ; it.More(); it.Next()) {
65 //      Add(it.Value());
66 //      }
67       Add(CS);
68     }
69 // end of correction by vro.
70 #else
71     for (TopExp_Explorer exp(CS,Type) ; exp.More(); exp.Next()) {
72       Add(exp.Current());
73     }
74 #endif
75
76   }
77 }
78
79
80 //=======================================================================
81 //function : Add
82 //purpose  : 
83 //=======================================================================
84
85 void TNaming_ShapesSet::Add(const TNaming_ShapesSet& Shapes) 
86 {
87   TNaming_IteratorOnShapesSet it(Shapes);
88   for (; it.More(); it.Next()) {
89     myMap.Add(it.Value());
90   }
91 }
92
93
94 //=======================================================================
95 //function : Filter
96 //purpose  : 
97 //=======================================================================
98
99 void TNaming_ShapesSet::Filter(const TNaming_ShapesSet& Shapes) 
100 {
101
102   TNaming_ShapesSet ToRemove;  
103   TNaming_IteratorOnShapesSet it(*this);
104   for (; it.More(); it.Next()) {
105     const TopoDS_Shape& S = it.Value();
106     if (!Shapes.Contains(S)) {
107       ToRemove.Add(S);
108     }
109   }
110   Remove(ToRemove);
111 }
112
113 //=======================================================================
114 //function : Remove
115 //purpose  : 
116 //=======================================================================
117
118 void TNaming_ShapesSet::Remove(const TNaming_ShapesSet& Shapes) 
119 {  
120   TNaming_IteratorOnShapesSet it(Shapes);
121   for (; it.More(); it.Next()) {
122     myMap.Remove(it.Value());
123   }
124 }
125
126