From b062dc431dd9e6791207f6895881377f77b304d8 Mon Sep 17 00:00:00 2001 From: emv Date: Tue, 19 May 2020 16:39:40 +0300 Subject: [PATCH] # Added debug commands to draw Bnd_Box and Bnd_OBB # Reverted points addition into Box of the grid cell. --- src/Draw/Draw_Debug.cxx | 48 ++++++++++++++++++++++++++++++++ src/Extrema/Extrema_GenExtPS.cxx | 34 ++++++++++++++-------- src/Extrema/Extrema_GenExtPS.hxx | 2 +- 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/src/Draw/Draw_Debug.cxx b/src/Draw/Draw_Debug.cxx index af6d6a743d..ef5bb2a567 100644 --- a/src/Draw/Draw_Debug.cxx +++ b/src/Draw/Draw_Debug.cxx @@ -18,6 +18,10 @@ #include #include +#include +#include +#include + // 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(); + } +} diff --git a/src/Extrema/Extrema_GenExtPS.cxx b/src/Extrema/Extrema_GenExtPS.cxx index 1ed3279e60..5d28882d50 100644 --- a/src/Extrema/Extrema_GenExtPS.cxx +++ b/src/Extrema/Extrema_GenExtPS.cxx @@ -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 (BVH_Constants_LeafNodeSizeSingle)); // create hierarchy of BVH trees - const Standard_Integer aCoeff = static_cast(Ceiling (Sqrt (Min (myNbUSamples, myNbVSamples)))); + const Standard_Integer aCoeff = static_cast(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; } //======================================================================= diff --git a/src/Extrema/Extrema_GenExtPS.hxx b/src/Extrema/Extrema_GenExtPS.hxx index 833d88b672..6452b233a7 100644 --- a/src/Extrema/Extrema_GenExtPS.hxx +++ b/src/Extrema/Extrema_GenExtPS.hxx @@ -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& -- 2.39.5