Test for 0022778: Bug in BRepMesh
[occt.git] / src / BOPTools / BOPTools_InterferenceLine.cxx
CommitLineData
b311480e 1// Created on: 2000-11-21
2// Created by: Peter KURNEV
3// Copyright (c) 2000-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#include <BOPTools_InterferenceLine.ixx>
23#include <BOPTools_ListIteratorOfListOfInterference.hxx>
24
25//=======================================================================
26//function : BOPTools_InterferenceLine::BOPTools_InterferenceLine
27//purpose :
28//=======================================================================
b311480e 29BOPTools_InterferenceLine::BOPTools_InterferenceLine() {}
7fd59977 30
31//=======================================================================
32//function : RealList
33//purpose :
34//=======================================================================
35 const BOPTools_ListOfInterference& BOPTools_InterferenceLine::RealList() const
36{
37 Standard_Integer anInd;
38 List();
39 BOPTools_ListOfInterference aTmpList;
40 BOPTools_ListIteratorOfListOfInterference anIt;
41
42 anIt.Initialize(myList);
43 for (; anIt.More(); anIt.Next()) {
44 const BOPTools_Interference& anInterference=anIt.Value();
45 aTmpList.Append(anInterference);
46 }
47 //
48 BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList;
49 pList->Clear();
50 //
51 anIt.Initialize(aTmpList);
52 for (; anIt.More(); anIt.Next()) {
53 const BOPTools_Interference& anInterference=anIt.Value();
54 anInd=anInterference.Index();
55 if (anInd) {
56 pList->Append(anInterference);
57 }
58 }
59 return myList;
60}
61
62//=======================================================================
63//function : List
64//purpose :
65//=======================================================================
66 const BOPTools_ListOfInterference& BOPTools_InterferenceLine::List () const
67{
68 BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList;
69
70 pList->Clear();
71
72 BOPTools_ListIteratorOfListOfInterference anIt;
73
74 anIt.Initialize(mySSList);
75 for (; anIt.More(); anIt.Next()) {
76 const BOPTools_Interference& anInterference=anIt.Value();
77 pList->Append(anInterference);
78 }
79
80 anIt.Initialize(myESList);
81 for (; anIt.More(); anIt.Next()) {
82 const BOPTools_Interference& anInterference=anIt.Value();
83 pList->Append(anInterference);
84 }
85
86 anIt.Initialize(myVSList);
87 for (; anIt.More(); anIt.Next()) {
88 const BOPTools_Interference& anInterference=anIt.Value();
89 pList->Append(anInterference);
90 }
91
92 anIt.Initialize(myEEList);
93 for (; anIt.More(); anIt.Next()) {
94 const BOPTools_Interference& anInterference=anIt.Value();
95 pList->Append(anInterference);
96 }
97
98 anIt.Initialize(myVEList);
99 for (; anIt.More(); anIt.Next()) {
100 const BOPTools_Interference& anInterference=anIt.Value();
101 pList->Append(anInterference);
102 }
103
104 anIt.Initialize(myVVList);
105 for (; anIt.More(); anIt.Next()) {
106 const BOPTools_Interference& anInterference=anIt.Value();
107 pList->Append(anInterference);
108 }
109
110 return myList;
111}
112
113//=======================================================================
114//function : GetOnType
115//purpose :
116//=======================================================================
117 const BOPTools_ListOfInterference& BOPTools_InterferenceLine::GetOnType
118 (const BooleanOperations_KindOfInterference theType) const
119{
120 switch (theType) {
121 case BooleanOperations_SurfaceSurface:
122 return mySSList;
123
124 case BooleanOperations_EdgeSurface:
125 return myESList;
126
127 case BooleanOperations_VertexSurface:
128 return myVSList;
129
130 case BooleanOperations_EdgeEdge:
131 return myEEList;
132
133 case BooleanOperations_VertexEdge:
134 return myVEList;
135
136 case BooleanOperations_VertexVertex:
137 return myVVList;
138 default:
139 return myEmptyList;
140 }
141
142}
143
144//=======================================================================
145//function : HasInterference
146//purpose :
147//=======================================================================
148 Standard_Boolean BOPTools_InterferenceLine::HasInterference () const
149{
150 Standard_Integer anInd;
151 Standard_Boolean bFlag=Standard_False;
152 BOPTools_ListIteratorOfListOfInterference anIt;
153 //
154 List();
155 //
156 anIt.Initialize(myList);
157 for (; anIt.More(); anIt.Next()) {
158 const BOPTools_Interference& anInterference=anIt.Value();
159 anInd=anInterference.Index();
160 if (anInd) {
161 return !bFlag;
162 }
163 }
164 return bFlag;
165}
166
167//=======================================================================
168//function : IsComputed
169//purpose :
170//=======================================================================
171 Standard_Boolean BOPTools_InterferenceLine::IsComputed
172 (const Standard_Integer theWith,
173 const BooleanOperations_KindOfInterference theType)const
174{
175 BooleanOperations_KindOfInterference aType;
176 Standard_Integer aWith, anInd;
177
178 const BOPTools_ListOfInterference& aList=GetOnType(theType);
179 BOPTools_ListIteratorOfListOfInterference anIt(aList);
180 for (; anIt.More(); anIt.Next()) {
181 const BOPTools_Interference& anInterference=anIt.Value();
182 aType=anInterference.Type();
183 aWith=anInterference.With();
184 //
185 anInd=anInterference.Index();
186 //
187 if ((aType==theType && aWith==theWith) && anInd) {
188 return Standard_True;
189 }
190 }
191 return Standard_False;
192}
193//=======================================================================
194//function : AddInterference
195//purpose :
196//=======================================================================
197 void BOPTools_InterferenceLine::AddInterference(const BOPTools_Interference& anInterference)
198{
199 Standard_Integer aWith, anInd;
200 BooleanOperations_KindOfInterference aType;
201
202 aWith=anInterference.With();
203 aType=anInterference.Type();
204 anInd=anInterference.Index();
205 AddInterference(aWith, aType, anInd);
206}
207
208
209//=======================================================================
210//function : AddInterference
211//purpose :
212//=======================================================================
213 void BOPTools_InterferenceLine::AddInterference(const Standard_Integer aWith,
214 const BooleanOperations_KindOfInterference aType,
215 const Standard_Integer anIndex)
216{
217 BOPTools_Interference anInterference(aWith, aType, anIndex);
218 const BOPTools_ListOfInterference& aList=GetOnType(aType);
219 BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*) &aList;
220 pList->Append(anInterference);
221}
222