// File: TopOpeBRepDS_ProcessEdgeInterferences.cxx // Created: Thu Mar 21 11:40:31 1996 // Author: Modelistation // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettracePEI(); Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettracePI(); Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer); Standard_IMPORT Standard_Boolean TopOpeBRepDS_GettraceEDPR(); static Standard_Boolean TRCE(const Standard_Integer SIX) { Standard_Boolean b1 = TopOpeBRepDS_GettracePEI(); Standard_Boolean b2 = TopOpeBRepDS_GettracePI(); Standard_Boolean b3 = TopOpeBRepDS_GettraceSPSX(SIX); return (b1 || b2 || b3); } Standard_EXPORT void debredunke(const Standard_Integer i){cout<<"++ debredunke e"<IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) ) { // EVI I rejetee si son arete-support est E accedant I Standard_Boolean k1 = ! ::FUN_interfhassupport(DS,I,E); res = k1; // EVI rejetee si transition ON EDGE before ou after const TopOpeBRepDS_Transition& T = I->Transition(); TopAbs_ShapeEnum shab = T.ShapeBefore(),shaa = T.ShapeAfter(); TopAbs_State stab = T.Before(),staa = T.After(); Standard_Boolean k2 = ! (((shab == TopAbs_EDGE) && (stab == TopAbs_ON)) || ((shaa == TopAbs_EDGE) && (staa == TopAbs_ON))); res = res && k2; const TopoDS_Shape& VG = DS.Shape(I->Geometry()); /* xpu : 20-01-98 // EVI I rejetee si son vertex-geometrie est un vertex de l'arete // qui accede I. Standard_Boolean k3 = ! ::FUN_vertexofedge(VG,E); res = res && k3; */ // EVI rejetee si OUT FACE before et after // et si le vertex-geometrie de l'interference collisionne avec // un des vertex de l'arete (E) accedant l'interference (I) #ifdef DEB // Standard_Boolean k4I = (((shab == TopAbs_FACE) && (stab == TopAbs_OUT)) && // ((shaa == TopAbs_FACE) && (staa == TopAbs_OUT))); #endif { TopoDS_Vertex Vf,Vr; TopExp::Vertices(TopoDS::Edge(E),Vf,Vr); TopTools_ListIteratorOfListOfShape it(DS.ShapeSameDomain(VG)); for (; it.More(); it.Next()) { const TopoDS_Shape& Vsd = it.Value(); if ( Vsd.IsSame(Vf) ) { break; } else if ( Vsd.IsSame(Vr) ) { break; } } } #ifdef DEB // Standard_Boolean k4 = ! ( k4I && k4C ); #endif // res = res && k4; } else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) ) { Handle(TopOpeBRepDS_CurvePointInterference) aCPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I); // MSV Oct 4, 2001: reject interference having the parameter coinciding with // one of sides of the edge range Standard_Real eps = Precision::PConfusion(); Standard_Real par = aCPI->Parameter(); Standard_Real f,l; BRep_Tool::Range(TopoDS::Edge(E), f,l); if (Abs(par-f) < eps || Abs(par-l) < eps) res = Standard_False; } return res; } //------------------------------------------------------ Standard_EXPORT Standard_Integer FUN_unkeepEinterferences //------------------------------------------------------ (TopOpeBRepDS_ListOfInterference& LI,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SIX) { #ifdef DEB Standard_Boolean TRC=TRCE(SIX); #endif const TopoDS_Shape& E = BDS.Shape(SIX); Standard_Boolean isEd; isEd = BRep_Tool::Degenerated(TopoDS::Edge(E)); #ifdef DEB if (TRC) {cout<<"FUN_unkeepEinterferences on "<Dump(cout);cout<Transition(); TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); it2.Next(); while ( it2.More() ) { const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value(); TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2); TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2; ::FDS_Tdata(I2,tsb2,isb2,tsa2,isa2); const TopOpeBRepDS_Transition T2 = I2->Transition(); // + 03-03-97 Standard_Boolean idGS = (GT2 == GT1 && G2 == G1 && ST2 == ST1 && S2 == S1); Standard_Boolean idiba = (isb1 == isb2 && isa1 == isa2); Standard_Boolean cond = idGS; cond = cond && idiba; // ++971219 if (cond) { Standard_Boolean idshape = ::FUN_transitionSHAPEEQUAL(T1,T2); Standard_Boolean idstate = ::FUN_transitionSTATEEQUAL(T1,T2); Standard_Boolean newV = Standard_True; Standard_Boolean oppostate = false; if (newV) { // sym is not precise enough (croix3_3-> OUT/IN; ON/OUT) #define M_OUTIN(st1,st2) ((st1 == TopAbs_OUT)&&(st2 == TopAbs_IN)) TopAbs_State t1b = T1.Before(), t2b = T2.Before(); TopAbs_State t1a = T1.After(), t2a = T2.After(); oppostate = M_OUTIN(t1b,t2b) || M_OUTIN(t2b,t1b); oppostate = oppostate && (M_OUTIN(t1a,t2a) || M_OUTIN(t2a,t1a)); } Standard_Boolean sym; if (newV) sym = idshape && oppostate; else sym = idshape && !idstate; if ( sym ) { // les 2 interferences ne different que leurs etats (symetriques) #ifdef DEB // cout<<"TopOpeBRepDS FUN_unkeepEsymetrictransitions on edge "<Dump(cout);cout<Dump(cout);cout<ChangeDS(); TopOpeBRepDS_ListOfInterference L1,L2; TopOpeBRepDS_ListIteratorOfListOfInterference it1; it1.Initialize(LI); while (it1.More() ) { Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1); const TopOpeBRepDS_Transition& T1 = I1->Transition(); TopAbs_State stab1 = T1.Before(); TopAbs_State staa1 = T1.After(); Standard_Boolean steq = (tsb1 == tsa1 && isb1 == isa1 && stab1 == staa1); if (steq) L1.Append(I1); else L2.Append(I1); it1.Next(); } // it1.More() LI.Clear(); LI.Append(L1); LI.Append(L2); #ifdef DEB if(TRC && modif){ FDS_dumpLI(LI,"apres groupage STATETRANS : "); } #endif } // FUN_orderSTATETRANSonG //------------------------------------------------------ Standard_EXPORT void FUN_orderSTATETRANS //------------------------------------------------------ // partition de LI en deux sous listes : // L1/ = interfs dont la transition a des etats egaux // L2/ = les autres interfs // L = L1 + L2; (TopOpeBRepDS_ListOfInterference& LI,const Handle(TopOpeBRepDS_HDataStructure)& HDS,const Standard_Integer SIX) { #ifdef DEB Standard_Boolean TRC=TRCE(SIX); if (TRC) deborderSTATETRANS(SIX); #endif TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI); tki.Init(); for (; tki.More(); tki.Next()) { TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); ::FUN_orderSTATETRANSonG(loi,HDS,SIX); } LI.Clear(); tki.Init(); for (; tki.More(); tki.Next()) { TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); LI.Append(loi); } } // FUN_orderSTATETRANS //------------------------------------------------------ Standard_EXPORT void FUN_resolveEUNKNOWN //------------------------------------------------------ (TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SIX) { #ifdef DEB Standard_Boolean TRC=TRCE(SIX); if (TRC) debredunke(SIX); Standard_Boolean modif = Standard_False; #endif const TopoDS_Shape& E = BDS.Shape(SIX); TopOpeBRepDS_ListIteratorOfListOfInterference it1; const TopoDS_Edge& EE = TopoDS::Edge(E); Standard_Real fE,lE; BRep_Tool::Range(EE,fE,lE); // process interferences of LI with UNKNOWN transition for (it1.Initialize(LI); it1.More(); it1.Next() ) { Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition(); Standard_Boolean isunk = T1.IsUnknown(); if (!isunk) continue; #ifdef DEB modif = Standard_True; if(TRC){debredunke(SIX);TCollection_AsciiString s="E";s=s+SIX+" T UNKNOWN ";I1->Dump(cout,s,"\n");} #endif TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1); Standard_Boolean idt = (tsb1==TopAbs_FACE && tsa1==TopAbs_FACE && GT1==TopOpeBRepDS_POINT && ST1==TopOpeBRepDS_FACE); Standard_Boolean idi = (isb1==S1 && isa1==S1); Standard_Boolean etgf = idt && idi; // edge tangent a une face en 1 point if (!etgf) continue; #ifdef DEB if(TRC){debredunke(SIX);TCollection_AsciiString s="E";s=s+SIX+" etgf ";I1->Dump(cout,s,"\n");} #endif Handle(TopOpeBRepDS_CurvePointInterference) cpi = MAKECPI(I1); if (cpi.IsNull()) continue; Standard_Real bid; Handle(Geom_Curve) CE = BRep_Tool::Curve(EE,bid,bid); if (CE.IsNull()) continue; // NYI : get points from 2d curve Standard_Real parcpi = cpi->Parameter(); Standard_Real ttb = 0.8; Standard_Real parb = (1-ttb)*fE + ttb*parcpi; Standard_Real tta = 0.2; Standard_Real para = (1-tta)*parcpi + tta*lE; gp_Pnt Pb;CE->D0(parb,Pb); gp_Pnt Pa;CE->D0(para,Pa); BRep_Builder BB; const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(S1)); TopoDS_Shell sh; BB.MakeShell(sh); TopoDS_Solid so; BB.MakeSolid(so); BB.Add(sh,FS);BB.Add(so,sh); TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(so); PSC.StateP3DReference(Pb); TopAbs_State stateb = PSC.State(); PSC.StateP3DReference(Pa); TopAbs_State statea = PSC.State(); if (stateb==TopAbs_UNKNOWN || statea==TopAbs_UNKNOWN) continue; TopOpeBRepDS_Transition& newT1 = I1->ChangeTransition(); newT1.Set(stateb,statea,tsb1,tsa1); #ifdef DEB if(TRC){debredunke(SIX);TCollection_AsciiString s="E";s=s+SIX+" T corrected ";I1->Dump(cout,s,"\n");} #endif } #ifdef DEB if(TRC && modif){ FDS_dumpLI(LI,"apres correction UNKNOWN : "); } #endif FUN_unkeepUNKNOWN(LI,BDS,SIX); #ifdef DEB if(TRC && modif){ FDS_dumpLI(LI,"sans suppression UNKNOWN residuels : "); } #endif } // ---------------------------------------------------------------------- Standard_EXPORT void FUN_purgeDSonSE(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const Standard_Integer EIX,TopOpeBRepDS_ListOfInterference& LI) // ---------------------------------------------------------------------- { #ifdef DEB Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(EIX); if (trc) {cout<Dump(cout);cout<