// file: TopOpeBRepBuild_GridEE.cxx // Created: Thu Mar 7 10:49:33 1996 // Author: Jean Yves LEBEY // #include #include #include #ifdef DRAW #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOSG(); #endif #define M_FORWARD(st) (st == TopAbs_FORWARD) #define M_REVERSED(st) (st == TopAbs_REVERSED) #define M_INTERNAL(st) (st == TopAbs_INTERNAL) #define M_EXTERNAL(st) (st == TopAbs_EXTERNAL) Standard_EXPORT Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2); //======================================================================= //function : GMergeEdges //purpose : //======================================================================= void TopOpeBRepBuild_Builder::GMergeEdges(const TopTools_ListOfShape& LE1,const TopTools_ListOfShape& LE2,const TopOpeBRepBuild_GTopo& G1) { if ( LE1.IsEmpty() ) return; TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); const TopoDS_Shape& E1 = LE1.First(); #ifdef DEB Standard_Integer iE; Standard_Boolean tSPS1 = GtraceSPS(E1,iE); if(tSPS1){ cout<Transition(); TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S); TopAbs_ShapeEnum SB,SA; Standard_Integer IB,IA; FDS_Tdata(I,SB,IB,SA,IA); TopAbs_ShapeEnum b = T.ShapeBefore(), a = T.ShapeAfter(); Standard_Boolean rejet = ( (b != SHA) || (a != SHA) ); if ( rejet ) EPit.Next(); else { more = Standard_True; break; } } return more; } // Unused : /*#ifdef DEB static Standard_Integer FUN_getTRASHA(const Standard_Integer geti, const TopOpeBRepDS_ListOfInterference& lFOR, const Standard_Integer FOR, const TopOpeBRepDS_ListOfInterference& lREV, const Standard_Integer REV, const TopOpeBRepDS_ListOfInterference& lINT, const Standard_Integer INT) { Standard_Integer trasha = 0; if (geti == 1) { // get i before if (REV) trasha = lREV.First()->Transition().Before(); if (INT) trasha = lINT.First()->Transition().Before(); } if (geti == 2) { // get i after if (FOR) trasha = lFOR.Last()->Transition().After(); if (INT) trasha = lINT.Last()->Transition().After(); } return trasha; } #endif*/ #ifdef DEB void debfillp(const Standard_Integer i) {cout <<"+ + debfillp "<Geometry(); TopOpeBRepDS_Kind KG = I->GeometryType(); Standard_Boolean Gb1 = (KG == TopOpeBRepDS_VERTEX); if (Gb1) { Handle(TopOpeBRepDS_EdgeVertexInterference) EVI= Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I); Standard_Boolean vhassd = HDS->HasSameDomain(HDS->DS().Shape(G)); Gb1 = (EVI.IsNull()) ? Standard_False : EVI->GBound(); Gb1 = Gb1 && !vhassd; } return Gb1; } #define TheIN (1) #define TheON (2) #define TheOUT (3) #define HASSD2d (2) #define HASSD3d (3) #define FIRST (1) #define LAST (2) //======================================================================= //function : GFillPointTopologyPVS //purpose : //======================================================================= void TopOpeBRepBuild_Builder::GFillPointTopologyPVS(const TopoDS_Shape& E, const TopOpeBRepBuild_GTopo& G, TopOpeBRepBuild_PaveSet& PVS) { #ifdef DEB // TopAbs_State TB1,TB2; // G.StatesON(TB1,TB2); // TopOpeBRepDS_Config GConf1 = G.Config1(); // TopOpeBRepDS_Config GConf2 = G.Config2(); #endif TopAbs_ShapeEnum t1,t2,ShapeInterf; G.Type(t1,t2); ShapeInterf = t1; const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS(); const Standard_Integer iEDS = BDS.Shape(E); #ifdef DEB // Standard_Integer rkE = BDS.AncestorRank(E); #endif Standard_Boolean isSE = BDS.IsSectionEdge(TopoDS::Edge(E)); Standard_Boolean dgE = BRep_Tool::Degenerated(TopoDS::Edge(E)); Standard_Boolean isEd; isEd = BRep_Tool::Degenerated(TopoDS::Edge(E)); #ifdef DEB // Standard_Boolean hsd = myDataStructure->HasSameDomain(E); //xpu170498 #endif Standard_Boolean isfafa = BDS.Isfafa(); //xpu120598 #ifdef DEB Standard_Boolean tSPSE=GtraceSPS(iEDS); TCollection_AsciiString striE=TopOpeBRepDS::SPrint(TopAbs_EDGE,iEDS); const TopoDS_Shape& EPVS=PVS.Edge();Standard_Integer iEPVS;Standard_Boolean tSPSEPVS=GtraceSPS(EPVS,iEPVS); Standard_Boolean tSPS = tSPSE || tSPSEPVS; if(tSPS){ cout< keep the interf } //kp1 // - kp6 - nyiReducing // xpu250998 : cto900M5 (e5,p1) // prequesitory : if we have I3d on Gb0 FORWARD or REVERSED, we do NOT need // interference on Gb1 to determinate split IN/OUT of edge. Standard_Boolean kp6 = (!isSE); if (kp6) { kp6 = Standard_False; TopOpeBRepDS_ListIteratorOfListOfInterference it(loiSHAINT); for (; it.More(); it.Next()){ const Handle(TopOpeBRepDS_Interference)& I = it.Value(); TopOpeBRepDS_Kind ST = I->SupportType(); if (ST != TopOpeBRepDS_FACE) continue; TopAbs_Orientation O = I->Transition().Orientation(TopAbs_IN); Standard_Boolean FORREV = (O == TopAbs_FORWARD) || (O == TopAbs_REVERSED); if (!FORREV) continue; Standard_Boolean Gb1 = ::FUN_isonbound(myDataStructure,I); if (!Gb1) {kp6 = Standard_True; break;} } // it(l3dFOR+l3dREV) } // 1. //--- tki.Init(); while (tki.More()) { // lieu courant : Kcur,Gcur; Interferences : LICur TopOpeBRepDS_Kind Kcur; Standard_Integer Gcur; const TopOpeBRepDS_ListOfInterference& LICur = tki.Value(Kcur,Gcur); Standard_Boolean point = (Kcur == TopOpeBRepDS_POINT); //xpu170498 Standard_Boolean vertex = (Kcur == TopOpeBRepDS_VERTEX);//xpu170498 #ifdef DEB // Standard_Integer nLICur = LICur.Extent(); Standard_Boolean trcI = Standard_False; if(trcI) {TopOpeBRepDS_Dumper DSD(myDataStructure); TCollection_AsciiString aa("lI"); aa += TCollection_AsciiString(Gcur); DSD.DumpLOI(LICur,cout,aa);} #endif TopoDS_Shape vGsd; if (vertex) FUN_ds_getoov(BDS.Shape(Gcur), myDataStructure, vGsd); //xpu221098 // recall : I3d=(I3dF,I3dFE) : I3dF=(T(F),G,F), I3dFE=(T(F),G,E) // I2d=I2dFE // I1d=(T(E),V,E) if ((Kcur == TopOpeBRepDS_VERTEX) && (kp1 == Gcur)) {tki.Next();continue;} const Handle(TopOpeBRepDS_Interference)& I = LICur.First(); Standard_Real parSE = FDS_Parameter(I); TopOpeBRepDS_ListOfInterference LICurcopy; TopOpeBRepDS_ListOfInterference l3dFcur; FDS_assign(LICur,LICurcopy); Standard_Integer n3d=FUN_selectSKinterference(LICurcopy,TopOpeBRepDS_FACE,l3dFcur); TopOpeBRepDS_ListOfInterference l2dFEcur; FDS_assign(LICur,LICurcopy); Standard_Integer n2d=FUN_ds_hasI2d(iEDS,LICurcopy,l2dFEcur); TopOpeBRepDS_ListOfInterference l1dEcur; FDS_assign(LICur,LICurcopy); FUN_selectTRASHAinterference(LICurcopy,TopAbs_EDGE,l1dEcur); TopAbs_State stb; Standard_Integer isb; Standard_Integer bdim; TopAbs_State sta; Standard_Integer isa; Standard_Integer adim; FUN_ds_GetTr(BDS,iEDS,Gcur,LICur, stb,isb,bdim, sta,isa,adim); if (isSE) { // before Standard_Boolean bIN1d = (stb==TopAbs_IN)&&(bdim==1); Standard_Boolean bIN2d = (stb==TopAbs_IN)&&(bdim==2); Standard_Boolean bIN3d = (stb==TopAbs_IN)&&(bdim==3); Standard_Boolean bOUT2d = (stb==TopAbs_OUT)&&(bdim==2); Standard_Boolean bOUT3d = (stb==TopAbs_OUT)&&(bdim==3); // after Standard_Boolean aIN1d = (sta==TopAbs_IN)&&(adim==1); Standard_Boolean aIN2d = (sta==TopAbs_IN)&&(adim==2); Standard_Boolean aIN3d = (sta==TopAbs_IN)&&(adim==3); Standard_Boolean aOUT2d = (sta==TopAbs_OUT)&&(adim==2); Standard_Boolean aOUT3d = (sta==TopAbs_OUT)&&(adim==3); TopOpeBRepDS_Transition newT; Standard_Boolean INb=Standard_False,INa=Standard_False; if (isfafa) { if (isspon) { if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;} INb = bIN1d; INa = aIN1d; newT.Index(isb); newT.ShapeBefore(TopAbs_EDGE); newT.ShapeAfter(TopAbs_EDGE); } else if (isspin) { INb = bIN2d; INa = aIN2d; newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE); } else if (isspou) { INb = !bOUT2d; INa = !aOUT2d; newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE); } } else { if (isspon) { if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;} INb = bIN1d || bIN2d; INa = aIN1d || aIN2d; newT.Index(isb); newT.ShapeBefore(TopAbs_EDGE); newT.ShapeAfter(TopAbs_EDGE); } else if (isspin) { if ((stb == TopAbs_OUT)&&(sta == TopAbs_OUT)) {tki.Next(); continue;} INb = bIN3d; INa = aIN3d; if (INb) newT.Index(isb); else newT.Index(isa); newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE); } else if (isspou) { if ((stb == TopAbs_IN)&&(sta == TopAbs_IN)) {tki.Next(); continue;} INb = !bOUT3d; INa = !aOUT3d; if (bOUT3d) newT.Index(isb); else newT.Index(isa); newT.ShapeBefore(TopAbs_FACE); newT.ShapeAfter(TopAbs_FACE); } } TopAbs_State sb = INb ? TopAbs_IN : TopAbs_OUT; TopAbs_State sa = INa ? TopAbs_IN : TopAbs_OUT; newT.StateBefore(sb);newT.StateAfter(sa); Standard_Integer S=0; // dummy Standard_Boolean B = (Kcur == TopOpeBRepDS_POINT) ? Standard_False : (Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I)->GBound()); Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(newT,S,Gcur,parSE,Kcur,B); TopOpeBRepDS_ListOfInterference li; li.Append(newI); TopOpeBRepDS_PointIterator itCur(li); GFillPointTopologyPVS(E,itCur,G,PVS); #ifdef DEB if(tSPS) {newI->Dump(cout,"\nnewinterf ","\n\n"); debfillp2(iEDS);} #endif {tki.Next(); continue;} } // isSE // - kp3 - // xpu200598 interference 2d at GPOINT Standard_Boolean kp3 = (n2d > 0) && point; if (kp3) l2dFEcur.First()->Transition().Orientation(TopAbs_IN); TopOpeBRepDS_PointIterator itCur(LICur); Standard_Integer iICur=0; while ( itCur.More() ) { iICur++; const Handle(TopOpeBRepDS_Interference)& I1=itCur.Value(); const TopOpeBRepDS_Transition& T1=I1->Transition(); T1.Orientation(TopAbs_IN); TopAbs_ShapeEnum SB1,SA1;Standard_Integer IB1,IA1;TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1; FDS_Idata(I1,SB1,IB1,SA1,IA1,GT1,G1,ST1,S1); #ifdef DEB if(tSPS) {I1->Dump(cout,"\n? keepinterf ","\n\n"); debfillp2(iEDS);} #endif Standard_Boolean keepinterf1 = Standard_False; if (isEd) { keepinterf1 = Standard_True; } else { if (GLOBAL_faces2d) { // split 2d Standard_Boolean has2d3d = (n2d >0 && n3d >0); // JYL300998 // JYL300998 : traitement correct de cto 100 K1 e27 (chanceux auparavant, schema d'I faux) // e27 n'est PAS arete de section mais doit etre traitee comme telle. // e27 possede des I de nature 2d et 3d en V8 // on privilegie l'info 3d if (has2d3d && !isSE) { #ifdef DEB const Handle(TopOpeBRepDS_Interference)& i2d = #endif l2dFEcur.First(); const Handle(TopOpeBRepDS_Interference)& i3d = l3dFcur.First(); Standard_Boolean id3d = (I1 == i3d); #ifdef DEB Standard_Boolean id2d = (I1 == i2d); #endif keepinterf1 = id3d; #ifdef DEB if (tSPS) { cout<<"DEB : GFillPointTopologyPVS E"<Dump(cout,"2d : ","\n"); i3d->Dump(cout,"3d : ","\n"); I1->Dump (cout,"I1 : ","\n"); if (id3d) cout<<"--> Interference 3d "; if (id2d) cout<<"--> Interference 2d "; if (keepinterf1) cout<<" traitee"<SupportType(); #ifdef DEB Standard_Integer iE; Standard_Boolean tSPSE = GtraceSPS(E,iE); Standard_Integer iEPVS; Standard_Boolean tSPSEPVS = GtraceSPS(EPVS,iEPVS); Standard_Boolean tSPS = tSPSE || tSPSEPVS; if ( tSPS ) debfillp(iE); #endif TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2); TopOpeBRepDS_Config Conf = G1.Config1(); TopAbs_State TB = TB1; // iG = index of new point or existing vertex Standard_Integer iG = EPit.Current(); Standard_Boolean ispoint = EPit.IsPoint(); TopoDS_Vertex VIG; // NYI pointer if (ispoint) VIG = TopoDS::Vertex(NewVertex(iG)); else VIG = TopoDS::Vertex(myDataStructure->Shape(iG)); if (VIG.IsNull()) return; //PMN 17/02/99 Nothing to add. Standard_Boolean hasVSD = Standard_False; Standard_Integer iVRE = 0; TopoDS_Shape VRE; // NYI pointer if (!ispoint) { hasVSD = myDataStructure->HasSameDomain(VIG); if (hasVSD) { // on prend VRE = vertex reference de VIG iVRE = myDataStructure->SameDomainReference(VIG); VRE = TopoDS::Vertex(myDataStructure->Shape(iVRE)); } } TopoDS_Vertex VPV; // NYI pointer on VRE or VIG if (hasVSD) VPV = TopoDS::Vertex(VRE); else VPV = VIG; // else VPV = TopoDS::Vertex(VIG); Standard_Real par = EPit.Parameter(); TopAbs_Orientation ori = EPit.Orientation(TB); #ifdef DEB if ( tSPS ) debfillp(iE); #endif Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(E,EPVS); if (Conf == TopOpeBRepDS_DIFFORIENTED) ori = TopAbs::Complement(ori); #ifdef DEB if (!TopOpeBRepBuild_GetcontextNOSG()) { #endif if (!samegeom) ori = TopAbs::Complement(ori); #ifdef DEB } #endif Standard_Boolean lesmemes = E.IsEqual(myEdgeReference); if ( !lesmemes ) { Standard_Real parref = par; const TopoDS_Edge& EE = TopoDS::Edge(E); GParamOnReference(VPV,EE,parref); #ifdef DEB if(tSPS){ cout<<"par "< parref "<Shape(vclo); #endif TopAbs_Orientation oriI = EPit.Orientation(TopAbs_IN); // kpbound = lesmemes && Eclosed && hasVSD && (ori == TopAbs_INTERNAL) && (TB == TopAbs_OUT); -xpu140898 // xpu110398 cto 009 L2 : e6ou en v11 // xpu140898 USA60111 : e9ou (!=0) + e7ou(=0) Standard_Boolean INTEXT = (oriI == TopAbs_INTERNAL) && (TB == TopAbs_IN); INTEXT = INTEXT || ((oriI == TopAbs_EXTERNAL) && (TB == TopAbs_OUT)); kpbound = lesmemes && Eclosed && INTEXT; if ( kpbound ) { kpbound = vclo.IsSame(VIG); if (!kpbound) { TopoDS_Shape VSD; Standard_Boolean ok = FUN_ds_getoov(VIG,myDataStructure->DS(),VSD); if (ok) kpbound = vclo.IsSame(VSD); } } } if (!kpbound) { VPV.Orientation(ori); Standard_Boolean vofe = Standard_False; Handle(TopOpeBRepBuild_Pave) PV = new TopOpeBRepBuild_Pave(VPV,par,vofe); if (hasVSD) { PV->HasSameDomain(Standard_True); const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value(); Standard_Integer iVSD = myDataStructure->Shape(VSD); if (iVSD == iVRE) PV->SameDomain(VIG); else PV->SameDomain(VSD); } //modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000 PV -> InterferenceType() = ST1; PVS.Append(PV); #ifdef DEB gp_Pnt P = BRep_Tool::Pnt(VPV); if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";} if(tSPS){cout<HasSameDomain(Standard_True); const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value(); Standard_Integer iVSD = myDataStructure->Shape(VSD); if (iVSD == iVRE) PVF->SameDomain(VIG); else PVF->SameDomain(VSD); } //modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000 PVF -> InterferenceType() = ST1; PVS.Append(PVF); #ifdef DEB gp_Pnt PF = BRep_Tool::Pnt(VPV); if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";} if(tSPS){cout<HasSameDomain(Standard_True); const TopoDS_Shape& VSD = myDataStructure->SameDomain(VPV).Value(); Standard_Integer iVSD = myDataStructure->Shape(VSD); if (iVSD == iVRE) PVR->SameDomain(VIG); else PVR->SameDomain(VSD); } //modified by NIZHNY-MZV Mon Feb 21 14:48:37 2000 PVR -> InterferenceType() = ST1; PVS.Append(PVR); #ifdef DEB gp_Pnt PR = BRep_Tool::Pnt(VPV); if(tSPS){cout<<"+";if(ispoint)cout<<" PDS ";else cout<<" VDS ";} if(tSPS){cout<Pln(); gp_Pnt p3 = BRep_Tool::Pnt(V); Standard_Real u,v; ElSLib::Parameters(pln,p3,u,v); gp_Pnt2d p2(u,v); Standard_Real f,l,tolpc; Handle(Geom2d_Curve) C2D; C2D = FC2D_CurveOnSurface(myEdgeReference,myFaceReference,f,l,tolpc); if (C2D.IsNull()) Standard_ProgramError::Raise("TopOpeBRepBuild_Builder::GParamOnReference"); // Standard_Real U; Geom2dAdaptor_Curve AC(C2D); switch ( AC.GetType() ) { case GeomAbs_Line: P = ElCLib::Parameter(AC.Line(),p2); break; case GeomAbs_Circle: P = ElCLib::Parameter(AC.Circle(),p2); break; case GeomAbs_Ellipse: P = ElCLib::Parameter(AC.Ellipse(),p2); break; case GeomAbs_Hyperbola: P = ElCLib::Parameter(AC.Hyperbola(),p2); break; case GeomAbs_Parabola: P = ElCLib::Parameter(AC.Parabola(),p2); break; default : #ifdef DEB cout<<"NYI : GParamOnReference : OtherCurve on planar surface"<