0023252: Fillet regression
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_CompositeClassifier.cxx
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
21
22 #include <TopOpeBRepBuild_CompositeClassifier.ixx>
23 #include <BRepTools.hxx>
24 #include <TCollection_AsciiString.hxx>
25
26 #define MYBB ((TopOpeBRepBuild_BlockBuilder*)myBlockBuilder)
27
28 // sourvenir d'un raise sur FrozenShape lors du Add(myShell,aFace)
29 // avec un shell qui a ete deja ete place dans le solide interne du 
30 // TopOpeBRepTool_SolidClassifier par LoadShell.
31
32 #ifdef DEB
33 //static Standard_Integer dddjyl = 0;
34 //static Standard_Integer dddebi = 0;
35 //static Standard_Integer dddebi2 = 0;
36 //static void SAVSS(const TopoDS_Shape& S1,const TopoDS_Shape& S2)
37 //{
38 //  TCollection_AsciiString aname_1("cc_1"), aname_2("cc_2");
39 //  Standard_CString name_1 = aname_1.ToCString(), name_2 = aname_2.ToCString();
40 //  cout<<"compositeclassifier : "<<name_1<<","<<name_2<<endl;
41 //  BRepTools::Write(S1,name_1); BRepTools::Write(S2,name_2); 
42 //}
43 #endif
44
45 //=======================================================================
46 //function : Initialize
47 //purpose  : 
48 //=======================================================================
49
50 TopOpeBRepBuild_CompositeClassifier::TopOpeBRepBuild_CompositeClassifier
51 (const TopOpeBRepBuild_BlockBuilder& BB) :
52 myBlockBuilder((void*)&BB)
53 {
54 }
55
56
57 //=======================================================================
58 //function : Compare
59 //purpose  : 
60 //=======================================================================
61
62 TopAbs_State TopOpeBRepBuild_CompositeClassifier::Compare
63 (const Handle(TopOpeBRepBuild_Loop)& L1,
64  const Handle(TopOpeBRepBuild_Loop)& L2)
65
66   TopAbs_State state = TopAbs_UNKNOWN;
67
68   Standard_Boolean isshape1 = L1->IsShape();
69   Standard_Boolean isshape2 = L2->IsShape();
70
71   if      ( isshape2 && isshape1 )  { // L1 is Shape , L2 is Shape
72     const TopoDS_Shape& s1 = L1->Shape();
73     const TopoDS_Shape& s2 = L2->Shape();
74     state = CompareShapes(s1,s2);
75   }
76   else if ( isshape2 && !isshape1 ) { // L1 is Block , L2 is Shape
77     TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator();
78     Bit1.Initialize();
79     Standard_Boolean yena1 = Bit1.More();
80     while (yena1) {
81       const TopoDS_Shape& s1 = MYBB->Element(Bit1);
82       const TopoDS_Shape& s2 = L2->Shape();
83       state = CompareElementToShape(s1,s2);
84       yena1 = Standard_False;
85       if (state == TopAbs_UNKNOWN) { 
86         if (Bit1.More()) Bit1.Next();
87         yena1 = Bit1.More();
88       }
89     }
90   }
91   else if ( !isshape2 && isshape1 ) { // L1 is Shape , L2 is Block
92     const TopoDS_Shape& s1 = L1->Shape();
93     ResetShape(s1);
94     TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator();
95     for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
96       const TopoDS_Shape& s2 = MYBB->Element(Bit2);
97       if (!CompareElement(s2)) 
98         break;
99     }
100     state = State();
101   }
102   else if ( !isshape2 && !isshape1 ) { // L1 is Block , L2 is Block
103     TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator();
104     Bit1.Initialize();
105     Standard_Boolean yena1 = Bit1.More();
106     while (yena1) {
107       const TopoDS_Shape& s1 = MYBB->Element(Bit1);
108       ResetElement(s1);
109       TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator();
110       for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) {
111         const TopoDS_Shape& s2 = MYBB->Element(Bit2);
112         CompareElement(s2);
113       }
114       state = State();
115       yena1 = Standard_False;
116       if (state == TopAbs_UNKNOWN) { 
117         if (Bit1.More()) Bit1.Next();
118         yena1 = Bit1.More();
119       }
120     }
121   }
122
123   return state;
124
125 }