b311480e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
4e57c75e |
15 | #include <TopExp_Explorer.hxx> |
16 | #include <TopoDS_Edge.hxx> |
17 | #include <BRep_Tool.hxx> |
7fd59977 |
18 | |
19 | //======================================================================= |
4e57c75e |
20 | //function : |
21 | //purpose : |
7fd59977 |
22 | //======================================================================= |
4e57c75e |
23 | inline BOPTools_EdgeSet::BOPTools_EdgeSet() |
7fd59977 |
24 | { |
7fd59977 |
25 | } |
26 | //======================================================================= |
4e57c75e |
27 | //function : |
28 | //purpose : |
7fd59977 |
29 | //======================================================================= |
4e57c75e |
30 | inline BOPTools_EdgeSet::BOPTools_EdgeSet(const Handle(NCollection_BaseAllocator)& theObj) |
31 | : |
32 | myMap(100, theObj), |
33 | myEdges(theObj) |
7fd59977 |
34 | { |
7fd59977 |
35 | } |
36 | //======================================================================= |
4e57c75e |
37 | //function : ~ |
38 | //purpose : |
7fd59977 |
39 | //======================================================================= |
4e57c75e |
40 | inline BOPTools_EdgeSet::~BOPTools_EdgeSet() |
7fd59977 |
41 | { |
7fd59977 |
42 | } |
7fd59977 |
43 | //======================================================================= |
4e57c75e |
44 | //function : Clear |
45 | //purpose : |
7fd59977 |
46 | //======================================================================= |
4e57c75e |
47 | inline void BOPTools_EdgeSet::Clear() |
7fd59977 |
48 | { |
4e57c75e |
49 | myMap.Clear(); |
50 | myEdges.Clear(); |
7fd59977 |
51 | } |
52 | //======================================================================= |
4e57c75e |
53 | //function : SetShape |
54 | //purpose : |
7fd59977 |
55 | //======================================================================= |
4e57c75e |
56 | inline void BOPTools_EdgeSet::SetShape(const TopoDS_Shape& theShape) |
7fd59977 |
57 | { |
4e57c75e |
58 | myShape=theShape; |
7fd59977 |
59 | } |
60 | //======================================================================= |
4e57c75e |
61 | //function : Shape |
62 | //purpose : |
7fd59977 |
63 | //======================================================================= |
4e57c75e |
64 | inline const TopoDS_Shape& BOPTools_EdgeSet::Shape()const |
7fd59977 |
65 | { |
4e57c75e |
66 | return myShape; |
7fd59977 |
67 | } |
68 | //======================================================================= |
4e57c75e |
69 | //function : AddEdge |
70 | //purpose : |
7fd59977 |
71 | //======================================================================= |
4e57c75e |
72 | inline void BOPTools_EdgeSet::AddEdge(const TopoDS_Edge& theEdge) |
7fd59977 |
73 | { |
4e57c75e |
74 | if (!BRep_Tool::Degenerated(theEdge)){ |
75 | myEdges.Append(theEdge); |
76 | myMap.Add(theEdge); |
77 | } |
7fd59977 |
78 | } |
79 | //======================================================================= |
4e57c75e |
80 | //function : AddEdges |
81 | //purpose : |
7fd59977 |
82 | //======================================================================= |
4e57c75e |
83 | inline void BOPTools_EdgeSet::AddEdges(const BOPCol_ListOfShape& theLS) |
7fd59977 |
84 | { |
4e57c75e |
85 | BOPCol_ListIteratorOfListOfShape aIt; |
86 | // |
87 | aIt.Initialize(theLS); |
88 | for (; aIt.More(); aIt.Next()) { |
89 | const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aIt.Value()); |
90 | AddEdge(aE); |
91 | } |
7fd59977 |
92 | } |
7fd59977 |
93 | //======================================================================= |
4e57c75e |
94 | //function : AddEdges |
95 | //purpose : |
7fd59977 |
96 | //======================================================================= |
4e57c75e |
97 | inline void BOPTools_EdgeSet::AddEdges(const TopoDS_Shape& theFace) |
7fd59977 |
98 | { |
4e57c75e |
99 | TopExp_Explorer aExp(theFace, TopAbs_EDGE); |
100 | for(; aExp.More(); aExp.Next()) { |
101 | const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aExp.Current()); |
102 | AddEdge(aE); |
103 | } |
7fd59977 |
104 | } |
105 | //======================================================================= |
4e57c75e |
106 | //function : Get |
107 | //purpose : |
7fd59977 |
108 | //======================================================================= |
4e57c75e |
109 | inline void BOPTools_EdgeSet::Get(BOPCol_ListOfShape& theLS)const |
7fd59977 |
110 | { |
4e57c75e |
111 | BOPCol_ListIteratorOfListOfShape aIt; |
112 | // |
113 | aIt.Initialize(myEdges); |
114 | for (; aIt.More(); aIt.Next()) { |
115 | const TopoDS_Shape& aS=aIt.Value(); |
116 | theLS.Append(aS); |
117 | } |
7fd59977 |
118 | } |
7fd59977 |
119 | //======================================================================= |
4e57c75e |
120 | //function : Contains |
121 | //purpose : |
7fd59977 |
122 | //======================================================================= |
4e57c75e |
123 | inline Standard_Boolean BOPTools_EdgeSet::Contains(const BOPTools_EdgeSet& theOther)const |
7fd59977 |
124 | { |
4e57c75e |
125 | Standard_Integer aNbEOther, aNbE; |
126 | Standard_Boolean bRet; |
127 | BOPCol_ListIteratorOfListOfShape aIt; |
128 | // |
129 | aNbE=0; |
130 | aNbEOther=theOther.myEdges.Extent(); |
131 | aIt.Initialize(theOther.myEdges); |
132 | for (; aIt.More(); aIt.Next()) { |
133 | const TopoDS_Shape& aS=aIt.Value(); |
134 | bRet=myMap.Contains(aS); |
135 | if (!bRet) { |
136 | return bRet; |
137 | } |
138 | ++aNbE; |
139 | } |
140 | bRet=(aNbE==aNbEOther); |
141 | // |
142 | return bRet; |
7fd59977 |
143 | } |