0026172: Visualization, AIS_LocalContext - locally selected object should not stay...
[occt.git] / src / QABugs / QABugs_19.cxx
index 110efd9..f131aab 100755 (executable)
 #include <DBRep.hxx>
 #include <DrawTrSurf.hxx>
 #include <ViewerTest.hxx>
+#include <V3d_View.hxx>
 #include <TopoDS_Shape.hxx>
 #include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
 #include <AIS_TexturedShape.hxx>
 #include <Image_PixMap.hxx>
 #include <Image_Color.hxx>
@@ -38,8 +40,9 @@
 #include <cstdio>
 #include <cmath>
 #include <iostream>
-#include <OSD_PerfMeter.hxx>
 #include <OSD_Timer.hxx>
+#include <OSD_Parallel.hxx>
+#include <OSD_PerfMeter.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
 #include <BRepPrimAPI_MakeSphere.hxx>
 #include <BRepAlgo_Cut.hxx>
@@ -48,6 +51,7 @@
 #include <TCollection_HAsciiString.hxx>
 #include <GeomFill_Trihedron.hxx>
 #include <BRepOffsetAPI_MakePipe.hxx>
+#include <Standard_Atomic.hxx>
 
 #include <Standard_Version.hxx>
 
@@ -155,33 +159,23 @@ static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*
   return 0;
 }
 
-#ifdef HAVE_TBB
-
-#include <Standard_Atomic.hxx>
-#include <tbb/blocked_range.h>
-#include <tbb/parallel_for.h>
-
 class IncrementerDecrementer
 {
 public:
     IncrementerDecrementer (Standard_Integer* theVal, Standard_Boolean thePositive) : myVal (theVal), myPositive (thePositive)
     {}
-    void operator() (const tbb::blocked_range<size_t>& r) const
+    void operator() (const size_t) const
     {
-        if (myPositive)
-            for (size_t i = r.begin(); i != r.end(); ++i)
-                Standard_Atomic_Increment (myVal);
-        else
-            for (size_t i = r.begin(); i != r.end(); ++i)
-                Standard_Atomic_Decrement (myVal);
+      if ( myPositive )
+        Standard_Atomic_Increment(myVal);
+      else
+        Standard_Atomic_Decrement(myVal);
     }
 private:
     Standard_Integer*   myVal;
-    Standard_Boolean   myPositive;
+    Standard_Boolean    myPositive;
 };
-#endif
 
-#ifdef HAVE_TBB
 static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
 {
   int aSum = 0;
@@ -199,26 +193,16 @@ static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*
   const int N = 1 << 24; //big enough to ensure concurrency
 
   //increment
-  tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, true));
+  OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, true));
   QCOMPARE (aSum, N);
 
   //decrement
-  tbb::parallel_for (tbb::blocked_range<size_t> (0, N), IncrementerDecrementer (&aSum, false));
+  OSD_Parallel::For(0, N, IncrementerDecrementer (&aSum, false));
   QCOMPARE (aSum, 0);
 
   return 0;
 }
 
-#else /* HAVE_TBB */
-
-static Standard_Integer OCC22980 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char **argv)
-{
-  di << "Test skipped: command " << argv[0] << " requires TBB library\n";
-  return 0;
-}
-
-#endif /* HAVE_TBB */
-
 #include <TDocStd_Application.hxx>
 #include <XCAFApp_Application.hxx>
 #include <TDocStd_Document.hxx>
@@ -328,7 +312,7 @@ static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const To
     di << "Not Done1 " << "\n";
     return Standard_False;
   }
-  const TopoDS_Shape& step1ModifiedShape = transformer1.ModifiedShape(originalWire);
+  TopoDS_Shape step1ModifiedShape = transformer1.ModifiedShape(originalWire);
   
   BRepExtrema_DistShapeShape distShapeShape1(grossPlateFace,step1ModifiedShape,Extrema_ExtFlag_MIN);
   if(!distShapeShape1.IsDone())
@@ -346,7 +330,7 @@ static Standard_Boolean OCC23774Test(const TopoDS_Face& grossPlateFace, const To
     di << "Not Done1 \n";
     return Standard_False;
   }
-  const TopoDS_Shape& step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
+  TopoDS_Shape step2ModifiedShape = transformer1.ModifiedShape(step1ModifiedShape);
 
   //This is identity matrix for values but for type is gp_Rotation ?!
   gp_Trsf2d mirror11 = mirror1;
@@ -394,102 +378,148 @@ static Standard_Integer OCC23774(Draw_Interpretor& di, Standard_Integer n, const
 #include <Geom_BSplineSurface.hxx>
 #include <Draw.hxx>
 #include <OSD_Thread.hxx>
-static void GeomConvertTest (Draw_Interpretor& di, Standard_Integer theTargetNbUPoles, Standard_CString theFileName)
-{
-       Handle(Geom_Surface) aSurf = DrawTrSurf::GetSurface(theFileName);
-       GeomConvert_ApproxSurface aGAS (aSurf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
-       if (!aGAS.IsDone()) {
-               di << "ApproxSurface is not done!" << "\n";
-               return;
-       }
-       const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
-       if (aBSurf.IsNull()) {
-               di << "BSplineSurface is not created!" << "\n";
-               return;
-       }
-       di << "Number of UPoles:" << aBSurf->NbUPoles() << "\n";
-       QCOMPARE (aBSurf->NbUPoles(), theTargetNbUPoles);
-}
 
-struct aData {
-       Draw_Interpretor* di;
-       Standard_Integer nbupoles;
-       Standard_CString filename;
+struct GeomConvertTest_Data
+{
+  Standard_Integer nbupoles;
+  Handle(Geom_Surface) surf;
 };
 
-Standard_EXPORT Standard_Address convert(Standard_Address data)
+static Standard_Address GeomConvertTest (Standard_Address data)
 {
-       aData* info = (aData*) data;
-       GeomConvertTest(*(info->di),info->nbupoles,info->filename);
-       return NULL;
+  GeomConvertTest_Data* info = (GeomConvertTest_Data*)data;
+
+  GeomConvert_ApproxSurface aGAS (info->surf, 1e-4, GeomAbs_C1, GeomAbs_C1, 9, 9, 100, 1);
+  if (!aGAS.IsDone()) {
+    cout << "Error: ApproxSurface is not done!" << endl;
+    return Standard_False;
+  }
+  const Handle(Geom_BSplineSurface)& aBSurf = aGAS.Surface();
+  if (aBSurf.IsNull()) {
+    cout << "Error: BSplineSurface is not created!" << endl;
+    return Standard_False;
+  }
+  cout << "Number of UPoles:" << aBSurf->NbUPoles();
+  if (aBSurf->NbUPoles() == info->nbupoles)
+  {
+    cout << ": OK" << endl;
+    return data; // any non-null pointer
+  }
+  else
+  {
+    cout << ": Error, must be " << info->nbupoles << endl;
+    return 0;
+  }
 }
 
 static Standard_Integer OCC23952sweep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-       if (argc != 3) {
-               di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
-               return 1;
-       }
-       struct aData aStorage;
-       aStorage.di = &di;
-       aStorage.nbupoles = Draw::Atoi(argv[1]); 
-       aStorage.filename = argv[2];
+  if (argc != 3) {
+    cout << "Error: invalid number of arguments" << endl;
+    return 1;
+  }
 
-       OSD_Thread aThread1(convert);
-       aThread1.Run(&aStorage);
-       GeomConvertTest(di,aStorage.nbupoles,aStorage.filename);
-       cout << "result of thread: " << aThread1.Wait() << endl;
+  struct GeomConvertTest_Data aStorage;
+  aStorage.nbupoles = Draw::Atoi(argv[1]); 
+  aStorage.surf = DrawTrSurf::GetSurface(argv[2]);
+  if (aStorage.surf.IsNull())
+  {
+    cout << "Error: " << argv[2] << " is not a DRAW surface!" << endl;
+    return 0;
+  }
 
-       return 0;
-}
+  // start conversion in several threads
+  const int NBTHREADS = 100;
+  OSD_Thread aThread[NBTHREADS];
+  for (int i=0; i < NBTHREADS; i++)
+  { 
+    aThread[i].SetFunction (GeomConvertTest);
+    if (!aThread[i].Run(&aStorage))
+      di << "Error: Cannot start thread << " << i << "\n";
+  }
 
-#include <GeomInt_IntSS.hxx>
-static void GeomIntSSTest (Draw_Interpretor& di, Standard_Integer theNbSol, Standard_CString theFileName1, Standard_CString theFileName2)
-{
-       Handle(Geom_Surface) aSurf1 = DrawTrSurf::GetSurface(theFileName1);
-       Handle(Geom_Surface) aSurf2 = DrawTrSurf::GetSurface(theFileName2);
-       GeomInt_IntSS anInter;
-       anInter.Perform(aSurf1, aSurf2, Precision::Confusion(), Standard_True);
-       if (!anInter.IsDone()) {
-               di << "An intersection is not done!" << "\n";
-               return;
-       }
+  // check results
+  for (int i=0; i < NBTHREADS; i++)
+  { 
+    Standard_Address aResult = 0;
+    if (!aThread[i].Wait(aResult))
+      di << "Error: Failed waiting for thread << " << i << "\n";
+    if (!aResult) 
+      di << "Error: wrong number of poles in thread " << i << "!\n";
+  }
 
-       di << "Number of Lines:" << anInter.NbLines() << "\n";
-       QCOMPARE (anInter.NbLines(), theNbSol);
+  return 0;
 }
 
-struct aNewData {
-       Draw_Interpretor* di;
-       Standard_Integer nbsol;
-       Standard_CString filename1;
-       Standard_CString filename2;
+#include <GeomInt_IntSS.hxx>
+
+struct GeomIntSSTest_Data
+{
+  Standard_Integer nbsol;
+  Handle(Geom_Surface) surf1, surf2;
 };
-Standard_EXPORT Standard_Address convert_inter(Standard_Address data)
+
+static Standard_Address GeomIntSSTest (Standard_Address data)
 {
-       aNewData* info = (aNewData*) data;
-       GeomIntSSTest(*(info->di),info->nbsol,info->filename1,info->filename2);
-       return NULL;
+  GeomIntSSTest_Data* info = (GeomIntSSTest_Data*)data;
+  GeomInt_IntSS anInter;
+  anInter.Perform (info->surf1, info->surf2, Precision::Confusion(), Standard_True);
+  if (!anInter.IsDone()) {
+    cout << "An intersection is not done!" << endl;
+    return 0;
+  }
+
+  cout << "Number of Lines:" << anInter.NbLines();
+  if (anInter.NbLines() == info->nbsol)
+  {
+    cout << ": OK" << endl;
+    return data; // any non-null pointer
+  }
+  else
+  {
+    cout << ": Error, must be " << info->nbsol << endl;
+    return 0;
+  }
 }
 
 static Standard_Integer OCC23952intersect (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-       if (argc != 4) {
-               di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
-               return 1;
-       }
-       struct aNewData aStorage;
-       aStorage.di = &di;
-       aStorage.nbsol = Draw::Atoi(argv[1]); 
-       aStorage.filename1 = argv[2];
-       aStorage.filename2 = argv[3];
+  if (argc != 4) {
+    cout << "Error: invalid number of arguments" << endl;
+    return 1;
+  }
 
-       OSD_Thread aThread1(convert_inter);
-       aThread1.Run(&aStorage);
-       GeomIntSSTest(di,aStorage.nbsol,aStorage.filename1,aStorage.filename2);
-       cout << "result of thread: " << aThread1.Wait() << endl;
+  struct GeomIntSSTest_Data aStorage;
+  aStorage.nbsol = Draw::Atoi(argv[1]); 
+  aStorage.surf1 = DrawTrSurf::GetSurface(argv[2]);
+  aStorage.surf2 = DrawTrSurf::GetSurface(argv[3]);
+  if (aStorage.surf1.IsNull() || aStorage.surf2.IsNull())
+  {
+    cout << "Error: Either " << argv[2] << " or " << argv[3] << " is not a DRAW surface!" << endl;
+    return 0;
+  }
 
-       return 0;
+  // start conversion in several threads
+  const int NBTHREADS = 100;
+  OSD_Thread aThread[NBTHREADS];
+  for (int i=0; i < NBTHREADS; i++)
+  { 
+    aThread[i].SetFunction (GeomIntSSTest);
+    if (!aThread[i].Run(&aStorage))
+      di << "Error: Cannot start thread << " << i << "\n";
+  }
+
+  // check results
+  for (int i=0; i < NBTHREADS; i++)
+  { 
+    Standard_Address aResult = 0;
+    if (!aThread[i].Wait(aResult))
+      di << "Error: Failed waiting for thread << " << i << "\n";
+    if (!aResult) 
+      di << "Error: wrong number of intersections in thread " << i << "!\n"; 
+  }
+
+  return 0;
 }
 
 #include <Geom_SurfaceOfRevolution.hxx> 
@@ -1380,6 +1410,39 @@ static Standard_Integer OCC24086 (Draw_Interpretor& di, Standard_Integer argc, c
        return 0;
 }
 
+#include <Geom_Circle.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Extrema_ExtPC.hxx>
+#include <gp_Cylinder.hxx>
+#include <ElSLib.hxx>
+static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+  if (argc != 1) {
+    di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
+    return 1;
+  }
+
+  gp_Pnt aP3D( -1725.97, 843.257, -4.22741e-013 );
+  gp_Ax2 aAxis( gp_Pnt( 0, 843.257, 0 ), gp_Dir( 0, -1, 0 ), gp::DX() );
+  Handle(Geom_Circle) aCircle = new Geom_Circle( aAxis, 1725.9708621929999 );
+  GeomAdaptor_Curve aC3D( aCircle );
+
+  Extrema_ExtPC aExtPC( aP3D, aC3D );
+  //Standard_Real aParam = (aExtPC.Point(1)).Parameter();
+  gp_Pnt aProj = (aExtPC.Point(1)).Value();
+  di << "Projected point: X = " << aProj.X() << "; Y = " << aProj.Y() << "; Z = " << aProj.Z() << "\n";
+
+  // Result of deviation
+  gp_Ax2 aCylAxis( gp_Pnt( 0, 2103.87, 0 ), -gp::DY(), -gp::DX() );
+  gp_Cylinder aCylinder( aCylAxis, 1890. );
+
+  Standard_Real aU = 0., aV = 0.;
+  ElSLib::Parameters( aCylinder, aProj, aU, aV );
+  di << "Parameters on cylinder: U = " << aU << "; V = " << aV << "\n";
+  
+  return 0;
+}
+
 #include <Extrema_FuncExtPS.hxx>
 #include <math_FunctionSetRoot.hxx>
 #include <math_Vector.hxx>
@@ -1740,7 +1803,7 @@ struct QABugs_NHandleClass
 #include <STEPCAFControl_Writer.hxx>
 static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-  if (argc != 1) {
+  if (argc != 2) {
     di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
     return 1;
   }
@@ -1762,11 +1825,52 @@ static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, c
     return 1;
   }
 
-  writer.Write("test_box.step");
+  writer.Write(argv[1]);
   return 0;
 }
 
 
+//=======================================================================
+//function : OCC23950
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+  if (argc != 2) {
+    di << "Usage : " << argv[0] << " step_file\n";
+    return 1;
+  }
+
+  Handle(TDocStd_Document) aDoc = new TDocStd_Document ("dummy");
+  TopoDS_Shape s6 = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
+  gp_Trsf t0;
+  TopLoc_Location location0 (t0);
+
+  TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
+  XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape (lab1, s6);
+  TDataStd_Name::Set(lab1, "Point1");
+
+  TDF_Label labelA0 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->NewShape ();
+  TDataStd_Name::Set(labelA0, "ASSEMBLY");
+
+  TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
+
+  Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
+  XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
+  XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
+
+  STEPControl_StepModelType mode = STEPControl_AsIs;
+  STEPCAFControl_Writer writer;
+  if (! writer.Transfer (aDoc, mode))
+  {
+    di << "The document cannot be translated or gives no result" << "\n";
+    return 1;
+  }
+
+  writer.Write (argv[1]);
+  return 0;
+}
+
 //=======================================================================
 //function : OCC24622
 //purpose  : The command tests sourcing Image_PixMap to AIS_TexturedShape
@@ -2144,11 +2248,11 @@ static TopoDS_Shape CreateTestShape (int& theShapeNb)
 #include <TNaming_Builder.hxx>
 static Standard_Integer OCC24931 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
-  if (argc != 1) {
+  if (argc != 2) {
     di << "Usage: " << argv[0] << " invalid number of arguments"<<"\n";
     return 1;
   }
-  TCollection_ExtendedString aFileName ("testdocument.xml");
+  TCollection_ExtendedString aFileName (argv[1]);
   PCDM_StoreStatus aSStatus  = PCDM_SS_Failure;
 
   Handle(TDocStd_Application) anApp = new AppStd_Application;
@@ -2222,6 +2326,12 @@ static Standard_Integer OCC24834 (Draw_Interpretor& di, Standard_Integer n, cons
     return 1;
   }
 
+  int i = sizeof (char*);  
+  if (i > 4) {
+    std::cout << "64-bit architecture is not supported.\n";
+    return 0;
+  }
+
   NCollection_List<MyStubObject> aList;
   const Standard_Integer aSmallBlockSize = 40;
   const Standard_Integer aLargeBlockSize = 1500000;
@@ -2319,7 +2429,1356 @@ static Standard_Integer OCC24889 (Draw_Interpretor& theDI,
   return 0;
 }
 
+#include <math_GlobOptMin.hxx>
+#include <math_MultipleVarFunctionWithHessian.hxx>
+//=======================================================================
+//function : OCC25004
+//purpose  : Check extremaCC on Branin function.
+//=======================================================================
+// Function is:
+// f(u,v) = a*(v - b*u^2 + c*u-r)^2+s(1-t)*cos(u)+s
+// Standard borders are:
+// -5 <= u <= 10
+//  0 <= v <= 15
+class BraninFunction : public math_MultipleVarFunctionWithHessian
+{
+public:
+  BraninFunction()
+  {
+    a = 1.0;
+    b = 5.1 / (4.0 * M_PI * M_PI);
+    c = 5.0 / M_PI;
+    r = 6.0;
+    s = 10.0;
+    t = 1.0 / (8.0 *  M_PI);
+  }
+  virtual Standard_Integer NbVariables() const
+  {
+    return 2;
+  }
+  virtual Standard_Boolean Value(const math_Vector& X,Standard_Real& F)
+  {
+    Standard_Real u = X(1);
+    Standard_Real v = X(2);
+
+    Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
+    Standard_Real aLnPt = s * (1 - t) * cos(u); // Linear part of funcrtion.
+    F = a * aSqPt * aSqPt + aLnPt + s;
+    return Standard_True;
+  }
+  virtual Standard_Boolean Gradient(const math_Vector& X,math_Vector& G)
+  {
+    Standard_Real u = X(1);
+    Standard_Real v = X(2);
+
+    Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
+    G(1) = 2 * a * aSqPt * (c - 2 * b * u) - s * (1 - t) * sin(u);
+    G(2) = 2 * a * aSqPt;
+
+    return Standard_True;
+  }
+  virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
+  {
+    Value(X,F);
+    Gradient(X,G);
+
+    return Standard_True;
+  }
+  virtual Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G,math_Matrix& H)
+  {
+    Value(X,F);
+    Gradient(X,G);
+
+    Standard_Real u = X(1);
+    Standard_Real v = X(2);
+
+    Standard_Real aSqPt = (v - b * u * u + c * u - r); // Square Part of function.
+    Standard_Real aTmpPt = c - 2 * b *u; // Tmp part.
+    H(1,1) = 2 * a * aTmpPt * aTmpPt - 4 * a * b * aSqPt - s * (1 - t) * cos(u);
+    H(1,2) = 2 * a * aTmpPt;
+    H(2,1) = H(1,2);
+    H(2,2) = 2 * a;
+
+    return Standard_True;
+  }
+
+private:
+  // Standard parameters.
+  Standard_Real a, b, c, r, s, t;
+};
+
+static Standard_Integer OCC25004 (Draw_Interpretor& theDI,
+                                  Standard_Integer /*theNArg*/,
+                                  const char** /*theArgs*/)
+{
+  math_MultipleVarFunction* aFunc = new BraninFunction();
+
+  math_Vector aLower(1,2), aUpper(1,2);
+  aLower(1) = -5;
+  aLower(2) =  0;
+  aUpper(1) = 10;
+  aUpper(2) = 15;
+
+  Standard_Integer aGridOrder = 16;
+  math_Vector aFuncValues(1, aGridOrder * aGridOrder);
+
+  Standard_Real aLipConst = 0;
+  math_Vector aCurrPnt1(1, 2), aCurrPnt2(1, 2);
+
+  // Get Lipshitz constant estimation on regular grid.
+  Standard_Integer i, j, idx = 1;
+  for(i = 1; i <= aGridOrder; i++)
+  {
+    for(j = 1; j <= aGridOrder; j++)
+    {
+      aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
+      aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
+
+      aFunc->Value(aCurrPnt1, aFuncValues(idx));
+      idx++;
+    }
+  }
+
+  Standard_Integer k, l;
+  Standard_Integer idx1, idx2;
+  for(i = 1; i <= aGridOrder; i++)
+  for(j = 1; j <= aGridOrder; j++)
+  for(k = 1; k <= aGridOrder; k++)
+  for(l = 1; l <= aGridOrder; l++)
+    {
+      if (i == k && j == l) 
+        continue;
+
+      aCurrPnt1(1) = aLower(1) + (aUpper(1) - aLower(1)) * (i - 1) / (aGridOrder - 1.0);
+      aCurrPnt1(2) = aLower(2) + (aUpper(2) - aLower(2)) * (j - 1) / (aGridOrder - 1.0);
+      idx1 = (i - 1) * aGridOrder + j;
+
+      aCurrPnt2(1) = aLower(1) + (aUpper(1) - aLower(1)) * (k - 1) / (aGridOrder - 1.0);
+      aCurrPnt2(2) = aLower(2) + (aUpper(2) - aLower(2)) * (l - 1) / (aGridOrder - 1.0);
+      idx2 = (k - 1) * aGridOrder + l;
+
+      aCurrPnt1.Add(-aCurrPnt2);
+      Standard_Real dist = aCurrPnt1.Norm();
+
+      Standard_Real C = Abs(aFuncValues(idx1) - aFuncValues(idx2)) / dist;
+      if (C > aLipConst)
+        aLipConst = C;
+    }
+
+  math_GlobOptMin aFinder(aFunc, aLower, aUpper, aLipConst);
+  aFinder.Perform();
+  //(-pi , 12.275), (pi , 2.275), (9.42478, 2.475)
+
+  Standard_Real anExtValue = aFinder.GetF();
+  theDI << "F = " << anExtValue << "\n";
+
+  Standard_Integer aNbExt = aFinder.NbExtrema();
+  theDI << "NbExtrema = " << aNbExt << "\n";
+
+  return 0;
+}
+
+#include <OSD_Environment.hxx>
+#include <Plugin.hxx>
+#include <Plugin_Macro.hxx>
+#include <Resource_Manager.hxx>
+
+#define THE_QATEST_DOC_FORMAT       "My Proprietary Format"
+
+#define QA_CHECK(theDesc, theExpr, theValue) \
+{\
+  const bool isTrue = !!(theExpr); \
+  std::cout << theDesc << (isTrue ? " TRUE  " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is FAIL\n"); \
+}
+
+class Test_TDocStd_Application : public TDocStd_Application
+{
+public:
+
+  static void initGlobalPluginMap (const TCollection_AsciiString& thePlugin,
+                                   const TCollection_AsciiString& theSaver,
+                                   const TCollection_AsciiString& theLoader)
+  {
+    const Handle(Resource_Manager)& aManager = Plugin::AdditionalPluginMap();
+    aManager->SetResource ((theSaver  + ".Location").ToCString(), thePlugin.ToCString());
+    aManager->SetResource ((theLoader + ".Location").ToCString(), thePlugin.ToCString());
+  }
+
+  Test_TDocStd_Application (const TCollection_AsciiString& thePlugin,
+                            const TCollection_AsciiString& theSaver,
+                            const TCollection_AsciiString& theLoader)
+  {
+    initGlobalPluginMap (thePlugin, theSaver, theLoader);
+
+    // explicitly initialize resource manager
+    myResources = new Resource_Manager ("");
+    myResources->SetResource ("xml.FileFormat", THE_QATEST_DOC_FORMAT);
+    myResources->SetResource (THE_QATEST_DOC_FORMAT ".Description",     "Test XML Document");
+    myResources->SetResource (THE_QATEST_DOC_FORMAT ".FileExtension",   "xml");
+    myResources->SetResource (THE_QATEST_DOC_FORMAT ".StoragePlugin",   theSaver.ToCString());
+    myResources->SetResource (THE_QATEST_DOC_FORMAT ".RetrievalPlugin", theLoader.ToCString());
+  }
+
+  virtual Standard_CString ResourcesName() { return ""; }
+  virtual void Formats (TColStd_SequenceOfExtendedString& theFormats) { theFormats.Clear(); }
+};
+
+//=======================================================================
+//function : OCC24925
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC24925 (Draw_Interpretor& theDI,
+                                  Standard_Integer  theArgNb,
+                                  const char**      theArgVec)
+{
+  if (theArgNb != 2
+   && theArgNb != 5)
+  {
+    std::cout << "Error: wrong syntax! See usage:\n";
+    theDI.PrintHelp (theArgVec[0]);
+    return 1;
+  }
+
+  Standard_Integer anArgIter = 1;
+  TCollection_ExtendedString aFileName = theArgVec[anArgIter++];
+  TCollection_AsciiString    aPlugin   = "TKXml";
+  TCollection_AsciiString    aSaver    = "03a56820-8269-11d5-aab2-0050044b1af1"; // XmlStorageDriver   in XmlDrivers.cxx
+  TCollection_AsciiString    aLoader   = "03a56822-8269-11d5-aab2-0050044b1af1"; // XmlRetrievalDriver in XmlDrivers.cxx
+  if (anArgIter < theArgNb)
+  {
+    aPlugin = theArgVec[anArgIter++];
+    aSaver  = theArgVec[anArgIter++];
+    aLoader = theArgVec[anArgIter++];
+  }
+
+  PCDM_StoreStatus  aSStatus = PCDM_SS_Failure;
+  PCDM_ReaderStatus aRStatus = PCDM_RS_OpenError;
+
+  Handle(TDocStd_Application) anApp = new Test_TDocStd_Application (aPlugin, aSaver, aLoader);
+  {
+    Handle(TDocStd_Document) aDoc;
+    anApp->NewDocument (THE_QATEST_DOC_FORMAT, aDoc);
+    TDF_Label aLab = aDoc->Main();
+    TDataStd_Integer::Set (aLab, 0);
+    TDataStd_Name::Set (aLab, "QABugs_19.cxx");
+
+    aSStatus = anApp->SaveAs (aDoc, aFileName);
+    anApp->Close (aDoc);
+  }
+  QA_CHECK ("SaveAs()", aSStatus == PCDM_SS_OK, true);
+
+  {
+    Handle(TDocStd_Document) aDoc;
+    aRStatus = anApp->Open (aFileName, aDoc);
+    anApp->Close (aDoc);
+  }
+  QA_CHECK ("Open()  ", aRStatus == PCDM_RS_OK, true);
+  return 0;
+}
+
+//=======================================================================
+//function : OCC25043
+//purpose  :
+//=======================================================================
+#include <BRepAlgoAPI_Check.hxx>
+static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
+                                  Standard_Integer  theArgNb,
+                                  const char**      theArgVec)
+{
+  if (theArgNb != 2) {
+    theDI << "Usage: " << theArgVec[0] << " shape\n";
+    return 1;
+  }
+  
+  TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
+  if (aShape.IsNull()) 
+  {
+    theDI << theArgVec[1] << " shape is NULL\n";
+    return 1;
+  }
+  
+  BRepAlgoAPI_Check  anAlgoApiCheck(aShape, Standard_True, Standard_True);
+
+  if (!anAlgoApiCheck.IsValid())
+  {
+    BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
+    for (; anCheckIter.More(); anCheckIter.Next())
+    {
+      const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
+      const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
+      BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
+      for (; aFaultyIter.More(); aFaultyIter.Next())
+      {
+        const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
+        
+        Standard_Boolean anIsFaultyShapeFound = Standard_False;
+        TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
+        for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
+        {
+          if (anExp.Current().IsEqual(aFaultyShape))
+            anIsFaultyShapeFound = Standard_True;
+        }
+        
+        if (!anIsFaultyShapeFound)
+        {
+          theDI << "Error. Faulty Shape is NOT found in source shape.\n";
+          return 0;
+        }
+        else 
+        {
+          theDI << "Info. Faulty shape if found in source shape\n";
+        }
+      }
+    }
+  }
+  else 
+  {
+    theDI << "Error. Problems are not detected. Test is not performed.";
+  }
+
+  return 0;
+}
+
+//=======================================================================
+//function : OCC24606
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
+                                  Standard_Integer  theArgNb,
+                                  const char**      theArgVec)
+{
+  if (theArgNb > 1)
+  {
+    std::cerr << "Error: incorrect number of arguments.\n";
+    theDI << "Usage : " << theArgVec[0] << "\n";
+    return 1;
+  }
+
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (aView.IsNull())
+  {
+    std::cerr << "Errro: no active view, please call 'vinit'.\n";
+    return 1;
+  }
+
+  aView->DepthFitAll();
+  aView->FitAll();
+
+  return 0;
+}
+
+//=======================================================================
+//function : OCC23010
+//purpose  :
+//=======================================================================
+#include <STEPCAFControl_Reader.hxx>
 
+class mOcafApplication : public TDocStd_Application
+{
+  void Formats(TColStd_SequenceOfExtendedString& Formats)
+  {
+    Formats.Append(TCollection_ExtendedString("mOcafApplication"));
+  }
+  Standard_CString ResourcesName()
+  {
+    return Standard_CString("Resources");
+  }
+};
+
+static Standard_Integer OCC23010 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+  if (argc != 2) {
+    di << "Usage: " << argv[0] << " invalid number of arguments" << "\n";
+    return 1;
+  }
+  std::string fileName=argv[1];
+  mOcafApplication *mCasApp = new mOcafApplication();
+  Handle(TDocStd_Document) doc;
+  mCasApp->NewDocument("MDTV-XCAF", doc);
+  STEPCAFControl_Reader stepReader;
+  IFSelect_ReturnStatus status = stepReader.ReadFile (fileName.c_str());
+  if (status != IFSelect_RetDone)
+    return false;
+  stepReader.SetColorMode(Standard_True);
+  stepReader.SetLayerMode(Standard_True);
+  stepReader.SetNameMode(Standard_True);
+  stepReader.Transfer(doc); // ERROR HERE!!!
+  delete mCasApp;
+  return 0;
+}
+
+//=======================================================================
+//function : OCC25202
+//purpose  :
+//=======================================================================
+#include <ShapeBuild_ReShape.hxx>
+static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
+                                  Standard_Integer theArgN,
+                                  const char** theArgVal)
+{
+  //  0      1    2     3     4     5     6 
+  //reshape res shape numF1 face1 numF2 face2
+  if(theArgN < 7)
+    {
+      theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
+      return 1;
+    }
+
+  TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
+  const Standard_Integer  aNumOfRE1 = Draw::Atoi(theArgVal[3]),
+                          aNumOfRE2 = Draw::Atoi(theArgVal[5]);
+  TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
+              aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
+
+  if(aShape.IsNull())
+  {
+    theDI << theArgVal[2] << " is null shape\n";
+    return 1;
+  }
+
+  if(aShapeForRepl1.IsNull())
+  {
+    theDI << theArgVal[4] << " is not a replaced type\n";
+    return 1;
+  }
+
+  if(aShapeForRepl2.IsNull())
+  {
+    theDI << theArgVal[6] << " is not a replaced type\n";
+    return 1;
+  }
+
+
+  TopoDS_Shape aReplacedShape;
+  ShapeBuild_ReShape aReshape;
+
+  //////////////////// explode (begin)
+  TopTools_MapOfShape M;
+  M.Add(aShape);
+  Standard_Integer aNbShapes = 0;
+  for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
+    {
+      const TopoDS_Shape& Sx = ex.Current();
+      Standard_Boolean added = M.Add(Sx);
+      if (added)
+       {
+         aNbShapes++;
+         if(aNbShapes == aNumOfRE1)
+           {
+             aReplacedShape = Sx;
+
+             aReshape.Replace(aReplacedShape, aShapeForRepl1);
+           }
+
+         if(aNbShapes == aNumOfRE2)
+           {
+             aReplacedShape = Sx;
+
+             aReshape.Replace(aReplacedShape, aShapeForRepl2);
+           }
+       }
+    }
+  //////////////////// explode (end)
+
+  if(aReplacedShape.IsNull())
+    {
+      theDI << "There is not any shape for replacing.\n";
+    }
+
+  DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
+
+  return 0;
+}
+
+#include <ShapeFix_Wireframe.hxx>
+//=======================================================================
+//function : OCC7570
+//purpose  : 
+//=======================================================================
+static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
+{
+  if (n != 2) {
+    di<<"Usage: "<<a[0]<<" invalid number of arguments"<<"\n";
+    return 1;
+  }
+  TopoDS_Shape in_shape (DBRep::Get (a[1]));
+  ShapeFix_Wireframe fix_tool (in_shape);
+  fix_tool.ModeDropSmallEdges () = Standard_True;
+  fix_tool.SetPrecision (1.e+6);
+  fix_tool.SetLimitAngle (0.01);
+  fix_tool.FixSmallEdges ();
+  TopoDS_Shape new_shape = fix_tool.Shape ();
+  return 0;
+}
+
+#include <AIS_TypeFilter.hxx>
+//=======================================================================
+//function : OCC25340
+//purpose  : 
+//=======================================================================
+static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
+                                 Standard_Integer  /*theArgNb*/,
+                                 const char** /*theArgVec*/)
+{
+  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
+  {
+    std::cerr << "Error: No opened viewer!\n";
+    return 1;
+  }
+  Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
+  aCtx->AddFilter (aFilter);
+  return 0;
+}
+
+//=======================================================================
+//function : OCC24826
+//purpose  :
+//=======================================================================
+class ParallelTest_Saxpy
+{
+public:
+  typedef NCollection_Array1<Standard_Real> Vector;
+
+  //! Constructor
+  ParallelTest_Saxpy(const Vector& theX, Vector& theY, Standard_Real theScalar)
+  : myX(theX),
+    myY(theY),
+    myScalar(theScalar)
+  {
+  }
+
+  //! Dummy calculation
+  void operator() (const Standard_Integer theIndex) const
+  {
+    myY(theIndex) = myScalar * myX(theIndex) + myY(theIndex);
+  }
+
+private:
+  ParallelTest_Saxpy( const ParallelTest_Saxpy& );
+  ParallelTest_Saxpy& operator =( ParallelTest_Saxpy& );
+
+private:
+  const Vector&       myX;
+  Vector&             myY;
+  const Standard_Real myScalar;
+};
+
+//---------------------------------------------------------------------
+static Standard_Integer OCC24826(Draw_Interpretor& theDI,
+                                 Standard_Integer  trheArgc,
+                                 const char**      theArgv)
+{
+  if ( trheArgc != 2 )
+  {
+    theDI << "Usage: "
+          << theArgv[0]
+          << " vec_length\n";
+    return 1;
+  }
+
+  // Generate data;
+  Standard_Integer aLength = Draw::Atoi(theArgv[1]);
+
+  NCollection_Array1<Standard_Real> aX (0, aLength - 1);
+  NCollection_Array1<Standard_Real> anY(0, aLength - 1);
+
+  for ( Standard_Integer i = 0; i < aLength; ++i )
+  {
+    aX(i) = anY(i) = (Standard_Real) i;
+  }
+
+  OSD_Timer aTimer;
+
+  aTimer.Start();
+
+  //! Serial proccesing
+  for ( Standard_Integer i = 0; i < aLength; ++i )
+  {
+    anY(i) = 1e-6 * aX(i) + anY(i);
+  }
+
+  aTimer.Stop();
+  cout << "Processing time (sequential mode):\n";
+  aTimer.Show();
+
+  const ParallelTest_Saxpy aFunctor(aX, anY, 1e-6);
+
+  aTimer.Reset();
+  aTimer.Start();
+
+  // Parallel processing
+  OSD_Parallel::For(0, aLength, aFunctor);
+
+  aTimer.Stop();
+  cout << "Processing time (parallel mode):\n";
+  aTimer.Show();
+
+  return 0;
+}
+
+/*****************************************************************************/
+
+#include <GeomAPI_IntSS.hxx>
+//=======================================================================
+//function : OCC25100
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+  if (argc < 2)
+  {
+    di << "the method requires a shape name\n";
+    return 1;
+  }
+
+  TopoDS_Shape S = DBRep::Get(argv[1]);
+  if ( S.IsNull() )
+  {
+    di << "Shape is empty" << "\n";
+    return 1;
+  }
+  
+  TopExp_Explorer aFaceExp(S, TopAbs_FACE);
+  const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
+
+  GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
+
+  if (!anIntersector.IsDone())
+  {
+    di << "Error. Intersection is not done\n";
+    return 1;
+  }
+
+  di << "Test complete\n";
+
+  return 0;
+}
+
+//=======================================================================
+//function : OCC25348
+//purpose  : 
+//=======================================================================
+static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
+                                 Standard_Integer  /*theArgNb*/,
+                                 const char** /*theArgVec*/)
+{
+  Handle(NCollection_IncAllocator) anAlloc1;
+  NCollection_List<int> aList1(anAlloc1);
+  for (int i=0; i < 10; i++)
+  {
+    Handle(NCollection_IncAllocator) anAlloc2;
+    NCollection_List<int> aList2(anAlloc2);
+    aList2.Append(i);
+    aList1.Assign(aList2);
+  }
+  theDI << "Test complete\n";
+  return 0;
+}
+
+#include <IntCurvesFace_ShapeIntersector.hxx>
+#include <BRepBndLib.hxx>
+//=======================================================================
+//function : OCC25413
+//purpose  : 
+//=======================================================================
+static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
+{
+  if (narg != 2) {
+    di << "Usage: " << a[0] << " invalid number of arguments" << "\n";
+    return 1;
+  }
+  TopoDS_Shape aShape = DBRep::Get (a[1]);
+
+  IntCurvesFace_ShapeIntersector Inter;
+  Inter.Load(aShape, Precision::Confusion());
+
+  Bnd_Box aBndBox;
+  BRepBndLib::Add(aShape, aBndBox);
+
+  gp_Dir aDir(0., 1., 0.);
+  const int N = 250;
+  Standard_Real xMin = aBndBox.CornerMin().X();
+  Standard_Real zMin = aBndBox.CornerMin().Z();
+  Standard_Real xMax = aBndBox.CornerMax().X();
+  Standard_Real zMax = aBndBox.CornerMax().Z();
+  Standard_Real xStep = (xMax - xMin) / N;
+  Standard_Real zStep = (zMax - zMin) / N;
+
+  for (Standard_Real x = xMin; x <= xMax; x += xStep)
+    for (Standard_Real z = zMin; z <= zMax; z += zStep)
+    {
+      gp_Pnt aPoint(x, 0.0, z);
+      gp_Lin aLine(aPoint, aDir);
+      Inter.PerformNearest(aLine, -100., 100.);
+    }
+  return 0;
+}
+
+
+#include <BOPAlgo_PaveFiller.hxx>
+//
+#include <BRepAlgoAPI_BooleanOperation.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+//
+#include <BOPTools.hxx>
+//
+#include <BOPCol_MapOfShape.hxx>
+#include <BOPCol_ListOfShape.hxx>
+//=======================================================================
+//function : OCC25446
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC25446 (Draw_Interpretor& theDI, 
+                                  Standard_Integer argc, 
+                                  const char ** argv)
+{
+  if (argc != 5) {
+    theDI << "Usage: OCC25446 res b1 b2 op\n";
+    return 1;
+  }
+  //
+  TopoDS_Shape aS1 = DBRep::Get(argv[2]);
+  if (aS1.IsNull()) {
+    theDI << argv[2] << " shape is NULL\n";
+    return 1;
+  }
+  //
+  TopoDS_Shape aS2 = DBRep::Get(argv[3]);
+  if (aS2.IsNull()) {
+    theDI << argv[3] << " shape is NULL\n";
+    return 1;
+  }
+  //
+  Standard_Integer iOp;
+  BOPAlgo_Operation aOp;
+  //
+  iOp = Draw::Atoi(argv[4]);
+  if (iOp < 0 || iOp > 4) {
+    theDI << "Invalid operation type\n";
+    return 1;
+  }
+  aOp = (BOPAlgo_Operation)iOp;
+  //
+  Standard_Integer iErr;
+  BOPCol_ListOfShape aLS;
+  BOPAlgo_PaveFiller aPF;
+  //
+  aLS.Append(aS1);
+  aLS.Append(aS2);
+  aPF.SetArguments(aLS);
+  //
+  aPF.Perform();
+  iErr = aPF.ErrorStatus();
+  if (iErr) {
+    theDI << "Intersection failed with error status: " << iErr << "\n";
+    return 1;
+  }
+  //
+  BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
+  // 
+  switch (aOp) {
+  case BOPAlgo_COMMON:
+    pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
+    break;
+  case BOPAlgo_FUSE:
+    pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
+    break;
+  case BOPAlgo_CUT:
+    pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
+    break;
+  case BOPAlgo_CUT21:
+    pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
+    break;
+  case BOPAlgo_SECTION:
+    pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
+    break;
+  default:
+    break;
+  }
+  //
+  iErr = pBuilder->ErrorStatus();
+  if (!pBuilder->IsDone()) {
+    theDI << "BOP failed with error status: " << iErr << "\n";
+    return 1;
+  }
+  //
+  const TopoDS_Shape& aRes = pBuilder->Shape();
+  DBRep::Set(argv[1], aRes);
+  //
+  BOPCol_MapOfShape aMapArgs, aMapShape;
+  BOPCol_MapIteratorOfMapOfShape aIt;
+  Standard_Boolean bIsDeletedHist, bIsDeletedMap;
+  TopAbs_ShapeEnum aType;
+  //
+  BOPTools::MapShapes(aS1, aMapArgs);
+  BOPTools::MapShapes(aS2, aMapArgs);
+  BOPTools::MapShapes(aRes, aMapShape);
+  //
+  aIt.Initialize(aMapArgs);
+  for (; aIt.More(); aIt.Next()) {
+    const TopoDS_Shape& aS = aIt.Value();
+    aType = aS.ShapeType();
+    if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE || 
+          aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
+      continue;
+    }
+    //
+    bIsDeletedHist = pBuilder->IsDeleted(aS);
+    bIsDeletedMap = !aMapShape.Contains(aS) &&
+      (pBuilder->Modified(aS).Extent() == 0);
+    //
+    if (bIsDeletedHist != bIsDeletedMap) {
+      theDI << "Error. Wrong value of IsDeleted flag.\n";
+      return 1;
+    }
+  }
+  //
+  theDI << "Test complete\n";
+  return 0;
+}
+
+//====================================================
+// Auxiliary functor class for the command OCC25545;
+// it gets access to a vertex with the given index and
+// checks that X coordinate of the point is equal to index;
+// if it is not so then a data race is reported.
+//====================================================
+struct OCC25545_Functor
+{
+  OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
+    : myShapeVec(&theShapeVec),
+      myIsRaceDetected(0)
+  {}
+
+  void operator()(size_t i) const
+  {
+    if (!myIsRaceDetected) {
+      const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
+      gp_Pnt aP = BRep_Tool::Pnt (aV);
+      if (aP.X () != static_cast<double> (i)) {
+        Standard_Atomic_Increment(&myIsRaceDetected);
+      }
+    }
+  }
+
+  const std::vector<TopoDS_Shape>* myShapeVec;
+  mutable volatile int myIsRaceDetected;
+};
+
+//=======================================================================
+//function : OCC25545
+//purpose  : Tests data race when concurrently accessing TopLoc_Location::Transformation()
+//=======================================================================
+#ifdef HAVE_TBB
+static Standard_Integer OCC25545 (Draw_Interpretor& di, 
+                                  Standard_Integer, 
+                                  const char **)
+{
+  // Place vertices in a vector, giving the i-th vertex the
+  // transformation that translates it on the vector (i,0,0) from the origin.
+  size_t n = 1000;
+  std::vector<TopoDS_Shape> aShapeVec (n);
+  std::vector<TopLoc_Location> aLocVec (n);
+  TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
+  aShapeVec[0] = aShape;
+  for (size_t i = 1; i < n; ++i) {
+    gp_Trsf aT;
+    aT.SetTranslation (gp_Vec (1, 0, 0));
+    aLocVec[i] = aLocVec[i - 1] * aT;
+    aShapeVec[i] = aShape.Moved (aLocVec[i]);
+  }
+
+  // Evaluator function will access vertices geometry
+  // concurrently
+  OCC25545_Functor aFunc(aShapeVec);
+
+  //concurrently process
+  tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
+  QVERIFY (!aFunc.myIsRaceDetected);
+  return 0;
+}
+#else
+static Standard_Integer OCC25545 (Draw_Interpretor&, 
+                                  Standard_Integer, 
+                                  const char **argv)
+{
+  cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
+  return 0;
+}
+#endif
+
+//=======================================================================
+//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;
+}
+
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
+#include <TColStd_DataMapOfIntegerInteger.hxx>
+#include <OSD.hxx>
+#include <ShapeFix_Wire.hxx>
+#include <ShapeExtend_Status.hxx>
+#ifdef WNT
+#define EXCEPTION ...
+#else
+#define EXCEPTION Standard_Failure
+#endif
+
+static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)&   theFix,
+                                       const Standard_Boolean theIs3d)
+{
+       for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++)
+       {
+               Standard_Boolean isFound;
+               if (theIs3d)
+                       isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i );
+               else
+                       isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i );
+               if (isFound) return ShapeExtend_Status(i);
+       }
+       return ShapeExtend_OK;
+}
+
+//===================
+//function : OCC24881
+//purpose  : 
+//===================
+static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
+{
+  if (narg < 2) {
+    di<<"Usage: "<<a[0]<<" invalid number of arguments"<<"\n";
+    return 1;
+  }
+//    cout <<"FileName1: " << argv[1] <<endl;
+
+  TopoDS_Shape aShape = DBRep::Get (a[1]);
+
+    OSD::SetSignal();
+    Handle(ShapeFix_Wire) aWireFix = new ShapeFix_Wire;
+
+    // map FixStatus - NbSuchStatuses
+    TColStd_DataMapOfIntegerInteger aStatusNbDMap;
+    Standard_Integer nbFixed=0, nbOk=0;
+
+//Begin: STEP 7
+    ShapeExtend_Status aStatus=ShapeExtend_OK;
+    try {
+       TopExp_Explorer aFaceExplorer(aShape, TopAbs_FACE);
+       for (; aFaceExplorer.More(); aFaceExplorer.Next())
+       {
+               TopoDS_Shape aFace = aFaceExplorer.Current();
+               // loop on wires
+               TopoDS_Iterator aWireItr(aFace);
+               for (; aWireItr.More(); aWireItr.Next() )
+               {
+                       Standard_Boolean wasOk = Standard_False;
+                       TopoDS_Wire aSrcWire = TopoDS::Wire(aWireItr.Value());
+
+                       aWireFix->Load (aSrcWire);
+                       aWireFix->SetFace (TopoDS::Face(aFace));
+                       aWireFix->FixReorder(); //correct order is a prerequisite
+                       // fix 3d
+                       if (!aWireFix->FixGaps3d())
+                       {
+                               // not fixed, why?
+                               aStatus = getStatusGap(aWireFix, Standard_True);
+                               if (aStatus == ShapeExtend_OK)
+                                       wasOk = Standard_True;
+                               else
+                               {
+                                       // keep 3d fail status
+                                       if (aStatusNbDMap.IsBound (aStatus))
+                                               aStatusNbDMap(aStatus)++;
+                                       else
+                                               aStatusNbDMap.Bind(aStatus,1);
+                                       continue;
+                               }
+                       }
+
+                       // fix 2d
+                       if (aWireFix->FixGaps2d())
+                               nbFixed++;
+                       else
+                       {
+                               aStatus = getStatusGap(aWireFix, Standard_False);
+                               if (aStatus == ShapeExtend_OK)
+                               {
+                                       if (wasOk)
+                                       {
+                                               nbOk++;
+                                               continue;
+                                       }
+                                       else
+                                               nbFixed++;
+                               }
+                               else
+                               {
+                                       // keep 2d fail status
+                                       Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL;
+                                       if (aStatusNbDMap.IsBound (aStatus2d))
+                                               aStatusNbDMap(aStatus2d)++;
+                                       else
+                                               aStatusNbDMap.Bind(aStatus2d,1);
+                                       continue;
+                               }
+                       }
+               }
+       }
+//End: STEP 7
+     } catch (EXCEPTION) {
+       di << "Exception is raised = " <<aStatus << "\n";
+       return 1;
+
+     }
+// report what is done
+
+       if (nbFixed)
+       {
+               di <<"Fix_FillGaps_Fixed: nbFixed = "<<nbFixed <<"\n";
+
+       }    
+       if (nbOk)
+       {
+               di << "Fix_FillGaps_NothingToDo" <<"\n";
+
+       }
+       TColStd_DataMapIteratorOfDataMapOfIntegerInteger aStatusItr(aStatusNbDMap);
+       for (; aStatusItr.More(); aStatusItr.Next()) 
+       {
+               switch ((ShapeExtend_Status) aStatusItr.Key()) 
+               {
+                       // treat 3d status
+                       case ShapeExtend_FAIL1:
+                       di <<"Fix_FillGaps_3dNoCurveFail, nb failed = ";
+                       break;
+                       case ShapeExtend_FAIL2:
+                       di <<"Fix_FillGaps_3dSomeGapsFail, nb failed = ";
+                       break;
+                       default:
+                       // treat 2d status
+                       switch ((ShapeExtend_Status) (aStatusItr.Key() - ShapeExtend_FAIL)) 
+                       {
+                               case ShapeExtend_FAIL1:
+                               di <<"Fix_FillGaps_2dNoPCurveFail, nb failed = ";
+                               break;
+                               case ShapeExtend_FAIL2:
+                               di <<"Fix_FillGaps_2dSomeGapsFail, nb failed = ";
+                               break;
+                               default:
+                               break;
+                       }
+               }
+               di <<aStatusItr.Value()<< "\n";
+       }
+       di << ("__________________________________") <<"\n";
+
+  return 0;
+}
+
+//=======================================================================
+//function : OCC26172
+//purpose  :
+//=======================================================================
+static Standard_Integer OCC26172 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
+{
+  if (theArgNb != 1)
+  {
+    std::cerr << "Error: wrong number of arguments! See usage:\n";
+    theDI.PrintHelp (theArgVec[0]);
+    return 1;
+  }
+
+  Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+  if(anAISContext.IsNull())
+  {
+    std::cerr << "Error: no active view. Please call vinit.\n";
+    return 1;
+  }
+
+  gp_Pnt aStart (100, 100, 100);
+  gp_Pnt anEnd (300, 400, 600);
+  BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
+  TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  Handle(AIS_Shape) aTestAISShape = new AIS_Shape (anEdge);
+  anAISContext->Display (aTestAISShape);
+
+  // 2. activate it in selection modes
+  TColStd_SequenceOfInteger aModes;
+  aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
+  aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_EDGE));
+
+  anAISContext->OpenLocalContext();
+  anAISContext->Deactivate (aTestAISShape);
+  anAISContext->Load (aTestAISShape, -1, true);
+  for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
+  {
+    anAISContext->Activate (aTestAISShape, aModes (anIt));
+  }
+
+  // select entities in vertex selection mode
+  Handle(SelectMgr_Selection) aSelection = aTestAISShape->Selection (aModes (1));
+  for (aSelection->Init(); aSelection->More(); aSelection->Next())
+  {
+    Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
+    if (anEntity.IsNull())
+    {
+      continue;
+    }
+
+    Handle(SelectMgr_EntityOwner) anOwner =
+      Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
+
+    if (anOwner.IsNull())
+    {
+      continue;
+    }
+
+    anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
+  }
+
+  // select entities in edge selection mode
+  aSelection = aTestAISShape->Selection (aModes (2));
+  for (aSelection->Init(); aSelection->More(); aSelection->Next())
+  {
+    Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
+    if (anEntity.IsNull())
+    {
+      continue;
+    }
+
+    Handle(SelectMgr_EntityOwner) anOwner =
+      Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
+
+    if (anOwner.IsNull())
+    {
+      continue;
+    }
+
+    anAISContext->LocalContext()->AddOrRemoveSelected (anOwner);
+  }
+
+  // deactivate vertex mode and check clearing of outdated selection
+  anAISContext->Deactivate (aTestAISShape, aModes (1));
+  anAISContext->LocalContext()->ClearOutdatedSelection (aTestAISShape, true);
+
+  return 0;
+}
+
+#include <IntTools_Context.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+
+//=======================================================================
+//function : xprojponf
+//purpose  : 
+//=======================================================================
+Standard_Integer xprojponf (Draw_Interpretor& di, 
+                            Standard_Integer n, 
+                            const char** a)
+{
+  if (n!=3) {
+    di<<" use xprojponf p f \n";
+    return 0;
+  }
+  // 
+  gp_Pnt aP, aPS;
+  TopoDS_Shape aS;
+  TopoDS_Face aF;
+  Handle(IntTools_Context) aCtx;
+  //
+  DrawTrSurf::GetPoint(a[1], aP);
+  aS=DBRep::Get(a[2]);
+  //
+  if (aS.IsNull()) {
+    di<<" null shape is not allowed\n";
+    return 0;
+  }
+  //
+  if (aS.ShapeType()!=TopAbs_FACE) {
+    di << a[2] << " not a face\n";
+    return 0;
+  }
+  //
+  aCtx=new IntTools_Context;
+  //
+  aF=TopoDS::Face(aS);
+  GeomAPI_ProjectPointOnSurf& aPPS=aCtx->ProjPS(aF);
+  //
+  aPPS.Perform(aP);
+  if (!aPPS.IsDone()) {
+    di<<" projection failed\n";
+    return 0;
+  }
+  //
+  aPS=aPPS.NearestPoint();
+  di<< " point px " << aPS.X() << " " << aPS.Y() << " " <<  aPS.Z() << "\n";
+  //
+  return 0;
+}
+
+//=======================================================================
+//function : OCC25547
+//purpose  :
+//=======================================================================
+#include <BRepMesh_CircleTool.hxx>
+
+static Standard_Boolean inspect_point(const gp_XY&        thePoint,
+                                      const gp_XY&        theCenter,
+                                      const Standard_Real theRadius)
+{
+  static Standard_Real aPrecision   = Precision::PConfusion();
+  static Standard_Real aSqPrecision = aPrecision * aPrecision;
+  const gp_XY aDistVec = thePoint - theCenter;
+  if (aDistVec.SquareModulus() - (theRadius * theRadius) < aSqPrecision)
+    return Standard_True;
+  else
+    return Standard_False;
+}
+
+static Standard_Integer OCC24923(
+  Draw_Interpretor& theDI, 
+  Standard_Integer  argc, 
+  const char **     argv)
+{
+  srand(static_cast<unsigned int>(time(NULL)));
+
+  const Standard_Real    aMaxDeviation = (argc > 1) ? Draw::Atof(argv[1]) : 0.01;
+  const Standard_Integer aPointsNb     = 10000000;
+  const Standard_Real    aMinAngle     = 5 * M_PI / 180.;
+  static Standard_Real   aSqPrecision  = Precision::PConfusion() * Precision::PConfusion();
+
+  Standard_Integer aFailedNb = 0;
+  for (Standard_Integer i = 0; i < aPointsNb; ++i)
+  {
+    gp_XY p[3];
+    for (Standard_Integer j = 0; j < 3; ++j)
+      p[j].SetCoord(((Standard_Real)rand())/RAND_MAX, ((Standard_Real)rand())/RAND_MAX);
+
+    // Check that points do not compose degenerated triangle.
+    gp_XY aVec1 = p[1] - p[0];
+    gp_XY aVec2 = p[2] - p[0];
+    if (aVec1.SquareModulus() > aSqPrecision && 
+        aVec2.SquareModulus() > aSqPrecision &&
+        (aVec1 ^ aVec2) > aMinAngle)
+    {
+      gp_XY aCenter;
+      Standard_Real aRadius;
+      if (BRepMesh_CircleTool::MakeCircle(p[0], p[1], p[2], aCenter, aRadius))
+      {
+        if (!inspect_point(p[0], aCenter, aRadius) || 
+            !inspect_point(p[1], aCenter, aRadius) || 
+            !inspect_point(p[2], aCenter, aRadius))
+        {
+         /* theDI << "Missed: " <<
+            "p1=(" << p1.X() << ", " << p1.Y() << "), " <<
+            "p2=(" << p2.X() << ", " << p2.Y() << "), " <<
+            "p3=(" << p3.X() << ", " << p3.Y() << "), " <<
+            "c=(" << aCenter.X() << ", " << aCenter.Y() << "), " <<
+            "r=" << aRadius << "\n";*/
+            
+          ++aFailedNb;
+        }
+
+        continue;
+      }
+    }
+
+    // Ensure that aPointsNb suitable for tests are generated
+    --i;
+  }
+
+  const Standard_Real aDeviation = 
+    1. - (Standard_Real)(aPointsNb - aFailedNb) / (Standard_Real)aPointsNb;
+
+  theDI << "Number of failed cases: " << aFailedNb << " (Total " << aPointsNb << ")\n";
+  if (aDeviation > aMaxDeviation)
+  {
+    theDI << "Failed. Number of incorrect results is too huge: " << 
+      aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)" << "\n";
+    return 1;
+  }
+
+  theDI << "Deviation of incorrect results is: " <<
+    aDeviation * 100 << "% (Max " << aMaxDeviation * 100 << "%)" << "\n";
+  theDI << "Test completed\n";
+  return 0;
+}
 
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
@@ -2363,7 +3822,34 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC24755", "OCC24755", __FILE__, OCC24755, group);
   theCommands.Add ("OCC24834", "OCC24834", __FILE__, OCC24834, group);
   theCommands.Add ("OCC24889", "OCC24889", __FILE__, OCC24889, group);
-  theCommands.Add ("OCC23951", "OCC23951", __FILE__, OCC23951, group);
-  theCommands.Add ("OCC24931", "OCC24931", __FILE__, OCC24931, group);
+  theCommands.Add ("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
+  theCommands.Add ("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
+  theCommands.Add ("OCC24945", "OCC24945", __FILE__, OCC24945, group);
+  theCommands.Add ("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
+  theCommands.Add ("OCC25004", "OCC25004", __FILE__, OCC25004, group);
+  theCommands.Add ("OCC24925",
+                   "OCC24925 filename [pluginLib=TKXml storageGuid retrievalGuid]"
+                   "\nOCAF persistence without setting environment variables",
+                   __FILE__, OCC24925, group);
+  theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
+  theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
+  theCommands.Add ("OCC24826,", "This test performs simple saxpy test.\n Usage: OCC24826 length", __FILE__, OCC24826, group);
+  theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
+  theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
+  theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
+  theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
+  theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
+  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 ("OCC25545", 
+                   "no args; tests data race when concurrently accessing \n"
+                   "\t\tTopLoc_Location::Transformation()",
+                   __FILE__, OCC25545, group);
+  theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
+  theCommands.Add ("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
+  theCommands.Add ("OCC26172", "OCC26172", __FILE__, OCC26172, group);
+  theCommands.Add ("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
+  theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
   return;
 }