7fd59977 |
1 | // File: BOP_CompositeClassifier.cxx |
2 | // Created: Fri Jan 5 15:26:38 1996 |
3 | // Author: Jean Yves LEBEY |
4 | // <jyl@meteox> |
5 | |
6 | #include <BOP_CompositeClassifier.ixx> |
7 | |
8 | //======================================================================= |
9 | //function : BOP_CompositeClassifier::BOP_CompositeClassifier |
10 | //purpose : |
11 | //======================================================================= |
12 | BOP_CompositeClassifier::BOP_CompositeClassifier (const BOP_BlockBuilder& BB) |
13 | : |
14 | myBlockBuilder((void*)&BB) |
15 | {} |
16 | //======================================================================= |
17 | //function : Compare |
18 | //purpose : |
19 | //======================================================================= |
20 | TopAbs_State BOP_CompositeClassifier::Compare(const Handle(BOP_Loop)& L1, |
21 | const Handle(BOP_Loop)& L2) |
22 | { |
23 | TopAbs_State state = TopAbs_UNKNOWN; |
24 | |
25 | Standard_Boolean isshape1, isshape2, yena1 ; |
26 | |
27 | isshape1 = L1->IsShape(); |
28 | isshape2 = L2->IsShape(); |
29 | |
30 | if ( isshape2 && isshape1 ) { |
31 | // L1 is Shape , L2 is Shape |
32 | const TopoDS_Shape& s1 = L1->Shape(); |
33 | const TopoDS_Shape& s2 = L2->Shape(); |
34 | state = CompareShapes(s1,s2); |
35 | } |
36 | |
37 | else if ( isshape2 && !isshape1 ) { |
38 | // L1 is Block , L2 is Shape |
39 | BOP_BlockIterator Bit1 = L1->BlockIterator(); |
40 | Bit1.Initialize(); |
41 | yena1 = Bit1.More(); |
42 | while (yena1) { |
43 | const TopoDS_Shape& s1 = |
44 | ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1); |
45 | const TopoDS_Shape& s2 = L2->Shape(); |
46 | |
47 | state = CompareElementToShape(s1,s2); |
48 | yena1 = Standard_False; |
49 | if (state == TopAbs_UNKNOWN) { |
50 | if (Bit1.More()) Bit1.Next(); |
51 | yena1 = Bit1.More(); |
52 | } |
53 | } |
54 | } |
55 | else if ( !isshape2 && isshape1 ) { |
56 | // L1 is Shape , L2 is Block |
57 | const TopoDS_Shape& s1 = L1->Shape(); |
58 | |
59 | ResetShape(s1); |
60 | BOP_BlockIterator Bit2 = L2->BlockIterator(); |
61 | for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { |
62 | const TopoDS_Shape& s2 = |
63 | ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2); |
64 | CompareElement(s2); |
65 | } |
66 | state = State(); |
67 | } |
68 | |
69 | else if ( !isshape2 && !isshape1 ) { |
70 | // L1 is Block , L2 is Block |
71 | BOP_BlockIterator Bit1 = L1->BlockIterator(); |
72 | Bit1.Initialize(); |
73 | yena1 = Bit1.More(); |
74 | while (yena1) { |
75 | const TopoDS_Shape& s1 = |
76 | ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1); |
77 | |
78 | ResetElement(s1); |
79 | BOP_BlockIterator Bit2 = L2->BlockIterator(); |
80 | for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { |
81 | const TopoDS_Shape& s2 = |
82 | ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2); |
83 | CompareElement(s2); |
84 | } |
85 | |
86 | state = State(); |
87 | yena1 = Standard_False; |
88 | if (state == TopAbs_UNKNOWN) { |
89 | if (Bit1.More()) Bit1.Next(); |
90 | yena1 = Bit1.More(); |
91 | } |
92 | } |
93 | } |
94 | return state; |
95 | } |