0025547: static class mehtods not exported in BrepMesh_GeomTool
[occt.git] / src / QABugs / QABugs_19.cxx
index 62008a7..245fe29 100755 (executable)
@@ -3126,6 +3126,85 @@ static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
   return 0;
 }
 
+//=======================================================================
+//function : OCC25547
+//purpose  :
+//=======================================================================
+#include <BRepMesh_GeomTool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepAdaptor_HSurface.hxx>
+#include <BRepAdaptor_Surface.hxx>
+static Standard_Integer OCC25547(
+  Draw_Interpretor& theDI, 
+  Standard_Integer  /*argc*/, 
+  const char **     /*argv*/)
+{
+  // The general aim of this test is to prevent linkage errors due to missed
+  // Standard_EXPORT attribute for static methods.
+
+  // However, start checking the main functionality at first.
+  const Standard_Real aFirstP = 0., aLastP = M_PI;
+  Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
+  Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
+  TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
+  BRepAdaptor_Curve aAdaptor(aEdge);
+  BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
+
+  if (aGeomTool.NbPoints() == 0)
+  {
+    theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
+    return 1;
+  }
+
+  // Test static methods.
+  TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
+  BRepAdaptor_Surface aSurf(aFace);
+  Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
+
+  gp_Pnt aPnt;
+  gp_Dir aNormal;
+  if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
+  {
+    theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
+    return 1;
+  }
+
+  gp_XY aRefPnts[4] = {
+    gp_XY(-10., -10.), gp_XY(10., 10.), 
+    gp_XY(-10., 10.), gp_XY(10., -10.)
+  };
+
+  gp_Pnt2d aIntPnt;
+  Standard_Real aParams[2];
+  BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
+    aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3], 
+    aIntPnt.ChangeCoord(), aParams);
+
+  Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
+  if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
+  {
+    theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
+    return 1;
+  }
+
+  aIntFlag = BRepMesh_GeomTool::IntSegSeg(
+    aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3], 
+    Standard_False, Standard_False, aIntPnt);
+
+  aDiff = aIntPnt.Distance(gp::Origin2d());
+  if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
+  {
+    theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
+    return 1;
+  }
+
+
+  theDI << "Test complete\n";
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3187,5 +3266,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
   theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
   theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
+  theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
   return;
 }