0023024: Update headers of OCCT files
[occt.git] / src / BOP / BOP_CompositeClassifier.cxx
CommitLineData
b311480e 1// Created on: 1996-01-05
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <BOP_CompositeClassifier.ixx>
23
24//=======================================================================
25//function : BOP_CompositeClassifier::BOP_CompositeClassifier
26//purpose :
27//=======================================================================
b311480e 28BOP_CompositeClassifier::BOP_CompositeClassifier (const BOP_BlockBuilder& BB)
7fd59977 29 :
30 myBlockBuilder((void*)&BB)
31{}
32//=======================================================================
33//function : Compare
34//purpose :
35//=======================================================================
36 TopAbs_State BOP_CompositeClassifier::Compare(const Handle(BOP_Loop)& L1,
37 const Handle(BOP_Loop)& L2)
38{
39 TopAbs_State state = TopAbs_UNKNOWN;
40
41 Standard_Boolean isshape1, isshape2, yena1 ;
42
43 isshape1 = L1->IsShape();
44 isshape2 = L2->IsShape();
45
46 if ( isshape2 && isshape1 ) {
47 // L1 is Shape , L2 is Shape
48 const TopoDS_Shape& s1 = L1->Shape();
49 const TopoDS_Shape& s2 = L2->Shape();
50 state = CompareShapes(s1,s2);
51 }
52
53 else if ( isshape2 && !isshape1 ) {
54 // L1 is Block , L2 is Shape
55 BOP_BlockIterator Bit1 = L1->BlockIterator();
56 Bit1.Initialize();
57 yena1 = Bit1.More();
58 while (yena1) {
59 const TopoDS_Shape& s1 =
60 ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1);
61 const TopoDS_Shape& s2 = L2->Shape();
62
63 state = CompareElementToShape(s1,s2);
64 yena1 = Standard_False;
65 if (state == TopAbs_UNKNOWN) {
66 if (Bit1.More()) Bit1.Next();
67 yena1 = Bit1.More();
68 }
69 }
70 }
71 else if ( !isshape2 && isshape1 ) {
72 // L1 is Shape , L2 is Block
73 const TopoDS_Shape& s1 = L1->Shape();
74
75 ResetShape(s1);
76 BOP_BlockIterator Bit2 = L2->BlockIterator();
77 for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
78 const TopoDS_Shape& s2 =
79 ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2);
80 CompareElement(s2);
81 }
82 state = State();
83 }
84
85 else if ( !isshape2 && !isshape1 ) {
86 // L1 is Block , L2 is Block
87 BOP_BlockIterator Bit1 = L1->BlockIterator();
88 Bit1.Initialize();
89 yena1 = Bit1.More();
90 while (yena1) {
91 const TopoDS_Shape& s1 =
92 ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit1);
93
94 ResetElement(s1);
95 BOP_BlockIterator Bit2 = L2->BlockIterator();
96 for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
97 const TopoDS_Shape& s2 =
98 ((BOP_BlockBuilder*)myBlockBuilder)->Element(Bit2);
99 CompareElement(s2);
100 }
101
102 state = State();
103 yena1 = Standard_False;
104 if (state == TopAbs_UNKNOWN) {
105 if (Bit1.More()) Bit1.Next();
106 yena1 = Bit1.More();
107 }
108 }
109 }
110 return state;
111}