summaryrefslogtreecommitdiff
path: root/src/BOPTools/BOPTools_InterferenceLine.cxx
blob: 75f082efbe0164bb8cdd245561cb67f79f761189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// File:	BOPTools_InterferenceLine.cxx
// Created:	Tue Nov 21 12:19:30 2000
// Author:	Peter KURNEV
//		<pkv@irinox>


#include <BOPTools_InterferenceLine.ixx>
#include <BOPTools_ListIteratorOfListOfInterference.hxx>

//=======================================================================
//function : BOPTools_InterferenceLine::BOPTools_InterferenceLine
//purpose  : 
//=======================================================================
  BOPTools_InterferenceLine::BOPTools_InterferenceLine() {}

//=======================================================================
//function : RealList
//purpose  : 
//=======================================================================
  const BOPTools_ListOfInterference& BOPTools_InterferenceLine::RealList() const
{
  Standard_Integer anInd;
  List();
  BOPTools_ListOfInterference aTmpList;
  BOPTools_ListIteratorOfListOfInterference anIt;

  anIt.Initialize(myList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    aTmpList.Append(anInterference);
  }
  //
  BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList;
  pList->Clear();
  //
  anIt.Initialize(aTmpList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    anInd=anInterference.Index();
    if (anInd) {
      pList->Append(anInterference);
    }
  }
  return myList;
}

//=======================================================================
//function : List
//purpose  : 
//=======================================================================
  const BOPTools_ListOfInterference& BOPTools_InterferenceLine::List () const
{
  BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*)&myList;
  
  pList->Clear();

  BOPTools_ListIteratorOfListOfInterference anIt;

  anIt.Initialize(mySSList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    pList->Append(anInterference);
  }

  anIt.Initialize(myESList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    pList->Append(anInterference);
  }

  anIt.Initialize(myVSList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    pList->Append(anInterference);
  }

  anIt.Initialize(myEEList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    pList->Append(anInterference);
  }

  anIt.Initialize(myVEList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    pList->Append(anInterference);
  }

  anIt.Initialize(myVVList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    pList->Append(anInterference);
  }

  return myList;
}

//=======================================================================
//function : GetOnType
//purpose  : 
//=======================================================================
  const BOPTools_ListOfInterference& BOPTools_InterferenceLine::GetOnType
                       (const BooleanOperations_KindOfInterference theType) const
{
  switch (theType) {
  case BooleanOperations_SurfaceSurface:
    return mySSList;

  case BooleanOperations_EdgeSurface:
    return myESList;
    
  case BooleanOperations_VertexSurface:
    return myVSList;
    
  case BooleanOperations_EdgeEdge:
    return myEEList;

  case BooleanOperations_VertexEdge:
    return myVEList;
    
  case BooleanOperations_VertexVertex:
    return  myVVList; 
  default:
    return  myEmptyList;
  }
  
}

//=======================================================================
//function : HasInterference
//purpose  : 
//=======================================================================
  Standard_Boolean BOPTools_InterferenceLine::HasInterference () const
{
  Standard_Integer anInd;
  Standard_Boolean bFlag=Standard_False;
  BOPTools_ListIteratorOfListOfInterference anIt;
  //
  List();
  //
  anIt.Initialize(myList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    anInd=anInterference.Index();
    if (anInd) {
      return !bFlag;
    }
  }
  return bFlag;
}

//=======================================================================
//function : IsComputed
//purpose  : 
//=======================================================================
  Standard_Boolean BOPTools_InterferenceLine::IsComputed 
           (const Standard_Integer theWith,
	    const BooleanOperations_KindOfInterference theType)const
{
  BooleanOperations_KindOfInterference aType;
  Standard_Integer aWith, anInd;

  const BOPTools_ListOfInterference& aList=GetOnType(theType);
  BOPTools_ListIteratorOfListOfInterference anIt(aList);
  for (; anIt.More(); anIt.Next()) {
    const BOPTools_Interference& anInterference=anIt.Value();
    aType=anInterference.Type();
    aWith=anInterference.With();
    //
    anInd=anInterference.Index();
    //
    if ((aType==theType && aWith==theWith) && anInd) {
      return Standard_True;
    }
  }
  return Standard_False;
}
//=======================================================================
//function : AddInterference
//purpose  : 
//=======================================================================
  void BOPTools_InterferenceLine::AddInterference(const BOPTools_Interference& anInterference) 
{
  Standard_Integer aWith, anInd;
  BooleanOperations_KindOfInterference aType;

  aWith=anInterference.With();
  aType=anInterference.Type();
  anInd=anInterference.Index();
  AddInterference(aWith, aType, anInd);
}


//=======================================================================
//function : AddInterference
//purpose  : 
//=======================================================================
  void BOPTools_InterferenceLine::AddInterference(const Standard_Integer aWith,
						  const BooleanOperations_KindOfInterference aType,
						  const Standard_Integer anIndex) 
{
  BOPTools_Interference anInterference(aWith, aType, anIndex);
  const BOPTools_ListOfInterference& aList=GetOnType(aType);
  BOPTools_ListOfInterference* pList=(BOPTools_ListOfInterference*) &aList;
  pList->Append(anInterference);
}