b311480e |
1 | // Created on: 1998-05-07 |
2 | // Created by: Xuan PHAM PHU |
3 | // Copyright (c) 1998-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 <TopOpeBRepBuild_BuilderON.jxx> |
23 | |
24 | #include <TopOpeBRepTool_EXPORT.hxx> |
25 | #include <TopOpeBRepTool_SC.hxx> |
26 | #include <TopOpeBRepDS_InterferenceTool.hxx> |
27 | #include <TopOpeBRepDS_EXPORT.hxx> |
28 | #include <TopOpeBRepDS_connex.hxx> |
29 | #include <TopOpeBRepDS.hxx> |
30 | #include <TopOpeBRepBuild_define.hxx> |
31 | #include <BRep_Tool.hxx> |
32 | #include <TopoDS.hxx> |
33 | #include <TopExp.hxx> |
34 | #include <Precision.hxx> |
35 | |
36 | |
37 | #define M_OUT(st) (st == TopAbs_OUT) |
38 | #define M_IN( st) (st == TopAbs_IN) |
39 | #define M_FORWARD(st) (st == TopAbs_FORWARD) |
40 | #define M_REVERSED(st) (st == TopAbs_REVERSED) |
41 | |
42 | #ifdef DEB |
43 | Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEINTERNAL(); |
44 | Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEEXTERNAL(); |
45 | Standard_EXPORT void debfillonf(const Standard_Integer iF); |
46 | Standard_EXPORT void debON2d(const Standard_Integer iF) |
47 | {cout<<"++ debON2d "<<iF<<" "<<endl;} |
48 | #endif |
49 | |
50 | Standard_EXPORT TopAbs_State FUN_build_TB(const TopOpeBRepBuild_PBuilder& PB,const Standard_Integer rank); // xpu290698 |
51 | Standard_EXPORT Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder& B, |
52 | const TopoDS_Shape& sEG,const TopoDS_Shape& sFOR,const TopoDS_Shape& sFS, |
53 | const Standard_Boolean EGBoundFOR, |
54 | const TopOpeBRepDS_Transition& TFE,const TopAbs_State TB1,const TopAbs_State TB2); |
55 | Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString& m); |
56 | |
57 | Standard_EXPORTEXTERN TopOpeBRepDS_PDataStructure GLOBAL_DS2d; |
58 | |
59 | //======================================================================= |
60 | //function : Perform2d |
61 | //purpose : |
62 | //======================================================================= |
63 | void TopOpeBRepBuild_BuilderON::Perform2d |
64 | (const TopOpeBRepBuild_PBuilder& PB, |
65 | const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG, |
66 | const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES) |
67 | { |
68 | myPB = PB; |
69 | myFace = FOR; |
70 | myPG = PG; |
71 | myPLSclass = PLSclass; |
72 | myPWES = PWES; |
73 | |
74 | const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS(); |
75 | if (GLOBAL_DS2d == NULL) GLOBAL_DS2d = (TopOpeBRepDS_PDataStructure)new TopOpeBRepDS_DataStructure(); |
76 | const TopOpeBRepDS_ListOfInterference& lFEI = GLOBAL_DS2d->ShapeInterferences(FOR); |
77 | |
78 | #ifdef DEB |
79 | Standard_Integer iFOR;Standard_Boolean tFOR=myPB->GtraceSPS(FOR,iFOR); |
80 | if (tFOR) debfillonf(iFOR); |
81 | if (tFOR) {cout<<endl<<"LI on F"<<iFOR<<":"<<endl; |
82 | for (TopOpeBRepDS_ListIteratorOfListOfInterference iit(lFEI); iit.More(); iit.Next()) |
83 | {iit.Value()->Dump(cout);cout<<endl;}} |
84 | #endif |
85 | |
86 | for (TopOpeBRepDS_ListIteratorOfListOfInterference itI(lFEI); itI.More(); itI.Next()){ |
87 | const Handle(TopOpeBRepDS_Interference)& I = itI.Value(); |
88 | TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(I,GT,GI,ST,SI); |
89 | |
90 | const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI)); |
91 | #ifdef DEB |
92 | // Standard_Integer iEG=BDS.Shape(EG); |
93 | #endif |
94 | const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON); |
95 | #ifdef DEB |
96 | // Standard_Integer nEspON=lEspON.Extent(); |
97 | #endif |
98 | for(TopTools_ListIteratorOfListOfShape it(lEspON);it.More();it.Next()) { |
99 | const TopoDS_Shape& EspON=it.Value(); |
100 | GFillONParts2dWES2(I,EspON); |
101 | } |
102 | } |
103 | } |
104 | |
105 | //======================================================================= |
106 | //function : GFillONPartsWES2 |
107 | //purpose : |
108 | //======================================================================= |
109 | void TopOpeBRepBuild_BuilderON::GFillONParts2dWES2(const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& EspON) |
110 | { |
111 | const Handle(TopOpeBRepDS_HDataStructure)& HDS=myPB->DataStructure(); |
112 | const TopOpeBRepDS_DataStructure& BDS= HDS->DS(); |
113 | const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI=Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I); |
114 | TopAbs_State TB1,TB2;myPG->StatesON(TB1,TB2); |
115 | TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI); |
116 | // const TopOpeBRepDS_Transition& TFE=SSI->Transition(); |
117 | Standard_Boolean EGBoundFOR=SSI->GBound(); |
118 | const TopoDS_Face& FOR=TopoDS::Face(myFace); Standard_Integer iFOR=BDS.Shape(FOR); |
119 | const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI)); |
120 | #ifdef DEB |
121 | // Standard_Integer iEG=BDS.Shape(EG); |
122 | #endif |
123 | const TopoDS_Face& FS=TopoDS::Face(BDS.Shape(SI)); |
124 | #ifdef DEB |
125 | // Standard_Integer iFS=BDS.Shape(FS); |
126 | // Standard_Boolean isclosedFF=BRep_Tool::IsClosed(EG,FOR); |
127 | // Standard_Boolean isclosedFS=BRep_Tool::IsClosed(EG,FS); |
128 | // Standard_Boolean isclosed=(isclosedFF || isclosedFS); |
129 | // Standard_Boolean isrest=BDS.IsSectionEdge(EG); |
130 | // Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON); |
131 | // Standard_Integer rankFS=myPB->GShapeRank(FS); |
132 | #endif |
133 | Standard_Integer rankEG=myPB->GShapeRank(EG); |
134 | #ifdef DEB |
135 | // Standard_Integer rankFOR=myPB->GShapeRank(FOR); |
136 | #endif |
137 | |
138 | // TopAbs_State TBEG = (rankEG == 1) ? TB1 : TB2; |
139 | TopAbs_State TBEG = FUN_build_TB(myPB,rankEG); |
140 | #ifdef DEB |
141 | // TopAbs_State TFEbef = TFE.Before(); |
142 | // TopAbs_State TFEaft = TFE.After(); |
143 | // Standard_Boolean EGboundFOR = |
144 | // Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I)->GBound(); |
145 | #endif |
146 | Standard_Boolean eghassd = HDS->HasSameDomain(EG); |
147 | |
148 | #ifdef DEB |
149 | Standard_Boolean tFOR=myPB->GtraceSPS(iFOR); |
150 | // Standard_Boolean tE=myPB->GtraceSPS(GI); |
151 | // Standard_Boolean tEFOR = (tE && tFOR); |
152 | if (tFOR) {debON2d(iFOR);} |
153 | if (tFOR) {I->Dump(cout);cout<<endl;} |
154 | #endif |
155 | |
156 | Standard_Integer iFCX=SI; |
157 | Standard_Boolean FFinSDSO = Standard_True; |
158 | #ifdef DEB |
159 | // Standard_Boolean FFinSDDO = Standard_False; |
160 | #endif |
161 | Standard_Boolean FFinSD= Standard_True; |
162 | TopoDS_Face FCX = FS; |
163 | |
164 | #ifdef DEB |
165 | // TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation(); |
166 | // TopAbs_Orientation oFS = BDS.Shape(iFS).Orientation(); |
167 | // TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation(); |
168 | // Standard_Integer irefFOR = BDS.SameDomainRef(FOR); |
169 | // Standard_Integer irefFCX = BDS.SameDomainRef(FCX); |
170 | // Standard_Boolean FORisref = (irefFOR == iFOR); |
171 | // Standard_Boolean FCXisref = (irefFCX == iFCX); |
172 | #endif |
173 | |
174 | TopAbs_Orientation oegFCXF;Standard_Boolean EGBoundFCX = FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF); |
175 | TopAbs_Orientation oegFCX ; |
176 | #ifdef DEB |
177 | // Standard_Boolean ok2 = |
178 | #endif |
179 | FUN_tool_orientEinF(EG,FCX,oegFCX); |
180 | |
181 | Standard_Boolean opeFus = myPB->Opefus(); |
182 | Standard_Boolean opeCut = myPB->Opec12() || myPB->Opec21(); |
183 | Standard_Boolean opeCom = myPB->Opecom(); |
184 | |
185 | |
186 | Standard_Boolean yap6 = Standard_True; |
187 | yap6 = yap6 && FFinSD; |
188 | // yap6 = yap6 && (!EGBoundFOR); |
189 | // yap6 = yap6 && EGBoundFCX; |
190 | yap6 = yap6 && (EGBoundFOR || EGBoundFCX); |
191 | yap6 = yap6 && eghassd; |
192 | |
193 | //========================================= |
194 | if ( yap6) { |
195 | #ifdef DEB |
196 | if (tFOR) cout<<"* yap6 = 1"<<endl; |
197 | #endif |
198 | TopAbs_Orientation neworiE; |
199 | // FF est samedomain avec FCX |
200 | // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX |
201 | // au lieu de la transition par rapport a la matiere 3d de la face FS |
202 | // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD |
203 | |
204 | Standard_Boolean b = Standard_False; |
205 | |
206 | Standard_Boolean SO = FFinSDSO;//(FFinSDSO && (oFOR == oFCX)) || (FFinSDDO && (oFOR != oFCX)); |
207 | #ifdef DEB |
208 | // Standard_Integer rkToFill = BDS.AncestorRank(myFace); //DEB |
209 | #endif |
210 | Standard_Boolean rk1 = (rankEG == 1); |
211 | if (!rk1) return; |
212 | |
213 | TopAbs_Orientation oegFOR; |
214 | Standard_Boolean shareG; |
215 | Standard_Boolean ok = Standard_False; |
216 | if (EGBoundFCX) |
217 | ok = FUN_ds_shareG(myPB->DataStructure(),iFOR,iFCX,GI,TopoDS::Edge(EspON),shareG); |
218 | else if (EGBoundFOR) |
219 | ok = FUN_ds_shareG(myPB->DataStructure(),iFCX,iFOR,GI,TopoDS::Edge(EspON),shareG); |
220 | if (!ok) return; // nyiFUNRAISE |
221 | #ifdef DEB |
222 | if (tFOR) cout<<" shareG="<<shareG<<endl; |
223 | #endif |
224 | |
225 | if (SO) { |
226 | // FOR and FCX share geometric domain. |
227 | if (opeFus) b = shareG; |
228 | else if (opeCut) b = (!shareG) && M_OUT(TBEG); |
229 | else if (opeCom) b = shareG; |
230 | } |
231 | if (!b) return; |
232 | |
233 | if (!EGBoundFOR) { |
234 | TopAbs_Orientation oegFCXF1; FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF1); |
235 | neworiE = oegFCXF; |
236 | } |
237 | else if (EGBoundFOR) { |
238 | FUN_tool_orientEinFFORWARD(EG,TopoDS::Face(FOR),oegFOR); |
239 | neworiE = oegFOR; |
240 | } |
241 | |
242 | // Standard_Real f,l; FUN_tool_bounds(EG,f,l); Standard_Real parON = (f+l)*.4352; |
243 | Standard_Real f,l; FUN_tool_bounds(TopoDS::Edge(EspON),f,l); Standard_Real parON = (f+l)*.4352; // xpu120698 |
244 | Standard_Boolean ESO; ok = FUN_tool_curvesSO(TopoDS::Edge(EspON),parON,EG,ESO); |
245 | if (!ok) return; // xpu120698 |
246 | if (!ESO) neworiE = TopAbs::Complement(neworiE); |
247 | |
248 | TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation(); |
249 | TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation(); |
250 | if (oFOR != oFCX) neworiE = TopAbs::Complement(neworiE); |
251 | |
252 | TopoDS_Shape newE = EspON; |
253 | newE.Orientation(neworiE); |
254 | myPWES->AddStartElement(newE); |
255 | #ifdef DEB |
256 | if (tFOR) cout<<" add spON e"<<GI<<endl; |
257 | #endif |
258 | return; |
259 | } // yap6 |
260 | |
261 | } // GFillONPartsWES2 |