1 // Created on: 1994-08-30
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public version 2.1 as published
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TopOpeBRepBuild_Builder.jxx>
20 #include <TopoDS_Solid.hxx>
21 #include <TopoDS_Shell.hxx>
22 #include <TopoDS_Wire.hxx>
25 #include <BRep_Builder.hxx>
26 #include <TopOpeBRepTool_ShapeExplorer.hxx>
27 #include <TopOpeBRepTool_EXPORT.hxx>
28 #include <TopOpeBRepDS_EXPORT.hxx>
29 #include <TopOpeBRepDS_connex.hxx>
30 #include <TopOpeBRepBuild_define.hxx>
31 #include <TopOpeBRepBuild_WireToFace.hxx>
32 #include <TopOpeBRepBuild_kpresu.hxx>
33 #include <Standard_ProgramError.hxx>
36 extern Standard_Boolean TopOpeBRepBuild_GettraceKPB();
40 Standard_EXPORT Standard_Boolean FUNKP_KPiskolesh(const TopOpeBRepBuild_Builder& BU,const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& Sarg,TopTools_ListOfShape& lShsd,TopTools_ListOfShape& lfhsd);
41 Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU, const TopoDS_Shape& Fac1, const TopTools_ListOfShape& LF2,
42 const TopAbs_State Stfac1, const TopAbs_State Stfac2,
43 const Standard_Boolean R1, const Standard_Boolean R2,TopTools_ListOfShape& Lres);
46 //=======================================================================
47 //function : MergeKPartiskole
49 //=======================================================================
51 void TopOpeBRepBuild_Builder::MergeKPartiskole()
54 Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB();
55 if (TKPB) KPreturn(myIsKPart);
59 Standard_Integer ibid;
61 if ( myIsKPart != 1 ) return;
63 GMapShapes(myShape1,myShape2);
64 // NYI : on doit pouvoir faire l'economie du mapping GMapShapes(...)
65 // NYI en allant chercher l'indice 1,2 retourne par GShapeRank(S)
66 // NYI dans la DS. l'index est defini pour tous les shapes HasSameDomain
68 TopTools_ListOfShape& lmergesha1 = ChangeMerged(myShape1,myState1);
69 ChangeMerged(myShape2,myState2);
71 TopTools_ListOfShape lShsd1,lShsd2; // liste de solides HasSameDomain
72 TopTools_ListOfShape lfhsd1,lfhsd2; // liste de faces HasSameDomain
73 KPiskolesh(myShape1,lShsd1,lfhsd1);
74 KPiskolesh(myShape2,lShsd2,lfhsd2);
75 // traitement de tous les solides NYI
76 TopoDS_Shape sol1 = lShsd1.First();
77 TopoDS_Shape sol2 = lShsd2.First();
79 ChangeMerged(sol1,myState1);
80 ChangeMerged(sol2,myState2);
82 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm1;
83 itm1.Initialize(myKPMAPf1f2);
84 if ( ! itm1.More() ) return;
89 for (; itm1.More();itm1.Next()) {
90 const TopoDS_Shape& f = itm1.Key();
91 Standard_Integer fi = myDataStructure->Shape(f);
92 cout<<"face "<<fi<<" : ";
93 const TopTools_ListOfShape& l = itm1.Value();
94 TopTools_ListIteratorOfListOfShape it(l);
95 for(; it.More(); it.Next()) {
96 const TopoDS_Shape& ff = it.Value();
97 Standard_Integer ffi = myDataStructure->Shape(ff);
102 itm1.Initialize(myKPMAPf1f2);
106 TopTools_ListOfShape LFIN;
107 TopTools_ListOfShape* plfIN = NULL;
108 const TopoDS_Shape* pfOU = NULL;
109 const TopoDS_Shape* pfIN = NULL;
111 for (; itm1.More();itm1.Next()) {
112 // const TopoDS_Shape& f = itm1.Key();
113 // myDataStructure->Shape(f); //DEB
114 const TopTools_ListOfShape& los = itm1.Value();
115 Standard_Boolean emp = los.IsEmpty();
117 if (plfIN == NULL) plfIN = (TopTools_ListOfShape*)&itm1.Value();
118 if (pfOU == NULL) pfOU = &itm1.Key();
119 if (pfIN == NULL) pfIN = &plfIN->First();
120 for (TopTools_ListIteratorOfListOfShape it(los);it.More();it.Next()) LFIN.Append(it.Value());
124 if ( plfIN==NULL) return;
125 if ( pfOU==NULL) return;
126 if ( pfIN==NULL) return;
129 Standard_Integer ifOU; Standard_Boolean tSPS = GtraceSPS(*pfOU,ifOU);
131 // Standard_Integer iOU = myDataStructure->Shape(*pfOU);
132 // Standard_Integer iIN = myDataStructure->Shape(*pfIN);
133 GdumpSHA(*pfOU, (char *) "MergeKPartiskole pfOU ");cout<<endl;
134 GdumpSAMDOM(LFIN, (char *) "LFIN : ");
139 Standard_Integer rankpfOU = GShapeRank(*pfOU);
140 Standard_Integer rankpfIN = GShapeRank(*pfIN);
141 if ( rankpfOU != 1 && rankpfOU != 2 ) return;
142 if ( rankpfIN != 1 && rankpfIN != 2 ) return;
144 // solfOU = solide dont la face *pfOU est OUT / faces LFIN
145 // solfIN = solide dont les faces *plfIN sont IN / face *pfOU
147 if (rankpfOU == 1) solfOU = sol1;
150 if (rankpfIN == 1) solfIN = sol1;
152 TopAbs_State stsolfOU = KPclasSS(solfOU,*pfOU, solfIN);
153 TopAbs_State stsolfIN = KPclasSS(solfIN,LFIN,solfOU);
154 TopAbs_State stfOU = TopAbs_OUT;
155 TopAbs_State stfIN = TopAbs_IN;
157 TopAbs_State stsol1=TopAbs_UNKNOWN,stsol2=TopAbs_UNKNOWN;
158 TopAbs_State stfac1=TopAbs_UNKNOWN,stfac2=TopAbs_UNKNOWN;
159 TopoDS_Shape fac1,fac2;
160 if (rankpfOU == 1 ) {
161 stsol1 = stsolfOU; stfac1 = stfOU; fac1 = *pfOU;
162 stsol2 = stsolfIN; stfac2 = stfIN; fac2 = *pfIN;
164 else if (rankpfOU == 2 ) {
165 stsol1 = stsolfIN; stfac1 = stfIN; fac1 = *pfIN;
166 stsol2 = stsolfOU; stfac2 = stfOU; fac2 = *pfOU;
169 Standard_Integer ires,icla1,icla2;
170 KPiskoleanalyse(stfac1,stfac2,stsol1,stsol2,ires,icla1,icla2);
171 if (ires == RESUNDEF) return;
172 if (icla1 == SHEUNDEF || icla2 == SHEUNDEF) return;
174 TopoDS_Shape she1; // she1 = shell accedant fac1
175 TopTools_IndexedDataMapOfShapeListOfShape Mfacshe1;
176 TopExp::MapShapesAndAncestors(sol1,TopAbs_FACE,TopAbs_SHELL,Mfacshe1);
177 const TopTools_ListOfShape& lshe1 = Mfacshe1.FindFromKey(fac1);
178 TopTools_ListIteratorOfListOfShape itlshe1(lshe1);
179 she1 = itlshe1.Value();
181 TopoDS_Shape she2; // she2 = shell accedant fac2
182 TopTools_IndexedDataMapOfShapeListOfShape Mfacshe2;
183 TopExp::MapShapesAndAncestors(sol2,TopAbs_FACE,TopAbs_SHELL,Mfacshe2);
184 const TopTools_ListOfShape& lshe2 = Mfacshe2.FindFromKey(fac2);
185 TopTools_ListIteratorOfListOfShape itlshe2(lshe2);
186 she2 = itlshe2.Value();
188 ChangeMerged(she1,myState1);
189 ChangeMerged(she2,myState2);
192 if (TKPB) { cout<<"stsol1 ";TopAbs::Print(stsol1,cout); cout<<" "; }
193 if (TKPB) { cout<<"stsol2 ";TopAbs::Print(stsol2,cout); cout<<endl; }
199 if ( ires == RESNULL ) {
203 else if (ires == RESSHAPE1) {
204 myBuildTool.MakeShell(newshe);
205 newshe = TopoDS::Shell(she1);
208 else if (ires == RESSHAPE2) {
209 myBuildTool.MakeShell(newshe);
210 newshe = TopoDS::Shell(she2);
213 else if ( ires == RESFACE1 ) {
215 // resultat = face de rang 1 et face de rang 1 = face OUT
216 lmergesha1.Append(*pfOU);
217 ChangeMerged(fac2,myState2).Append(*pfOU);
219 else if (rankpfOU == 2) {
220 // resultat = face de rang 1 et face de rang 1 = faces IN
221 GCopyList(*plfIN,lmergesha1);
222 GCopyList(*plfIN,ChangeMerged(fac2,myState2));
227 else if ( ires == RESFACE2 ) {
229 // resultat = face de rang 2 et face de rang 2 = face OUT
230 lmergesha1.Append(*pfOU);
231 ChangeMerged(fac1,myState1).Append(*pfOU);
233 else if (rankpfOU == 1) {
234 // resultat = face de rang 2 et face de rang 2 = faces IN
235 GCopyList(*plfIN,lmergesha1);
236 GCopyList(*plfIN,ChangeMerged(fac1,myState1));
241 else if (ires == RESNEWSHE) {
243 itm1.Initialize(myKPMAPf1f2);
244 if (! itm1.More() ) return;
246 TopTools_DataMapOfShapeShape addedfaces;
247 for (; itm1.More();itm1.Next()) {
249 const TopoDS_Shape& f1 = itm1.Key();
250 const TopTools_ListOfShape& lf2 = itm1.Value();
251 if (lf2.IsEmpty()) continue;
253 TopTools_ListIteratorOfListOfShape it2;
255 const TopoDS_Shape& f2 = it2.Value();
258 Standard_Integer ii1 = myDataStructure->Shape(f1);
259 Standard_Integer ii2 = myDataStructure->Shape(f2);
261 Standard_Integer rankf1 = GShapeRank(f1);
262 Standard_Integer rankf2 = GShapeRank(f2);
263 if (rankf1 == 0) continue;
264 if (rankf2 == 0) continue;
266 TopAbs_State stf1,stf2; KPclassFF(f1,f2,stf1,stf2);
267 if ( rankf1 == 1 ) KPiskoleanalyse(stf1,stf2,stsol1,stsol2,ires,ibid,ibid);
268 if ( rankf1 == 2 ) KPiskoleanalyse(stf2,stf1,stsol2,stsol1,ires,ibid,ibid);
269 if (ires == RESUNDEF) continue;
271 Standard_Boolean r1 = (stsol1 == TopAbs_IN);
272 Standard_Boolean r2 = (stsol2 == TopAbs_IN);
274 if ( rankf1 == 1 ) fac = KPmakeface(f1,lf2,stf1,stf2,r1,r2);
275 if ( rankf1 == 2 ) fac = KPmakeface(f1,lf2,stf1,stf2,r2,r1);
276 if ( fac.IsNull() ) continue;
277 if ( ! fac.IsNull() ) addedfaces.Bind(fac,fac);
279 TopAbs_State statemergef1 = (rankf1 == 1) ? myState1 : myState2;
280 TopAbs_State statemergef2 = (rankf2 == 2) ? myState2 : myState1;
281 ChangeMerged(f1,statemergef1).Append(fac);
283 for (;it2.More();it2.Next())
284 ChangeMerged(it2.Value(),statemergef2).Append(fac);
286 // les faces de she1 sauf les tangentes et celles deja ajoutees
287 TopOpeBRepTool_ShapeExplorer fex1;
288 for (fex1.Init(she1,TopAbs_FACE); fex1.More(); fex1.Next()) {
289 const TopoDS_Shape& facur = fex1.Current();
291 Standard_Boolean isfsd = myKPMAPf1f2.IsBound(facur);
292 Standard_Boolean isadded = addedfaces.IsBound(facur);
293 Standard_Boolean toadd = (!isfsd) && (!isadded) ;
296 TopoDS_Shape fori = facur;
297 if (stsol1 == TopAbs_IN) fori.Complement();
298 addedfaces.Bind(fori,fori);
302 // les faces de she2 sauf les tangentes et celles deja ajoutees
303 TopOpeBRepTool_ShapeExplorer fex2;
304 for (fex2.Init(she2,TopAbs_FACE); fex2.More(); fex2.Next()) {
305 const TopoDS_Shape& facur = fex2.Current();
307 Standard_Boolean isfsd = myKPMAPf1f2.IsBound(facur);
308 Standard_Boolean isadded = addedfaces.IsBound(facur);
309 Standard_Boolean toadd = (!isfsd) && (!isadded) ;
312 TopoDS_Shape fori = facur;
313 if (stsol2 == TopAbs_IN) fori.Complement();
314 addedfaces.Bind(fori,fori);
317 } // === fin iteration fac1,fac2
319 TopTools_DataMapIteratorOfDataMapOfShapeShape itadd(addedfaces);
320 Standard_Boolean yauadd = itadd.More();
322 myBuildTool.MakeShell(newshe);
323 myBuildTool.Closed(newshe,Standard_True); // NYI : check exact du caractere closed du shell
325 for (; itadd.More(); itadd.Next() ) {
326 const TopoDS_Shape& ftoadd = itadd.Key();
327 myBuildTool.AddShellFace(newshe,ftoadd);
330 } // === fin RESNEWSHE
334 cout<<"MergeKPartiskole : ires = "<<ires<<endl;
339 if ( !newshe.IsNull() ) {
340 myBuildTool.MakeSolid(newsol);
341 myBuildTool.AddSolidShell(newsol,newshe);
344 if ( icla1 == SHECLASAUTR || icla1 == SHEGARDAUTR ) {
345 // n.b. : ne pas prendre she1 accedant f1
346 TopTools_ListOfShape loshe1;
347 TopOpeBRepTool_ShapeExplorer ex1;
348 for (ex1.Init(sol1,TopAbs_SHELL); ex1.More(); ex1.Next()) {
349 const TopoDS_Shape& shecur = ex1.Current();
350 if (she1.IsEqual(shecur)) continue;
351 if (icla1 == SHECLASAUTR) {
352 TopAbs_State state1 = KPclasSS(shecur,fac1,sol2);
353 if (state1 == myState1) loshe1.Append(shecur);
355 else if (icla1 == SHEGARDAUTR) {
356 loshe1.Append(shecur);
360 // Standard_Integer nshe1 = loshe1.Extent();
362 TopTools_ListIteratorOfListOfShape itloshe1;
363 for( itloshe1.Initialize(loshe1); itloshe1.More(); itloshe1.Next() ) {
364 const TopoDS_Shape& shecur = itloshe1.Value();
365 myBuildTool.AddSolidShell(newsol,shecur);
369 if ( icla2 == SHECLASAUTR || icla2 == SHEGARDAUTR ) {
370 // n.b. : ne pas prendre she2 accedant f2
371 TopTools_ListOfShape loshe2;
372 TopOpeBRepTool_ShapeExplorer ex2;
373 for (ex2.Init(sol2,TopAbs_SHELL); ex2.More(); ex2.Next()) {
374 const TopoDS_Shape& shecur = ex2.Current();
375 if (she2.IsEqual(shecur)) continue;
376 if (icla2 == SHECLASAUTR) {
377 TopAbs_State state2 = KPclasSS(shecur,fac2,sol1);
378 if (state2 == myState2) loshe2.Append(shecur);
380 else if (icla2 == SHEGARDAUTR) {
381 loshe2.Append(shecur);
385 // Standard_Integer nshe2 = loshe2.Extent();
387 TopTools_ListIteratorOfListOfShape itloshe2;
388 for( itloshe2.Initialize(loshe2); itloshe2.More(); itloshe2.Next() ) {
389 const TopoDS_Shape& shecur = itloshe2.Value();
390 myBuildTool.AddSolidShell(newsol,shecur);
395 if ( !newsol.IsNull() ) {
396 lmergesha1.Append(newsol);
399 } // MergeKPartiskole
402 //=======================================================================
403 //function : KPiskole
404 //purpose : detection faces collees
405 //=======================================================================
407 Standard_Integer TopOpeBRepBuild_Builder::KPiskole()
410 TopTools_ListOfShape lShsd1,lShsd2; // liste de solides HasSameDomain
411 TopTools_ListOfShape lfhsd1,lfhsd2; // liste de faces HasSameDomain
413 Standard_Boolean iskp1 = KPiskolesh(myShape1,lShsd1,lfhsd1);
414 if ( !iskp1 ) return 0;
415 Standard_Integer nfhsd1 = lfhsd1.Extent();
416 if ( nfhsd1 == 0 ) return 0;
418 Standard_Boolean iskp2 = KPiskolesh(myShape2,lShsd2,lfhsd2);
419 if ( !iskp2 ) return 0;
420 Standard_Integer nfhsd2 = lfhsd2.Extent();
421 if ( nfhsd2 == 0 ) return 0;
423 // Si l'un des objets est constitue de plusieur solides on passe
424 // dans le cas general , sinon on obtient
425 //** Exception ** Standard_OutOfRange: TCollection_IndexedDataMap::FindFromKey at
426 // TopOpeBRepBuild_Builder::MergeKPartiskole(this = 0xf7988),
427 // line 397 in "/adv_21/MDL/k1deb/ref/prod/TopOpeBRepBuild/src/TopOpeBRepBuild_KPart.cxx"
429 Standard_Integer nshsd1 = lShsd1.Extent();
430 Standard_Integer nshsd2 = lShsd2.Extent();
431 if (nshsd1>1 || nshsd2>1) return 0;
433 TopTools_ListOfShape lf1,lf2;
434 TopTools_ListOfShape les; //section
436 for (TopTools_ListIteratorOfListOfShape itlf1(lfhsd1);
437 itlf1.More();itlf1.Next()) {
439 const TopoDS_Shape& f1 = itlf1.Value();
441 // Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1); // DEB
443 lf1.Clear(); lf1.Append(f1);
444 lf2.Clear(); KPSameDomain(lf1,lf2);
446 // Standard_Integer n1 = lf1.Extent();
447 // Standard_Integer n2 = lf2.Extent();
451 Standard_Integer iF1; Standard_Boolean tSPS1 = GtraceSPS(f1,iF1);
453 GdumpSHA(f1, (char *) "KPiskole ");cout<<endl;
454 GdumpSAMDOM(lf2, (char *) "lf2 : ");
458 for (TopTools_ListIteratorOfListOfShape itlf2(lf2);
459 itlf2.More(); itlf2.Next() ) {
461 const TopoDS_Shape& f2 = itlf2.Value();
463 // Standard_Boolean isb2 = myKPMAPf1f2.IsBound(f2); // DEB
465 TopAbs_State state1,state2;
466 Standard_Boolean classok = KPiskoleFF(f1,f2,state1,state2);
467 if ( ! classok ) return 0;
469 // on va reconstuire la face OUT
470 if ( state1 == TopAbs_OUT && state2 == TopAbs_IN) {
471 Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1);
472 if ( ! isb1 ) { TopTools_ListOfShape los; myKPMAPf1f2.Bind(f1,los); }
473 TopTools_ListOfShape& los = myKPMAPf1f2.ChangeFind(f1);
476 Standard_Boolean isb2 = myKPMAPf1f2.IsBound(f2);
477 if ( ! isb2 ) { TopTools_ListOfShape los1; myKPMAPf1f2.Bind(f2,los1); }
479 else if ( state2 == TopAbs_OUT && state1 == TopAbs_IN) {
480 Standard_Boolean isb2 = myKPMAPf1f2.IsBound(f2);
481 if ( ! isb2 ) { TopTools_ListOfShape los; myKPMAPf1f2.Bind(f2,los); }
482 TopTools_ListOfShape& los = myKPMAPf1f2.ChangeFind(f2);
485 Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1);
486 if ( ! isb1 ) { TopTools_ListOfShape los1; myKPMAPf1f2.Bind(f1,los1); }
489 // les aretes de la face IN sont des aretes de section
491 if (state1 == TopAbs_IN) fw = f1;
492 else if (state2 == TopAbs_IN) fw = f2;
493 if (fw.IsNull()) continue;
495 TopOpeBRepTool_ShapeExplorer ex(fw,TopAbs_EDGE);
496 for (;ex.More();ex.Next()) les.Append(ex.Current());
500 // aretes de section iskole
501 TopOpeBRepDS_DataStructure& DS = myDataStructure->ChangeDS();
502 DS.InitSectionEdges(); TopTools_ListIteratorOfListOfShape it(les);
503 for (;it.More();it.Next()) DS.AddSectionEdge(TopoDS::Edge(it.Value()));
506 } // TopOpeBRepBuild_Builder::KPiskole
508 //=======================================================================
509 //function : KPiskoleanalyse
511 //=======================================================================
513 void TopOpeBRepBuild_Builder::KPiskoleanalyse(const TopAbs_State Stfac1, const TopAbs_State Stfac2,
514 const TopAbs_State Stsol1, const TopAbs_State Stsol2,
515 Standard_Integer& ires,Standard_Integer& icla1,Standard_Integer& icla2) const
517 ires = RESUNDEF; icla1 = icla2 = SHEUNDEF;
520 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
521 ires = RESNEWSHE; icla1 = SHEGARDAUTR; icla2 = SHEGARDAUTR;
523 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
524 ires = RESSHAPE1; icla1 = SHECLASAUTR; icla2 = SHEAUCU;
526 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
527 ires = RESSHAPE2; icla1 = SHEAUCU; icla2 = SHECLASAUTR;
531 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
532 ires = RESSHAPE1; icla1 = SHEGARDAUTR; icla2 = SHEAUCU;
534 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
535 ires = RESNEWSHE; icla1 = SHECLASAUTR; icla2 = SHEAUCU;
537 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
538 ires = RESNULL; icla1 = icla2 = SHEAUCU;
542 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
543 ires = RESSHAPE2; icla1 = SHEAUCU; icla2 = SHEGARDAUTR;
545 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
546 ires = RESNULL; icla1 = icla2 = SHEAUCU;
548 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
549 ires = RESNEWSHE; icla1 = SHEAUCU; icla2 = SHECLASAUTR;
553 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
554 if (Stfac1 == TopAbs_IN) {
555 ires = RESFACE1; icla1 = icla2 = SHEAUCU;
557 if (Stfac2 == TopAbs_IN) {
558 ires = RESFACE2; icla1 = icla2 = SHEAUCU;
561 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
562 ires = RESSHAPE2; icla1 = SHECLASAUTR; icla2 = SHEGARDAUTR;
564 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
565 ires = RESSHAPE1; icla1 = SHEGARDAUTR; icla2 = SHECLASAUTR;
570 Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB();
571 if (TKPB) cout<<"ires = "<<ires<<" icla1 "<<icla1<<" icla2 "<<icla2<<endl;
573 } // TopOpeBRepBuild_Builder::KPiskoleanalyse
575 Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU,
576 const TopoDS_Shape& Fac1,
577 const TopTools_ListOfShape& LF2,
578 const TopAbs_State Stfac1,
579 const TopAbs_State /*Stfac2*/,
580 const Standard_Boolean R1,
581 const Standard_Boolean R2,
582 TopTools_ListOfShape& Lres)
584 // reconstruisons la face qui contient les autres
586 TopoDS_Face fac; BB.MakeFace(fac);
588 Standard_Integer rankIN = 0;
589 TopTools_ListOfShape LFSO,LFDO;
592 Standard_Integer iF1; Standard_Boolean tSPS = BU.GtraceSPS(Fac1,iF1);
593 if(tSPS) { BU.GdumpSHA(Fac1, (char *) "KPmakeFace ");cout<<endl; }
596 if (Stfac1 == TopAbs_OUT) {
597 TopoDS_Shape aLocalShape = Fac1.EmptyCopied();
598 fac = TopoDS::Face(aLocalShape);
599 // fac = TopoDS::Face(Fac1.EmptyCopied());
600 Standard_Integer rankF = BU.GShapeRank(Fac1);
601 rankIN = (rankF) ? ( (rankF==1) ? 2 : 1) : 0;
602 BU.GFindSamDomSODO(Fac1,LFSO,LFDO);
605 Standard_ProgramError::Raise("KPmakeface Stfac1 != OUT");
609 Standard_ProgramError::Raise("KPmakeface rankIN = 0");
612 TopTools_ListOfShape LFIN;
613 BU.GFindSameRank(LFSO,rankIN,LFIN);
614 BU.GFindSameRank(LFDO,rankIN,LFIN);
618 BU.GdumpSAMDOM(LFSO, (char *) "LESO : ");
619 BU.GdumpSAMDOM(LFDO, (char *) "LEDO : ");
620 BU.GdumpSAMDOM(LFIN, (char *) "LFIN : ");
624 TopOpeBRepBuild_WireToFace wtof;
626 TopOpeBRepTool_ShapeExplorer wex1;
627 for (wex1.Init(Fac1,TopAbs_WIRE); wex1.More(); wex1.Next()) {
628 const TopoDS_Shape& wicur = wex1.Current();
629 TopoDS_Wire wori = TopoDS::Wire(wicur);
630 if (R1) wori.Complement();
632 //myBuildTool.AddFaceWire(fac,wori);
635 TopOpeBRepTool_ShapeExplorer wex2;
636 for (TopTools_ListIteratorOfListOfShape it2(LF2);it2.More();it2.Next()) {
637 const TopoDS_Shape& Fac2 = it2.Value();
638 for (wex2.Init(Fac2,TopAbs_WIRE); wex2.More(); wex2.Next()) {
639 const TopoDS_Shape& wicur = wex2.Current();
640 TopoDS_Wire wori = TopoDS::Wire(wicur);
641 if (R2) wori.Complement();
643 //myBuildTool.AddFaceWire(fac,wori);
647 const TopoDS_Face& F1 = TopoDS::Face(Fac1);
648 wtof.MakeFaces(F1,Lres);
650 // Standard_Integer nlres = Lres.Extent(); // DEB
654 } // FUNKP_KPmakefaces
656 //=======================================================================
657 //function : KPmakeface
659 //=======================================================================
661 TopoDS_Shape TopOpeBRepBuild_Builder::KPmakeface(const TopoDS_Shape& Fac1,
662 const TopTools_ListOfShape& LF2,
663 const TopAbs_State Stfac1,
664 const TopAbs_State /*Stfac2*/,
665 const Standard_Boolean R1,
666 const Standard_Boolean R2)
668 // reconstruisons la face qui contient l'autre
670 TopoDS_Face fac; BB.MakeFace(fac);
672 Standard_Integer rankIN = 0;
673 TopTools_ListOfShape LFSO,LFDO;
676 Standard_Integer iF1;
677 Standard_Boolean tSPS = GtraceSPS(Fac1,iF1);
679 GdumpSHA(Fac1, (char *) "KPmakeFace ");
684 if (Stfac1 == TopAbs_OUT) {
685 TopoDS_Shape aLocalShape = Fac1.EmptyCopied();
686 fac = TopoDS::Face(aLocalShape);
687 // fac = TopoDS::Face(Fac1.EmptyCopied());
688 Standard_Integer rankF = GShapeRank(Fac1);
689 rankIN = (rankF) ? ( (rankF==1) ? 2 : 1) : 0;
690 GFindSamDomSODO(Fac1,LFSO,LFDO);
693 Standard_ProgramError::Raise("KPmakeface Stfac1 != OUT");
694 return myFaceReference; //Dummy
698 Standard_ProgramError::Raise("KPmakeface rankIN = 0");
699 return myFaceReference; //Dummy
702 TopTools_ListOfShape LFIN;
703 GFindSameRank(LFSO,rankIN,LFIN);
704 GFindSameRank(LFDO,rankIN,LFIN);
708 GdumpSAMDOM(LFSO, (char *) "LESO : ");
709 GdumpSAMDOM(LFDO, (char *) "LEDO : ");
710 GdumpSAMDOM(LFIN, (char *) "LFIN : ");
715 TopOpeBRepTool_ShapeExplorer wex1;
716 for (wex1.Init(Fac1,TopAbs_WIRE); wex1.More(); wex1.Next()) {
717 const TopoDS_Shape& wicur = wex1.Current();
718 TopoDS_Shape wori = wicur;
719 if (R1) wori.Complement();
720 myBuildTool.AddFaceWire(fac,wori);
723 TopOpeBRepTool_ShapeExplorer wex2;
724 for (TopTools_ListIteratorOfListOfShape it2(LF2);it2.More();it2.Next()) {
725 const TopoDS_Shape& Fac2 = it2.Value();
726 for (wex2.Init(Fac2,TopAbs_WIRE); wex2.More(); wex2.Next()) {
727 const TopoDS_Shape& wicur = wex2.Current();
728 TopoDS_Shape wori = wicur;
729 if (R2) wori.Complement();
730 myBuildTool.AddFaceWire(fac,wori);
735 } // TopOpeBRepBuild_Builder::KPmakeface
737 Standard_EXPORT Standard_Boolean FUNKP_KPiskolesh(const TopOpeBRepBuild_Builder& BU,
738 const TopOpeBRepDS_DataStructure& BDS,
739 const TopoDS_Shape& Sarg,
740 TopTools_ListOfShape& lShsd,
741 TopTools_ListOfShape& /*lfhsd*/)
742 // <lShsd> : the list of solids same domain with <Sarg>
743 // sol is <lShsd>'s first solid
744 // <lfhsd> : the list of <sol>'s same domain faces, none of the list carries geometric interf
746 if ( Sarg.IsNull() ) return Standard_False;
748 Standard_Integer nsol = BU.KPlhsd(Sarg,TopAbs_SOLID,lShsd);
749 if ( nsol == 0 ) return Standard_False;
750 const TopoDS_Shape& sol = lShsd.First();
752 TopTools_ListOfShape lfhg;
753 Standard_Integer nfhg = BU.KPlhg(sol,TopAbs_FACE,lfhg);
755 TopTools_ListIteratorOfListOfShape its(lfhg);
756 for(; its.More(); its.Next()) {
757 TopOpeBRepDS_ListIteratorOfListOfInterference iti(BDS.ShapeInterferences(its.Value()));
758 for (;iti.More();iti.Next()) {
759 Handle(TopOpeBRepDS_ShapeShapeInterference) ssi;
760 ssi = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(iti.Value());
762 return Standard_False;
767 return Standard_True;
768 } // FUNKP_KPiskolesh
770 //=======================================================================
771 //function : KPiskolesh
774 // S est il un shape traite par le cas particulier du collage ?
775 // si oui : retourne un solide et une liste de faces de collage
776 //=======================================================================
778 Standard_Boolean TopOpeBRepBuild_Builder::KPiskolesh(const TopoDS_Shape& Sarg,
779 TopTools_ListOfShape& lShsd,
780 TopTools_ListOfShape& lfhsd) const
783 Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB();
785 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
786 Standard_Boolean iskolesh = FUNKP_KPiskolesh(*this,BDS,Sarg,lShsd,lfhsd);
787 if (!iskolesh) return Standard_False;
790 Standard_Integer nfhsd =
792 KPlhsd(Sarg,TopAbs_FACE,lfhsd);
793 TopTools_ListIteratorOfListOfShape it(lfhsd);
794 for (; it.More(); it.Next() ) {
795 const TopoDS_Shape& fac = it.Value();
796 Standard_Boolean isplan = FUN_tool_plane(fac); //pro7993 BUG
797 if ( !isplan ) return Standard_False;
799 Standard_Integer nw = KPls(fac,TopAbs_WIRE);
800 if (nw > 1) return Standard_False;
802 TopTools_ListOfShape lehg;
803 Standard_Integer nehg = KPlhg(fac,TopAbs_EDGE,lehg);
804 if ( nehg != 0 ) return Standard_False;
807 Standard_Integer isol = myDataStructure->Shape(Sarg);
808 Standard_Integer ifac = myDataStructure->Shape(fac);
809 if(TKPB){cout<<"isol "<<isol<<endl;}
810 if(TKPB){cout<<"nfhsd "<<nfhsd<<endl;}
811 if(TKPB){cout<<"ifac "<<ifac<<endl;}
812 if(TKPB){cout<<"isplan "<<isplan<<endl;}
813 if(TKPB){cout<<"nehg "<<nehg<<endl;}
814 if(TKPB){cout<<endl;}
818 return Standard_True;
819 } // TopOpeBRepBuild_Builder::KPiskolesh