b311480e |
1 | // Created on: 1997-01-14 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1997-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 | |
17 | #include <TopOpeBRepBuild_Builder.ixx> |
18 | #include <TopOpeBRepBuild_define.hxx> |
19 | #include <TopOpeBRepDS_CurveExplorer.hxx> |
20 | #include <TopOpeBRepDS_TKI.hxx> |
21 | #include <TopOpeBRepDS_ProcessInterferencesTool.hxx> |
22 | #include <TopOpeBRepBuild_GTool.hxx> |
23 | #include <TopoDS.hxx> |
24 | #include <GeomAPI_ProjectPointOnCurve.hxx> |
25 | #include <BRep_Tool.hxx> |
26 | #include <gp_Pnt.hxx> |
27 | #include <TopExp.hxx> |
28 | #include <Geom_Curve.hxx> |
29 | #include <Geom2d_TrimmedCurve.hxx> |
30 | #include <Standard_ProgramError.hxx> |
31 | #include <TopOpeBRepDS_EXPORT.hxx> |
32 | #include <TopOpeBRepDS_connex.hxx> |
33 | #include <TopOpeBRepDS_TKI.hxx> |
34 | #include <Geom2d_Curve.hxx> |
35 | #include <Geom_Curve.hxx> |
36 | #include <BRep_Tool.hxx> |
37 | #include <BRep_Builder.hxx> |
38 | #include <TopOpeBRepTool_CurveTool.hxx> |
39 | #include <TopOpeBRepTool_TOOL.hxx> |
40 | #include <TopOpeBRepTool_2d.hxx> |
41 | #include <TopOpeBRepTool_EXPORT.hxx> |
42 | |
43 | #define MGhc3 Handle(Geom_Curve) |
44 | #define MGhc2 Handle(Geom2d_Curve) |
45 | |
0797d9d3 |
46 | #ifdef OCCT_DEBUG |
1d0a9d4d |
47 | extern Standard_Boolean TopOpeBRepBuild_GettraceSPS(); |
48 | extern Standard_Boolean TopOpeBRepDS_GettraceDSNC(); |
7fd59977 |
49 | Standard_EXPORT void debsplitse(const Standard_Integer) {} |
50 | Standard_EXPORT void debsplitsemess(const Standard_Integer i,const TCollection_AsciiString& s = ""); |
51 | Standard_EXPORT void debsplitsemess(const Standard_Integer i,const TCollection_AsciiString& s){cout<<"+++ debsplitse "<<s<<" E"<<i<<endl;debsplitse(i);} |
52 | Standard_EXPORT void debspseou(const Standard_Integer i) {debsplitsemess(i,"OUT");} |
53 | Standard_EXPORT void debspsein(const Standard_Integer i) {debsplitsemess(i,"IN ");} |
54 | Standard_EXPORT void debspseon(const Standard_Integer i) {debsplitsemess(i,"ON ");} |
1d0a9d4d |
55 | extern Standard_Boolean TopOpeBRepTool_GettraceC2D(); |
7fd59977 |
56 | #endif |
57 | |
58 | #ifdef DRAW |
59 | #include <TopOpeBRepTool_DRAW.hxx> |
60 | #endif |
61 | |
62 | //Standard_IMPORT void FUN_tool_ttranslate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE); |
63 | |
64 | #include <TopOpeBRepTool_ShapeTool.hxx> |
65 | #include <GeomAdaptor_Surface.hxx> |
66 | #include <GeomAbs_SurfaceType.hxx> |
67 | //--------------------------------------------- |
68 | static Standard_Boolean FUN_periodicS(const TopoDS_Shape& F) |
69 | //--------------------------------------------- |
70 | { |
71 | if (F.IsNull()) return Standard_False; |
72 | if (F.ShapeType() != TopAbs_FACE) return Standard_False; |
73 | Handle(Geom_Surface) SSS = TopOpeBRepTool_ShapeTool::BASISSURFACE(TopoDS::Face(F)); |
74 | GeomAdaptor_Surface GAS(SSS); |
75 | GeomAbs_SurfaceType styp = GAS.GetType(); |
76 | Standard_Boolean periodic = Standard_False; |
77 | if (styp == GeomAbs_Cylinder) periodic = Standard_True; |
78 | if (styp == GeomAbs_Cone) periodic = Standard_True; |
79 | if (styp == GeomAbs_Sphere) periodic = Standard_True; |
80 | // NYI : for Torus,SurfaceOfRevolution.. |
81 | return periodic; |
82 | } |
83 | |
84 | static Standard_Boolean FUN_periodic(const TopoDS_Face& F,Standard_Boolean& uper,Standard_Boolean& vper) |
85 | { |
86 | const Handle(Geom_Surface)& su = BRep_Tool::Surface(F); |
87 | uper = su->IsUPeriodic(); |
88 | vper = su->IsVPeriodic(); |
89 | Standard_Boolean per = (uper || vper); |
90 | return per; |
91 | } |
92 | |
93 | static Standard_Boolean FUN_onboundsper(const gp_Pnt2d& uv,const TopoDS_Face& F) |
94 | { |
95 | // 2d : |
96 | const Handle(Geom_Surface)& su = BRep_Tool::Surface(F); |
97 | Standard_Boolean uclo = su->IsUPeriodic(); |
98 | Standard_Boolean vclo = su->IsVPeriodic(); |
99 | if (!uclo && !vclo) return Standard_False; |
100 | |
101 | Standard_Real u1,u2,v1,v2; su->Bounds(u1,u2,v1,v2); |
102 | Standard_Real toluv = 1.e-8*1.e-2; // nyinyitol |
103 | if (uclo) { |
104 | Standard_Real d1 = Abs(u1-uv.X()); Standard_Boolean on1 = (d1 < toluv); |
105 | Standard_Real d2 = Abs(u2-uv.X()); Standard_Boolean on2 = (d2 < toluv); |
106 | return (on1 || on2); |
107 | } |
108 | if (vclo) { |
109 | Standard_Real d1 = Abs(v1-uv.Y()); Standard_Boolean on1 = (d1 < toluv); |
110 | Standard_Real d2 = Abs(v2-uv.Y()); Standard_Boolean on2 = (d2 < toluv); |
111 | return (on1 || on2); |
112 | } |
113 | return Standard_False; |
114 | } |
115 | |
116 | static Standard_Boolean FUN_onboundsper(const TopoDS_Edge& E,const TopoDS_Face& F, gp_Pnt2d& uv) |
117 | // uv is found by projection pnt(E,par) |
118 | { |
119 | // 3d : |
120 | Standard_Real f,l; FUN_tool_bounds(E,f,l); Standard_Real x=0.45678; Standard_Real par=f*x+(1-x)*l; |
121 | Standard_Real tolF = BRep_Tool::Tolerance(F)*1.e2; // nyitol |
122 | Standard_Boolean ok = FUN_tool_parF(E,par,F,uv,tolF); |
123 | if (!ok) return Standard_False; |
124 | |
125 | Standard_Boolean onbp = ::FUN_onboundsper(uv,F); |
126 | return onbp; |
127 | } |
128 | |
129 | |
130 | |
131 | //----------------------------------------------------------------------- |
132 | static Standard_Boolean FUN_PinC(const gp_Pnt& P,const Handle(Geom_Curve)& C,const Standard_Real pmin,const Standard_Real pmax,const Standard_Real tol) |
133 | //----------------------------------------------------------------------- |
134 | { |
135 | Standard_Boolean PinC = Standard_False; |
136 | GeomAPI_ProjectPointOnCurve mydm(P,C,pmin,pmax); |
137 | Standard_Boolean dmdone = ( mydm.Extrema().IsDone() ); |
138 | if ( dmdone ) { |
139 | if ( mydm.NbPoints() ) { |
140 | Standard_Real d = mydm.LowerDistance(); |
141 | PinC = (d <= tol); |
142 | } |
143 | } |
144 | return PinC; |
145 | } |
146 | |
147 | //----------------------------------------------------------------------- |
148 | static Standard_Boolean FUN_PinE(const gp_Pnt& P, const TopoDS_Edge& E) |
149 | //----------------------------------------------------------------------- |
150 | { |
151 | Standard_Boolean PinE = Standard_False; |
152 | Standard_Real f,l; Handle(Geom_Curve) CE = BRep_Tool::Curve(E,f,l); |
153 | Standard_Real tolE = BRep_Tool::Tolerance(E); |
154 | PinE = FUN_PinC(P,CE,f,l,tolE); |
155 | return PinE; |
156 | } |
157 | |
158 | #include <BRep_Tool.hxx> |
ec357c5c |
159 | #include <TopOpeBRepDS_ShapeShapeInterference.hxx> |
7fd59977 |
160 | //----------------------------------------------------------------------- |
161 | static Standard_Boolean FUN_EstaEE(const TopoDS_Edge& E, const TopAbs_State sta, const TopoDS_Edge& EE) |
162 | //----------------------------------------------------------------------- |
163 | { |
164 | Standard_Boolean EinEE = Standard_False; |
165 | Standard_Real f,l; |
166 | //modified by NIZNHY-PKV Wed Nov 3 11:40:14 1999 from |
167 | |
168 | if (BRep_Tool::Degenerated(E)) { |
169 | if (sta == TopAbs_IN) return Standard_False; |
170 | else return Standard_True; |
171 | } |
172 | //modified by NIZNHY-PKV Wed Nov 3 11:40:19 1999 to |
173 | |
174 | Handle(Geom_Curve) CE = BRep_Tool::Curve(E,f,l); |
175 | Standard_Real t = 0.417789; // Oi blya... ??? |
176 | Standard_Real p = (1-t)*f + t*l; |
177 | gp_Pnt P = CE->Value(p); |
178 | EinEE = FUN_PinE(P,EE); |
179 | if (sta == TopAbs_IN) return EinEE; |
180 | else if (sta == TopAbs_OUT) return !EinEE; |
181 | else Standard_ProgramError::Raise("TopOpeBRepBuild FUN_EstaEE on invalid state"); |
182 | return EinEE; |
183 | } |
184 | |
185 | //======================================================================= |
186 | //function : TopOpeBRepBuild_Builder::InitSection |
187 | //purpose : |
188 | //======================================================================= |
189 | void TopOpeBRepBuild_Builder::InitSection() |
190 | { |
191 | mySectionDone = Standard_False; |
192 | mySection.Clear(); |
193 | mySplitSectionEdgesDone = Standard_False; |
194 | mySplitON.Clear(); |
195 | } |
196 | |
197 | //----------------------------------------------------------------------- |
198 | // LE : list of edges from where is extracted LEsta = edges located <sta> / edge E |
199 | // N.B. : LEsta is expanded and NOT reinitialized |
200 | static void FUN_selLEE(TopTools_ListOfShape& LE,const TopoDS_Edge& E,const TopAbs_State sta,TopTools_ListOfShape& LEsta) |
201 | { |
202 | TopTools_ListIteratorOfListOfShape it(LE); |
203 | while (it.More()) { |
204 | const TopoDS_Edge& Ecur = TopoDS::Edge(it.Value()); |
205 | Standard_Boolean ok = FUN_EstaEE(Ecur,sta,E); |
206 | if (ok) { |
207 | LEsta.Append(Ecur); |
208 | LE.Remove(it); |
209 | } |
210 | else it.Next(); |
211 | } |
212 | } |
213 | |
214 | //----------------------------------------------------------------------- |
215 | // search the existence of shape E in time as shape of a mesh cell |
216 | // (shape,listofshape) of the list loslos. |
217 | Standard_Boolean FUN_FindEinSLOS(const TopoDS_Shape& E,const TopOpeBRepBuild_ListOfShapeListOfShape& loslos) |
218 | { |
219 | Standard_Boolean f = Standard_False; |
220 | for (TopOpeBRepBuild_ListIteratorOfListOfShapeListOfShape it(loslos); it.More(); it.Next()) { |
221 | const TopoDS_Shape& S = it.Value().Shape(); |
222 | Standard_Boolean issame = (S.IsSame(E)); |
223 | if (issame) { |
224 | f = Standard_True; |
225 | break; |
226 | } |
227 | } |
228 | return f; |
229 | } |
230 | |
231 | //======================================================================= |
232 | //function : SplitSectionEdges |
233 | //purpose : |
234 | //======================================================================= |
235 | void TopOpeBRepBuild_Builder::SplitSectionEdges() |
236 | { |
237 | if (mySplitSectionEdgesDone) return; |
238 | |
239 | const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); |
240 | Standard_Integer i,n = BDS.NbSectionEdges(); |
241 | |
0797d9d3 |
242 | #ifdef OCCT_DEBUG |
7fd59977 |
243 | if (TopOpeBRepDS_GettraceDSNC() && !mySplitSectionEdgesDone) |
244 | cout<<"TopOpeBRepBuild_Builder::SSE : compute "<<n<<" section edges"<<endl; |
245 | #endif |
246 | |
247 | for (i = 1; i <= n; i++) { // 1 |
248 | const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); |
249 | if(E.IsNull()) continue; |
250 | SplitSectionEdge(E); |
251 | } // 1 |
252 | |
253 | TopOpeBRepBuild_DataMapOfShapeListOfShapeListOfShape MEIN; |
254 | TopTools_DataMapOfShapeListOfShape MEOUT; |
255 | |
256 | for (i = 1; i <= n; i++) { // 2 |
257 | const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); |
258 | if(E.IsNull()) continue; |
259 | Standard_Integer iE = myDataStructure->Shape(E); |
260 | Standard_Integer rE = BDS.AncestorRank(E); |
261 | |
0797d9d3 |
262 | #ifdef OCCT_DEBUG |
7fd59977 |
263 | Standard_Boolean tSPS = GtraceSPS(E,iE); if (tSPS) debsplitsemess(iE); Standard_Integer DEBiESD = 1; |
264 | #endif |
265 | |
266 | Standard_Boolean isspliton = IsSplit(E,TopAbs_ON); |
267 | if (!isspliton) continue; |
268 | |
269 | const TopTools_ListOfShape& LESD = BDS.ShapeSameDomain(E); |
270 | if ( LESD.IsEmpty() ) continue; |
271 | |
272 | const TopTools_ListOfShape& LEspon = Splits(E,TopAbs_ON); |
273 | TopTools_ListOfShape LEoutLESD; GCopyList(LEspon,LEoutLESD); |
274 | Standard_Integer iRef = BDS.SameDomainRef(E); |
275 | |
276 | // LEoutLESD = list of edges Split(E,ON) OUT of all |
277 | // edges of the list of edges same domain of E in 3d only |
278 | // edges LEoutLESD are attached in Split(ON) to E only. |
279 | |
280 | for (TopTools_ListIteratorOfListOfShape itLESD(LESD); itLESD.More(); itLESD.Next()) { // 2.1 |
281 | const TopoDS_Edge& ESD = TopoDS::Edge(itLESD.Value()); |
282 | Standard_Integer iESD = myDataStructure->Shape(ESD); |
283 | const TopTools_ListOfShape& LESDspon = Splits(ESD,TopAbs_ON); |
284 | |
0797d9d3 |
285 | #ifdef OCCT_DEBUG |
7fd59977 |
286 | if (tSPS) { |
287 | TCollection_AsciiString str("# edge ");str=str+iE+" sd3d edge "+iESD; |
288 | TCollection_AsciiString stru(str.Length(),'-'); |
289 | cout<<endl;if(DEBiESD==1)cout<<stru<<endl; |
290 | DEBiESD++;cout<<str<<endl;debsplitsemess(iE); |
291 | } |
292 | #endif |
293 | |
294 | // reduction of LEoutLESD = edges OUT all ESD |
295 | TopTools_ListOfShape dummylos; |
296 | FUN_selLEE(LEoutLESD,ESD,TopAbs_IN,dummylos); |
297 | |
298 | const TopoDS_Edge *pE1 = NULL, *pE2 = NULL; |
299 | const TopTools_ListOfShape *plos1 = NULL, *plos2 = NULL; |
300 | Standard_Integer nLEspon = LEspon.Extent(); |
301 | Standard_Integer nLESDspon = LESDspon.Extent(); |
302 | |
303 | if ( nLEspon != 0 && nLESDspon != 0 ) { |
0ebaa4db |
304 | Standard_Boolean takeE = ((rE == 1 && iESD != iRef) || iE == iRef); |
305 | pE1 = takeE ? &E : &ESD; |
306 | pE2 = !takeE ? &E : &ESD; |
307 | plos1 = takeE ? &LEspon : &LESDspon; |
308 | plos2 = !takeE ? &LEspon : &LESDspon; |
7fd59977 |
309 | } |
310 | else if ( nLEspon != 0 ) { |
0ebaa4db |
311 | pE1 = &E; |
312 | pE2 = &ESD; |
313 | plos1 = &LEspon; |
314 | plos2 = &LESDspon; |
7fd59977 |
315 | } |
316 | else if ( nLESDspon != 0 ) { |
0ebaa4db |
317 | pE1 = &ESD; |
318 | pE2 = &E; |
319 | plos1 = &LESDspon; |
320 | plos2 = &LEspon; |
7fd59977 |
321 | } |
322 | |
323 | if (pE1 == NULL || pE2 == NULL) continue; |
324 | if (plos1 == NULL || plos2 == NULL) continue; |
325 | |
326 | const TopoDS_Edge& E1 = *pE1; |
327 | const TopoDS_Edge& E2 = *pE2; |
328 | const TopTools_ListOfShape& LE1 = *plos1; |
329 | |
330 | // selection of edges IN E2 = LEinE2 |
331 | TopTools_ListOfShape LE1loc; |
332 | GCopyList(LE1,LE1loc); |
333 | TopTools_ListOfShape LE1inE2; |
334 | FUN_selLEE(LE1loc,E2,TopAbs_IN,LE1inE2); |
335 | Standard_Integer nLE1inE2 = LE1inE2.Extent(); |
336 | |
337 | #ifdef DRAW |
338 | if (tSPS) { |
339 | cout<<"# edges ON "<<iE<<" "; |
340 | TopAbs::Print(TopAbs_IN,cout); cout<<" / esd"; |
341 | cout<<" "<<iESD; |
342 | cout<<" : ("<<nLE1inE2<<")"<<endl; |
343 | TCollection_AsciiString str("ON");str=str+iE+"IN"+iESD; |
344 | FDRAW_DINLOE(" ",LE1inE2,str,""); |
345 | } |
346 | #endif |
347 | |
348 | // edges E1 and E2 share LE1inE2 |
349 | if (nLE1inE2 != 0) { // 2.2 |
350 | |
351 | Standard_Boolean E1b = MEIN.IsBound(E1); |
352 | TopOpeBRepBuild_ListOfShapeListOfShape thelist; |
353 | if (!E1b) MEIN.Bind(E1, thelist); |
354 | TopOpeBRepBuild_ListOfShapeListOfShape& LE1loslos = MEIN.ChangeFind(E1); |
0797d9d3 |
355 | #ifdef OCCT_DEBUG |
7fd59977 |
356 | // Standard_Integer nLE1 = LE1loslos.Extent(); |
357 | #endif |
358 | |
359 | Standard_Boolean E2b = MEIN.IsBound(E2); |
360 | TopOpeBRepBuild_ListOfShapeListOfShape thelist2; |
361 | if (!E2b) MEIN.Bind(E2,thelist2); |
362 | TopOpeBRepBuild_ListOfShapeListOfShape& LE2loslos = MEIN.ChangeFind(E2); |
0797d9d3 |
363 | #ifdef OCCT_DEBUG |
7fd59977 |
364 | // Standard_Integer nLE2 = LE2loslos.Extent(); |
365 | #endif |
366 | |
367 | Standard_Boolean E2elemofE1 = FUN_FindEinSLOS(E2,LE1loslos); |
368 | Standard_Boolean E1elemofE2 = FUN_FindEinSLOS(E1,LE2loslos); |
369 | |
370 | Standard_Boolean condadd = (!E2elemofE1 && !E1elemofE2); |
371 | if (condadd) { |
372 | // regularization of edges of LE1inE2 -> LR |
373 | TopTools_ListOfShape LR; |
374 | for (TopTools_ListIteratorOfListOfShape ite(LE1inE2);ite.More();ite.Next()){ |
375 | const TopoDS_Edge& e = TopoDS::Edge(ite.Value()); |
376 | TopTools_ListOfShape newle; Standard_Boolean ok = TopOpeBRepTool_TOOL::SplitE(e,newle); |
377 | if (ok) LR.Append(newle); |
378 | else LR.Append(e); |
379 | } |
380 | { |
381 | TopOpeBRepBuild_ShapeListOfShape thelist3; |
382 | LE1loslos.Append(thelist3); |
383 | TopOpeBRepBuild_ShapeListOfShape& E1slos = LE1loslos.Last(); |
384 | E1slos.ChangeShape() = E2; |
385 | GCopyList(LR,E1slos.ChangeList()); |
386 | } |
387 | { |
388 | TopOpeBRepBuild_ShapeListOfShape thelist4; |
389 | LE2loslos.Append(thelist4); |
390 | TopOpeBRepBuild_ShapeListOfShape& E2slos = LE2loslos.Last(); |
391 | E2slos.ChangeShape() = E1; |
392 | GCopyList(LR,E2slos.ChangeList()); |
393 | } |
394 | } |
395 | } // 2.2 |
396 | } |
397 | |
398 | #ifdef DRAW |
399 | if (tSPS) { |
400 | cout<<endl<<"# edges ON "<<iE<<" "; |
401 | TopAbs::Print(TopAbs_OUT,cout);cout<<" / lesd"; |
402 | for(TopTools_ListIteratorOfListOfShape it(LESD);it.More();it.Next()) |
403 | cout<<" "<<myDataStructure->Shape(it.Value()); |
404 | Standard_Integer n=LEoutLESD.Extent();cout<<" : ("<<n<<")"<<endl; |
405 | TCollection_AsciiString str("ON");str=str+iE+"OUT"; |
406 | FDRAW_DINLOE(" ",LEoutLESD,str,""); |
407 | } |
408 | #endif |
409 | |
410 | if (!MEOUT.IsBound(E)) { |
411 | TopTools_ListOfShape thelist5; |
412 | MEOUT.Bind(E, thelist5); |
413 | } |
414 | GCopyList(LEoutLESD,MEOUT.ChangeFind(E)); |
415 | |
416 | } // 2 |
417 | |
418 | for (i = 1; i <= n; i++) { // 3 |
419 | const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); |
420 | if(E.IsNull()) continue; |
0797d9d3 |
421 | #ifdef OCCT_DEBUG |
7fd59977 |
422 | Standard_Integer iE = myDataStructure->Shape(E); |
423 | // Standard_Integer rE = GShapeRank(E); |
424 | Standard_Boolean tSPS = GtraceSPS(E,iE); |
425 | if (tSPS) debsplitsemess(iE); |
426 | #endif |
427 | |
428 | Standard_Boolean isspliton = IsSplit(E,TopAbs_ON);; |
429 | if (!isspliton) continue; |
430 | |
431 | const TopTools_ListOfShape& LESD = BDS.ShapeSameDomain(E); |
432 | if ( LESD.IsEmpty() ) continue; |
433 | |
434 | Standard_Boolean isbMEOUT = MEOUT.IsBound(E); |
435 | Standard_Boolean isbMEIN = MEIN.IsBound(E); |
436 | if (!isbMEOUT && !isbMEIN) continue; |
437 | |
438 | TopTools_ListOfShape& LEspon = ChangeSplit(E,TopAbs_ON); |
439 | LEspon.Clear(); |
440 | |
441 | if (isbMEOUT) { |
442 | const TopTools_ListOfShape& LEOUT = MEOUT.Find(E); |
0797d9d3 |
443 | #ifdef OCCT_DEBUG |
7fd59977 |
444 | // Standard_Integer nOUT = LEOUT.Extent(); |
445 | #endif |
446 | GCopyList(LEOUT,LEspon); |
447 | } |
448 | |
449 | if (isbMEIN) { |
450 | const TopOpeBRepBuild_ListOfShapeListOfShape& loslos = MEIN.Find(E); |
0797d9d3 |
451 | #ifdef OCCT_DEBUG |
7fd59977 |
452 | // Standard_Integer nloslos = loslos.Extent(); |
453 | #endif |
454 | for (TopOpeBRepBuild_ListIteratorOfListOfShapeListOfShape it(loslos); it.More(); it.Next()) { |
455 | const TopTools_ListOfShape& los = it.Value().List(); |
0797d9d3 |
456 | #ifdef OCCT_DEBUG |
7fd59977 |
457 | // Standard_Integer nlos = los.Extent(); |
458 | #endif |
459 | GCopyList(los,LEspon); |
460 | } |
461 | } |
462 | } // 3 |
463 | |
464 | BRep_Builder BB; |
465 | for (i = 1; i <= n; i++) { // 4 |
466 | const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); if(E.IsNull()) continue; |
0797d9d3 |
467 | #ifdef OCCT_DEBUG |
7fd59977 |
468 | Standard_Integer idebE; Standard_Boolean tSPS = GtraceSPS(E,idebE); if (tSPS) debsplitsemess(idebE); |
469 | #endif |
470 | const TopTools_ListOfShape& lesd = BDS.ShapeSameDomain(E); |
471 | if (lesd.IsEmpty()) continue; |
472 | |
473 | Standard_Integer iE = BDS.Shape(E); |
0797d9d3 |
474 | #ifdef OCCT_DEBUG |
7fd59977 |
475 | // Standard_Integer rE = BDS.AncestorRank(E); |
476 | #endif |
477 | Standard_Integer RE = BDS.SameDomainRef(E); |
478 | if (iE != RE) continue; |
479 | |
480 | TopTools_ListOfShape lF; TopTools_ListIteratorOfListOfShape itlesd; |
481 | for(itlesd.Initialize(lesd);itlesd.More();itlesd.Next()) { |
482 | const TopoDS_Edge& esd = TopoDS::Edge(itlesd.Value()); |
0797d9d3 |
483 | #ifdef OCCT_DEBUG |
7fd59977 |
484 | // Standard_Integer iesd = BDS.Shape(esd); |
485 | #endif |
486 | const TopTools_ListOfShape& lf = FDSCNX_EdgeConnexitySameShape(esd,myDataStructure); |
487 | GCopyList(lf,lF); |
488 | } |
0797d9d3 |
489 | #ifdef OCCT_DEBUG |
7fd59977 |
490 | // Standard_Integer nlF = lF.Extent(); |
491 | #endif |
492 | |
493 | TopTools_ListOfShape& lon = ChangeSplit(E,TopAbs_ON); |
494 | Standard_Real tolE = BRep_Tool::Tolerance(E); |
495 | TopTools_ListIteratorOfListOfShape it(lF); for(;it.More();it.Next()) { |
496 | const TopoDS_Face& F = TopoDS::Face(it.Value()); |
497 | Standard_Integer iF = BDS.Shape(F); Standard_Integer rF = BDS.AncestorRank(iF); |
498 | |
499 | TopoDS_Edge esdF; Standard_Boolean besdF = Standard_False; // NYI pointer on esdF |
500 | for(itlesd.Initialize(lesd);itlesd.More();itlesd.Next()) { |
501 | const TopoDS_Edge& esd = TopoDS::Edge(itlesd.Value()); |
502 | Standard_Integer iesd = BDS.Shape(esd); Standard_Integer resd = BDS.AncestorRank(iesd); |
503 | if (resd == rF) { |
504 | TopExp_Explorer ex; |
505 | for (ex.Init(F,TopAbs_EDGE);ex.More();ex.Next()) { |
506 | // for (TopExp_Explorer ex(F,TopAbs_EDGE);ex.More();ex.Next()) { |
507 | const TopoDS_Shape& ee = ex.Current(); |
508 | Standard_Boolean eq = (ee.IsEqual(esd)); |
509 | if (eq) { esdF = esd; besdF = Standard_True; break; } |
510 | } |
511 | } |
512 | if (besdF) break; |
513 | } |
514 | |
515 | TopTools_ListIteratorOfListOfShape itlon(lon); for(;itlon.More();itlon.Next()) { |
516 | TopoDS_Edge& eon = TopoDS::Edge(itlon.Value()); |
517 | Standard_Real f,l; Standard_Boolean hasPC = FC2D_HasCurveOnSurface(eon,F); |
518 | if (hasPC) continue; |
0797d9d3 |
519 | #ifdef OCCT_DEBUG |
7fd59977 |
520 | if (TopOpeBRepTool_GettraceC2D()) { |
521 | cout<<"\n#TopOpeBRepBuild_Builder::SSE : hasPC = 0 ES"<<i<<" E"<<idebE<<" sur F"<<iF<<endl; |
522 | cout<<"tsee s "<<iF<<" "<<idebE<<";"<<endl; |
523 | } |
524 | #endif |
525 | // Standard_Real tolpc; MGhc2 PC = FC2D_CurveOnSurface(eon,F,esdF,f,l,tolpc); |
526 | Standard_Real tolpc; MGhc2 PC = FC2D_CurveOnSurface(eon,F,esdF,f,l,tolpc,Standard_True);//xpu051198 :PRO15049 |
527 | hasPC = (!PC.IsNull()); |
528 | if (!hasPC) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::SSE null PC on F"); |
529 | Standard_Real tol = Max(tolE,tolpc); |
530 | BB.UpdateEdge(eon,PC,F,tol); |
531 | } |
532 | } |
533 | } // 4 |
534 | |
535 | Standard_Integer nsha = BDS.NbShapes(); |
536 | for (i = 1; i <= nsha; i++) { // 5 |
537 | const TopoDS_Shape& FOR = myDataStructure->Shape(i); |
538 | Standard_Boolean isface = (FOR.ShapeType() == TopAbs_FACE); |
539 | if (!isface) continue; |
540 | const TopoDS_Face& FF = TopoDS::Face(FOR); |
0797d9d3 |
541 | #ifdef OCCT_DEBUG |
7fd59977 |
542 | // Standard_Integer iFF = BDS.Shape(FF); |
543 | #endif |
544 | const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(FF); Standard_Integer nLI = LI.Extent(); |
545 | if (nLI == 0) continue; |
546 | for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI); ILI.More(); ILI.Next() ) { |
547 | const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(ILI.Value()); |
548 | if (SSI.IsNull()) continue; |
549 | TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI); |
550 | if (ST != TopOpeBRepDS_FACE) continue; |
551 | const TopOpeBRepDS_Transition& TFE = SSI->Transition(); |
552 | TopAbs_ShapeEnum shab = TFE.ShapeBefore(),shaa = TFE.ShapeAfter(); |
553 | if (shaa != TopAbs_FACE || shab != TopAbs_FACE) continue; |
554 | const TopoDS_Face& FS = TopoDS::Face( myDataStructure->Shape(SI)); |
0797d9d3 |
555 | #ifdef OCCT_DEBUG |
7fd59977 |
556 | // Standard_Integer iFS = myDataStructure->Shape(FS); |
557 | #endif |
558 | Standard_Boolean FSisper = FUN_periodicS(FS); |
559 | if (!FSisper) continue; |
560 | |
561 | const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->Shape(GI)); |
0797d9d3 |
562 | #ifdef OCCT_DEBUG |
7fd59977 |
563 | // Standard_Integer iEG = myDataStructure->Shape(EG); |
564 | #endif |
565 | Standard_Boolean isrest = myDataStructure->DS().IsSectionEdge(EG); if (!isrest) continue; |
0797d9d3 |
566 | #ifdef OCCT_DEBUG |
7fd59977 |
567 | // Standard_Real tolE = BRep_Tool::Tolerance(EG); |
568 | #endif |
569 | Standard_Boolean haspc = FC2D_HasCurveOnSurface(EG,FS); if (haspc) continue; |
570 | Standard_Boolean hasc3d = FC2D_HasC3D(EG); |
571 | if (!hasc3d) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::SSE EG without C3D"); |
572 | Standard_Real pf,pl,tolpc; Handle(Geom2d_Curve) PC; |
573 | Standard_Boolean trim3d = Standard_True; PC = FC2D_CurveOnSurface(EG,FS,pf,pl,tolpc,trim3d); |
574 | if (PC.IsNull()) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::SSE EG without PC on FS"); |
575 | } |
576 | } //5 |
577 | |
578 | for (i = 1; i <= nsha; i++) { // 6 |
579 | // xpu201198, for all periodic surfaces |
580 | const TopoDS_Shape& FOR = myDataStructure->Shape(i); |
581 | Standard_Boolean isface = (FOR.ShapeType() == TopAbs_FACE); |
582 | if (!isface) continue; |
583 | const TopoDS_Face& FF = TopoDS::Face(FOR); |
0797d9d3 |
584 | #ifdef OCCT_DEBUG |
7fd59977 |
585 | // Standard_Integer iFF = BDS.Shape(FF); |
586 | #endif |
587 | Standard_Boolean FFuper,FFvper; Standard_Boolean FFisper = FUN_periodic(FF,FFuper,FFvper); |
588 | if (!FFisper) continue; |
589 | |
590 | const TopOpeBRepDS_ListOfInterference& LI = BDS.ShapeInterferences(FF); Standard_Integer nLI = LI.Extent(); |
591 | if (nLI == 0) continue; |
592 | for (TopOpeBRepDS_ListIteratorOfListOfInterference ILI(LI); ILI.More(); ILI.Next() ) { |
593 | const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(ILI.Value()); |
594 | if (SSI.IsNull()) continue; |
595 | TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI); |
596 | if (ST != TopOpeBRepDS_FACE) continue; |
597 | Standard_Boolean GB = SSI->GBound(); |
598 | if (GB == 1) continue; |
599 | |
600 | const TopoDS_Edge& EG = TopoDS::Edge(myDataStructure->Shape(GI)); |
0797d9d3 |
601 | #ifdef OCCT_DEBUG |
7fd59977 |
602 | // Standard_Integer iEG = myDataStructure->Shape(EG); |
603 | #endif |
604 | Standard_Boolean isrest = myDataStructure->DS().IsSectionEdge(EG); if (!isrest) continue; |
605 | |
606 | // xpu191198 : cto016* |
607 | Standard_Real pf,pl,tolpc; Handle(Geom2d_Curve) PC; |
608 | Standard_Boolean trim3d = Standard_True; PC = FC2D_CurveOnSurface(EG,FF,pf,pl,tolpc,trim3d); |
609 | Standard_Boolean isoU,isoV; gp_Pnt2d o2d; gp_Dir2d d2d; |
610 | Standard_Boolean ISO = TopOpeBRepTool_TOOL::UVISO(PC,isoU,isoV,d2d,o2d); |
611 | if (ISO) { |
612 | TopTools_ListIteratorOfListOfShape itON(Splits(EG,TopAbs_ON)); |
613 | TopTools_ListOfShape newlON; |
614 | for (; itON.More(); itON.Next()){ |
615 | TopoDS_Edge eon = TopoDS::Edge(itON.Value()); |
616 | |
617 | Standard_Real pfon,plon,tolpcon; Handle(Geom2d_Curve) PCon; |
618 | PCon = FC2D_CurveOnSurface(eon,FF,pfon,plon,tolpcon,trim3d); |
619 | |
620 | Standard_Boolean isouon,isovon; gp_Pnt2d o2don; gp_Dir2d d2don; |
621 | Standard_Boolean ISOon = TopOpeBRepTool_TOOL::UVISO(PCon,isouon,isovon,d2don,o2don); |
622 | Standard_Boolean PCko = !ISOon || ((isoU && !isouon) || (isoV && !isovon)); |
623 | if (PCko) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::splitON"); |
624 | |
625 | Standard_Boolean test = (FFuper && isoU) || (FFvper && isoV); |
626 | if (!test) { newlON.Append(eon); continue;} |
627 | |
628 | gp_Pnt2d uvok; Standard_Boolean isonclo = FUN_onboundsper(eon,FF,uvok); //3d |
629 | if (isonclo) { newlON.Append(eon); continue;} |
630 | |
631 | Standard_Boolean isonclo2 = FUN_onboundsper(o2don,FF); //2d |
632 | if (isonclo2) { |
633 | gp_Vec2d tr; |
634 | if (isoU) {Standard_Real dtr = uvok.X() - o2don.X();tr = gp_Vec2d(dtr,0.);} |
635 | else {Standard_Real dtr = uvok.Y() - o2don.Y();tr = gp_Vec2d(0.,dtr);} |
636 | Standard_Real mag = tr.Magnitude(); |
637 | Standard_Real toluv = 1.e-8*1.e2; // NYINYI |
638 | if (mag > toluv) TopOpeBRepTool_TOOL::TrslUVModifE(tr,FF,eon); |
639 | } |
640 | newlON.Append(eon); |
641 | } // itON |
642 | TopTools_ListOfShape& nlON = ChangeSplit(EG,TopAbs_ON); |
643 | nlON.Clear(); nlON.Append(newlON); |
644 | } // ISO |
645 | } //ILI(LI) |
646 | } //6 |
647 | mySplitSectionEdgesDone = Standard_True; |
648 | } // SplitSectionEdges |
649 | |
7fd59977 |
650 | #define TheIN (1) |
651 | #define TheON (2) |
652 | #define TheOUT (3) |
1d0a9d4d |
653 | Standard_Integer GLOBAL_issp = 0; //++ |
7fd59977 |
654 | |
655 | #define HASSD2d (2) |
656 | #define HASSD3d (3) |
657 | Standard_EXPORT Standard_Integer GLOBAL_hassd = 0; //++ |
658 | |
659 | //======================================================================= |
660 | //function : SplitSectionEdge |
661 | //purpose : |
662 | //======================================================================= |
663 | void TopOpeBRepBuild_Builder::SplitSectionEdge(const TopoDS_Shape& EA) |
664 | { |
0797d9d3 |
665 | #ifdef OCCT_DEBUG |
7fd59977 |
666 | Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EA,iE); |
667 | if (tSPS) debsplitsemess(iE); |
668 | #endif |
669 | |
670 | TopOpeBRepDS_DataStructure& BDS = myDataStructure->ChangeDS(); |
671 | const TopoDS_Edge& EOR = TopoDS::Edge(EA); |
672 | TopoDS_Edge EF = EOR; EF.Orientation(TopAbs_FORWARD); |
673 | Standard_Integer rankEF = myDataStructure->DS().AncestorRank(EF); // GShapeRank <- GMapShapes, appele par Merge |
674 | |
675 | // FUN_removeonGB(myDataStructure,EOR); //xpu041198 |
676 | |
677 | Standard_Boolean hg = myDataStructure->HasGeometry(EOR); |
678 | Standard_Boolean hsd3d = FDS_HasSameDomain3d(BDS,EOR); |
679 | Standard_Boolean hsd2d = FDS_HasSameDomain2d(BDS,EOR); |
0797d9d3 |
680 | #ifdef OCCT_DEBUG |
7fd59977 |
681 | Standard_Boolean issplit = IsSplit(EOR,TopAbs_ON); |
682 | #endif |
683 | |
684 | Standard_Boolean cond = (hg || hsd3d); //REST2 //( hg && (!hsd) ); |
685 | |
686 | GLOBAL_hassd = 0; // initializing |
687 | if(hsd3d) GLOBAL_hassd=3; //++ |
688 | if(hsd2d) GLOBAL_hassd=2; //++ |
689 | |
690 | if (mySplitSectionEdgesDone) { |
0797d9d3 |
691 | #ifdef OCCT_DEBUG |
7fd59977 |
692 | if(tSPS) { |
693 | GdumpSHA(EF, (char *) "SplitSectionEdges done : "); |
694 | if (issplit) cout<<" "<<Splits(EOR,TopAbs_ON).Extent()<<" edges splitON"<<endl; |
695 | else cout<<" !IsSplit"<<endl; |
696 | } |
697 | #endif |
698 | return; |
699 | } |
700 | |
0797d9d3 |
701 | #ifdef OCCT_DEBUG |
7fd59977 |
702 | if(tSPS)GdumpSHASTA(EF,TopAbs_ON,"--- SplitSectionEdges "); |
703 | if(tSPS)cout<<" (hg="<<hg<<"||hsd3d="<<hsd3d<<")="<<cond<<endl; |
704 | #endif |
705 | |
706 | // xpu161198 BUC60382(e3on) SE EOR has all its interferences "on bounds" |
707 | Standard_Boolean allGb1=Standard_False; |
708 | TopoDS_Vertex vf,vl; TopExp::Vertices(TopoDS::Edge(EOR),vf,vl); |
709 | const TopOpeBRepDS_ListOfInterference& loi = BDS.ShapeInterferences(EOR); |
710 | TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); |
711 | for (; it.More(); it.Next()){ |
712 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
713 | TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S); |
714 | if (GT == TopOpeBRepDS_POINT) {allGb1=Standard_False; break;} |
715 | Standard_Integer rkG = BDS.AncestorRank(G); |
716 | const TopoDS_Vertex& v = TopoDS::Vertex(BDS.Shape(G)); |
717 | if (rkG==rankEF) { |
718 | allGb1 = (v.IsSame(vf) || v.IsSame(vl)); |
719 | } |
720 | else { |
721 | TopoDS_Shape oov; Standard_Boolean hsdmv = FUN_ds_getoov(v,myDataStructure,oov); |
722 | if (!hsdmv) allGb1=Standard_False; |
723 | allGb1 = (oov.IsSame(vf) || oov.IsSame(vl)); |
724 | } |
725 | if (!allGb1) break; |
726 | } // tki |
727 | |
728 | |
729 | Standard_Boolean mke = !cond; |
730 | mke = mke || !hg; //xpu271098 cto002J2(e9on) |
731 | mke = mke || allGb1; //xpu161198 BUC60382(e3on) |
732 | if (mke) { |
733 | MarkSplit(EOR,TopAbs_ON); |
734 | TopTools_ListOfShape& LON = ChangeSplit(EOR,TopAbs_ON); |
0797d9d3 |
735 | #ifdef OCCT_DEBUG |
7fd59977 |
736 | // Standard_Integer non = LON.Extent(); // DEB |
737 | #endif |
738 | |
739 | TopoDS_Edge newEOR; |
740 | FUN_ds_CopyEdge(EOR,newEOR); |
741 | Standard_Boolean hasnewEOR=Standard_False; |
742 | BRep_Builder BB; |
743 | TopExp_Explorer exv(EOR, TopAbs_VERTEX); |
744 | for (; exv.More(); exv.Next()){ |
745 | const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current()); |
746 | Standard_Real parv = BRep_Tool::Parameter(v,EOR); |
747 | Standard_Integer iv = BDS.Shape(v); |
748 | Standard_Integer ivref = 0; |
749 | Standard_Boolean hsd = Standard_False; |
750 | if (iv != 0) |
751 | hsd = myDataStructure->HasSameDomain(v); |
752 | if (hsd) |
753 | ivref = myDataStructure->SameDomainReference(v); |
754 | Standard_Boolean setref = hsd && (iv != ivref); |
755 | TopoDS_Vertex vref = TopoDS::Vertex(BDS.Shape(ivref)); |
756 | if (!setref) |
757 | {BB.Add(newEOR,v); FUN_ds_Parameter(newEOR,v,parv); continue;} |
758 | hasnewEOR = Standard_True; |
759 | vref.Orientation(v.Orientation()); |
760 | BB.Add(newEOR,vref); |
761 | FUN_ds_Parameter(newEOR,vref,parv); |
762 | } |
763 | if (hasnewEOR) |
764 | LON.Append(newEOR); |
765 | else |
766 | LON.Append(EOR); |
767 | return; |
768 | } // mke |
769 | |
770 | TopTools_ListOfShape LESD1,LESD2; GFindSamDom(EOR,LESD1,LESD2); |
771 | |
0797d9d3 |
772 | #ifdef OCCT_DEBUG |
7fd59977 |
773 | if(tSPS)GdumpSHASTA(EF,TopAbs_ON,"--- SplitSectionEdges "); |
774 | if(tSPS){ |
775 | cout<<" (hg="<<hg<<"||hsd3d="<<hsd3d<<")="<<cond<<endl; |
776 | GdumpSHA(EOR, (char *) "SplitSectionEdge"); |
777 | cout<<endl; |
778 | GdumpSAMDOM(LESD1, (char *) "LESD1 : "); |
779 | GdumpSAMDOM(LESD2, (char *) "LESD2 : "); |
780 | } |
781 | #endif |
782 | |
783 | { |
0797d9d3 |
784 | #ifdef OCCT_DEBUG |
7fd59977 |
785 | if (tSPS) debspseon(iE); |
786 | #endif |
787 | TopOpeBRepBuild_GTopo G = TopOpeBRepBuild_GTool::GComUnsh(TopAbs_FACE,TopAbs_FACE); |
788 | myEdgeReference = EF; |
789 | TopOpeBRepBuild_PaveSet PVS(EF); |
790 | |
791 | GLOBAL_issp = TheON; //++ |
792 | GFillEdgePVS(EF,myEmptyShapeList,G,PVS); |
793 | GLOBAL_issp = 0; //++ |
794 | |
795 | // Create an edge builder EDBU |
796 | TopOpeBRepBuild_PaveClassifier VCL(EF); |
797 | Standard_Boolean equalpar = PVS.HasEqualParameters(); |
798 | if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters()); |
799 | TopOpeBRepBuild_EdgeBuilder EDBU; |
800 | EDBU.InitEdgeBuilder(PVS,VCL); |
801 | |
802 | // Build the new edges LEM |
803 | TopTools_ListOfShape LEM; |
804 | GEDBUMakeEdges(EF,EDBU,LEM); |
805 | |
806 | // xpu : 18-03-98 (cto 016 B2) |
807 | // splits edges of LEM with internal vertices |
808 | TopTools_ListOfShape newLEM; TopTools_ListIteratorOfListOfShape ite(LEM); |
809 | for (; ite.More(); ite.Next()){ |
810 | const TopoDS_Edge& esp = TopoDS::Edge(ite.Value()); |
811 | TopTools_ListOfShape lspe; Standard_Boolean ok = TopOpeBRepTool_TOOL::SplitE(esp,lspe); |
812 | Standard_Boolean nonwesp = (!ok) || (lspe.Extent() < 2); |
813 | if (nonwesp) newLEM.Append(esp); |
814 | else newLEM.Append(lspe); |
815 | } |
816 | LEM.Clear(); LEM.Append(newLEM); |
817 | |
818 | // connect new edges LEM as split parts (ON,SOLID) |
819 | MarkSplit(EOR,TopAbs_ON); |
820 | TopTools_ListOfShape& LON = ChangeSplit(EOR,TopAbs_ON); |
821 | GCopyList(LEM,LON); |
822 | } |
823 | |
824 | //modified by NIZHNY-MZV Mon Apr 17 16:25:51 2000 TopTools_ListOfShape losOO; |
825 | //modified by NIZHNY-MZV Mon Apr 17 16:25:52 2000 if (rankEF == 1) losOO.Append(GLOBALDS_shape2); |
826 | //modified by NIZHNY-MZV Mon Apr 17 16:25:53 2000 else if (rankEF == 2) losOO.Append(GLOBALDS_shape1); |
827 | |
828 | { |
0797d9d3 |
829 | #ifdef OCCT_DEBUG |
7fd59977 |
830 | if (tSPS) debspsein(iE); |
831 | #endif |
832 | TopOpeBRepBuild_GTopo G = TopOpeBRepBuild_GTool::GCutUnsh(TopAbs_FACE,TopAbs_FACE); |
833 | G = G.CopyPermuted(); // parts (IN,OUT) 3d are constructed |
834 | myEdgeReference = EF; |
835 | TopOpeBRepBuild_PaveSet PVS(EF); |
836 | |
837 | GLOBAL_issp = TheIN; //++ |
838 | GFillEdgePVS(EF,myEmptyShapeList,G,PVS); |
839 | GLOBAL_issp = 0; //++ |
840 | |
841 | // Create an edge builder EDBU |
842 | TopOpeBRepBuild_PaveClassifier VCL(EF); |
843 | Standard_Boolean equalpar = PVS.HasEqualParameters(); |
844 | if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters()); |
845 | TopOpeBRepBuild_EdgeBuilder EDBU; |
846 | EDBU.InitEdgeBuilder(PVS,VCL); |
847 | |
848 | // Build the new edges LEM |
849 | TopTools_ListOfShape LEMNC; |
850 | GEDBUMakeEdges(EF,EDBU,LEMNC); |
851 | |
852 | //modified by NIZHNY-MZV Mon Apr 17 15:23:28 2000 TopTools_ListOfShape LEM; |
853 | //modified by NIZHNY-MZV Mon Apr 17 15:23:16 2000 GKeepShapes(EF,losOO,TopAbs_IN,LEMNC,LEM); |
854 | |
855 | // connect new edges LEM as split parts (IN,SOLID) |
856 | MarkSplit(EOR,TopAbs_IN); |
857 | TopTools_ListOfShape& LINN = ChangeSplit(EOR,TopAbs_IN); |
858 | GCopyList(LEMNC,LINN); |
859 | } |
860 | |
861 | { |
0797d9d3 |
862 | #ifdef OCCT_DEBUG |
7fd59977 |
863 | if (tSPS) debspseou(iE); |
864 | #endif |
865 | TopOpeBRepBuild_GTopo G = TopOpeBRepBuild_GTool::GCutUnsh(TopAbs_FACE,TopAbs_FACE); |
866 | // parts (OUT,IN) 3d are constructed |
867 | myEdgeReference = EF; |
868 | TopOpeBRepBuild_PaveSet PVS(EF); |
869 | |
870 | GLOBAL_issp = TheOUT; //++ |
871 | GFillEdgePVS(EF,myEmptyShapeList,G,PVS); |
872 | GLOBAL_issp = 0; //++ |
873 | |
874 | // Create an edge builder EDBU |
875 | TopOpeBRepBuild_PaveClassifier VCL(EF); |
876 | Standard_Boolean equalpar = PVS.HasEqualParameters(); |
877 | if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters()); |
878 | TopOpeBRepBuild_EdgeBuilder EDBU; |
879 | EDBU.InitEdgeBuilder(PVS,VCL); |
880 | |
881 | // Build the new edges LEM |
882 | TopTools_ListOfShape LEM; |
883 | GEDBUMakeEdges(EF,EDBU,LEM); |
884 | |
885 | // connect new edges LEM as split parts (OUT,SOLID) |
886 | MarkSplit(EOR,TopAbs_OUT); |
887 | TopTools_ListOfShape& LINN = ChangeSplit(EOR,TopAbs_OUT); |
888 | GCopyList(LEM,LINN); |
889 | } |
890 | |
891 | GLOBAL_hassd=0; //++ |
892 | } |
893 | |
894 | //======================================================================= |
895 | //function : Section |
896 | //purpose : |
897 | //======================================================================= |
898 | const TopTools_ListOfShape& TopOpeBRepBuild_Builder::Section() |
899 | { |
900 | if (mySectionDone) return mySection; |
901 | mySectionDone = Standard_True; |
902 | SectionCurves(mySection); |
903 | SectionEdges(mySection); |
904 | return mySection; |
905 | } |
906 | |
907 | //======================================================================= |
908 | //function : Section |
909 | //purpose : |
910 | //======================================================================= |
911 | void TopOpeBRepBuild_Builder::Section(TopTools_ListOfShape& L) |
912 | { |
913 | L = Section(); |
914 | } |
915 | |
916 | //======================================================================= |
917 | //function : SectionCurves |
918 | //purpose : |
919 | //======================================================================= |
920 | void TopOpeBRepBuild_Builder::SectionCurves(TopTools_ListOfShape& LSE) |
921 | { |
922 | TopOpeBRepDS_CurveExplorer cex(myDataStructure->DS()); |
923 | for (; cex.More(); cex.Next()) { |
924 | Standard_Integer ic = cex.Index(); |
925 | TopTools_ListIteratorOfListOfShape itloe(NewEdges(ic)); |
926 | for(;itloe.More();itloe.Next()) { |
927 | LSE.Append(itloe.Value()); |
928 | } |
929 | } |
930 | } |
931 | |
932 | //======================================================================= |
933 | //function : SectionEdges |
934 | //purpose : |
935 | //======================================================================= |
936 | void TopOpeBRepBuild_Builder::SectionEdges(TopTools_ListOfShape& LSE) |
937 | { |
938 | const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); |
939 | Standard_Integer i,nes = BDS.NbSectionEdges(); |
940 | |
941 | Standard_Integer iskpart = IsKPart(); |
942 | if ( iskpart == 1 ) { // iskole |
943 | for (i=1;i<=nes;i++ ) { |
944 | const TopoDS_Edge& E = TopoDS::Edge(BDS.SectionEdge(i)); |
945 | // modif fbi 16-09-97: case possible if RemoveSectionEdge was called |
946 | if(E.IsNull()) |
947 | continue; |
948 | // end modif fbi |
949 | LSE.Append(E); |
950 | } |
951 | return; |
952 | } |
953 | |
954 | SplitSectionEdges(); |
955 | |
956 | // common of edges of section |
957 | |
958 | TopTools_MapOfShape MOS; |
959 | |
960 | for (i=1;i<=nes;i++) { |
961 | |
962 | const TopoDS_Shape& es = BDS.SectionEdge(i); |
963 | // modif fbi 16-09-97: case possible if RemoveSectionEdge was called |
964 | if(es.IsNull()) |
965 | continue; |
966 | // end modif fbi |
967 | Standard_Boolean issplitIN = IsSplit(es,TopAbs_IN); |
968 | Standard_Boolean issplitON = IsSplit(es,TopAbs_ON); |
969 | TopAbs_State staspl=(issplitON)?TopAbs_ON:(issplitIN)?TopAbs_IN:TopAbs_UNKNOWN; |
970 | |
0797d9d3 |
971 | #ifdef OCCT_DEBUG |
7fd59977 |
972 | Standard_Integer iii; Standard_Boolean tSPS = GtraceSPS(es,iii); |
973 | if (tSPS) { |
974 | GdumpSHA(es, (char *) "--- Section "); |
975 | cout<<" splitIN "<<issplitIN<<" "<<Splits(es,TopAbs_IN).Extent()<<endl; |
976 | cout<<" splitON "<<issplitON<<" "<<Splits(es,TopAbs_ON).Extent()<<endl; |
977 | } |
978 | #endif |
979 | |
980 | if (staspl != TopAbs_UNKNOWN) { |
981 | for(TopTools_ListIteratorOfListOfShape it(Splits(es,staspl));it.More();it.Next()) { |
982 | const TopoDS_Shape& S = it.Value(); |
983 | if ( !MOS.Contains(S) ) { |
984 | MOS.Add(S); |
985 | LSE.Append(S); |
986 | } |
987 | } |
988 | } |
989 | else { |
990 | Standard_Boolean hasgeom = myDataStructure->HasGeometry(es); |
991 | Standard_Boolean hassame = myDataStructure->HasSameDomain(es); |
992 | Standard_Boolean take = !(hasgeom || hassame); |
993 | if (take) { |
994 | if ( !MOS.Contains(es) ) { |
995 | MOS.Add(es); |
996 | LSE.Append(es); |
997 | } |
998 | } |
999 | } |
1000 | } // for i [1..nes] |
1001 | } // SectionEdges |
1002 | |
1003 | //======================================================================= |
1004 | //function : FillSecEdgeAncestorMap |
1005 | //purpose : |
1006 | //======================================================================= |
1007 | |
1008 | void TopOpeBRepBuild_Builder::FillSecEdgeAncestorMap(const Standard_Integer aShapeRank, |
1009 | const TopTools_MapOfShape& aMapON, |
1010 | TopTools_DataMapOfShapeShape& anAncMap) |
1011 | const |
1012 | { |
1013 | const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); |
1014 | |
1015 | Standard_Integer i,nse = BDS.NbSectionEdges(); |
1016 | for (i=1; i<=nse; i++) { |
1017 | const TopoDS_Shape& es = BDS.SectionEdge(i); |
1018 | if(es.IsNull() || ShapeRank(es) != aShapeRank) |
1019 | continue; |
1020 | if (aMapON.Contains(es)) { |
1021 | anAncMap.Bind(es,es); |
1022 | continue; |
1023 | } |
1024 | TopAbs_State states[3] = {TopAbs_IN, TopAbs_ON, TopAbs_OUT}; |
1025 | for (Standard_Integer j=0; j < 3; j++) { |
1026 | // Standard_Boolean isSplit = IsSplit(es,states[j]); |
1027 | if (IsSplit(es,states[j])) { |
1028 | TopTools_ListIteratorOfListOfShape it(Splits(es,states[j])); |
1029 | for(;it.More();it.Next()) { |
1030 | const TopoDS_Shape& aS = it.Value(); |
1031 | if (aMapON.Contains(aS)) |
1032 | anAncMap.Bind(aS,es); |
1033 | } |
1034 | } |
1035 | } |
1036 | } |
1037 | } |