diff --git a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx b/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx index 81c90cbf53..1d2b2a5b84 100755 --- a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx +++ b/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx @@ -530,78 +530,110 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::VResolution GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const { - - Standard_Real TolConf = Precision::Confusion(); - Standard_Real TolAng = Precision::Angular(); + Standard_Real TolConf, TolAng; + GeomAbs_SurfaceType bRet; + // + bRet=GeomAbs_SurfaceOfRevolution; + TolConf = Precision::Confusion(); + TolAng = Precision::Angular(); + // switch ( myBasisCurve->GetType()) { + case GeomAbs_Line: { + const gp_Ax1& Axe = (myBasisCurve->Line()).Position(); - case GeomAbs_Line: - { - const gp_Ax1& Axe = (myBasisCurve->Line()).Position(); - - if (myAxis.IsParallel(Axe, TolAng)) { - return GeomAbs_Cylinder; + if (myAxis.IsParallel(Axe, TolAng)) { + bRet=GeomAbs_Cylinder; + return bRet; + } + else if (myAxis.IsNormal( Axe, TolAng)) { + bRet=GeomAbs_Plane; + return bRet; + } + else { + Standard_Real uf = myBasisCurve->FirstParameter(); + Standard_Real ul = myBasisCurve->LastParameter(); + Standard_Boolean istrim = (!Precision::IsInfinite(uf) && + !Precision::IsInfinite(ul)); + if(istrim){ + gp_Pnt pf = myBasisCurve->Value(uf); + gp_Pnt pl = myBasisCurve->Value(ul); + Standard_Real len = pf.Distance(pl); + //on calcule la distance projetee sur l axe. + gp_Vec vlin(pf,pl); + gp_Vec vaxe(myAxis.Direction()); + Standard_Real projlen = Abs(vaxe.Dot(vlin)); + Standard_Real aTolConf = len*TolAng; + if ((len - projlen) <= aTolConf) { + bRet=GeomAbs_Cylinder; + return bRet; + } + else if (projlen <= aTolConf) { + bRet=GeomAbs_Plane; + return bRet; + } } - else if (myAxis.IsNormal( Axe, TolAng)) { - return GeomAbs_Plane; + gp_Vec V(myAxis.Location(), + myBasisCurve->Line().Location()); + gp_Vec W(Axe.Direction()); + if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){ + bRet=GeomAbs_Cone; + return bRet; } else { - Standard_Real uf = myBasisCurve->FirstParameter(); - Standard_Real ul = myBasisCurve->LastParameter(); - Standard_Boolean istrim = (!Precision::IsInfinite(uf) && - !Precision::IsInfinite(ul)); - if(istrim){ - gp_Pnt pf = myBasisCurve->Value(uf); - gp_Pnt pl = myBasisCurve->Value(ul); - Standard_Real len = pf.Distance(pl); - //on calcule la distance projetee sur l axe. - gp_Vec vlin(pf,pl); - gp_Vec vaxe(myAxis.Direction()); - Standard_Real projlen = Abs(vaxe.Dot(vlin)); - Standard_Real aTolConf = len*TolAng; - if ((len - projlen) <= aTolConf) { - return GeomAbs_Cylinder; - } - else if (projlen <= aTolConf) { - return GeomAbs_Plane; - } - } - gp_Vec V(myAxis.Location(), - myBasisCurve->Line().Location()); - gp_Vec W(Axe.Direction()); - if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){ - return GeomAbs_Cone; - } - else { - return GeomAbs_SurfaceOfRevolution; - } + return bRet; } - break; } + break; + }//case GeomAbs_Line: + // + case GeomAbs_Circle: { - case GeomAbs_Circle: - { - const gp_Circ& C = myBasisCurve->Circle(); - if (!C.Position().IsCoplanar(myAxis,TolConf,TolAng)) { - return GeomAbs_SurfaceOfRevolution; - } - else if( gp_Lin(myAxis).Distance(C.Location()) <= TolConf) { - return GeomAbs_Sphere; - } - else { - Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location()); - if(MajorRadius > C.Radius()) return GeomAbs_Torus; - return GeomAbs_SurfaceOfRevolution; - } - break; + Standard_Real MajorRadius, aR; + gp_Lin aLin(myAxis); + // + const gp_Circ& C=myBasisCurve->Circle(); + const gp_Pnt& aLC=C.Location(); + aR=C.Radius(); + // + + if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) { + return bRet; } - + else if(aLin.Distance(aLC) <= TolConf) { + bRet=GeomAbs_Sphere; + return bRet; + } + else { + MajorRadius = aLin.Distance(aLC); + if(MajorRadius>aR) { + //modified by NIZNHY-PKV Thu Feb 24 09:46:29 2011f + Standard_Real aT, aDx, dX; + gp_Pnt aPx; + // + aT=0.; + aPx=ElCLib::Value(aT, C); + aDx=aLin.Distance(aPx); + dX=aDx-MajorRadius-aR; + if (dX<0.) { + dX=-dX; + } + if (dXGetShape(nF1)); const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2)); @@ -570,7 +578,6 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC, continue; } } - // -&& // aBC.AppendNewBlock(aPBNew); } @@ -1324,9 +1331,10 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC, { Standard_Integer nV; Standard_Boolean bIsVertexOnLine; - Standard_Real aT, aTolVExt; - - + Standard_Real aT, aTolVExt, aTolTresh; + BRep_Builder aBB; + // + aTolTresh=0.01; nV=aPave.Index(); const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); const IntTools_Curve& aC=aBC.Curve(); @@ -1342,6 +1350,11 @@ static Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC, aPaveSet.Append(aPaveNew); //<-B BOPTools_Tools::UpdateVertex (aC, aT, aV); + //modified by NIZNHY-PKV Sat Mar 05 13:43:27 2011f + if(aTolR3D #include #include +#include //======================================================================= // function: ProcessAloneStickVertices @@ -3053,3 +3085,102 @@ Standard_Integer RejectBuildingEdge(const IntTools_Curve& theC, theTF = maxD; return eIndex; } +//modified by NIZNHY-PKV Sat Mar 05 12:18:43 2011f +//======================================================================= +//function : CorrectTolR3D +//purpose : +//======================================================================= +void CorrectTolR3D(BOPTools_PaveFiller& aPF, + const BOPTools_SSInterference& aFF, + const TColStd_MapOfInteger& aMVStick, + Standard_Real& aTolR3D) +{ + Standard_Boolean bHasBounds; + Standard_Integer i, nF[2], nV, aNbCurves; + Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax; + Standard_Real aTolR, aTolTresh, aAmin, aAmax; + TColStd_MapIteratorOfMapOfInteger aIt; + gp_Pnt aP, aP1, aP2; + gp_Dir aDN[2]; + gp_Vec aVT; + Handle(Geom_Surface) aS[2]; + Handle(Geom_Curve) aC3D; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aType; + TopoDS_Face aF[2]; + // + BooleanOperations_PShapesDataStructure myDS=aPF.DS(); + IntTools_Context& myContext=aPF.ChangeContext(); + // + aTolTresh=0.0005; + aAmin=0.012;// 0.7-7 deg + aAmax=0.12; + // + if (!aMVStick.Extent()) { + return; + } + // + BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF); + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + aNbCurves=aSCvs.Length(); + if (aNbCurves!=1){ + return; + } + // + aFFi.Indices(nF[0], nF[1]); + for (i=0; i<2; ++i) { + aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i]))); + aS[i]=BRep_Tool::Surface(aF[i]); + aGAS.Load(aS[i]); + aType=aGAS.GetType(); + if (aType!=GeomAbs_BSplineSurface) { + return; + } + } + // + BOPTools_Curve& aBC=aSCvs(1); + const IntTools_Curve& aIC=aBC.Curve(); + bHasBounds=aIC.HasBounds(); + if (!bHasBounds){ + return; + } + // + aIC.Bounds (aT1, aT2, aP1, aP2); + aT=IntTools_Tools::IntermediatePoint(aT1, aT2); + aC3D=aIC.Curve(); + aC3D->D0(aT, aP); + // + for (i=0; i<2; ++i) { + GeomAPI_ProjectPointOnSurf& aPPS=myContext.ProjPS(aF[i]); + aPPS.Perform(aP); + aPPS.LowerDistanceParameters(aU, aV); + BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]); + } + // + aA=aDN[0].Angle(aDN[1]); + aA=fabs(aA); + if (aA>0.5*PI) { + aA=PI-aA; + } + // + if (aAaAmax) { + return; + } + // + aTolVmax=-1.; + aIt.Initialize(aMVStick); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Key(); + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV))); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolV>aTolVmax) { + aTolVmax=aTolV; + } + } + // + aTolR=aTolVmax/aA; + if (aTolR #include +#include +#include -static Standard_Real GetAddToParam(const gp_Lin& L,const Standard_Real P,const Bnd_Box& B); +static + void FaceNormal (const TopoDS_Face& aF, + const Standard_Real U, + const Standard_Real V, + gp_Dir& aDN); -//extern void DrawSegment(const gp_Pnt& P1,const gp_Lin& L,const Standard_Real par); -//extern Standard_Boolean DebugDrawSegment; +static + Standard_Real GetAddToParam(const gp_Lin& L,const Standard_Real P,const Bnd_Box& B); + +//======================================================================= +//function : BRepClass3d_SClassifier +//purpose : +//======================================================================= BRepClass3d_SClassifier::BRepClass3d_SClassifier() { } +//======================================================================= +//function : BRepClass3d_SClassifier +//purpose : +//======================================================================= BRepClass3d_SClassifier::BRepClass3d_SClassifier(BRepClass3d_SolidExplorer& S, const gp_Pnt& P, const Standard_Real Tol) { @@ -42,7 +57,11 @@ BRepClass3d_SClassifier::BRepClass3d_SClassifier(BRepClass3d_SolidExplorer& S, } -void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& SolidExplorer, +//======================================================================= +//function : PerformInfinitePoint +//purpose : +//======================================================================= +void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& aSE, const Standard_Real /*Tol*/) { //-- Idee : On prend un point A dans la face1 et un point B dans la face B //-- ( si on a une seule face , on prend 2 points dans la meme face.) @@ -51,62 +70,82 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So //-- premier point. Si le solide a une seule face et que la droite AB ne le coupe pas //-- on ne peut pas decider. - if(SolidExplorer.Reject(gp_Pnt(0,0,0))) { + if(aSE.Reject(gp_Pnt(0,0,0))) { myState=3; //-- in ds le cas solide sans face return; } - - - Standard_Integer nump = 0; + // + //------------------------------------------------------------ + // 1 + Standard_Boolean bFound, bFlag; + Standard_Integer nump; + Standard_Real aParam, aU1, aV1, aU2, aV2; gp_Pnt A,B; - - Standard_Real aParam = 0.5; + gp_Dir aDN1, aDN2; + TopoDS_Face aF, aF1, aF2; + // + nump = 0; + aParam = 0.5; myFace.Nullify(); myState=2; - for(SolidExplorer.InitShell(); - SolidExplorer.MoreShell() && nump<2; - SolidExplorer.NextShell()) { - - for(SolidExplorer.InitFace(); - SolidExplorer.MoreFace() && nump<2; - ) { - - TopoDS_Shape aLocalShape = SolidExplorer.CurrentFace(); - TopoDS_Face f = TopoDS::Face(aLocalShape); -// TopoDS_Face f = TopoDS::Face(SolidExplorer.CurrentFace()); - SolidExplorer.NextFace(); - if(nump==0) { + for(aSE.InitShell(); aSE.MoreShell() && nump<2; aSE.NextShell()) { + for(aSE.InitFace(); aSE.MoreFace() && nump<2; ) { + aF =*((TopoDS_Face*)&aSE.CurrentFace()); + aSE.NextFace(); + if(!nump) { nump++; - if(SolidExplorer.FindAPointInTheFace(f,A,aParam)) { - if(SolidExplorer.MoreFace() == Standard_False) { - nump++; - SolidExplorer.FindAPointInTheFace(f,B,aParam); - } - } - else { + bFound=aSE.FindAPointInTheFace(aF, A, aU1, aV1, aParam); + if (!bFound) { return; } - } - else if(nump==1) { - if(SolidExplorer.FindAPointInTheFace(f,B,aParam)) { + aF1=aF; + if(!aSE.MoreFace()) { nump++; + bFound=aSE.FindAPointInTheFace(aF, B, aU2, aV2, aParam); + if (!bFound) { + return; + } + aF2=aF; } - else { + }// if(nump==0) { + else if(nump==1) { + bFound=aSE.FindAPointInTheFace(aF, B, aU2, aV2, aParam); + if(!bFound) { return; - } + } + aF2=aF; + nump++; } + }// for(aSE.InitFace(); aSE.MoreFace() && nump<2; ) { + }// for(aSE.InitShell(); aSE.MoreShell() && nump<2; aSE.NextShell()) { + // + //------------------------------------------------------------ + // 2 + Standard_Integer cpasbon; + Standard_Real parmin, aD2, aSP; + IntCurveSurface_TransitionOnCurve aTC; + TopAbs_State aState; + // + parmin = RealLast(); + // + bFlag=Standard_False; + if (aF1!=aF2) { + FaceNormal(aF1, aU1, aV1, aDN1); + FaceNormal(aF2, aU2, aV2, aDN2); + aSP=1.-aDN1*aDN2; + if (aSP < 1.e-5) { + bFlag=!bFlag; } } - //------------------------------------------------------------ - - Standard_Real parmin = RealLast(); - - if(A.SquareDistance(B)<0.000001) { + // + aD2=A.SquareDistance(B); + if(aD2<0.000001 || bFlag) { B.SetCoord(A.X()+1,A.Y()+1,A.Z()+1); } - Standard_Integer cpasbon = 0; + // + cpasbon = 0; gp_Vec AB(A,B); - + // do { switch (cpasbon) { @@ -119,45 +158,35 @@ void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& So gp_Lin L(A,gp_Dir(AB)); //-- cout<<"\npoint A "< 1.e+100 && L.Direction().IsParallel(gp_Dir(0.,0.,1.),1.e-8)) { if (iFlag==2) { - //modified by NIZNHY-PKV Thu Nov 14 15:06:16 2002 t myState = 4; return; } @@ -476,4 +503,26 @@ Standard_Real GetAddToParam(const gp_Lin& L, } return Par - P; } +//======================================================================= +//function : FaceNormal +//purpose : +//======================================================================= +void FaceNormal (const TopoDS_Face& aF, + const Standard_Real U, + const Standard_Real V, + gp_Dir& aDN) +{ + gp_Pnt aPnt ; + gp_Vec aD1U, aD1V, aN; + Handle(Geom_Surface) aS; + aS=BRep_Tool::Surface(aF); + aS->D1 (U, V, aPnt, aD1U, aD1V); + aN=aD1U.Crossed(aD1V); + aN.Normalize(); + aDN.SetXYZ(aN.XYZ()); + if (aF.Orientation() == TopAbs_REVERSED){ + aDN.Reverse(); + } + return; +} diff --git a/src/BRepTest/BRepTest_OtherCommands.cxx b/src/BRepTest/BRepTest_OtherCommands.cxx index a632c060a8..b6cccba7e2 100755 --- a/src/BRepTest/BRepTest_OtherCommands.cxx +++ b/src/BRepTest/BRepTest_OtherCommands.cxx @@ -327,6 +327,50 @@ static Standard_Integer MakeShell(Draw_Interpretor& , Standard_Integer , const c return 0; } +//======================================================================= +//function : xbounds +//purpose : +//======================================================================= +Standard_Integer xbounds(Draw_Interpretor& di, Standard_Integer n, const char** a) +{ + if (n<2) { + di << "Usage : " << a[0] << " face" << "\n"; + return 0; + } + // + + Standard_Real aUMin, aUMax, aVMin, aVMax; + TopoDS_Shape aS; + TopoDS_Face aF; + // + aS=DBRep::Get(a[1]); + if (aS.IsNull()) { + di << " null shapes is not allowed here\n"; + return 0; + } + if (aS.ShapeType()!=TopAbs_FACE) { + di << " shape" << a[1] <<" must be a face\n"; + return 0; + } + // + aF=*((TopoDS_Face*)&aS); + // + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); + // + TCollection_AsciiString aStr; + TCollection_AsciiString sUMin(aUMin); + TCollection_AsciiString sUMax(aUMax); + TCollection_AsciiString sVMin(aVMin); + TCollection_AsciiString sVMax(aVMax); + // + aStr=aStr+sUMin + "\n"; + aStr=aStr+sUMax + "\n"; + aStr=aStr+sVMin + "\n"; + aStr=aStr+sVMax + "\n"; + di < RmTol) { + //modified by NIZNHY-PKV Thu May 12 12:25:17 2011f + b2Sol=Standard_False; + if (R>dO1O2+TolTang) { + Standard_Real aX2, aTol2; + // + aTol2=Tol*Tol; + aX2=4.*(R*R-dO1O2*dO1O2); + if (aX2>aTol2) { + b2Sol=!b2Sol; + } + } + if(dO1O2 > RmTol && !b2Sol) { + //if(dO1O2 > RmTol) { + //modified by NIZNHY-PKV Thu May 12 12:25:20 2011t Standard_Real dx=dO1O2; Standard_Real dy=0.0; //(RpTol*RpTol-dx*dx); //Patch !!! dy=(dy>=0.0)? Sqrt(dy) : 0.0; diff --git a/src/IntTools/IntTools_EdgeEdge.cxx b/src/IntTools/IntTools_EdgeEdge.cxx index 5d257e58b8..f86dafb5d0 100755 --- a/src/IntTools/IntTools_EdgeEdge.cxx +++ b/src/IntTools/IntTools_EdgeEdge.cxx @@ -55,6 +55,7 @@ #include #include #include +#include //======================================================================= //function : IntTools_EdgeEdge::IntTools_EdgeEdge @@ -516,11 +517,8 @@ aCurveFrom->D0(t, aPFrom); Handle(Geom_Curve)aCurveTo=BRep_Tool::Curve (myCTo.Edge(), f, l); - //modified by NIZNHY-PKV Mon Jun 8 09:52:09 2009f - //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo); aProjector.Init(aCurveTo, myTminTo, myTmaxTo); aProjector.Perform(aPFrom); - //modified by NIZNHY-PKV Mon Jun 8 09:53:00 2009t aNbProj=aProjector.NbPoints(); // if (myCTo.GetType()==GeomAbs_Circle) { @@ -567,11 +565,8 @@ } } - //modified by NIZNHY-PKV Mon Jun 8 09:54:19 2009f - //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo); aProjector.Init(aCurveTo, myTminTo, myTmaxTo); aProjector.Perform(aPFrom); - //modified by NIZNHY-PKV Mon Jun 8 09:55:11 2009t // Standard_Integer j, aNbPoints; // @@ -585,11 +580,8 @@ } aCurveFrom->D0 (tt, aPFrom); - //modified by NIZNHY-PKV Mon Jun 8 09:54:52 2009f - //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo); aProjector.Init(aCurveTo, myTminTo, myTmaxTo); aProjector.Perform(aPFrom); - //modified by NIZNHY-PKV Mon Jun 8 09:55:07 2009t aNbPoints=aProjector.NbPoints(); if (aNbPoints) { break; @@ -863,11 +855,8 @@ } } // - //modified by NIZNHY-PKV Mon Jun 8 09:55:42 2009f - //aProjector.Init(aPm2, aCurveFrom, myTminFrom, myTmaxFrom); aProjector.Init(aCurveFrom, myTminFrom, myTmaxFrom); aProjector.Perform(aPm2); - //modified by NIZNHY-PKV Mon Jun 8 09:56:12 2009t Standard_Integer aNbPoints=aProjector.NbPoints(); if (aNbPoints) { Standard_Real aDD=aProjector.LowerDistance(); @@ -982,7 +971,6 @@ } } // - //modified by NIZNHY-PKV Wed May 13 11:08:46 2009f if (aCT1==GeomAbs_Circle && aCT2==GeomAbs_Circle) { Standard_Boolean bIsDone, bIsParallel; Standard_Integer aNbExt; @@ -1016,7 +1004,6 @@ } } } - //modified by NIZNHY-PKV Wed May 13 11:08:51 2009t // // Prepare values of arguments for the interval [ta, tb] pri=IntTools::PrepareArgs (myCFrom, tb, ta, myDiscret, myDeflection, anArgs); @@ -1133,11 +1120,8 @@ gp_Pnt aP1; aCurveFrom->D0 (aT1, aP1); GeomAPI_ProjectPointOnCurve aProjector; - //modified by NIZNHY-PKV Mon Jun 8 09:56:53 2009f - //aProjector.Init(aP1, aCurveTo, myTminTo, myTmaxTo); aProjector.Init(aCurveTo, myTminTo, myTmaxTo); aProjector.Perform(aP1); - //modified by NIZNHY-PKV Mon Jun 8 09:57:12 2009t aNbPoints=aProjector.NbPoints(); found=1; if (!aNbPoints) { @@ -1149,11 +1133,8 @@ tt=aT1-myEpsT; } aCurveFrom->D0 (tt, aP1); - //modified by NIZNHY-PKV Mon Jun 8 09:57:34 2009f - //aProjector.Init(aP1, aCurveTo, myTminTo, myTmaxTo); aProjector.Init(aCurveTo, myTminTo, myTmaxTo); aProjector.Perform(aP1); - //modified by NIZNHY-PKV Mon Jun 8 09:57:51 2009t aNbPoints=aProjector.NbPoints(); if (aNbPoints) { found=1; @@ -1456,12 +1437,9 @@ if(!isfirst || !islast) { if(isfirst) { aTx1 = aTF1; - //modified by NIZNHY-PKV Mon Jun 8 09:59:27 2009f - //GeomAPI_ProjectPointOnCurve aProjector(Curve1->Value(aTx1), Curve2, aTF2, aTL2); GeomAPI_ProjectPointOnCurve aProjector; aProjector.Init(Curve2, aTF2, aTL2); aProjector.Perform(Curve1->Value(aTx1)); - //modified by NIZNHY-PKV Mon Jun 8 10:00:12 2009t // if(aProjector.NbPoints() > 0) aTx2 = aProjector.LowerDistanceParameter(); @@ -1476,12 +1454,9 @@ if(islast) { aTx1 = aTL1; - //modified by NIZNHY-PKV Mon Jun 8 10:00:24 2009f - //GeomAPI_ProjectPointOnCurve aProjector(Curve1->Value(aTx1), Curve2, aTF2, aTL2); GeomAPI_ProjectPointOnCurve aProjector; aProjector.Init(Curve2, aTF2, aTL2); aProjector.Perform(Curve1->Value(aTx1)); - //modified by NIZNHY-PKV Mon Jun 8 10:00:26 2009t if(aProjector.NbPoints() > 0) aTx2 = aProjector.LowerDistanceParameter(); else { @@ -1587,11 +1562,8 @@ GeomAPI_ProjectPointOnCurve aProjector; Standard_Real aMidPar, aMidDist; aMidPar = (aTF1 + aTL1) * 0.5; - //modified by NIZNHY-PKV Mon Jun 8 10:01:32 2009f - //aProjector.Init(Curve1->Value(aMidPar), Curve2, aTF2, aTL2); aProjector.Init(Curve2, aTF2, aTL2); aProjector.Perform(Curve1->Value(aMidPar)); - //modified by NIZNHY-PKV Mon Jun 8 10:02:09 2009t if(aProjector.NbPoints() > 0) { aMidDist=aProjector.LowerDistance(); if(aMidDist * aMidDist < aDist2 || !istouch) { @@ -1675,13 +1647,17 @@ //======================================================================= void IntTools_EdgeEdge::ComputeLineLine() { - Standard_Real Tolang2 = 1.e-16; - Standard_Real Tol2 = myCriteria*myCriteria; - Standard_Boolean IsParallel = Standard_False, IsCoincide = Standard_False; - myIsDone = Standard_True; - + Standard_Boolean IsParallel, IsCoincide; + Standard_Real Tolang2, Tol2; gp_Pnt P11, P12, P21, P22; - + // + myIsDone = Standard_True; + // + IsParallel = Standard_False; + IsCoincide = Standard_False; + Tolang2 = 1.e-16; + Tol2 = myCriteria*myCriteria; + // gp_Lin C1 = myCFrom.Line(); gp_Lin C2 = myCTo.Line(); const gp_Dir& D1 = C1.Position().Direction(); @@ -1756,7 +1732,26 @@ if(IsParallel) { return; } - + // + //modified by NIZNHY-PKV Tue Mar 29 08:29:14 2011f + { + TopoDS_Iterator aIt1, aIt2; + // + aIt1.Initialize(myEdge1); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aV1=aIt1.Value(); + aIt2.Initialize(myEdge2); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aV2=aIt2.Value(); + if (aV2.IsSame(aV1)) { + // the two straight lines have commpn vertex + return; + } + } + } + } + //modified by NIZNHY-PKV Tue Mar 29 08:29:16 2011t + // Standard_Real aSin2 = 1. - aCos*aCos; gp_Pnt O1 = C1.Location(); gp_Pnt O2 = C2.Location(); @@ -1779,7 +1774,7 @@ if(d2 > Tol2) { return; } - + // IntTools_CommonPrt aCommonPrt; aCommonPrt.SetEdge1(myCFrom.Edge()); aCommonPrt.SetEdge2(myCTo.Edge()); diff --git a/src/STEPControl/STEPControl_ActorRead.cxx b/src/STEPControl/STEPControl_ActorRead.cxx index 6b0dd4853e..3d02b542ea 100755 --- a/src/STEPControl/STEPControl_ActorRead.cxx +++ b/src/STEPControl/STEPControl_ActorRead.cxx @@ -131,7 +131,11 @@ static void DumpWhatIs(const TopoDS_Shape& S) { nbFaces = 0, nbWires = 0, nbEdges = 0, - nbVertexes = 0; + nbVertexes = 0, + nbCompounds = 0; + + if (S.ShapeType() == TopAbs_COMPOUND) + nbCompounds++; for( ; itL.More(); itL.Next() ) { TopoDS_Iterator it( itL.Value() ); @@ -140,6 +144,8 @@ static void DumpWhatIs(const TopoDS_Shape& S) { if ( !aMapOfShape.Add(aSubShape) ) continue; aListOfShape.Append(aSubShape); + if (aSubShape.ShapeType() == TopAbs_COMPOUND) + nbCompounds++; if (aSubShape.ShapeType() == TopAbs_SOLID) nbSolids++; if (aSubShape.ShapeType() == TopAbs_SHELL) { @@ -158,6 +164,7 @@ static void DumpWhatIs(const TopoDS_Shape& S) { } } #ifdef DEB + cout << "//What is?// NB COMPOUNDS: " << nbCompounds << endl; cout << "//What is?// NB SOLIDS: " << nbSolids << endl; cout << "//What is?// NB SHELLS: " << nbShells << endl; cout << "//What is?// OPEN SHELLS: " << nbOpenShells << endl; @@ -169,6 +176,13 @@ static void DumpWhatIs(const TopoDS_Shape& S) { #endif } +namespace { + // Set global var to inform outer methods that current representation item is non-manifold. + // The better way is to pass this information via binder or via TopoDS_Shape itself, however, + // this is very specific info to do so... + Standard_Boolean NM_DETECTED = Standard_False; +}; + // ============================================================================ // Method : STEPControl_ActorRead::STEPControl_ActorRead () // Purpose : Empty constructor @@ -515,7 +529,19 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, TopoDS_Shape theResult = TransferBRep::ShapeResult (binder); if (!theResult.IsNull()) { Result1 = theResult; - B.Add(Cund, theResult); + // [BEGIN] ssv: OCCT#22436: extra compound in NMSSR case + if (NM_DETECTED && Result1.ShapeType() == TopAbs_COMPOUND) + { + TopoDS_Iterator it(Result1); + for ( ; it.More(); it.Next() ) + { + TopoDS_Shape aSubShape = it.Value(); + B.Add(Cund, aSubShape); + } + } + else + B.Add(Cund, theResult); + // [END] ssv: OCCT#22436: extra compound in NMSSR case nbComponents++; } } @@ -547,7 +573,19 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, theResult = TransferBRep::ShapeResult (binder); if (!theResult.IsNull()) { Result1 = theResult; - B.Add(Cund, theResult); + // [BEGIN] ssv: OCCT#22436: extra compound in NMSSR case + if (NM_DETECTED && Result1.ShapeType() == TopAbs_COMPOUND) + { + TopoDS_Iterator it(Result1); + for ( ; it.More(); it.Next() ) + { + TopoDS_Shape aSubShape = it.Value(); + B.Add(Cund, aSubShape); + } + } + else + B.Add(Cund, theResult); + // [END] ssv: OCCT#22436: extra compound in NMSSR case nbShapes++; } } @@ -688,6 +726,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han const Handle(Transfer_TransientProcess)& TP, Standard_Boolean& isBound) { + NM_DETECTED = Standard_False; Handle(TransferBRep_ShapeBinder) shbinder; if(!Recognize(sr)) return shbinder; @@ -717,6 +756,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han Standard_Boolean isManifold = Standard_True; if ( isNMMode && sr->IsKind(STANDARD_TYPE(StepShape_NonManifoldSurfaceShapeRepresentation)) ) { isManifold = Standard_False; + NM_DETECTED = Standard_True; #ifdef DEB Standard_Integer NMSSRItemsLen = sr->Items()->Length(); cout << "NMSSR with " << NMSSRItemsLen << " items detected" << endl; @@ -727,6 +767,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han Standard_Integer isIDeasMode = Interface_Static::IVal("read.step.ideas"); if (isNMMode && myNMTool.IsIDEASCase() && isIDeasMode) { isManifold = Standard_False; + NM_DETECTED = Standard_True; #ifdef DEB cout << "I-DEAS post processing for non-manifold topology ENABLED" << endl; #endif @@ -1592,22 +1633,12 @@ Standard_Boolean STEPControl_ActorRead::ComputeTransformation (const Handle(Step Handle(Geom_Axis2Placement) theTarg; StepToGeom_MakeAxis2Placement::Convert(trg,theTarg); if ( oldSRContext != TargContext ) PrepareUnits(oldSRContext,TP); - + gp_Ax3 ax3Orig(theOrig->Ax2()); gp_Ax3 ax3Targ(theTarg->Ax2()); - //ax3Orig - defines CS for component(always is equal to (0 0 0 ))(related product from NAUO) - //ax3Targ - defines place of component in assemby CS (relating product + // ne pas se tromper de sens ! - - - gp_Trsf aTrsf2; - gp_Ax3 anAxis(gp_Pnt(0.,0.,0.), gp::DZ(), gp::DX());; - aTrsf2.SetTransformation(anAxis,ax3Orig); - gp_Trsf aTrsf3; - aTrsf3.SetTransformation(ax3Targ,anAxis); - - Trsf = aTrsf3 * aTrsf2; - + Trsf.SetTransformation(ax3Targ, ax3Orig); return Trsf.Form() != gp_Identity; }