]> OCCT Git - occt-copy.git/commitdiff
# Added debug commands to draw Bnd_Box and Bnd_OBB
authoremv <emv@opencascade.com>
Tue, 19 May 2020 13:39:40 +0000 (16:39 +0300)
committeremv <emv@opencascade.com>
Thu, 21 May 2020 05:51:22 +0000 (08:51 +0300)
# Reverted points addition into Box of the grid cell.

src/Draw/Draw_Debug.cxx
src/Extrema/Extrema_GenExtPS.cxx
src/Extrema/Extrema_GenExtPS.hxx

index af6d6a743dbc9d9765cd55e4cabb03016d54fe83..ef5bb2a5675cfa5d50e3781ef39e1c0f9370003b 100644 (file)
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_Failure.hxx>
 
+#include <Bnd_OBB.hxx>
+#include <Bnd_Box.hxx>
+#include <Draw_Box.hxx>
+
 // This file defines global functions not declared in any public header,
 // intended for use from debugger prompt (Command Window in Visual Studio)
 
@@ -40,3 +44,47 @@ Standard_EXPORT const char* Draw_Eval (const char *theCommandStr)
     return anException.GetMessageString();
   }
 }
+
+//=======================================================================
+//function : DBRep_SetOBB
+//purpose  : Draw OBB
+//=======================================================================
+Standard_EXPORT const char* Draw_SetOBB(const char* theNameStr, void* theBox)
+{
+  if (theNameStr == 0 || theBox == 0)
+  {
+    return "Error: name or box is null";
+  }
+  try {
+    Bnd_OBB B = *(Bnd_OBB*)theBox;
+    Handle(Draw_Box) DB = new Draw_Box (B, Draw_orange);
+    Draw::Set (theNameStr, DB);
+    return theNameStr;
+  }
+  catch (Standard_Failure const& anException)
+  {
+    return anException.GetMessageString();
+  }
+}
+
+//=======================================================================
+//function : DBRep_SetBox
+//purpose  : Draw Box
+//=======================================================================
+Standard_EXPORT const char* Draw_SetBox(const char* theNameStr, void* theBox)
+{
+  if (theNameStr == 0 || theBox == 0)
+  {
+    return "Error: name or box is null";
+  }
+  try {
+    Bnd_Box B = *(Bnd_Box*)theBox;
+    Handle(Draw_Box) DB = new Draw_Box (B, Draw_orange);
+    Draw::Set (theNameStr, DB);
+    return theNameStr;
+  }
+  catch (Standard_Failure const& anException)
+  {
+    return anException.GetMessageString();
+  }
+}
index 1ed3279e60e9bfb1aeca70f95fc56e027810de55..5d28882d50851d2964004afbe3c88635bf3b88a0 100644 (file)
@@ -381,7 +381,10 @@ void Extrema_GenExtPS::BuildGrid()
 //=======================================================================
 void Extrema_GenExtPS::BuildTree()
 {
-  // The tree is not required for MINMAX mode,
+  // The tree is not required for MINMAX mode
+  if (myTarget == Extrema_ExtFlag_MINMAX)
+    return;
+
   // so fill the tree with elements with empty boxes
   if (myGridBoxSet.IsNull())
   {
@@ -392,7 +395,7 @@ void Extrema_GenExtPS::BuildTree()
       new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle));
 
     // create hierarchy of BVH trees
-    const Standard_Integer aCoeff = static_cast<Standard_Integer>(Ceiling (Sqrt (Min (myNbUSamples, myNbVSamples))));
+    const Standard_Integer aCoeff = static_cast<Standard_Integer>(Sqrt (Min (myNbUSamples, myNbVSamples)));
     const Standard_Integer aNbUT = myNbUSamples / aCoeff;
     const Standard_Integer aNbVT = myNbVSamples / aCoeff;
     const Standard_Integer aNbU = myNbUSamples / aNbUT;
@@ -427,7 +430,7 @@ void Extrema_GenExtPS::BuildTree()
     }
   }
 
-  if (myGridBoxSet->IsDirty() && myTarget != Extrema_ExtFlag_MINMAX)
+  if (myGridBoxSet->IsDirty())
   {
     // Fill the tree with the real boxes
     const Standard_Integer aNbSets = myGridBoxSet->Size();
@@ -448,10 +451,9 @@ void Extrema_GenExtPS::BuildTree()
 
         // Build box for the cell
         Bnd_Box aGridBox;
-        aGridBox.Add (myPoints->Value (iU, iV).Value());
-        aGridBox.Add (myPoints->Value (iU + 1, iV).Value());
-        aGridBox.Add (myPoints->Value (iU, iV + 1).Value());
-        aGridBox.Add (myPoints->Value (iU + 1, iV + 1).Value());
+        for (int i = 0; i < 2; ++i)
+          for (int j = 0; j < 2; ++j)
+            aGridBox.Add (myPoints->Value (iU + i * aUCoeff, iV + j * aVCoeff).Value());
         aGridBox.Enlarge (Precision::Confusion());
 
         const Extrema_POnSurf& aPMin = myPoints->Value (iU, iV);
@@ -668,6 +670,7 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
   fillSqDist (aParam10, aPoint);
   fillSqDist (aParam11, aPoint);
 
+  Standard_Boolean isFound = Standard_False;
   if (theNU != myNbUSamples && theNV != myNbVSamples &&
     (theTarget == Extrema_ExtFlag_MIN || theTarget == Extrema_ExtFlag_MINMAX))
   {
@@ -761,7 +764,8 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
 
     if (isMin)
     {
-      FindSolution (aParam);
+      if (FindSolution (aParam))
+        isFound = Standard_True;
     }
   }
 
@@ -795,18 +799,19 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
         (aParam8.GetSqrDistance() <= aDist))
     {
       // Find maximum.
-      FindSolution (aParam00);
+      if (FindSolution (aParam00))
+        isFound = Standard_True;
     }
   }
 
-  return Standard_False;
+  return isFound;
 }
 
 //=======================================================================
 //function : FindSolution
 //purpose  : 
 //=======================================================================
-void Extrema_GenExtPS::FindSolution (const Extrema_POnSurfParams &theParams)
+Standard_Boolean Extrema_GenExtPS::FindSolution (const Extrema_POnSurfParams &theParams)
 {
   math_Vector Tol (1, 2);
   Tol (1) = myTolU;
@@ -828,6 +833,7 @@ void Extrema_GenExtPS::FindSolution (const Extrema_POnSurfParams &theParams)
 
   myIsDone = Standard_True;
 
+  Standard_Boolean isFound = Standard_False;
   if (myTarget != Extrema_ExtFlag_MINMAX)
   {
     for (Standard_Integer i = aNbFuncSol + 1; i <= myF.NbExt(); ++i)
@@ -836,6 +842,7 @@ void Extrema_GenExtPS::FindSolution (const Extrema_POnSurfParams &theParams)
       if ((myTarget == Extrema_ExtFlag_MIN && aDist <= mySqDistance) ||
         (myTarget == Extrema_ExtFlag_MAX && aDist >= mySqDistance))
       {
+        isFound = Standard_True;
         if (aDist != mySqDistance)
           mySolutions.clear();
         mySolutions.push_back (Extrema_GenExtPS::ExtPSResult (myF.Point (i), aDist));
@@ -843,6 +850,11 @@ void Extrema_GenExtPS::FindSolution (const Extrema_POnSurfParams &theParams)
       }
     }
   }
+  else
+  {
+    isFound = myF.NbExt() > aNbFuncSol;
+  }
+  return isFound;
 }
 
 //=======================================================================
index 833d88b6723fdaca9910aad0923468f4fcbbae07..6452b233a7ca357f206ee6430f36646da27d0a98 100644 (file)
@@ -254,7 +254,7 @@ protected: //! @name Protected methods performing the job
   Standard_EXPORT void BuildTree();
 
   //! Looks for the solution starting at given point
-  Standard_EXPORT void FindSolution (const Extrema_POnSurfParams& theParams);
+  Standard_EXPORT Standard_Boolean FindSolution (const Extrema_POnSurfParams& theParams);
 
   //! Compute new edge parameters.
   Standard_EXPORT const Extrema_POnSurfParams&