From 59fe737420b55e62ef9a3fcdceb5173eaba7dabd Mon Sep 17 00:00:00 2001 From: abulyche Date: Tue, 17 Aug 2021 15:29:56 +0300 Subject: [PATCH] 0031641: Modeling Algorithms - IntCurvesFace_ShapeIntersector incorrect result Added command "intcshape" to BRepTest_OtherCommands.cxx for testing algorithm IntCurvesFace_ShapeIntersector --- src/BRepTest/BRepTest_OtherCommands.cxx | 90 +++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/BRepTest/BRepTest_OtherCommands.cxx b/src/BRepTest/BRepTest_OtherCommands.cxx index 682d7243ea..9038559712 100644 --- a/src/BRepTest/BRepTest_OtherCommands.cxx +++ b/src/BRepTest/BRepTest_OtherCommands.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,7 @@ #include #include +#include #include #include @@ -91,6 +93,7 @@ static static Standard_Integer emptyshape(Draw_Interpretor&, Standard_Integer, const char** ); static Standard_Integer subshape (Draw_Interpretor&, Standard_Integer, const char** ); static Standard_Integer brepintcs (Draw_Interpretor&, Standard_Integer, const char** ); +static Standard_Integer intcshape (Draw_Interpretor&, Standard_Integer, const char** ); static Standard_Integer MakeBoss (Draw_Interpretor&, Standard_Integer, const char** ); static Standard_Integer MakeShell (Draw_Interpretor&, Standard_Integer, const char** ); static Standard_Integer xbounds (Draw_Interpretor&, Standard_Integer, const char** ); @@ -119,6 +122,8 @@ void BRepTest::OtherCommands(Draw_Interpretor& theCommands) "Calcul d'intersection entre face et curve : BRepIntCS curve1 [curve2 ...] shape [res] [tol]" ,__FILE__,brepintcs,g); + theCommands.Add("intcshape", "command for testing algorithm IntCurvesFace_ShapeIntersector", + __FILE__, intcshape, g); theCommands.Add("makeboss", "create a boss on the shape myS", __FILE__, MakeBoss, g); theCommands.Add("mksh", "create a shell on Shape", __FILE__, MakeShell, g); theCommands.Add("xbounds", "xbounds face", __FILE__, xbounds, g); @@ -358,6 +363,91 @@ Standard_Integer brepintcs(Draw_Interpretor& di, Standard_Integer n, const char* return 0; } //======================================================================= +//function : intcshape +//purpose : +//======================================================================= +Standard_Integer intcshape(Draw_Interpretor& theDI, + Standard_Integer theArgNb, + const char** theArgVec) +{ + if (theArgNb < 2) { + theDI << " use intcshape Shape [Line] [Pmin] [Pmax]\n"; + return 1; + } + TopoDS_Shape aS = DBRep::Get(theArgVec[1]); + if (aS.IsNull()) { + theDI << " Null Shape is not allowed here\n"; + return 1; + } + + IntCurvesFace_ShapeIntersector anInter; + anInter.Load(aS, 1e-7); + + if (theArgNb > 2) + { + Handle(Geom_Curve) anObj = DrawTrSurf::GetCurve(theArgVec[2]); + if (anObj.IsNull()) + { + theDI << " Null curve is not allowed here\n"; + return 1; + } + Handle(Geom_Line) aL = Handle(Geom_Line)::DownCast(anObj); + Standard_Real aPMin = (theArgNb > 3) ? + Draw::Atof(theArgVec[3]) : (-RealLast()); + Standard_Real aPMax = (theArgNb > 4) ? + Draw::Atof(theArgVec[4]) : (RealLast()); + + anInter.Perform(aL->Lin(), aPMin, aPMax); + } + else + { + Draw_Viewer aDout; + theDI << "Pick positions with button \n"; + Standard_Integer anId, aX, aY, aB; + gp_Trsf aT; + gp_Pnt aP1, aP2; + aDout.Select(anId, aX, aY, aB); + + aDout.GetTrsf(anId, aT); + aT.Invert(); + Standard_Real aZ = aDout.Zoom(anId); + aP2.SetCoord((Standard_Real)aX / aZ, (Standard_Real)aY / aZ, 0.0); + aP2.Transform(aT); + aP1.SetCoord((Standard_Real)aX / aZ, (Standard_Real)aY / aZ, -1.0); + aP1.Transform(aT); + + gp_Ax1 anAxe(aP1, gp_Vec(aP1, aP2)); + anInter.Perform(anAxe, -RealLast(), RealLast()); + } + + Standard_Integer aNBPoints = 0; + for (Standard_Integer anI = 1; anI <= anInter.NbPnt(); anI++) + { + gp_Pnt aCurP = anInter.Pnt(anI); + IntCurveSurface_TransitionOnCurve aTransition = anInter.Transition(anI); + theDI << "(" << aCurP.X() << ", " << aCurP.Y() << ", " << aCurP.Z() << ") : "; + switch (aTransition) { + case IntCurveSurface_Tangent: + theDI << "Tangent\n"; + break; + case IntCurveSurface_In: + theDI << "In\n"; + break; + case IntCurveSurface_Out: + theDI << "Out\n"; + break; + default: + break; + } + aNBPoints++; + } + if (aNBPoints == 0) + { + theDI << "Points of intersections are not found\n"; + } + return 0; +} +//======================================================================= //function : MakeBoss //purpose : //======================================================================= -- 2.39.5