mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025332: Visualization - rewrite MinMaxValues methods to using of Bnd_Box
This commit is contained in:
@@ -111,10 +111,27 @@ is
|
|||||||
-- increased by the same amount.
|
-- increased by the same amount.
|
||||||
is static;
|
is static;
|
||||||
|
|
||||||
Get(me; aXmin, aYmin, aZmin, aXmax, aYmax, aZmax : out Real)
|
Get (me; theXmin, theYmin, theZmin, theXmax, theYmax, theZmax : out Real)
|
||||||
---Purpose: Returns the bounds of this bounding box. The gap is included.
|
---Purpose: Returns the bounds of this bounding box. The gap is included.
|
||||||
-- If this bounding box is infinite (i.e. "open"), returned values
|
-- If this bounding box is infinite (i.e. "open"), returned values
|
||||||
-- may be equal to +/- Precision::Infinite().
|
-- may be equal to +/- Precision::Infinite().
|
||||||
|
-- Standard_ConstructionError exception will be thrown if the box is void.
|
||||||
|
raises ConstructionError -- if IsVoid()
|
||||||
|
is static;
|
||||||
|
|
||||||
|
CornerMin(me) returns Pnt from gp
|
||||||
|
---Purpose: Returns the lower corner of this bounding box. The gap is included.
|
||||||
|
-- If this bounding box is infinite (i.e. "open"), returned values
|
||||||
|
-- may be equal to +/- Precision::Infinite().
|
||||||
|
-- Standard_ConstructionError exception will be thrown if the box is void.
|
||||||
|
raises ConstructionError -- if IsVoid()
|
||||||
|
is static;
|
||||||
|
|
||||||
|
CornerMax(me) returns Pnt from gp
|
||||||
|
---Purpose: Returns the upper corner of this bounding box. The gap is included.
|
||||||
|
-- If this bounding box is infinite (i.e. "open"), returned values
|
||||||
|
-- may be equal to +/- Precision::Infinite().
|
||||||
|
-- Standard_ConstructionError exception will be thrown if the box is void.
|
||||||
raises ConstructionError -- if IsVoid()
|
raises ConstructionError -- if IsVoid()
|
||||||
is static;
|
is static;
|
||||||
|
|
||||||
|
@@ -201,27 +201,74 @@ void Bnd_Box::Enlarge (const Standard_Real Tol)
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void Bnd_Box::Get (Standard_Real& x,
|
void Bnd_Box::Get (Standard_Real& theXmin,
|
||||||
Standard_Real& y,
|
Standard_Real& theYmin,
|
||||||
Standard_Real& z,
|
Standard_Real& theZmin,
|
||||||
Standard_Real& X,
|
Standard_Real& theXmax,
|
||||||
Standard_Real& Y,
|
Standard_Real& theYmax,
|
||||||
Standard_Real& Z) const
|
Standard_Real& theZmax) const
|
||||||
{
|
{
|
||||||
if (VoidFlag())
|
if (VoidFlag())
|
||||||
|
{
|
||||||
Standard_ConstructionError::Raise ("Bnd_Box is void");
|
Standard_ConstructionError::Raise ("Bnd_Box is void");
|
||||||
if (XminFlag()) x = -Bnd_Precision_Infinite;
|
}
|
||||||
else x = Xmin-Gap;
|
|
||||||
if (XmaxFlag()) X = Bnd_Precision_Infinite;
|
if (XminFlag()) theXmin = -Bnd_Precision_Infinite;
|
||||||
else X = Xmax+Gap;
|
else theXmin = Xmin - Gap;
|
||||||
if (YminFlag()) y = -Bnd_Precision_Infinite;
|
if (XmaxFlag()) theXmax = Bnd_Precision_Infinite;
|
||||||
else y = Ymin-Gap;
|
else theXmax = Xmax + Gap;
|
||||||
if (YmaxFlag()) Y = Bnd_Precision_Infinite;
|
if (YminFlag()) theYmin = -Bnd_Precision_Infinite;
|
||||||
else Y = Ymax+Gap;
|
else theYmin = Ymin - Gap;
|
||||||
if (ZminFlag()) z = -Bnd_Precision_Infinite;
|
if (YmaxFlag()) theYmax = Bnd_Precision_Infinite;
|
||||||
else z = Zmin-Gap;
|
else theYmax = Ymax + Gap;
|
||||||
if (ZmaxFlag()) Z = Bnd_Precision_Infinite;
|
if (ZminFlag()) theZmin = -Bnd_Precision_Infinite;
|
||||||
else Z = Zmax+Gap;
|
else theZmin = Zmin - Gap;
|
||||||
|
if (ZmaxFlag()) theZmax = Bnd_Precision_Infinite;
|
||||||
|
else theZmax = Zmax + Gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : CornerMin
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
gp_Pnt Bnd_Box::CornerMin() const
|
||||||
|
{
|
||||||
|
gp_Pnt aCornerMin;
|
||||||
|
if (VoidFlag())
|
||||||
|
{
|
||||||
|
Standard_ConstructionError::Raise ("Bnd_Box is void");
|
||||||
|
return aCornerMin;
|
||||||
|
}
|
||||||
|
if (XminFlag()) aCornerMin.SetX (-Bnd_Precision_Infinite);
|
||||||
|
else aCornerMin.SetX (Xmin - Gap);
|
||||||
|
if (YminFlag()) aCornerMin.SetY (-Bnd_Precision_Infinite);
|
||||||
|
else aCornerMin.SetY (Ymin - Gap);
|
||||||
|
if (ZminFlag()) aCornerMin.SetZ (-Bnd_Precision_Infinite);
|
||||||
|
else aCornerMin.SetZ (Zmin - Gap);
|
||||||
|
return aCornerMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : CornerMax
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
gp_Pnt Bnd_Box::CornerMax() const
|
||||||
|
{
|
||||||
|
gp_Pnt aCornerMax;
|
||||||
|
if(VoidFlag())
|
||||||
|
{
|
||||||
|
Standard_ConstructionError::Raise ("Bnd_Box is void");
|
||||||
|
return aCornerMax;
|
||||||
|
}
|
||||||
|
if (XmaxFlag()) aCornerMax.SetX (Bnd_Precision_Infinite);
|
||||||
|
else aCornerMax.SetX (Xmax + Gap);
|
||||||
|
if (YminFlag()) aCornerMax.SetY (Bnd_Precision_Infinite);
|
||||||
|
else aCornerMax.SetY (Ymax + Gap);
|
||||||
|
if (ZminFlag()) aCornerMax.SetZ (Bnd_Precision_Infinite);
|
||||||
|
else aCornerMax.SetZ (Zmax + Gap);
|
||||||
|
return aCornerMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -72,7 +72,8 @@ uses
|
|||||||
WNT,
|
WNT,
|
||||||
Image,
|
Image,
|
||||||
gp,
|
gp,
|
||||||
Font
|
Font,
|
||||||
|
Bnd
|
||||||
is
|
is
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
#include <Standard_Atomic.hxx>
|
#include <Standard_Atomic.hxx>
|
||||||
#include <Standard_Assert.hxx>
|
#include <Standard_Assert.hxx>
|
||||||
|
|
||||||
|
#include <NCollection_Sequence.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_HANDLE(Graphic3d_Camera, Standard_Transient)
|
IMPLEMENT_STANDARD_HANDLE(Graphic3d_Camera, Standard_Transient)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Camera, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Camera, Standard_Transient)
|
||||||
|
|
||||||
@@ -983,17 +985,7 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo
|
|||||||
// should be computed using information on boundaries of primary application actors,
|
// should be computed using information on boundaries of primary application actors,
|
||||||
// (e.g. representing the displayed model) - to ensure that they are not unreasonably clipped.
|
// (e.g. representing the displayed model) - to ensure that they are not unreasonably clipped.
|
||||||
|
|
||||||
|
if (theGraphicBB.IsVoid())
|
||||||
Standard_Real aMinMax[6]; // applicative min max boundaries
|
|
||||||
theMinMax.Get (aMinMax[0], aMinMax[1], aMinMax[2], aMinMax[3], aMinMax[4], aMinMax[5]);
|
|
||||||
|
|
||||||
Standard_Real aGraphicBB[6]; // real graphical boundaries (not accounting infinite flag).
|
|
||||||
theGraphicBB.Get (aGraphicBB[0], aGraphicBB[1], aGraphicBB[2], aGraphicBB[3], aGraphicBB[4], aGraphicBB[5]);
|
|
||||||
|
|
||||||
// Check if anything can be adjusted
|
|
||||||
Standard_Real aLim = (ShortRealLast() - 1.0);
|
|
||||||
if (Abs (aGraphicBB[0]) > aLim || Abs (aGraphicBB[1]) > aLim || Abs (aGraphicBB[2]) > aLim ||
|
|
||||||
Abs (aGraphicBB[3]) > aLim || Abs (aGraphicBB[4]) > aLim || Abs (aGraphicBB[5]) > aLim)
|
|
||||||
{
|
{
|
||||||
// ShortReal precision factor used to add meaningful tolerance to
|
// ShortReal precision factor used to add meaningful tolerance to
|
||||||
// ZNear, ZFar values in order to avoid equality after type conversion
|
// ZNear, ZFar values in order to avoid equality after type conversion
|
||||||
@@ -1023,26 +1015,34 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Measure depth of boundary points from camera eye
|
// Measure depth of boundary points from camera eye
|
||||||
gp_Pnt aPntsToMeasure[16] =
|
NCollection_Sequence<gp_Pnt> aPntsToMeasure;
|
||||||
{
|
|
||||||
gp_Pnt (aMinMax[0], aMinMax[1], aMinMax[2]),
|
|
||||||
gp_Pnt (aMinMax[0], aMinMax[1], aMinMax[5]),
|
|
||||||
gp_Pnt (aMinMax[0], aMinMax[4], aMinMax[2]),
|
|
||||||
gp_Pnt (aMinMax[0], aMinMax[4], aMinMax[5]),
|
|
||||||
gp_Pnt (aMinMax[3], aMinMax[1], aMinMax[2]),
|
|
||||||
gp_Pnt (aMinMax[3], aMinMax[1], aMinMax[5]),
|
|
||||||
gp_Pnt (aMinMax[3], aMinMax[4], aMinMax[2]),
|
|
||||||
gp_Pnt (aMinMax[3], aMinMax[4], aMinMax[5]),
|
|
||||||
|
|
||||||
gp_Pnt (aGraphicBB[0], aGraphicBB[1], aGraphicBB[2]),
|
Standard_Real aGraphicBB[6]; // real graphical boundaries (not accounting infinite flag).
|
||||||
gp_Pnt (aGraphicBB[0], aGraphicBB[1], aGraphicBB[5]),
|
theGraphicBB.Get (aGraphicBB[0], aGraphicBB[1], aGraphicBB[2], aGraphicBB[3], aGraphicBB[4], aGraphicBB[5]);
|
||||||
gp_Pnt (aGraphicBB[0], aGraphicBB[4], aGraphicBB[2]),
|
|
||||||
gp_Pnt (aGraphicBB[0], aGraphicBB[4], aGraphicBB[5]),
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[0], aGraphicBB[1], aGraphicBB[2]));
|
||||||
gp_Pnt (aGraphicBB[3], aGraphicBB[1], aGraphicBB[2]),
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[0], aGraphicBB[1], aGraphicBB[5]));
|
||||||
gp_Pnt (aGraphicBB[3], aGraphicBB[1], aGraphicBB[5]),
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[0], aGraphicBB[4], aGraphicBB[2]));
|
||||||
gp_Pnt (aGraphicBB[3], aGraphicBB[4], aGraphicBB[2]),
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[0], aGraphicBB[4], aGraphicBB[5]));
|
||||||
gp_Pnt (aGraphicBB[3], aGraphicBB[4], aGraphicBB[5])
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[3], aGraphicBB[1], aGraphicBB[2]));
|
||||||
};
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[3], aGraphicBB[1], aGraphicBB[5]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[3], aGraphicBB[4], aGraphicBB[2]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aGraphicBB[3], aGraphicBB[4], aGraphicBB[5]));
|
||||||
|
|
||||||
|
if (!theMinMax.IsVoid() && !theMinMax.IsWhole())
|
||||||
|
{
|
||||||
|
Standard_Real aMinMax[6]; // applicative min max boundaries
|
||||||
|
theMinMax.Get (aMinMax[0], aMinMax[1], aMinMax[2], aMinMax[3], aMinMax[4], aMinMax[5]);
|
||||||
|
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[0], aMinMax[1], aMinMax[2]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[0], aMinMax[1], aMinMax[5]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[0], aMinMax[4], aMinMax[2]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[0], aMinMax[4], aMinMax[5]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[3], aMinMax[1], aMinMax[2]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[3], aMinMax[1], aMinMax[5]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[3], aMinMax[4], aMinMax[2]));
|
||||||
|
aPntsToMeasure.Append (gp_Pnt (aMinMax[3], aMinMax[4], aMinMax[5]));
|
||||||
|
}
|
||||||
|
|
||||||
// Camera eye plane
|
// Camera eye plane
|
||||||
gp_Dir aCamDir = Direction();
|
gp_Dir aCamDir = Direction();
|
||||||
@@ -1057,14 +1057,11 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo
|
|||||||
const gp_XYZ& anAxialScale = myAxialScale;
|
const gp_XYZ& anAxialScale = myAxialScale;
|
||||||
|
|
||||||
// Get minimum and maximum distances to the eye plane
|
// Get minimum and maximum distances to the eye plane
|
||||||
for (Standard_Integer aPntIt = 0; aPntIt < 16; ++aPntIt)
|
Standard_Integer aCounter = 0;
|
||||||
|
NCollection_Sequence<gp_Pnt>::Iterator aPntIt(aPntsToMeasure);
|
||||||
|
for (; aPntIt.More(); aPntIt.Next())
|
||||||
{
|
{
|
||||||
gp_Pnt aMeasurePnt = aPntsToMeasure[aPntIt];
|
gp_Pnt aMeasurePnt = aPntIt.Value();
|
||||||
|
|
||||||
if (Abs (aMeasurePnt.X()) > aLim || Abs (aMeasurePnt.Y()) > aLim || Abs (aMeasurePnt.Z()) > aLim)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
aMeasurePnt = gp_Pnt (aMeasurePnt.X() * anAxialScale.X(),
|
aMeasurePnt = gp_Pnt (aMeasurePnt.X() * anAxialScale.X(),
|
||||||
aMeasurePnt.Y() * anAxialScale.Y(),
|
aMeasurePnt.Y() * anAxialScale.Y(),
|
||||||
@@ -1078,10 +1075,13 @@ void Graphic3d_Camera::ZFitAll (const Standard_Real theScaleFactor, const Bnd_Bo
|
|||||||
aDistance *= -1;
|
aDistance *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real& aChangeMinDist = aPntIt >= 8 ? aGraphicMinDist : aModelMinDist;
|
// the first eight points are from theGraphicBB, the last eight points are from theMinMax
|
||||||
Standard_Real& aChangeMaxDist = aPntIt >= 8 ? aGraphicMaxDist : aModelMaxDist;
|
// (they can be absent).
|
||||||
|
Standard_Real& aChangeMinDist = aCounter >= 8 ? aModelMinDist : aGraphicMinDist;
|
||||||
|
Standard_Real& aChangeMaxDist = aCounter >= 8 ? aModelMaxDist : aGraphicMaxDist;
|
||||||
aChangeMinDist = Min (aDistance, aChangeMinDist);
|
aChangeMinDist = Min (aDistance, aChangeMinDist);
|
||||||
aChangeMaxDist = Max (aDistance, aChangeMaxDist);
|
aChangeMaxDist = Max (aDistance, aChangeMaxDist);
|
||||||
|
aCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute depth of bounding box center
|
// Compute depth of bounding box center
|
||||||
|
@@ -73,7 +73,8 @@ uses
|
|||||||
Pnt from gp,
|
Pnt from gp,
|
||||||
SequenceOfHClipPlane from Graphic3d,
|
SequenceOfHClipPlane from Graphic3d,
|
||||||
BndBox4f from Graphic3d,
|
BndBox4f from Graphic3d,
|
||||||
BndBox4d from Graphic3d
|
BndBox4d from Graphic3d,
|
||||||
|
Box from Bnd
|
||||||
|
|
||||||
raises
|
raises
|
||||||
|
|
||||||
@@ -574,10 +575,8 @@ is
|
|||||||
---Purpose: Returns the current group of graphic attributes used
|
---Purpose: Returns the current group of graphic attributes used
|
||||||
-- for 3d marker primitives.
|
-- for 3d marker primitives.
|
||||||
|
|
||||||
MinMaxValues (me;
|
MinMaxValues (me; theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
||||||
theXMin, theYMin, theZMin : out Real from Standard;
|
returns Box from Bnd
|
||||||
theXMax, theYMax, theZMax : out Real from Standard;
|
|
||||||
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
|
||||||
is static;
|
is static;
|
||||||
---Level: Public
|
---Level: Public
|
||||||
---Purpose: Returns the coordinates of the boundary box of the structure <me>.
|
---Purpose: Returns the coordinates of the boundary box of the structure <me>.
|
||||||
@@ -587,9 +586,8 @@ is
|
|||||||
-- of the structure. This approach generally used for application
|
-- of the structure. This approach generally used for application
|
||||||
-- specific fit operation (e.g. fitting the model into screen,
|
-- specific fit operation (e.g. fitting the model into screen,
|
||||||
-- not taking into accout infinite helper elements).
|
-- not taking into accout infinite helper elements).
|
||||||
-- Warning: If the structure <me> is empty or infinite then :
|
-- Warning: If the structure <me> is empty then the empty box is returned,
|
||||||
-- theXMin = theYMin = theZMin = RealFirst ().
|
-- If the structure <me> is infinite then the whole box is returned.
|
||||||
-- theXMax = theYMax = theZMax = RealLast ().
|
|
||||||
---Category: Inquire methods
|
---Category: Inquire methods
|
||||||
|
|
||||||
PrimitivesAspect ( me;
|
PrimitivesAspect ( me;
|
||||||
|
@@ -1651,33 +1651,32 @@ void Graphic3d_Structure::Transform (TColStd_Array2OfReal& theMatrix) const
|
|||||||
//function : MinMaxValues
|
//function : MinMaxValues
|
||||||
//purpose :
|
//purpose :
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
void Graphic3d_Structure::MinMaxValues (Standard_Real& theXMin,
|
Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||||
Standard_Real& theYMin,
|
|
||||||
Standard_Real& theZMin,
|
|
||||||
Standard_Real& theXMax,
|
|
||||||
Standard_Real& theYMax,
|
|
||||||
Standard_Real& theZMax,
|
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
|
||||||
{
|
{
|
||||||
Graphic3d_BndBox4d aBox;
|
Graphic3d_BndBox4d aBox;
|
||||||
|
Bnd_Box aResult;
|
||||||
addTransformed (aBox, theToIgnoreInfiniteFlag);
|
addTransformed (aBox, theToIgnoreInfiniteFlag);
|
||||||
if (!aBox.IsValid())
|
if (aBox.IsValid())
|
||||||
{
|
{
|
||||||
theXMin = RealFirst();
|
aResult.Add (gp_Pnt (aBox.CornerMin().x(),
|
||||||
theYMin = RealFirst();
|
aBox.CornerMin().y(),
|
||||||
theZMin = RealFirst();
|
aBox.CornerMin().z()));
|
||||||
theXMax = RealLast();
|
aResult.Add (gp_Pnt (aBox.CornerMax().x(),
|
||||||
theYMax = RealLast();
|
aBox.CornerMax().y(),
|
||||||
theZMax = RealLast();
|
aBox.CornerMax().z()));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
theXMin = aBox.CornerMin().x();
|
Standard_Real aLimMin = ShortRealFirst() + 1.0;
|
||||||
theYMin = aBox.CornerMin().y();
|
Standard_Real aLimMax = ShortRealLast() - 1.0;
|
||||||
theZMin = aBox.CornerMin().z();
|
gp_Pnt aMin = aResult.CornerMin();
|
||||||
theXMax = aBox.CornerMax().x();
|
gp_Pnt aMax = aResult.CornerMax();
|
||||||
theYMax = aBox.CornerMax().y();
|
if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin &&
|
||||||
theZMax = aBox.CornerMax().z();
|
aMax.X() > aLimMax && aMax.Y() > aLimMax && aMax.Z() > aLimMax)
|
||||||
|
{
|
||||||
|
//For structure which infinite in all three dimensions the Whole bounding box will be returned
|
||||||
|
aResult.SetWhole();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@@ -106,17 +106,18 @@ void NIS_View::RemoveContext (NIS_InteractiveContext * theCtx)
|
|||||||
|
|
||||||
Standard_Boolean NIS_View::FitAll3d (const Quantity_Coefficient theCoef)
|
Standard_Boolean NIS_View::FitAll3d (const Quantity_Coefficient theCoef)
|
||||||
{
|
{
|
||||||
Bnd_B3f aBox = GetBndBox();
|
Bnd_B3f aB3fBox = GetBndBox();
|
||||||
|
|
||||||
if (aBox.IsVoid() || MyView->IsDefined() == Standard_False)
|
if (aB3fBox.IsVoid() || MyView->IsDefined() == Standard_False)
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_XYZ aMin = aBox.CornerMin();
|
Bnd_Box aBox;
|
||||||
gp_XYZ aMax = aBox.CornerMax();
|
aBox.Add (gp_Pnt (aB3fBox.CornerMin()));
|
||||||
|
aBox.Add (gp_Pnt (aB3fBox.CornerMax()));
|
||||||
|
|
||||||
if (!FitMinMax (myCamera, aMin, aMax, theCoef, 0.0, Standard_False))
|
if (!FitMinMax (myCamera, aBox, theCoef, 0.0, Standard_False))
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
@@ -150,11 +151,11 @@ Bnd_B3f NIS_View::GetBndBox() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Take the bounding box of AIS objects displayed in the view
|
// Take the bounding box of AIS objects displayed in the view
|
||||||
Standard_Real aVal[6];
|
Bnd_Box aVal = View()->MinMaxValues();
|
||||||
View()->MinMaxValues(aVal[0], aVal[1], aVal[2], aVal[3], aVal[4], aVal[5]);
|
if (!aVal.IsVoid())
|
||||||
if (aVal[3] < 0.5 * RealLast()) {
|
{
|
||||||
aBox.Add (gp_XYZ (aVal[0], aVal[1], aVal[2]));
|
aBox.Add (aVal.CornerMin());
|
||||||
aBox.Add (gp_XYZ (aVal[3], aVal[4], aVal[5]));
|
aBox.Add (aVal.CornerMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
return aBox;
|
return aBox;
|
||||||
|
@@ -42,7 +42,8 @@ uses
|
|||||||
Image,
|
Image,
|
||||||
gp,
|
gp,
|
||||||
OSD,
|
OSD,
|
||||||
Font
|
Font,
|
||||||
|
Bnd
|
||||||
|
|
||||||
is
|
is
|
||||||
|
|
||||||
|
@@ -136,7 +136,8 @@ uses
|
|||||||
SequenceOfHClipPlane from Graphic3d,
|
SequenceOfHClipPlane from Graphic3d,
|
||||||
RenderingMode from Graphic3d,
|
RenderingMode from Graphic3d,
|
||||||
RenderingParams from Graphic3d,
|
RenderingParams from Graphic3d,
|
||||||
XYZ from gp
|
XYZ from gp,
|
||||||
|
Box from Bnd
|
||||||
raises
|
raises
|
||||||
|
|
||||||
BadValue from V3d, TypeMismatch from Standard,
|
BadValue from V3d, TypeMismatch from Standard,
|
||||||
@@ -1531,8 +1532,7 @@ is
|
|||||||
|
|
||||||
FitMinMax (me;
|
FitMinMax (me;
|
||||||
theCamera : Camera_Handle from Graphic3d;
|
theCamera : Camera_Handle from Graphic3d;
|
||||||
theMinCorner : XYZ from gp;
|
theBox : Box from Bnd;
|
||||||
theMaxCorner : XYZ from gp;
|
|
||||||
theMargin : Real from Standard;
|
theMargin : Real from Standard;
|
||||||
theResolution : Real from Standard = 0.0;
|
theResolution : Real from Standard = 0.0;
|
||||||
theToEnlargeIfLine : Boolean from Standard = Standard_True)
|
theToEnlargeIfLine : Boolean from Standard = Standard_True)
|
||||||
@@ -1541,8 +1541,7 @@ is
|
|||||||
---Purpose: Transform camera eye, center and scale to fit in the
|
---Purpose: Transform camera eye, center and scale to fit in the
|
||||||
-- passed bounding box specified in WCS.
|
-- passed bounding box specified in WCS.
|
||||||
-- @param theCamera [in] the camera.
|
-- @param theCamera [in] the camera.
|
||||||
-- @param theMinCorner [in] the minimal corner of bounding box.
|
-- @param theBox [in] the bounding box.
|
||||||
-- @param theMaxCorner [in] the maximal corner of bounding box.
|
|
||||||
-- @param theMargin [in] the margin coefficient for view borders.
|
-- @param theMargin [in] the margin coefficient for view borders.
|
||||||
-- @param theResolution [in] the minimum size of projection of
|
-- @param theResolution [in] the minimum size of projection of
|
||||||
-- bounding box in Xv or Yv direction when it considered to
|
-- bounding box in Xv or Yv direction when it considered to
|
||||||
|
@@ -1509,12 +1509,7 @@ void V3d_View::FitAll (const Standard_Real theMargin, const Standard_Boolean the
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
if (!FitMinMax (myCamera, MyView->MinMaxValues(), theMargin, 10.0 * Precision::Confusion()))
|
||||||
MyView->MinMaxValues (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
gp_XYZ aMin (aXmin, aYmin, aZmin);
|
|
||||||
gp_XYZ aMax (aXmax, aYmax, aZmax);
|
|
||||||
|
|
||||||
if (!FitMinMax (myCamera, aMin, aMax, theMargin, 10.0 * Precision::Confusion()))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1545,19 +1540,13 @@ void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect,
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
|
Bnd_Box aBox = MyView->MinMaxValues();
|
||||||
|
if (aBox.IsVoid())
|
||||||
Standard_Real LIM = ShortRealLast() -1.;
|
{
|
||||||
if (Abs(Xmin) > LIM || Abs(Ymin) > LIM || Abs(Zmin) > LIM
|
|
||||||
|| Abs(Xmax) > LIM || Abs(Ymax) > LIM || Abs(Zmax) > LIM ) {
|
|
||||||
ImmediateUpdate();
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Xmin == Xmax && Ymin == Ymax && Zmin == Zmax) {
|
|
||||||
ImmediateUpdate();
|
ImmediateUpdate();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||||
MyView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
|
MyView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
|
||||||
MyView->Projects(Xmax,Ymax,Zmax,U1,V1,W1) ;
|
MyView->Projects(Xmax,Ymax,Zmax,U1,V1,W1) ;
|
||||||
Umin = Min(U,U1) ; Umax = Max(U,U1) ;
|
Umin = Min(U,U1) ; Umax = Max(U,U1) ;
|
||||||
@@ -2060,7 +2049,8 @@ Standard_Integer V3d_View::MinMax(Standard_Real& Umin,
|
|||||||
Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
|
Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
|
||||||
|
|
||||||
if( Nstruct ) {
|
if( Nstruct ) {
|
||||||
MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
|
Bnd_Box aBox = MyView->MinMaxValues();
|
||||||
|
aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||||
MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
|
MyView->Projects(Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
|
||||||
MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
|
MyView->Projects(Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
|
||||||
MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
|
MyView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
|
||||||
@@ -2107,7 +2097,8 @@ Standard_Integer V3d_View::MinMax(Standard_Real& Xmin,
|
|||||||
Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
|
Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ;
|
||||||
|
|
||||||
if( Nstruct ) {
|
if( Nstruct ) {
|
||||||
MyView->MinMaxValues(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax) ;
|
Bnd_Box aBox = MyView->MinMaxValues();
|
||||||
|
aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||||
}
|
}
|
||||||
return Nstruct ;
|
return Nstruct ;
|
||||||
}
|
}
|
||||||
@@ -2133,17 +2124,16 @@ Standard_Integer V3d_View::Gravity(Standard_Real& X, Standard_Real& Y, Standard_
|
|||||||
const Handle(Graphic3d_Structure)& aStruct = MyIterator.Key();
|
const Handle(Graphic3d_Structure)& aStruct = MyIterator.Key();
|
||||||
if (!aStruct->IsEmpty())
|
if (!aStruct->IsEmpty())
|
||||||
{
|
{
|
||||||
aStruct->MinMaxValues (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
|
Bnd_Box aBox = aStruct->MinMaxValues();
|
||||||
|
|
||||||
// Check bounding box for validness
|
// Check bounding box for validness
|
||||||
Standard_Real aLim = (ShortRealLast() - 1.0);
|
if (aBox.IsVoid())
|
||||||
if (Abs (Xmin) > aLim || Abs (Ymin) > aLim || Abs (Zmin) > aLim ||
|
|
||||||
Abs (Xmax) > aLim || Abs (Ymax) > aLim || Abs (Zmax) > aLim)
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use camera projection to find gravity point
|
// use camera projection to find gravity point
|
||||||
|
aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
|
||||||
gp_Pnt aPnts[8] = {
|
gp_Pnt aPnts[8] = {
|
||||||
gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
|
gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
|
||||||
gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
|
gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
|
||||||
@@ -3019,16 +3009,13 @@ const Handle(Graphic3d_Camera)& V3d_View::Camera() const
|
|||||||
// purpose : Internal
|
// purpose : Internal
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera,
|
Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera,
|
||||||
const gp_XYZ& theMinCorner,
|
const Bnd_Box& theBox,
|
||||||
const gp_XYZ& theMaxCorner,
|
|
||||||
const Standard_Real theMargin,
|
const Standard_Real theMargin,
|
||||||
const Standard_Real theResolution,
|
const Standard_Real theResolution,
|
||||||
const Standard_Boolean theToEnlargeIfLine) const
|
const Standard_Boolean theToEnlargeIfLine) const
|
||||||
{
|
{
|
||||||
// Check bounding box for validness
|
// Check bounding box for validness
|
||||||
Standard_Real aLim = (ShortRealLast() - 1.0);
|
if (theBox.IsVoid())
|
||||||
if (Abs (theMinCorner.X()) > aLim || Abs (theMinCorner.Y()) > aLim || Abs (theMinCorner.Z()) > aLim ||
|
|
||||||
Abs (theMaxCorner.X()) > aLim || Abs (theMaxCorner.Y()) > aLim || Abs (theMaxCorner.Z()) > aLim)
|
|
||||||
{
|
{
|
||||||
return Standard_False; // bounding box is out of bounds...
|
return Standard_False; // bounding box is out of bounds...
|
||||||
}
|
}
|
||||||
@@ -3039,12 +3026,14 @@ Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera,
|
|||||||
// option is to perform frustum plane adjustment algorithm in view camera space,
|
// option is to perform frustum plane adjustment algorithm in view camera space,
|
||||||
// which will lead to a number of additional world-view space conversions and
|
// which will lead to a number of additional world-view space conversions and
|
||||||
// loosing precision as well.
|
// loosing precision as well.
|
||||||
Standard_Real aXmin = theMinCorner.X() * theCamera->AxialScale().X();
|
gp_Pnt aMinCorner = theBox.CornerMin();
|
||||||
Standard_Real aXmax = theMaxCorner.X() * theCamera->AxialScale().X();
|
gp_Pnt aMaxCorner = theBox.CornerMax();
|
||||||
Standard_Real aYmin = theMinCorner.Y() * theCamera->AxialScale().Y();
|
Standard_Real aXmin = aMinCorner.X() * theCamera->AxialScale().X();
|
||||||
Standard_Real aYmax = theMaxCorner.Y() * theCamera->AxialScale().Y();
|
Standard_Real aXmax = aMaxCorner.X() * theCamera->AxialScale().X();
|
||||||
Standard_Real aZmin = theMinCorner.Z() * theCamera->AxialScale().Z();
|
Standard_Real aYmin = aMinCorner.Y() * theCamera->AxialScale().Y();
|
||||||
Standard_Real aZmax = theMaxCorner.Z() * theCamera->AxialScale().Z();
|
Standard_Real aYmax = aMaxCorner.Y() * theCamera->AxialScale().Y();
|
||||||
|
Standard_Real aZmin = aMinCorner.Z() * theCamera->AxialScale().Z();
|
||||||
|
Standard_Real aZmax = aMaxCorner.Z() * theCamera->AxialScale().Z();
|
||||||
|
|
||||||
Bnd_Box aBBox;
|
Bnd_Box aBBox;
|
||||||
aBBox.Update (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
aBBox.Update (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
@@ -2478,12 +2478,12 @@ inline void bndPresentation (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
case BndAction_Print:
|
case BndAction_Print:
|
||||||
{
|
{
|
||||||
Graphic3d_Vec3d aMin, aMax;
|
Bnd_Box aBox = thePrs->Presentation()->MinMaxValues();
|
||||||
thePrs->Presentation()->MinMaxValues (aMin.x(), aMin.y(), aMin.z(),
|
gp_Pnt aMin = aBox.CornerMin();
|
||||||
aMax.x(), aMax.y(), aMax.z());
|
gp_Pnt aMax = aBox.CornerMax();
|
||||||
theDI << theName << "\n"
|
theDI << theName << "\n"
|
||||||
<< aMin.x() << " " << aMin.y() << " " << aMin.z() << " "
|
<< aMin.X() << " " << aMin.Y() << " " << aMin.Z() << " "
|
||||||
<< aMax.x() << " " << aMax.y() << " " << aMax.z() << "\n";
|
<< aMax.X() << " " << aMax.Y() << " " << aMax.Z() << "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,8 @@ uses
|
|||||||
MMgt,
|
MMgt,
|
||||||
WNT,
|
WNT,
|
||||||
OSD,
|
OSD,
|
||||||
Font
|
Font,
|
||||||
|
Bnd
|
||||||
|
|
||||||
is
|
is
|
||||||
|
|
||||||
|
@@ -108,7 +108,8 @@ uses
|
|||||||
ExtendedString from TCollection,
|
ExtendedString from TCollection,
|
||||||
CGraduatedTrihedron from Graphic3d,
|
CGraduatedTrihedron from Graphic3d,
|
||||||
|
|
||||||
PixMap from Image
|
PixMap from Image,
|
||||||
|
Box from Bnd
|
||||||
|
|
||||||
raises
|
raises
|
||||||
TransformError from Visual3d,
|
TransformError from Visual3d,
|
||||||
@@ -670,9 +671,8 @@ is
|
|||||||
---Category: Inquire methods
|
---Category: Inquire methods
|
||||||
|
|
||||||
MinMaxValues (me;
|
MinMaxValues (me;
|
||||||
theXMin, theYMin, theZMin : out Real from Standard;
|
|
||||||
theXMax, theYMax, theZMax : out Real from Standard;
|
|
||||||
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
||||||
|
returns Box from Bnd
|
||||||
is static;
|
is static;
|
||||||
---Level: Public
|
---Level: Public
|
||||||
---Purpose: Returns the coordinates of the boundary box of all
|
---Purpose: Returns the coordinates of the boundary box of all
|
||||||
@@ -683,40 +683,14 @@ is
|
|||||||
|
|
||||||
MinMaxValues (me;
|
MinMaxValues (me;
|
||||||
theSet : MapOfStructure from Graphic3d;
|
theSet : MapOfStructure from Graphic3d;
|
||||||
theXMin, theYMin, theZMin : out Real from Standard;
|
|
||||||
theXMax, theYMax, theZMax : out Real from Standard;
|
|
||||||
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
||||||
|
returns Box from Bnd
|
||||||
is static;
|
is static;
|
||||||
---Level: Public
|
---Level: Public
|
||||||
---Purpose: Returns the coordinates of the boundary box of all
|
---Purpose: Returns the coordinates of the boundary box of all
|
||||||
-- structures in the set <theSet>.
|
-- structures in the set <theSet>.
|
||||||
-- If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
|
-- If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
|
||||||
-- also includes minimum and maximum limits of graphical elements
|
-- also includes minimum and maximum limits of graphical elements
|
||||||
-- forming parts of infinite structures.
|
|
||||||
|
|
||||||
MinMaxValues (me;
|
|
||||||
theXMin, theYMin : out Real from Standard;
|
|
||||||
theXMax, theYMax : out Real from Standard;
|
|
||||||
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
|
||||||
is static;
|
|
||||||
---Level: Public
|
|
||||||
---Purpose: Returns the coordinates of the projection of the
|
|
||||||
-- boundary box of all structures displayed in the view <me>.
|
|
||||||
-- If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
|
|
||||||
-- also includes minimum and maximum limits of graphical elements
|
|
||||||
-- forming parts of infinite structures.
|
|
||||||
|
|
||||||
MinMaxValues (me;
|
|
||||||
theSet : MapOfStructure from Graphic3d;
|
|
||||||
theXMin, theYMin : out Real from Standard;
|
|
||||||
theXMax, theYMax : out Real from Standard;
|
|
||||||
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
|
||||||
is static;
|
|
||||||
---Level: Public
|
|
||||||
---Purpose: Returns the coordinates of the projection of the
|
|
||||||
-- boundary box of all structures in the set <ASet>.
|
|
||||||
-- If <theToIgnoreInfiniteFlag> is TRUE, then the boundary box
|
|
||||||
-- also includes minimum and maximum limits of graphical elements
|
|
||||||
-- forming parts of infinite structures.
|
-- forming parts of infinite structures.
|
||||||
|
|
||||||
NumberOfDisplayedStructures ( me )
|
NumberOfDisplayedStructures ( me )
|
||||||
|
@@ -1124,24 +1124,8 @@ void Visual3d_View::AutoZFit()
|
|||||||
// ========================================================================
|
// ========================================================================
|
||||||
void Visual3d_View::ZFitAll (const Standard_Real theScaleFactor)
|
void Visual3d_View::ZFitAll (const Standard_Real theScaleFactor)
|
||||||
{
|
{
|
||||||
Standard_Real aMinMax[6]; // applicative min max boundaries
|
Bnd_Box aMinMaxBox = MinMaxValues (Standard_False); // applicative min max boundaries
|
||||||
MinMaxValues (aMinMax[0], aMinMax[1], aMinMax[2],
|
Bnd_Box aGraphicBox = MinMaxValues (Standard_True); // real graphical boundaries (not accounting infinite flag).
|
||||||
aMinMax[3], aMinMax[4], aMinMax[5],
|
|
||||||
Standard_False);
|
|
||||||
|
|
||||||
Standard_Real aGraphicBB[6]; // real graphical boundaries (not accounting infinite flag).
|
|
||||||
MinMaxValues (aGraphicBB[0], aGraphicBB[1], aGraphicBB[2],
|
|
||||||
aGraphicBB[3], aGraphicBB[4], aGraphicBB[5],
|
|
||||||
Standard_True);
|
|
||||||
|
|
||||||
Bnd_Box aMinMaxBox;
|
|
||||||
Bnd_Box aGraphicBox;
|
|
||||||
|
|
||||||
aMinMaxBox.Update (aMinMax[0], aMinMax[1], aMinMax[2],
|
|
||||||
aMinMax[3], aMinMax[4], aMinMax[5]);
|
|
||||||
|
|
||||||
aGraphicBox.Update (aGraphicBB[0], aGraphicBB[1], aGraphicBB[2],
|
|
||||||
aGraphicBB[3], aGraphicBB[4], aGraphicBB[5]);
|
|
||||||
|
|
||||||
const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
|
const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
|
||||||
aCamera->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox);
|
aCamera->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox);
|
||||||
@@ -1697,17 +1681,9 @@ Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& t
|
|||||||
// function : MinMaxValues
|
// function : MinMaxValues
|
||||||
// purpose :
|
// purpose :
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
|
Bnd_Box Visual3d_View::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||||
Standard_Real& theYMin,
|
|
||||||
Standard_Real& theZMin,
|
|
||||||
Standard_Real& theXMax,
|
|
||||||
Standard_Real& theYMax,
|
|
||||||
Standard_Real& theZMax,
|
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
|
||||||
{
|
{
|
||||||
MinMaxValues (myStructsDisplayed,
|
return MinMaxValues (myStructsDisplayed,
|
||||||
theXMin, theYMin, theZMin,
|
|
||||||
theXMax, theYMax, theZMax,
|
|
||||||
theToIgnoreInfiniteFlag);
|
theToIgnoreInfiniteFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1715,38 +1691,16 @@ void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
|
|||||||
// function : MinMaxValues
|
// function : MinMaxValues
|
||||||
// purpose :
|
// purpose :
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
|
Bnd_Box Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
|
||||||
Standard_Real& theXMin,
|
|
||||||
Standard_Real& theYMin,
|
|
||||||
Standard_Real& theZMin,
|
|
||||||
Standard_Real& theXMax,
|
|
||||||
Standard_Real& theYMax,
|
|
||||||
Standard_Real& theZMax,
|
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||||
{
|
{
|
||||||
|
Bnd_Box aResult;
|
||||||
if (theSet.IsEmpty ())
|
if (theSet.IsEmpty ())
|
||||||
{
|
{
|
||||||
theXMin = RealFirst();
|
// Return an empty box.
|
||||||
theYMin = RealFirst();
|
return aResult;
|
||||||
theZMin = RealFirst();
|
|
||||||
|
|
||||||
theXMax = RealLast();
|
|
||||||
theYMax = RealLast();
|
|
||||||
theZMax = RealLast();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
|
|
||||||
Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
|
Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
|
||||||
|
|
||||||
theXMin = RealLast();
|
|
||||||
theYMin = RealLast();
|
|
||||||
theZMin = RealLast();
|
|
||||||
|
|
||||||
theXMax = RealFirst ();
|
|
||||||
theYMax = RealFirst ();
|
|
||||||
theZMax = RealFirst ();
|
|
||||||
|
|
||||||
for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
|
for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
|
||||||
{
|
{
|
||||||
const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
|
const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
|
||||||
@@ -1757,30 +1711,10 @@ void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
|
|||||||
if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
|
if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
|
||||||
{
|
{
|
||||||
//XMin, YMin .... ZMax are initialized by means of infinite line data
|
//XMin, YMin .... ZMax are initialized by means of infinite line data
|
||||||
aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, Standard_False);
|
Bnd_Box aBox = aStructure->MinMaxValues (Standard_False);
|
||||||
if (aXm != RealFirst() && aXm < theXMin)
|
if (!aBox.IsWhole() && !aBox.IsVoid())
|
||||||
{
|
{
|
||||||
theXMin = aXm;
|
aResult.Add (aBox);
|
||||||
}
|
|
||||||
if (aYm != RealFirst() && aYm < theYMin)
|
|
||||||
{
|
|
||||||
theYMin = aYm;
|
|
||||||
}
|
|
||||||
if (aZm != RealFirst() && aZm < theZMin)
|
|
||||||
{
|
|
||||||
theZMin = aZm;
|
|
||||||
}
|
|
||||||
if (aXM != RealLast() && aXM > theXMax)
|
|
||||||
{
|
|
||||||
theXMax = aXM;
|
|
||||||
}
|
|
||||||
if (aYM != RealLast() && aYM > theYMax)
|
|
||||||
{
|
|
||||||
theYMax = aYM;
|
|
||||||
}
|
|
||||||
if (aZM != RealLast() && aZM > theZMax)
|
|
||||||
{
|
|
||||||
theZMax = aZM;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1788,72 +1722,17 @@ void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
|
|||||||
// are taken into account for calculation of MinMax
|
// are taken into account for calculation of MinMax
|
||||||
if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
|
if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
|
||||||
{
|
{
|
||||||
aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
|
Bnd_Box aBox = aStructure->MinMaxValues (theToIgnoreInfiniteFlag);
|
||||||
|
|
||||||
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
|
/* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
|
||||||
//"FitAll" operation ignores object with transform persitence parameter
|
//"FitAll" operation ignores object with transform persitence parameter
|
||||||
if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
|
if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
|
||||||
{
|
{
|
||||||
theXMin = Min (aXm, theXMin);
|
aResult.Add (aBox);
|
||||||
theYMin = Min (aYm, theYMin);
|
|
||||||
theZMin = Min (aZm, theZMin);
|
|
||||||
theXMax = Max (aXM, theXMax);
|
|
||||||
theYMax = Max (aYM, theYMax);
|
|
||||||
theZMax = Max (aZM, theZMax);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return aResult;
|
||||||
// The following cases are relevant
|
|
||||||
// For exemple if all structures are empty or infinite
|
|
||||||
if (theXMax < theXMin) { aXm = theXMin; theXMin = theXMax; theXMax = aXm; }
|
|
||||||
if (theYMax < theYMin) { aYm = theYMin; theYMin = theYMax; theYMax = aYm; }
|
|
||||||
if (theZMax < theZMin) { aZm = theZMin; theZMin = theZMax; theZMax = aZm; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================================================================
|
|
||||||
// function : MinMaxValues
|
|
||||||
// purpose :
|
|
||||||
// ========================================================================
|
|
||||||
void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
|
|
||||||
Standard_Real& theYMin,
|
|
||||||
Standard_Real& theXMax,
|
|
||||||
Standard_Real& theYMax,
|
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
|
||||||
{
|
|
||||||
MinMaxValues (myStructsDisplayed,
|
|
||||||
theXMin, theYMin,
|
|
||||||
theXMax, theYMax,
|
|
||||||
theToIgnoreInfiniteFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========================================================================
|
|
||||||
// function : MinMaxValues
|
|
||||||
// purpose :
|
|
||||||
// ========================================================================
|
|
||||||
void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
|
|
||||||
Standard_Real& theXMin,
|
|
||||||
Standard_Real& theYMin,
|
|
||||||
Standard_Real& theXMax,
|
|
||||||
Standard_Real& theYMax,
|
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
|
||||||
{
|
|
||||||
Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
|
|
||||||
Standard_Real aXp, aYp, aZp;
|
|
||||||
|
|
||||||
MinMaxValues (theSet, aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
|
|
||||||
|
|
||||||
Projects (aXm, aYm, aZm, aXp, aYp, aZp);
|
|
||||||
theXMin = aXp;
|
|
||||||
theYMin = aYp;
|
|
||||||
|
|
||||||
Projects (aXM, aYM, aZM, aXp, aYp, aZp);
|
|
||||||
theXMax = aXp;
|
|
||||||
theYMax = aYp;
|
|
||||||
|
|
||||||
if (theXMax < theXMin) { aXp = theXMax; theXMax = theXMin; theXMin = aXp; }
|
|
||||||
if (theYMax < theYMin) { aYp = theYMax; theYMax = theYMin; theYMin = aYp; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@@ -2199,23 +2078,16 @@ void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho theType)
|
|||||||
myGraphicDriver->TriedronEcho (MyCView, theType);
|
myGraphicDriver->TriedronEcho (MyCView, theType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Standard_Boolean checkFloat (const Standard_Real theValue)
|
|
||||||
{
|
|
||||||
return theValue > -FLT_MAX
|
|
||||||
&& theValue < FLT_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetMinMaxValuesCallback (Visual3d_View* theView)
|
static void SetMinMaxValuesCallback (Visual3d_View* theView)
|
||||||
{
|
{
|
||||||
Graphic3d_Vec3d aMin, aMax;
|
Bnd_Box aBox = theView->MinMaxValues();
|
||||||
theView->MinMaxValues (aMin.x(), aMin.y(), aMin.z(),
|
if (!aBox.IsVoid())
|
||||||
aMax.x(), aMax.y(), aMax.z());
|
|
||||||
if (checkFloat (aMin.x()) && checkFloat (aMin.y()) && checkFloat (aMin.z())
|
|
||||||
&& checkFloat (aMax.x()) && checkFloat (aMax.y()) && checkFloat (aMax.z()))
|
|
||||||
{
|
{
|
||||||
|
gp_Pnt aMin = aBox.CornerMin();
|
||||||
|
gp_Pnt aMax = aBox.CornerMax();
|
||||||
const Handle(Graphic3d_GraphicDriver)& aDriver = theView->GraphicDriver();
|
const Handle(Graphic3d_GraphicDriver)& aDriver = theView->GraphicDriver();
|
||||||
aDriver->GraduatedTrihedronMinMaxValues ((Standard_ShortReal )aMin.x(), (Standard_ShortReal )aMin.y(), (Standard_ShortReal )aMin.z(),
|
aDriver->GraduatedTrihedronMinMaxValues ((Standard_ShortReal )aMin.X(), (Standard_ShortReal )aMin.Y(), (Standard_ShortReal )aMin.Z(),
|
||||||
(Standard_ShortReal )aMax.x(), (Standard_ShortReal )aMax.y(), (Standard_ShortReal )aMax.z());
|
(Standard_ShortReal )aMax.X(), (Standard_ShortReal )aMax.Y(), (Standard_ShortReal )aMax.Z());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user