summaryrefslogtreecommitdiff
path: root/src/TopOpeBRepDS/TopOpeBRepDS_Transition.cxx
blob: 6513eea9bcc60d2fd3be12c5152c55e23ad1b889 (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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
// File:	TopOpeBRepDS_Transition.cxx
// Created:	Thu May 26 17:41:35 1994
// Author:	Jean Yves LEBEY
//		<jyl@fuegox>

#include <TopOpeBRepDS_Transition.ixx>

#include <TopOpeBRepDS.hxx>
#include <TopOpeBRepDS_define.hxx>

//=======================================================================
//function : TopOpeBRepDS_Transition
//purpose  : 
//=======================================================================
TopOpeBRepDS_Transition::TopOpeBRepDS_Transition() :
myStateBefore(TopAbs_UNKNOWN),myStateAfter(TopAbs_UNKNOWN),
myShapeBefore(TopAbs_FACE),myShapeAfter(TopAbs_FACE),
myIndexBefore(0),myIndexAfter(0)
{
}

//=======================================================================
//function : TopOpeBRepDS_Transition
//purpose  : 
//=======================================================================
TopOpeBRepDS_Transition::TopOpeBRepDS_Transition(const TopAbs_State SB,const TopAbs_State SA,const TopAbs_ShapeEnum ONB,const TopAbs_ShapeEnum ONA) :
myStateBefore(SB),myStateAfter(SA),
myShapeBefore(ONB),myShapeAfter(ONA),
myIndexBefore(0),myIndexAfter(0)
{
}

//=======================================================================
//function : TopOpeBRepDS_Transition
//purpose  : 
//=======================================================================
TopOpeBRepDS_Transition::TopOpeBRepDS_Transition(const TopAbs_Orientation O) :
myShapeBefore(TopAbs_FACE),myShapeAfter(TopAbs_FACE),
myIndexBefore(0),myIndexAfter(0)
{
  Set(O);
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::Set(const TopAbs_State SB,const TopAbs_State SA,const TopAbs_ShapeEnum ONB,const TopAbs_ShapeEnum ONA)
{
  myStateBefore = SB;
  myStateAfter = SA;
  myShapeBefore = ONB;
  myShapeAfter  = ONA;
}

//=======================================================================
//function : StateBefore
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::StateBefore(const TopAbs_State S)
{
  myStateBefore = S;
}

//=======================================================================
//function : StateAfter
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::StateAfter(const TopAbs_State S)
{
  myStateAfter = S;
}

//=======================================================================
//function : ShapeBefore
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::ShapeBefore(const TopAbs_ShapeEnum SE)
{
  myShapeBefore = SE;
}

//=======================================================================
//function : ShapeAfter
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::ShapeAfter(const TopAbs_ShapeEnum SE)
{
  myShapeAfter = SE;
}

//=======================================================================
//function : Before
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::Before(const TopAbs_State S,const TopAbs_ShapeEnum ONB)
{
  myStateBefore = S;
  myShapeBefore = ONB;
}

//=======================================================================
//function : After
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::After(const TopAbs_State S,const TopAbs_ShapeEnum ONA)
{
  myStateAfter = S;
  myShapeAfter = ONA;
}

//=======================================================================
//function : Index
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::Index(const Standard_Integer I)
{
  myIndexBefore = myIndexAfter = I;
}

//=======================================================================
//function : IndexBefore
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::IndexBefore(const Standard_Integer I)
{
  myIndexBefore = I;
}

//=======================================================================
//function : IndexAfter
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::IndexAfter(const Standard_Integer I)
{
  myIndexAfter = I;
}

//=======================================================================
//function : Before
//purpose  : 
//=======================================================================
TopAbs_State TopOpeBRepDS_Transition::Before() const 
{
  return myStateBefore;
}

//=======================================================================
//function : ONBefore
//purpose  : 
//=======================================================================
TopAbs_ShapeEnum TopOpeBRepDS_Transition::ONBefore() const 
{
  return myShapeBefore;
}

//=======================================================================
//function : After
//purpose  : 
//=======================================================================
TopAbs_State TopOpeBRepDS_Transition::After() const 
{
  return myStateAfter;
}

//=======================================================================
//function : ONAfter
//purpose  : 
//=======================================================================
TopAbs_ShapeEnum TopOpeBRepDS_Transition::ONAfter() const 
{
  return myShapeAfter;
}

//=======================================================================
//function : ShapeBefore
//purpose  : 
//=======================================================================
TopAbs_ShapeEnum TopOpeBRepDS_Transition::ShapeBefore() const 
{
  return myShapeBefore;
}

//=======================================================================
//function : ShapeAfter
//purpose  : 
//=======================================================================
TopAbs_ShapeEnum TopOpeBRepDS_Transition::ShapeAfter() const 
{
  return myShapeAfter;
}

//=======================================================================
//function : Index
//purpose  : 
//=======================================================================
Standard_Integer TopOpeBRepDS_Transition::Index() const
{
  if ( myIndexAfter != myIndexBefore ) 
    Standard_Failure::Raise("Transition::Index() on different shapes");
  return myIndexBefore;
}

//=======================================================================
//function : IndexBefore
//purpose  : 
//=======================================================================
Standard_Integer TopOpeBRepDS_Transition::IndexBefore() const
{
  return myIndexBefore;
}

//=======================================================================
//function : IndexAfter
//purpose  : 
//=======================================================================
Standard_Integer TopOpeBRepDS_Transition::IndexAfter() const
{
  return myIndexAfter;
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================
void TopOpeBRepDS_Transition::Set(const TopAbs_Orientation O)
{
  switch (O) {
  case TopAbs_FORWARD  : 
    myStateBefore = TopAbs_OUT; myStateAfter = TopAbs_IN; break;

  case TopAbs_REVERSED : 
    myStateBefore = TopAbs_IN;  myStateAfter = TopAbs_OUT; break;

  case TopAbs_INTERNAL : 
    myStateBefore = TopAbs_IN;  myStateAfter = TopAbs_IN; break;

  case TopAbs_EXTERNAL : 
    myStateBefore = TopAbs_OUT; myStateAfter = TopAbs_OUT; break;
  }
}

//=======================================================================
//function : Orientation
//purpose  : 
//=======================================================================
TopAbs_Orientation TopOpeBRepDS_Transition::Orientation(const TopAbs_State S,const TopAbs_ShapeEnum T) const
{
  if (myStateBefore == TopAbs_ON || myStateAfter == TopAbs_ON) {
    return OrientationON(S,T);
  }
  else {
    if (myStateBefore == S) {
      if (myStateAfter == S) return TopAbs_INTERNAL;
      else                   return TopAbs_REVERSED;
    }
    else  {
      if (myStateAfter == S) return TopAbs_FORWARD;
      else                   return TopAbs_EXTERNAL;
    }
  }
}

//=======================================================================
//function : OrientationON
//purpose  : 
//=======================================================================
TopAbs_Orientation TopOpeBRepDS_Transition::OrientationON(const TopAbs_State S,const TopAbs_ShapeEnum ) const // T) const
{
#ifdef DEB
  TopAbs_Orientation result;
#else
  TopAbs_Orientation result=TopAbs_FORWARD;
#endif

  if      (myStateBefore == TopAbs_ON && myStateAfter == TopAbs_ON) {
#if 0
    if      ( S == TopAbs_IN )  result = TopAbs_FORWARD;
    else if ( S == TopAbs_OUT ) result = TopAbs_REVERSED;
    else if ( S == TopAbs_ON )  result = TopAbs_INTERNAL;
#endif
    if      ( S == TopAbs_IN )  result = TopAbs_INTERNAL;
    else if ( S == TopAbs_OUT ) result = TopAbs_EXTERNAL;
    else if ( S == TopAbs_ON )  result = TopAbs_INTERNAL;
  }
  else if (myStateBefore == TopAbs_ON) {
    if (myStateAfter == S) return TopAbs_FORWARD;
    else                   return TopAbs_REVERSED;
  }
  else if (myStateAfter == TopAbs_ON) {
    if (myStateBefore == S) return TopAbs_REVERSED;
    else                    return TopAbs_FORWARD;
  }

  return result;
}

//=======================================================================
//function : Complement
//purpose  : 
//=======================================================================
TopOpeBRepDS_Transition TopOpeBRepDS_Transition::Complement() const
{
  TopOpeBRepDS_Transition T;
  T.myIndexBefore = myIndexBefore;
  T.myIndexAfter = myIndexAfter;

  // xpu : 14-01-98
  if ( myStateBefore == TopAbs_UNKNOWN && myStateAfter == TopAbs_UNKNOWN ) {
    T.Set(myStateAfter,myStateBefore,myShapeAfter,myShapeBefore);
    return T;
  }
  // xpu : 14-01-98

  if ( myStateBefore == TopAbs_ON || myStateAfter == TopAbs_ON) {
    T.Set(myStateAfter,myStateBefore,myShapeAfter,myShapeBefore);
  }
  else {
    TopAbs_Orientation  o = Orientation(TopAbs_IN);
    if      ( o == TopAbs_FORWARD)          // (OUT,IN) --> (IN,OUT)
      T.Set(TopAbs_IN,TopAbs_OUT,myShapeBefore,myShapeAfter);
    else if ( o == TopAbs_REVERSED)         // (IN,OUT) --> (OUT,IN)
      T.Set(TopAbs_OUT,TopAbs_IN,myShapeBefore,myShapeAfter);
    else if ( o == TopAbs_EXTERNAL)         // (OUT,OUT) --> (IN,IN)
      T.Set(TopAbs_IN,TopAbs_IN,myShapeBefore,myShapeAfter);
    else if ( o == TopAbs_INTERNAL)         // (IN,IN) --> (OUT,OUT)
      T.Set(TopAbs_OUT,TopAbs_OUT,myShapeBefore,myShapeAfter);
  }

  return T;
}
  
//=======================================================================
//function : IsUnknown
//purpose  : 
//=======================================================================
Standard_Boolean TopOpeBRepDS_Transition::IsUnknown() const
{
  return (myStateBefore == TopAbs_UNKNOWN) && (myStateAfter == TopAbs_UNKNOWN);
}

//=======================================================================
//function : DumpB
//purpose  : 
//=======================================================================
Standard_OStream& TopOpeBRepDS_Transition::DumpB(Standard_OStream& OS) const
{
#ifdef DEB
  TopOpeBRepDS::Print(myStateBefore,OS);
  TopOpeBRepDS::Print(TopOpeBRepDS::ShapeToKind(myShapeBefore),myIndexBefore,OS);
#endif
  return OS;
}

//=======================================================================
//function : DumpA
//purpose  : 
//=======================================================================
Standard_OStream& TopOpeBRepDS_Transition::DumpA(Standard_OStream& OS) const
{
#ifdef DEB
  TopOpeBRepDS::Print(myStateAfter,OS);
  TopOpeBRepDS::Print(TopOpeBRepDS::ShapeToKind(myShapeAfter),myIndexAfter,OS);
#endif
  return OS;
}

//=======================================================================
//function : Dump
//purpose  : 
//=======================================================================
Standard_OStream& TopOpeBRepDS_Transition::Dump(Standard_OStream& OS) const
{
#ifdef DEB
  OS<<"("; DumpB(OS); OS<<","; DumpA(OS); OS<<")";
#endif
  return OS;
}