]> OCCT Git - occt-copy.git/commitdiff
0031641: Modeling Algorithms - IntCurvesFace_ShapeIntersector incorrect result CR31641
authorabulyche <abulyche@opencascade.com>
Tue, 17 Aug 2021 12:29:56 +0000 (15:29 +0300)
committerabulyche <abulyche@opencascade.com>
Thu, 19 Aug 2021 10:56:32 +0000 (13:56 +0300)
Added command "intcshape" to BRepTest_OtherCommands.cxx for testing algorithm IntCurvesFace_ShapeIntersector

src/BRepTest/BRepTest_OtherCommands.cxx

index 682d7243ea354c3afdbf4d516760b1161b7c2510..9038559712194c6cfc2fa441d3cd552349bb4734 100644 (file)
@@ -20,6 +20,7 @@
 #include <Draw_Interpretor.hxx>
 #include <DBRep.hxx>
 #include <DrawTrSurf.hxx>
+#include <Draw_Viewer.hxx>
 
 #include <string.h>
 #include <stdio.h>
@@ -40,6 +41,7 @@
 #include <Geom_Line.hxx>
 
 #include <IntCurvesFace_Intersector.hxx>
+#include <IntCurvesFace_ShapeIntersector.hxx>
 
 #include <TopAbs.hxx>
 #include <TopAbs_Orientation.hxx>
@@ -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  : 
 //=======================================================================