b311480e |
1 | // Created on: 1996-01-05 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <BRepTools.hxx> |
19 | #include <TCollection_AsciiString.hxx> |
42cf5bc1 |
20 | #include <TopoDS_Shape.hxx> |
21 | #include <TopOpeBRepBuild_BlockBuilder.hxx> |
22 | #include <TopOpeBRepBuild_CompositeClassifier.hxx> |
23 | #include <TopOpeBRepBuild_Loop.hxx> |
7fd59977 |
24 | |
25 | #define MYBB ((TopOpeBRepBuild_BlockBuilder*)myBlockBuilder) |
26 | |
27 | // sourvenir d'un raise sur FrozenShape lors du Add(myShell,aFace) |
28 | // avec un shell qui a ete deja ete place dans le solide interne du |
29 | // TopOpeBRepTool_SolidClassifier par LoadShell. |
30 | |
0797d9d3 |
31 | #ifdef OCCT_DEBUG |
7fd59977 |
32 | //static Standard_Integer dddjyl = 0; |
33 | //static Standard_Integer dddebi = 0; |
34 | //static Standard_Integer dddebi2 = 0; |
35 | //static void SAVSS(const TopoDS_Shape& S1,const TopoDS_Shape& S2) |
36 | //{ |
37 | // TCollection_AsciiString aname_1("cc_1"), aname_2("cc_2"); |
38 | // Standard_CString name_1 = aname_1.ToCString(), name_2 = aname_2.ToCString(); |
04232180 |
39 | // std::cout<<"compositeclassifier : "<<name_1<<","<<name_2<<std::endl; |
7fd59977 |
40 | // BRepTools::Write(S1,name_1); BRepTools::Write(S2,name_2); |
41 | //} |
42 | #endif |
43 | |
44 | //======================================================================= |
45 | //function : Initialize |
46 | //purpose : |
47 | //======================================================================= |
48 | |
49 | TopOpeBRepBuild_CompositeClassifier::TopOpeBRepBuild_CompositeClassifier |
50 | (const TopOpeBRepBuild_BlockBuilder& BB) : |
51 | myBlockBuilder((void*)&BB) |
52 | { |
53 | } |
54 | |
55 | |
56 | //======================================================================= |
57 | //function : Compare |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | TopAbs_State TopOpeBRepBuild_CompositeClassifier::Compare |
62 | (const Handle(TopOpeBRepBuild_Loop)& L1, |
63 | const Handle(TopOpeBRepBuild_Loop)& L2) |
64 | { |
65 | TopAbs_State state = TopAbs_UNKNOWN; |
66 | |
67 | Standard_Boolean isshape1 = L1->IsShape(); |
68 | Standard_Boolean isshape2 = L2->IsShape(); |
69 | |
70 | if ( isshape2 && isshape1 ) { // L1 is Shape , L2 is Shape |
71 | const TopoDS_Shape& s1 = L1->Shape(); |
72 | const TopoDS_Shape& s2 = L2->Shape(); |
73 | state = CompareShapes(s1,s2); |
74 | } |
75 | else if ( isshape2 && !isshape1 ) { // L1 is Block , L2 is Shape |
76 | TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator(); |
77 | Bit1.Initialize(); |
78 | Standard_Boolean yena1 = Bit1.More(); |
79 | while (yena1) { |
80 | const TopoDS_Shape& s1 = MYBB->Element(Bit1); |
81 | const TopoDS_Shape& s2 = L2->Shape(); |
82 | state = CompareElementToShape(s1,s2); |
83 | yena1 = Standard_False; |
84 | if (state == TopAbs_UNKNOWN) { |
85 | if (Bit1.More()) Bit1.Next(); |
86 | yena1 = Bit1.More(); |
87 | } |
88 | } |
89 | } |
90 | else if ( !isshape2 && isshape1 ) { // L1 is Shape , L2 is Block |
91 | const TopoDS_Shape& s1 = L1->Shape(); |
92 | ResetShape(s1); |
93 | TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator(); |
94 | for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { |
95 | const TopoDS_Shape& s2 = MYBB->Element(Bit2); |
73a97e76 |
96 | if (!CompareElement(s2)) |
97 | break; |
7fd59977 |
98 | } |
99 | state = State(); |
100 | } |
101 | else if ( !isshape2 && !isshape1 ) { // L1 is Block , L2 is Block |
102 | TopOpeBRepBuild_BlockIterator Bit1 = L1->BlockIterator(); |
103 | Bit1.Initialize(); |
104 | Standard_Boolean yena1 = Bit1.More(); |
105 | while (yena1) { |
106 | const TopoDS_Shape& s1 = MYBB->Element(Bit1); |
107 | ResetElement(s1); |
108 | TopOpeBRepBuild_BlockIterator Bit2 = L2->BlockIterator(); |
109 | for (Bit2.Initialize(); Bit2.More(); Bit2.Next()) { |
110 | const TopoDS_Shape& s2 = MYBB->Element(Bit2); |
111 | CompareElement(s2); |
112 | } |
113 | state = State(); |
114 | yena1 = Standard_False; |
115 | if (state == TopAbs_UNKNOWN) { |
116 | if (Bit1.More()) Bit1.Next(); |
117 | yena1 = Bit1.More(); |
118 | } |
119 | } |
120 | } |
121 | |
122 | return state; |
123 | |
124 | } |