// Created on: 1994-08-30 // Created by: Jean Yves LEBEY // Copyright (c) 1994-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and / or modify it // under the terms of the GNU Lesser General Public version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB extern Standard_Boolean TopOpeBRepBuild_GettraceKPB(); void debiskole() {} #endif Standard_EXPORT Standard_Boolean FUNKP_KPiskolesh(const TopOpeBRepBuild_Builder& BU,const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Shape& Sarg,TopTools_ListOfShape& lShsd,TopTools_ListOfShape& lfhsd); Standard_EXPORT void FUNKP_KPmakefaces(const TopOpeBRepBuild_Builder& BU, const TopoDS_Shape& Fac1, const TopTools_ListOfShape& LF2, const TopAbs_State Stfac1, const TopAbs_State Stfac2, const Standard_Boolean R1, const Standard_Boolean R2,TopTools_ListOfShape& Lres); //======================================================================= //function : MergeKPartiskole //purpose : //======================================================================= void TopOpeBRepBuild_Builder::MergeKPartiskole() { #ifdef DEB Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB(); if (TKPB) KPreturn(myIsKPart); debiskole(); #endif Standard_Integer ibid; if ( myIsKPart != 1 ) return; GMapShapes(myShape1,myShape2); // NYI : on doit pouvoir faire l'economie du mapping GMapShapes(...) // NYI en allant chercher l'indice 1,2 retourne par GShapeRank(S) // NYI dans la DS. l'index est defini pour tous les shapes HasSameDomain TopTools_ListOfShape& lmergesha1 = ChangeMerged(myShape1,myState1); ChangeMerged(myShape2,myState2); TopTools_ListOfShape lShsd1,lShsd2; // liste de solides HasSameDomain TopTools_ListOfShape lfhsd1,lfhsd2; // liste de faces HasSameDomain KPiskolesh(myShape1,lShsd1,lfhsd1); KPiskolesh(myShape2,lShsd2,lfhsd2); // traitement de tous les solides NYI TopoDS_Shape sol1 = lShsd1.First(); TopoDS_Shape sol2 = lShsd2.First(); ChangeMerged(sol1,myState1); ChangeMerged(sol2,myState2); TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm1; itm1.Initialize(myKPMAPf1f2); if ( ! itm1.More() ) return; #ifdef DEB if (TKPB) { cout<<""<Shape(f); cout<<"face "<Shape(ff); cout<Shape(f); //DEB const TopTools_ListOfShape& los = itm1.Value(); Standard_Boolean emp = los.IsEmpty(); if (!emp) { if (plfIN == NULL) plfIN = (TopTools_ListOfShape*)&itm1.Value(); if (pfOU == NULL) pfOU = &itm1.Key(); if (pfIN == NULL) pfIN = &plfIN->First(); for (TopTools_ListIteratorOfListOfShape it(los);it.More();it.Next()) LFIN.Append(it.Value()); } } if ( plfIN==NULL) return; if ( pfOU==NULL) return; if ( pfIN==NULL) return; #ifdef DEB Standard_Integer ifOU; Standard_Boolean tSPS = GtraceSPS(*pfOU,ifOU); if(tSPS || TKPB) { // Standard_Integer iOU = myDataStructure->Shape(*pfOU); // Standard_Integer iIN = myDataStructure->Shape(*pfIN); GdumpSHA(*pfOU, (char *) "MergeKPartiskole pfOU ");cout<Shape(f1); Standard_Integer ii2 = myDataStructure->Shape(f2); #endif*/ Standard_Integer rankf1 = GShapeRank(f1); Standard_Integer rankf2 = GShapeRank(f2); if (rankf1 == 0) continue; if (rankf2 == 0) continue; TopAbs_State stf1,stf2; KPclassFF(f1,f2,stf1,stf2); if ( rankf1 == 1 ) KPiskoleanalyse(stf1,stf2,stsol1,stsol2,ires,ibid,ibid); if ( rankf1 == 2 ) KPiskoleanalyse(stf2,stf1,stsol2,stsol1,ires,ibid,ibid); if (ires == RESUNDEF) continue; Standard_Boolean r1 = (stsol1 == TopAbs_IN); Standard_Boolean r2 = (stsol2 == TopAbs_IN); TopoDS_Shape fac; if ( rankf1 == 1 ) fac = KPmakeface(f1,lf2,stf1,stf2,r1,r2); if ( rankf1 == 2 ) fac = KPmakeface(f1,lf2,stf1,stf2,r2,r1); if ( fac.IsNull() ) continue; if ( ! fac.IsNull() ) addedfaces.Bind(fac,fac); TopAbs_State statemergef1 = (rankf1 == 1) ? myState1 : myState2; TopAbs_State statemergef2 = (rankf2 == 2) ? myState2 : myState1; ChangeMerged(f1,statemergef1).Append(fac); it2.Initialize(lf2); for (;it2.More();it2.Next()) ChangeMerged(it2.Value(),statemergef2).Append(fac); // les faces de she1 sauf les tangentes et celles deja ajoutees TopOpeBRepTool_ShapeExplorer fex1; for (fex1.Init(she1,TopAbs_FACE); fex1.More(); fex1.Next()) { const TopoDS_Shape& facur = fex1.Current(); Standard_Boolean isfsd = myKPMAPf1f2.IsBound(facur); Standard_Boolean isadded = addedfaces.IsBound(facur); Standard_Boolean toadd = (!isfsd) && (!isadded) ; if ( toadd ) { TopoDS_Shape fori = facur; if (stsol1 == TopAbs_IN) fori.Complement(); addedfaces.Bind(fori,fori); } } // les faces de she2 sauf les tangentes et celles deja ajoutees TopOpeBRepTool_ShapeExplorer fex2; for (fex2.Init(she2,TopAbs_FACE); fex2.More(); fex2.Next()) { const TopoDS_Shape& facur = fex2.Current(); Standard_Boolean isfsd = myKPMAPf1f2.IsBound(facur); Standard_Boolean isadded = addedfaces.IsBound(facur); Standard_Boolean toadd = (!isfsd) && (!isadded) ; if ( toadd ) { TopoDS_Shape fori = facur; if (stsol2 == TopAbs_IN) fori.Complement(); addedfaces.Bind(fori,fori); } } } // === fin iteration fac1,fac2 TopTools_DataMapIteratorOfDataMapOfShapeShape itadd(addedfaces); Standard_Boolean yauadd = itadd.More(); if (yauadd) { myBuildTool.MakeShell(newshe); myBuildTool.Closed(newshe,Standard_True); // NYI : check exact du caractere closed du shell } for (; itadd.More(); itadd.Next() ) { const TopoDS_Shape& ftoadd = itadd.Key(); myBuildTool.AddShellFace(newshe,ftoadd); } } // === fin RESNEWSHE else { #ifdef DEB cout<<"MergeKPartiskole : ires = "<1 || nshsd2>1) return 0; TopTools_ListOfShape lf1,lf2; TopTools_ListOfShape les; //section for (TopTools_ListIteratorOfListOfShape itlf1(lfhsd1); itlf1.More();itlf1.Next()) { const TopoDS_Shape& f1 = itlf1.Value(); #ifdef DEB // Standard_Boolean isb1 = myKPMAPf1f2.IsBound(f1); // DEB #endif lf1.Clear(); lf1.Append(f1); lf2.Clear(); KPSameDomain(lf1,lf2); #ifdef DEB // Standard_Integer n1 = lf1.Extent(); // Standard_Integer n2 = lf2.Extent(); #endif #ifdef DEB Standard_Integer iF1; Standard_Boolean tSPS1 = GtraceSPS(f1,iF1); if(tSPS1) { GdumpSHA(f1, (char *) "KPiskole ");cout<ChangeDS(); DS.InitSectionEdges(); TopTools_ListIteratorOfListOfShape it(les); for (;it.More();it.Next()) DS.AddSectionEdge(TopoDS::Edge(it.Value())); return 1; } // TopOpeBRepBuild_Builder::KPiskole //======================================================================= //function : KPiskoleanalyse //purpose : //======================================================================= void TopOpeBRepBuild_Builder::KPiskoleanalyse(const TopAbs_State Stfac1, const TopAbs_State Stfac2, const TopAbs_State Stsol1, const TopAbs_State Stsol2, Standard_Integer& ires,Standard_Integer& icla1,Standard_Integer& icla2) const { ires = RESUNDEF; icla1 = icla2 = SHEUNDEF; if (Opefus()) { if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) { ires = RESNEWSHE; icla1 = SHEGARDAUTR; icla2 = SHEGARDAUTR; } else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) { ires = RESSHAPE1; icla1 = SHECLASAUTR; icla2 = SHEAUCU; } else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) { ires = RESSHAPE2; icla1 = SHEAUCU; icla2 = SHECLASAUTR; } } else if (Opec12()) { if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) { ires = RESSHAPE1; icla1 = SHEGARDAUTR; icla2 = SHEAUCU; } else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) { ires = RESNEWSHE; icla1 = SHECLASAUTR; icla2 = SHEAUCU; } else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) { ires = RESNULL; icla1 = icla2 = SHEAUCU; } } else if (Opec21()) { if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) { ires = RESSHAPE2; icla1 = SHEAUCU; icla2 = SHEGARDAUTR; } else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) { ires = RESNULL; icla1 = icla2 = SHEAUCU; } else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) { ires = RESNEWSHE; icla1 = SHEAUCU; icla2 = SHECLASAUTR; } } else if (Opecom()) { if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_OUT) { if (Stfac1 == TopAbs_IN) { ires = RESFACE1; icla1 = icla2 = SHEAUCU; } if (Stfac2 == TopAbs_IN) { ires = RESFACE2; icla1 = icla2 = SHEAUCU; } } else if (Stsol1 == TopAbs_OUT && Stsol2 == TopAbs_IN ) { ires = RESSHAPE2; icla1 = SHECLASAUTR; icla2 = SHEGARDAUTR; } else if (Stsol1 == TopAbs_IN && Stsol2 == TopAbs_OUT) { ires = RESSHAPE1; icla1 = SHEGARDAUTR; icla2 = SHECLASAUTR; } } #ifdef DEB Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB(); if (TKPB) cout<<"ires = "< : the list of solids same domain with // sol is 's first solid // : the list of 's same domain faces, none of the list carries geometric interf { if ( Sarg.IsNull() ) return Standard_False; Standard_Integer nsol = BU.KPlhsd(Sarg,TopAbs_SOLID,lShsd); if ( nsol == 0 ) return Standard_False; const TopoDS_Shape& sol = lShsd.First(); TopTools_ListOfShape lfhg; Standard_Integer nfhg = BU.KPlhg(sol,TopAbs_FACE,lfhg); if ( nfhg != 0 ) { TopTools_ListIteratorOfListOfShape its(lfhg); for(; its.More(); its.Next()) { TopOpeBRepDS_ListIteratorOfListOfInterference iti(BDS.ShapeInterferences(its.Value())); for (;iti.More();iti.Next()) { Handle(TopOpeBRepDS_ShapeShapeInterference) ssi; ssi = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(iti.Value()); if (ssi.IsNull()) { return Standard_False; } } } } return Standard_True; } // FUNKP_KPiskolesh //======================================================================= //function : KPiskolesh //purpose : // KPiskolesh : // S est il un shape traite par le cas particulier du collage ? // si oui : retourne un solide et une liste de faces de collage //======================================================================= Standard_Boolean TopOpeBRepBuild_Builder::KPiskolesh(const TopoDS_Shape& Sarg, TopTools_ListOfShape& lShsd, TopTools_ListOfShape& lfhsd) const { #ifdef DEB Standard_Boolean TKPB = TopOpeBRepBuild_GettraceKPB(); #endif const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); Standard_Boolean iskolesh = FUNKP_KPiskolesh(*this,BDS,Sarg,lShsd,lfhsd); if (!iskolesh) return Standard_False; #ifdef DEB Standard_Integer nfhsd = #endif KPlhsd(Sarg,TopAbs_FACE,lfhsd); TopTools_ListIteratorOfListOfShape it(lfhsd); for (; it.More(); it.Next() ) { const TopoDS_Shape& fac = it.Value(); Standard_Boolean isplan = FUN_tool_plane(fac); //pro7993 BUG if ( !isplan ) return Standard_False; Standard_Integer nw = KPls(fac,TopAbs_WIRE); if (nw > 1) return Standard_False; TopTools_ListOfShape lehg; Standard_Integer nehg = KPlhg(fac,TopAbs_EDGE,lehg); if ( nehg != 0 ) return Standard_False; #ifdef DEB Standard_Integer isol = myDataStructure->Shape(Sarg); Standard_Integer ifac = myDataStructure->Shape(fac); if(TKPB){cout<<"isol "<