#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)
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();
+ }
+}
//=======================================================================
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())
{
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;
}
}
- if (myGridBoxSet->IsDirty() && myTarget != Extrema_ExtFlag_MINMAX)
+ if (myGridBoxSet->IsDirty())
{
// Fill the tree with the real boxes
const Standard_Integer aNbSets = myGridBoxSet->Size();
// 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);
fillSqDist (aParam10, aPoint);
fillSqDist (aParam11, aPoint);
+ Standard_Boolean isFound = Standard_False;
if (theNU != myNbUSamples && theNV != myNbVSamples &&
(theTarget == Extrema_ExtFlag_MIN || theTarget == Extrema_ExtFlag_MINMAX))
{
if (isMin)
{
- FindSolution (aParam);
+ if (FindSolution (aParam))
+ isFound = Standard_True;
}
}
(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;
myIsDone = Standard_True;
+ Standard_Boolean isFound = Standard_False;
if (myTarget != Extrema_ExtFlag_MINMAX)
{
for (Standard_Integer i = aNbFuncSol + 1; i <= myF.NbExt(); ++i)
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));
}
}
}
+ else
+ {
+ isFound = myF.NbExt() > aNbFuncSol;
+ }
+ return isFound;
}
//=======================================================================