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 under
9 // the terms of the GNU Lesser General Public License 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>
34 #include <TopOpeBRepDS_ShapeShapeInterference.hxx>
37 extern Standard_Boolean TopOpeBRepBuild_GettraceKPB();
41 Standard_EXPORT Standard_Boolean FUNKP_KPiskolesh(const TopOpeBRepBuild_Builder& BU,const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& Sarg,TopTools_ListOfShape& lShsd,TopTools_ListOfShape& lfhsd);
42 Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU, const TopoDS_Shape& Fac1, const TopTools_ListOfShape& LF2,
43 const TopAbs_State Stfac1, const TopAbs_State Stfac2,
44 const Standard_Boolean R1, const Standard_Boolean R2,TopTools_ListOfShape& Lres);
47 //=======================================================================
48 //function : MergeKPartiskole
50 //=======================================================================
52 void TopOpeBRepBuild_Builder::MergeKPartiskole()
55 Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB();
56 if (TKPB) KPreturn(myIsKPart);
60 Standard_Integer ibid;
62 if ( myIsKPart != 1 ) return;
64 GMapShapes(myShape1,myShape2);
65 // NYI : on doit pouvoir faire l'economie du mapping GMapShapes(...)
66 // NYI en allant chercher l'indice 1,2 retourne par GShapeRank(S)
67 // NYI dans la DS. l'index est defini pour tous les shapes HasSameDomain
69 TopTools_ListOfShape& lmergesha1 = ChangeMerged(myShape1,myState1);
70 ChangeMerged(myShape2,myState2);
72 TopTools_ListOfShape lShsd1,lShsd2; // liste de solides HasSameDomain
73 TopTools_ListOfShape lfhsd1,lfhsd2; // liste de faces HasSameDomain
74 KPiskolesh(myShape1,lShsd1,lfhsd1);
75 KPiskolesh(myShape2,lShsd2,lfhsd2);
76 // traitement de tous les solides NYI
77 TopoDS_Shape sol1 = lShsd1.First();
78 TopoDS_Shape sol2 = lShsd2.First();
80 ChangeMerged(sol1,myState1);
81 ChangeMerged(sol2,myState2);
83 TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm1;
84 itm1.Initialize(myKPMAPf1f2);
85 if ( ! itm1.More() ) return;
90 for (; itm1.More();itm1.Next()) {
91 const TopoDS_Shape& f = itm1.Key();
92 Standard_Integer fi = myDataStructure->Shape(f);
93 cout<<"face "<<fi<<" : ";
94 const TopTools_ListOfShape& l = itm1.Value();
95 TopTools_ListIteratorOfListOfShape it(l);
96 for(; it.More(); it.Next()) {
97 const TopoDS_Shape& ff = it.Value();
98 Standard_Integer ffi = myDataStructure->Shape(ff);
103 itm1.Initialize(myKPMAPf1f2);
107 TopTools_ListOfShape LFIN;
108 TopTools_ListOfShape* plfIN = NULL;
109 const TopoDS_Shape* pfOU = NULL;
110 const TopoDS_Shape* pfIN = NULL;
112 for (; itm1.More();itm1.Next()) {
113 // const TopoDS_Shape& f = itm1.Key();
114 // myDataStructure->Shape(f); //DEB
115 const TopTools_ListOfShape& los = itm1.Value();
116 Standard_Boolean emp = los.IsEmpty();
118 if (plfIN == NULL) plfIN = (TopTools_ListOfShape*)&itm1.Value();
119 if (pfOU == NULL) pfOU = &itm1.Key();
120 if (pfIN == NULL) pfIN = &plfIN->First();
121 for (TopTools_ListIteratorOfListOfShape it(los);it.More();it.Next()) LFIN.Append(it.Value());
125 if ( plfIN==NULL) return;
126 if ( pfOU==NULL) return;
127 if ( pfIN==NULL) return;
130 Standard_Integer ifOU; Standard_Boolean tSPS = GtraceSPS(*pfOU,ifOU);
132 // Standard_Integer iOU = myDataStructure->Shape(*pfOU);
133 // Standard_Integer iIN = myDataStructure->Shape(*pfIN);
134 GdumpSHA(*pfOU, (char *) "MergeKPartiskole pfOU ");cout<<endl;
135 GdumpSAMDOM(LFIN, (char *) "LFIN : ");
140 Standard_Integer rankpfOU = GShapeRank(*pfOU);
141 Standard_Integer rankpfIN = GShapeRank(*pfIN);
142 if ( rankpfOU != 1 && rankpfOU != 2 ) return;
143 if ( rankpfIN != 1 && rankpfIN != 2 ) return;
145 // solfOU = solide dont la face *pfOU est OUT / faces LFIN
146 // solfIN = solide dont les faces *plfIN sont IN / face *pfOU
148 if (rankpfOU == 1) solfOU = sol1;
151 if (rankpfIN == 1) solfIN = sol1;
153 TopAbs_State stsolfOU = KPclasSS(solfOU,*pfOU, solfIN);
154 TopAbs_State stsolfIN = KPclasSS(solfIN,LFIN,solfOU);
155 TopAbs_State stfOU = TopAbs_OUT;
156 TopAbs_State stfIN = TopAbs_IN;
158 TopAbs_State stsol1=TopAbs_UNKNOWN,stsol2=TopAbs_UNKNOWN;
159 TopAbs_State stfac1=TopAbs_UNKNOWN,stfac2=TopAbs_UNKNOWN;
160 TopoDS_Shape fac1,fac2;
161 if (rankpfOU == 1 ) {
162 stsol1 = stsolfOU; stfac1 = stfOU; fac1 = *pfOU;
163 stsol2 = stsolfIN; stfac2 = stfIN; fac2 = *pfIN;
165 else if (rankpfOU == 2 ) {
166 stsol1 = stsolfIN; stfac1 = stfIN; fac1 = *pfIN;
167 stsol2 = stsolfOU; stfac2 = stfOU; fac2 = *pfOU;
170 Standard_Integer ires,icla1,icla2;
171 KPiskoleanalyse(stfac1,stfac2,stsol1,stsol2,ires,icla1,icla2);
172 if (ires == RESUNDEF) return;
173 if (icla1 == SHEUNDEF || icla2 == SHEUNDEF) return;
175 TopoDS_Shape she1; // she1 = shell accedant fac1
176 TopTools_IndexedDataMapOfShapeListOfShape Mfacshe1;
177 TopExp::MapShapesAndAncestors(sol1,TopAbs_FACE,TopAbs_SHELL,Mfacshe1);
178 const TopTools_ListOfShape& lshe1 = Mfacshe1.FindFromKey(fac1);
179 TopTools_ListIteratorOfListOfShape itlshe1(lshe1);
180 she1 = itlshe1.Value();
182 TopoDS_Shape she2; // she2 = shell accedant fac2
183 TopTools_IndexedDataMapOfShapeListOfShape Mfacshe2;
184 TopExp::MapShapesAndAncestors(sol2,TopAbs_FACE,TopAbs_SHELL,Mfacshe2);
185 const TopTools_ListOfShape& lshe2 = Mfacshe2.FindFromKey(fac2);
186 TopTools_ListIteratorOfListOfShape itlshe2(lshe2);
187 she2 = itlshe2.Value();
189 ChangeMerged(she1,myState1);
190 ChangeMerged(she2,myState2);
193 if (TKPB) { cout<<"stsol1 ";TopAbs::Print(stsol1,cout); cout<<" "; }
194 if (TKPB) { cout<<"stsol2 ";TopAbs::Print(stsol2,cout); cout<<endl; }
200 if ( ires == RESNULL ) {
204 else if (ires == RESSHAPE1) {
205 myBuildTool.MakeShell(newshe);
206 newshe = TopoDS::Shell(she1);
209 else if (ires == RESSHAPE2) {
210 myBuildTool.MakeShell(newshe);
211 newshe = TopoDS::Shell(she2);
214 else if ( ires == RESFACE1 ) {
216 // resultat = face de rang 1 et face de rang 1 = face OUT
217 lmergesha1.Append(*pfOU);
218 ChangeMerged(fac2,myState2).Append(*pfOU);
220 else if (rankpfOU == 2) {
221 // resultat = face de rang 1 et face de rang 1 = faces IN
222 GCopyList(*plfIN,lmergesha1);
223 GCopyList(*plfIN,ChangeMerged(fac2,myState2));
228 else if ( ires == RESFACE2 ) {
230 // resultat = face de rang 2 et face de rang 2 = face OUT
231 lmergesha1.Append(*pfOU);
232 ChangeMerged(fac1,myState1).Append(*pfOU);
234 else if (rankpfOU == 1) {
235 // resultat = face de rang 2 et face de rang 2 = faces IN
236 GCopyList(*plfIN,lmergesha1);
237 GCopyList(*plfIN,ChangeMerged(fac1,myState1));
242 else if (ires == RESNEWSHE) {
244 itm1.Initialize(myKPMAPf1f2);
245 if (! itm1.More() ) return;
247 TopTools_DataMapOfShapeShape addedfaces;
248 for (; itm1.More();itm1.Next()) {
250 const TopoDS_Shape& f1 = itm1.Key();
251 const TopTools_ListOfShape& lf2 = itm1.Value();
252 if (lf2.IsEmpty()) continue;
254 TopTools_ListIteratorOfListOfShape it2;
256 const TopoDS_Shape& f2 = it2.Value();
259 Standard_Integer ii1 = myDataStructure->Shape(f1);
260 Standard_Integer ii2 = myDataStructure->Shape(f2);
262 Standard_Integer rankf1 = GShapeRank(f1);
263 Standard_Integer rankf2 = GShapeRank(f2);
264 if (rankf1 == 0) continue;
265 if (rankf2 == 0) continue;
267 TopAbs_State stf1,stf2; KPclassFF(f1,f2,stf1,stf2);
268 if ( rankf1 == 1 ) KPiskoleanalyse(stf1,stf2,stsol1,stsol2,ires,ibid,ibid);
269 if ( rankf1 == 2 ) KPiskoleanalyse(stf2,stf1,stsol2,stsol1,ires,ibid,ibid);
270 if (ires == RESUNDEF) continue;
272 Standard_Boolean r1 = (stsol1 == TopAbs_IN);
273 Standard_Boolean r2 = (stsol2 == TopAbs_IN);
275 if ( rankf1 == 1 ) fac = KPmakeface(f1,lf2,stf1,stf2,r1,r2);
276 if ( rankf1 == 2 ) fac = KPmakeface(f1,lf2,stf1,stf2,r2,r1);
277 if ( fac.IsNull() ) continue;
278 if ( ! fac.IsNull() ) addedfaces.Bind(fac,fac);
280 TopAbs_State statemergef1 = (rankf1 == 1) ? myState1 : myState2;
281 TopAbs_State statemergef2 = (rankf2 == 2) ? myState2 : myState1;
282 ChangeMerged(f1,statemergef1).Append(fac);
284 for (;it2.More();it2.Next())
285 ChangeMerged(it2.Value(),statemergef2).Append(fac);
287 // les faces de she1 sauf les tangentes et celles deja ajoutees
288 TopOpeBRepTool_ShapeExplorer fex1;
289 for (fex1.Init(she1,TopAbs_FACE); fex1.More(); fex1.Next()) {
290 const TopoDS_Shape& facur = fex1.Current();
292 Standard_Boolean isfsd = myKPMAPf1f2.IsBound(facur);
293 Standard_Boolean isadded = addedfaces.IsBound(facur);
294 Standard_Boolean toadd = (!isfsd) && (!isadded) ;
297 TopoDS_Shape fori = facur;
298 if (stsol1 == TopAbs_IN) fori.Complement();
299 addedfaces.Bind(fori,fori);
303 // les faces de she2 sauf les tangentes et celles deja ajoutees
304 TopOpeBRepTool_ShapeExplorer fex2;
305 for (fex2.Init(she2,TopAbs_FACE); fex2.More(); fex2.Next()) {
306 const TopoDS_Shape& facur = fex2.Current();
308 Standard_Boolean isfsd = myKPMAPf1f2.IsBound(facur);
309 Standard_Boolean isadded = addedfaces.IsBound(facur);
310 Standard_Boolean toadd = (!isfsd) && (!isadded) ;
313 TopoDS_Shape fori = facur;
314 if (stsol2 == TopAbs_IN) fori.Complement();
315 addedfaces.Bind(fori,fori);
318 } // === fin iteration fac1,fac2
320 TopTools_DataMapIteratorOfDataMapOfShapeShape itadd(addedfaces);
321 Standard_Boolean yauadd = itadd.More();
323 myBuildTool.MakeShell(newshe);
324 myBuildTool.Closed(newshe,Standard_True); // NYI : check exact du caractere closed du shell
326 for (; itadd.More(); itadd.Next() ) {
327 const TopoDS_Shape& ftoadd = itadd.Key();
328 myBuildTool.AddShellFace(newshe,ftoadd);
331 } // === fin RESNEWSHE
335 cout<<"MergeKPartiskole : ires = "<<ires<<endl;
340 if ( !newshe.IsNull() ) {
341 myBuildTool.MakeSolid(newsol);
342 myBuildTool.AddSolidShell(newsol,newshe);
345 if ( icla1 == SHECLASAUTR || icla1 == SHEGARDAUTR ) {
346 // n.b. : ne pas prendre she1 accedant f1
347 TopTools_ListOfShape loshe1;
348 TopOpeBRepTool_ShapeExplorer ex1;
349 for (ex1.Init(sol1,TopAbs_SHELL); ex1.More(); ex1.Next()) {
350 const TopoDS_Shape& shecur = ex1.Current();
351 if (she1.IsEqual(shecur)) continue;
352 if (icla1 == SHECLASAUTR) {
353 TopAbs_State state1 = KPclasSS(shecur,fac1,sol2);
354 if (state1 == myState1) loshe1.Append(shecur);
356 else if (icla1 == SHEGARDAUTR) {
357 loshe1.Append(shecur);
361 // Standard_Integer nshe1 = loshe1.Extent();
363 TopTools_ListIteratorOfListOfShape itloshe1;
364 for( itloshe1.Initialize(loshe1); itloshe1.More(); itloshe1.Next() ) {
365 const TopoDS_Shape& shecur = itloshe1.Value();
366 myBuildTool.AddSolidShell(newsol,shecur);
370 if ( icla2 == SHECLASAUTR || icla2 == SHEGARDAUTR ) {
371 // n.b. : ne pas prendre she2 accedant f2
372 TopTools_ListOfShape loshe2;
373 TopOpeBRepTool_ShapeExplorer ex2;
374 for (ex2.Init(sol2,TopAbs_SHELL); ex2.More(); ex2.Next()) {
375 const TopoDS_Shape& shecur = ex2.Current();
376 if (she2.IsEqual(shecur)) continue;
377 if (icla2 == SHECLASAUTR) {
378 TopAbs_State state2 = KPclasSS(shecur,fac2,sol1);
379 if (state2 == myState2) loshe2.Append(shecur);
381 else if (icla2 == SHEGARDAUTR) {
382 loshe2.Append(shecur);
386 // Standard_Integer nshe2 = loshe2.Extent();
388 TopTools_ListIteratorOfListOfShape itloshe2;
389 for( itloshe2.Initialize(loshe2); itloshe2.More(); itloshe2.Next() ) {
390 const TopoDS_Shape& shecur = itloshe2.Value();
391 myBuildTool.AddSolidShell(newsol,shecur);
396 if ( !newsol.IsNull() ) {
397 lmergesha1.Append(newsol);
400 } // MergeKPartiskole
403 //=======================================================================
404 //function : KPiskole
405 //purpose : detection faces collees
406 //=======================================================================
408 Standard_Integer TopOpeBRepBuild_Builder::KPiskole()
411 TopTools_ListOfShape lShsd1,lShsd2; // liste de solides HasSameDomain
412 TopTools_ListOfShape lfhsd1,lfhsd2; // liste de faces HasSameDomain
414 Standard_Boolean iskp1 = KPiskolesh(myShape1,lShsd1,lfhsd1);
415 if ( !iskp1 ) return 0;
416 Standard_Integer nfhsd1 = lfhsd1.Extent();
417 if ( nfhsd1 == 0 ) return 0;
419 Standard_Boolean iskp2 = KPiskolesh(myShape2,lShsd2,lfhsd2);
420 if ( !iskp2 ) return 0;
421 Standard_Integer nfhsd2 = lfhsd2.Extent();
422 if ( nfhsd2 == 0 ) return 0;
424 // Si l'un des objets est constitue de plusieur solides on passe
425 // dans le cas general , sinon on obtient
426 //** Exception ** Standard_OutOfRange: TCollection_IndexedDataMap::FindFromKey at
427 // TopOpeBRepBuild_Builder::MergeKPartiskole(this = 0xf7988),
428 // line 397 in "/adv_21/MDL/k1deb/ref/prod/TopOpeBRepBuild/src/TopOpeBRepBuild_KPart.cxx"
430 Standard_Integer nshsd1 = lShsd1.Extent();
431 Standard_Integer nshsd2 = lShsd2.Extent();
432 if (nshsd1>1 || nshsd2>1) return 0;
434 TopTools_ListOfShape lf1,lf2;
435 TopTools_ListOfShape les; //section
437 for (TopTools_ListIteratorOfListOfShape itlf1(lfhsd1);
438 itlf1.More();itlf1.Next()) {
440 const TopoDS_Shape& f1 = itlf1.Value();
442 // Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1); // DEB
444 lf1.Clear(); lf1.Append(f1);
445 lf2.Clear(); KPSameDomain(lf1,lf2);
447 // Standard_Integer n1 = lf1.Extent();
448 // Standard_Integer n2 = lf2.Extent();
452 Standard_Integer iF1; Standard_Boolean tSPS1 = GtraceSPS(f1,iF1);
454 GdumpSHA(f1, (char *) "KPiskole ");cout<<endl;
455 GdumpSAMDOM(lf2, (char *) "lf2 : ");
459 for (TopTools_ListIteratorOfListOfShape itlf2(lf2);
460 itlf2.More(); itlf2.Next() ) {
462 const TopoDS_Shape& f2 = itlf2.Value();
464 // Standard_Boolean isb2 = myKPMAPf1f2.IsBound(f2); // DEB
466 TopAbs_State state1,state2;
467 Standard_Boolean classok = KPiskoleFF(f1,f2,state1,state2);
468 if ( ! classok ) return 0;
470 // on va reconstuire la face OUT
471 if ( state1 == TopAbs_OUT && state2 == TopAbs_IN) {
472 Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1);
473 if ( ! isb1 ) { TopTools_ListOfShape los; myKPMAPf1f2.Bind(f1,los); }
474 TopTools_ListOfShape& los = myKPMAPf1f2.ChangeFind(f1);
477 Standard_Boolean isb2 = myKPMAPf1f2.IsBound(f2);
478 if ( ! isb2 ) { TopTools_ListOfShape los1; myKPMAPf1f2.Bind(f2,los1); }
480 else if ( state2 == TopAbs_OUT && state1 == TopAbs_IN) {
481 Standard_Boolean isb2 = myKPMAPf1f2.IsBound(f2);
482 if ( ! isb2 ) { TopTools_ListOfShape los; myKPMAPf1f2.Bind(f2,los); }
483 TopTools_ListOfShape& los = myKPMAPf1f2.ChangeFind(f2);
486 Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1);
487 if ( ! isb1 ) { TopTools_ListOfShape los1; myKPMAPf1f2.Bind(f1,los1); }
490 // les aretes de la face IN sont des aretes de section
492 if (state1 == TopAbs_IN) fw = f1;
493 else if (state2 == TopAbs_IN) fw = f2;
494 if (fw.IsNull()) continue;
496 TopOpeBRepTool_ShapeExplorer ex(fw,TopAbs_EDGE);
497 for (;ex.More();ex.Next()) les.Append(ex.Current());
501 // aretes de section iskole
502 TopOpeBRepDS_DataStructure& DS = myDataStructure->ChangeDS();
503 DS.InitSectionEdges(); TopTools_ListIteratorOfListOfShape it(les);
504 for (;it.More();it.Next()) DS.AddSectionEdge(TopoDS::Edge(it.Value()));
507 } // TopOpeBRepBuild_Builder::KPiskole
509 //=======================================================================
510 //function : KPiskoleanalyse
512 //=======================================================================
514 void TopOpeBRepBuild_Builder::KPiskoleanalyse(const TopAbs_State Stfac1, const TopAbs_State Stfac2,
515 const TopAbs_State Stsol1, const TopAbs_State Stsol2,
516 Standard_Integer& ires,Standard_Integer& icla1,Standard_Integer& icla2) const
518 ires = RESUNDEF; icla1 = icla2 = SHEUNDEF;
521 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
522 ires = RESNEWSHE; icla1 = SHEGARDAUTR; icla2 = SHEGARDAUTR;
524 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
525 ires = RESSHAPE1; icla1 = SHECLASAUTR; icla2 = SHEAUCU;
527 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
528 ires = RESSHAPE2; icla1 = SHEAUCU; icla2 = SHECLASAUTR;
532 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
533 ires = RESSHAPE1; icla1 = SHEGARDAUTR; icla2 = SHEAUCU;
535 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
536 ires = RESNEWSHE; icla1 = SHECLASAUTR; icla2 = SHEAUCU;
538 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
539 ires = RESNULL; icla1 = icla2 = SHEAUCU;
543 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
544 ires = RESSHAPE2; icla1 = SHEAUCU; icla2 = SHEGARDAUTR;
546 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
547 ires = RESNULL; icla1 = icla2 = SHEAUCU;
549 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
550 ires = RESNEWSHE; icla1 = SHEAUCU; icla2 = SHECLASAUTR;
554 if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) {
555 if (Stfac1 == TopAbs_IN) {
556 ires = RESFACE1; icla1 = icla2 = SHEAUCU;
558 if (Stfac2 == TopAbs_IN) {
559 ires = RESFACE2; icla1 = icla2 = SHEAUCU;
562 else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) {
563 ires = RESSHAPE2; icla1 = SHECLASAUTR; icla2 = SHEGARDAUTR;
565 else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) {
566 ires = RESSHAPE1; icla1 = SHEGARDAUTR; icla2 = SHECLASAUTR;
571 Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB();
572 if (TKPB) cout<<"ires = "<<ires<<" icla1 "<<icla1<<" icla2 "<<icla2<<endl;
574 } // TopOpeBRepBuild_Builder::KPiskoleanalyse
576 Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU,
577 const TopoDS_Shape& Fac1,
578 const TopTools_ListOfShape& LF2,
579 const TopAbs_State Stfac1,
580 const TopAbs_State /*Stfac2*/,
581 const Standard_Boolean R1,
582 const Standard_Boolean R2,
583 TopTools_ListOfShape& Lres)
585 // reconstruisons la face qui contient les autres
587 TopoDS_Face fac; BB.MakeFace(fac);
589 Standard_Integer rankIN = 0;
590 TopTools_ListOfShape LFSO,LFDO;
593 Standard_Integer iF1; Standard_Boolean tSPS = BU.GtraceSPS(Fac1,iF1);
594 if(tSPS) { BU.GdumpSHA(Fac1, (char *) "KPmakeFace ");cout<<endl; }
597 if (Stfac1 == TopAbs_OUT) {
598 TopoDS_Shape aLocalShape = Fac1.EmptyCopied();
599 fac = TopoDS::Face(aLocalShape);
600 // fac = TopoDS::Face(Fac1.EmptyCopied());
601 Standard_Integer rankF = BU.GShapeRank(Fac1);
602 rankIN = (rankF) ? ( (rankF==1) ? 2 : 1) : 0;
603 BU.GFindSamDomSODO(Fac1,LFSO,LFDO);
606 Standard_ProgramError::Raise("KPmakeface Stfac1 != OUT");
610 Standard_ProgramError::Raise("KPmakeface rankIN = 0");
613 TopTools_ListOfShape LFIN;
614 BU.GFindSameRank(LFSO,rankIN,LFIN);
615 BU.GFindSameRank(LFDO,rankIN,LFIN);
619 BU.GdumpSAMDOM(LFSO, (char *) "LESO : ");
620 BU.GdumpSAMDOM(LFDO, (char *) "LEDO : ");
621 BU.GdumpSAMDOM(LFIN, (char *) "LFIN : ");
625 TopOpeBRepBuild_WireToFace wtof;
627 TopOpeBRepTool_ShapeExplorer wex1;
628 for (wex1.Init(Fac1,TopAbs_WIRE); wex1.More(); wex1.Next()) {
629 const TopoDS_Shape& wicur = wex1.Current();
630 TopoDS_Wire wori = TopoDS::Wire(wicur);
631 if (R1) wori.Complement();
633 //myBuildTool.AddFaceWire(fac,wori);
636 TopOpeBRepTool_ShapeExplorer wex2;
637 for (TopTools_ListIteratorOfListOfShape it2(LF2);it2.More();it2.Next()) {
638 const TopoDS_Shape& Fac2 = it2.Value();
639 for (wex2.Init(Fac2,TopAbs_WIRE); wex2.More(); wex2.Next()) {
640 const TopoDS_Shape& wicur = wex2.Current();
641 TopoDS_Wire wori = TopoDS::Wire(wicur);
642 if (R2) wori.Complement();
644 //myBuildTool.AddFaceWire(fac,wori);
648 const TopoDS_Face& F1 = TopoDS::Face(Fac1);
649 wtof.MakeFaces(F1,Lres);
651 // Standard_Integer nlres = Lres.Extent(); // DEB
655 } // FUNKP_KPmakefaces
657 //=======================================================================
658 //function : KPmakeface
660 //=======================================================================
662 TopoDS_Shape TopOpeBRepBuild_Builder::KPmakeface(const TopoDS_Shape& Fac1,
663 const TopTools_ListOfShape& LF2,
664 const TopAbs_State Stfac1,
665 const TopAbs_State /*Stfac2*/,
666 const Standard_Boolean R1,
667 const Standard_Boolean R2)
669 // reconstruisons la face qui contient l'autre
671 TopoDS_Face fac; BB.MakeFace(fac);
673 Standard_Integer rankIN = 0;
674 TopTools_ListOfShape LFSO,LFDO;
677 Standard_Integer iF1;
678 Standard_Boolean tSPS = GtraceSPS(Fac1,iF1);
680 GdumpSHA(Fac1, (char *) "KPmakeFace ");
685 if (Stfac1 == TopAbs_OUT) {
686 TopoDS_Shape aLocalShape = Fac1.EmptyCopied();
687 fac = TopoDS::Face(aLocalShape);
688 // fac = TopoDS::Face(Fac1.EmptyCopied());
689 Standard_Integer rankF = GShapeRank(Fac1);
690 rankIN = (rankF) ? ( (rankF==1) ? 2 : 1) : 0;
691 GFindSamDomSODO(Fac1,LFSO,LFDO);
694 Standard_ProgramError::Raise("KPmakeface Stfac1 != OUT");
695 return myFaceReference; //Dummy
699 Standard_ProgramError::Raise("KPmakeface rankIN = 0");
700 return myFaceReference; //Dummy
703 TopTools_ListOfShape LFIN;
704 GFindSameRank(LFSO,rankIN,LFIN);
705 GFindSameRank(LFDO,rankIN,LFIN);
709 GdumpSAMDOM(LFSO, (char *) "LESO : ");
710 GdumpSAMDOM(LFDO, (char *) "LEDO : ");
711 GdumpSAMDOM(LFIN, (char *) "LFIN : ");
716 TopOpeBRepTool_ShapeExplorer wex1;
717 for (wex1.Init(Fac1,TopAbs_WIRE); wex1.More(); wex1.Next()) {
718 const TopoDS_Shape& wicur = wex1.Current();
719 TopoDS_Shape wori = wicur;
720 if (R1) wori.Complement();
721 myBuildTool.AddFaceWire(fac,wori);
724 TopOpeBRepTool_ShapeExplorer wex2;
725 for (TopTools_ListIteratorOfListOfShape it2(LF2);it2.More();it2.Next()) {
726 const TopoDS_Shape& Fac2 = it2.Value();
727 for (wex2.Init(Fac2,TopAbs_WIRE); wex2.More(); wex2.Next()) {
728 const TopoDS_Shape& wicur = wex2.Current();
729 TopoDS_Shape wori = wicur;
730 if (R2) wori.Complement();
731 myBuildTool.AddFaceWire(fac,wori);
736 } // TopOpeBRepBuild_Builder::KPmakeface
738 Standard_EXPORT Standard_Boolean FUNKP_KPiskolesh(const TopOpeBRepBuild_Builder& BU,
739 const TopOpeBRepDS_DataStructure& BDS,
740 const TopoDS_Shape& Sarg,
741 TopTools_ListOfShape& lShsd,
742 TopTools_ListOfShape& /*lfhsd*/)
743 // <lShsd> : the list of solids same domain with <Sarg>
744 // sol is <lShsd>'s first solid
745 // <lfhsd> : the list of <sol>'s same domain faces, none of the list carries geometric interf
747 if ( Sarg.IsNull() ) return Standard_False;
749 Standard_Integer nsol = BU.KPlhsd(Sarg,TopAbs_SOLID,lShsd);
750 if ( nsol == 0 ) return Standard_False;
751 const TopoDS_Shape& sol = lShsd.First();
753 TopTools_ListOfShape lfhg;
754 Standard_Integer nfhg = BU.KPlhg(sol,TopAbs_FACE,lfhg);
756 TopTools_ListIteratorOfListOfShape its(lfhg);
757 for(; its.More(); its.Next()) {
758 TopOpeBRepDS_ListIteratorOfListOfInterference iti(BDS.ShapeInterferences(its.Value()));
759 for (;iti.More();iti.Next()) {
760 Handle(TopOpeBRepDS_ShapeShapeInterference) ssi;
761 ssi = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(iti.Value());
763 return Standard_False;
768 return Standard_True;
769 } // FUNKP_KPiskolesh
771 //=======================================================================
772 //function : KPiskolesh
775 // S est il un shape traite par le cas particulier du collage ?
776 // si oui : retourne un solide et une liste de faces de collage
777 //=======================================================================
779 Standard_Boolean TopOpeBRepBuild_Builder::KPiskolesh(const TopoDS_Shape& Sarg,
780 TopTools_ListOfShape& lShsd,
781 TopTools_ListOfShape& lfhsd) const
784 Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB();
786 const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
787 Standard_Boolean iskolesh = FUNKP_KPiskolesh(*this,BDS,Sarg,lShsd,lfhsd);
788 if (!iskolesh) return Standard_False;
791 Standard_Integer nfhsd =
793 KPlhsd(Sarg,TopAbs_FACE,lfhsd);
794 TopTools_ListIteratorOfListOfShape it(lfhsd);
795 for (; it.More(); it.Next() ) {
796 const TopoDS_Shape& fac = it.Value();
797 Standard_Boolean isplan = FUN_tool_plane(fac); //pro7993 BUG
798 if ( !isplan ) return Standard_False;
800 Standard_Integer nw = KPls(fac,TopAbs_WIRE);
801 if (nw > 1) return Standard_False;
803 TopTools_ListOfShape lehg;
804 Standard_Integer nehg = KPlhg(fac,TopAbs_EDGE,lehg);
805 if ( nehg != 0 ) return Standard_False;
808 Standard_Integer isol = myDataStructure->Shape(Sarg);
809 Standard_Integer ifac = myDataStructure->Shape(fac);
810 if(TKPB){cout<<"isol "<<isol<<endl;}
811 if(TKPB){cout<<"nfhsd "<<nfhsd<<endl;}
812 if(TKPB){cout<<"ifac "<<ifac<<endl;}
813 if(TKPB){cout<<"isplan "<<isplan<<endl;}
814 if(TKPB){cout<<"nehg "<<nehg<<endl;}
815 if(TKPB){cout<<endl;}
819 return Standard_True;
820 } // TopOpeBRepBuild_Builder::KPiskolesh