mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024393: Visualization - objects position with enchanced precision
Graphic3d_ZLayerSettings - public fields have been replaced by methods. Added new property Origin defining local coordinate system for all Layer objects. Syntax of Draw Harness command VZLayer has been redesigned. Graphic3d_CStructure now stores bounding box with double precision floats. OpenGl_BVHTreeSelector - frustum culling now works with double precision floats.
This commit is contained in:
@@ -28,6 +28,7 @@ Graphic3d_AspectMarker3d.hxx
|
||||
Graphic3d_AspectText3d.cxx
|
||||
Graphic3d_AspectText3d.hxx
|
||||
Graphic3d_AspectTextDefinitionError.hxx
|
||||
Graphic3d_BndBox3d.hxx
|
||||
Graphic3d_BndBox4d.hxx
|
||||
Graphic3d_BndBox4f.hxx
|
||||
Graphic3d_BoundBuffer.hxx
|
||||
|
22
src/Graphic3d/Graphic3d_BndBox3d.hxx
Normal file
22
src/Graphic3d/Graphic3d_BndBox3d.hxx
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_BndBox3d_Header
|
||||
#define _Graphic3d_BndBox3d_Header
|
||||
|
||||
#include <BVH_Box.hxx>
|
||||
#include <BVH_Types.hxx>
|
||||
|
||||
typedef BVH_Box<Standard_Real, 3> Graphic3d_BndBox3d;
|
||||
|
||||
#endif // _Graphic3d_BndBox3d_Header
|
@@ -24,14 +24,14 @@ struct Graphic3d_CLight
|
||||
|
||||
public:
|
||||
|
||||
Graphic3d_Vec3d Position; //!< light position
|
||||
Graphic3d_Vec4 Color; //!< light color
|
||||
Graphic3d_Vec4 Position; //!< light position
|
||||
Graphic3d_Vec4 Direction; //!< direction of directional/spot light
|
||||
Graphic3d_Vec4 Params; //!< packed light parameters
|
||||
Graphic3d_TypeOfLightSource Type; //!< Graphic3d_TypeOfLightSource enumeration
|
||||
Standard_Boolean IsHeadlight; //!< flag to mark head light
|
||||
Standard_ShortReal Smoothness; //!< radius (cone angle) for point (directional) light
|
||||
Standard_ShortReal Intensity; //!< intensity multiplier for light
|
||||
Graphic3d_TypeOfLightSource Type; //!< Graphic3d_TypeOfLightSource enumeration
|
||||
Standard_Boolean IsHeadlight; //!< flag to mark head light
|
||||
|
||||
//! Const attenuation factor of positional light source
|
||||
Standard_ShortReal ConstAttenuation() const { return Params.x(); }
|
||||
@@ -58,14 +58,14 @@ public:
|
||||
|
||||
//! Empty constructor
|
||||
Graphic3d_CLight()
|
||||
: Color (1.0f, 1.0f, 1.0f, 1.0f),
|
||||
Position (0.0f, 0.0f, 0.0f, 1.0f),
|
||||
: Position (0.0, 0.0, 0.0),
|
||||
Color (1.0f, 1.0f, 1.0f, 1.0f),
|
||||
Direction (0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Params (0.0f, 0.0f, 0.0f, 0.0f),
|
||||
Type (Graphic3d_TOLS_AMBIENT),
|
||||
IsHeadlight (Standard_False),
|
||||
Smoothness (0.0f),
|
||||
Intensity (1.0f)
|
||||
Intensity (1.0f),
|
||||
Type (Graphic3d_TOLS_AMBIENT),
|
||||
IsHeadlight (Standard_False)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#ifndef _Graphic3d_CStructure_HeaderFile
|
||||
#define _Graphic3d_CStructure_HeaderFile
|
||||
|
||||
#include <Graphic3d_BndBox4f.hxx>
|
||||
#include <Graphic3d_BndBox3d.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_HighlightStyle.hxx>
|
||||
#include <Graphic3d_SequenceOfGroup.hxx>
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
|
||||
|
||||
//! Set transformation persistence.
|
||||
void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
|
||||
virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
|
||||
|
||||
//! @return associated clip planes
|
||||
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
|
||||
@@ -70,14 +70,14 @@ public:
|
||||
void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; }
|
||||
|
||||
//! @return bounding box of this presentation
|
||||
const Graphic3d_BndBox4f& BoundingBox() const
|
||||
const Graphic3d_BndBox3d& BoundingBox() const
|
||||
{
|
||||
return myBndBox;
|
||||
}
|
||||
|
||||
//! @return bounding box of this presentation
|
||||
//! without transformation matrix applied
|
||||
Graphic3d_BndBox4f& ChangeBoundingBox()
|
||||
Graphic3d_BndBox3d& ChangeBoundingBox()
|
||||
{
|
||||
return myBndBox;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
}
|
||||
|
||||
//! Set z layer ID to display the structure in specified layer
|
||||
void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
|
||||
virtual void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
|
||||
|
||||
//! Get z layer ID
|
||||
Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
|
||||
@@ -163,7 +163,7 @@ protected:
|
||||
|
||||
Handle(Graphic3d_GraphicDriver) myGraphicDriver;
|
||||
Graphic3d_SequenceOfGroup myGroups;
|
||||
Graphic3d_BndBox4f myBndBox;
|
||||
Graphic3d_BndBox3d myBndBox;
|
||||
Handle(Geom_Transformation) myTrsf;
|
||||
Handle(Graphic3d_TransformPers) myTrsfPers;
|
||||
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
|
||||
|
@@ -26,18 +26,6 @@ namespace
|
||||
|
||||
static const int THE_NB_DEFAULT_LAYERS = sizeof(THE_DEFAULT_LAYERS) / sizeof(*THE_DEFAULT_LAYERS);
|
||||
|
||||
void combineBox (Bnd_Box& aCombined, const Graphic3d_BndBox4f& theBox)
|
||||
{
|
||||
if (theBox.IsValid())
|
||||
{
|
||||
aCombined.Add (gp_Pnt (theBox.CornerMin().x(),
|
||||
theBox.CornerMin().y(),
|
||||
theBox.CornerMin().z()));
|
||||
aCombined.Add (gp_Pnt (theBox.CornerMax().x(),
|
||||
theBox.CornerMax().y(),
|
||||
theBox.CornerMax().z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -436,23 +424,23 @@ Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxili
|
||||
|
||||
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
|
||||
{
|
||||
Graphic3d_BndBox4f aBox = ZLayerBoundingBox (THE_DEFAULT_LAYERS[aLayer],
|
||||
aCamera,
|
||||
aWinWidth,
|
||||
aWinHeight,
|
||||
theToIncludeAuxiliary);
|
||||
combineBox (aResult, aBox);
|
||||
Bnd_Box aBox = ZLayerBoundingBox (THE_DEFAULT_LAYERS[aLayer],
|
||||
aCamera,
|
||||
aWinWidth,
|
||||
aWinHeight,
|
||||
theToIncludeAuxiliary);
|
||||
aResult.Add (aBox);
|
||||
}
|
||||
|
||||
Standard_Integer aMaxZLayer = ZLayerMax();
|
||||
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId <= aMaxZLayer; ++aLayerId)
|
||||
{
|
||||
Graphic3d_BndBox4f aBox = ZLayerBoundingBox (aLayerId,
|
||||
aCamera,
|
||||
aWinWidth,
|
||||
aWinHeight,
|
||||
theToIncludeAuxiliary);
|
||||
combineBox (aResult, aBox);
|
||||
Bnd_Box aBox = ZLayerBoundingBox (aLayerId,
|
||||
aCamera,
|
||||
aWinWidth,
|
||||
aWinHeight,
|
||||
theToIncludeAuxiliary);
|
||||
aResult.Add(aBox);
|
||||
}
|
||||
|
||||
return aResult;
|
||||
|
@@ -308,11 +308,11 @@ public:
|
||||
//! @param theWindowHeight viewport height (for applying transformation-persistence)
|
||||
//! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
|
||||
//! @return computed bounding box
|
||||
virtual Graphic3d_BndBox4f ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight,
|
||||
const Standard_Boolean theToIncludeAuxiliary) const = 0;
|
||||
virtual Bnd_Box ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight,
|
||||
const Standard_Boolean theToIncludeAuxiliary) const = 0;
|
||||
|
||||
//! Remove Z layer from the specified view. All structures
|
||||
//! displayed at the moment in layer will be displayed in default layer
|
||||
|
@@ -44,13 +44,14 @@ namespace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
: myAspect (defaultAspect()),
|
||||
myEquation (0.0, 0.0, 1.0, 0.0),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False),
|
||||
: myAspect (defaultAspect()),
|
||||
myPlane (0.0, 0.0, 1.0, 0.0),
|
||||
myEquation (0.0, 0.0, 1.0, 0.0),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod(0)
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
makeId();
|
||||
}
|
||||
@@ -60,13 +61,14 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
|
||||
: myAspect (defaultAspect()),
|
||||
myEquation (theEquation),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False),
|
||||
: myAspect (defaultAspect()),
|
||||
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
|
||||
myEquation (theEquation),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod(0)
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
makeId();
|
||||
}
|
||||
@@ -77,13 +79,14 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient(theOther),
|
||||
myAspect (defaultAspect()),
|
||||
myEquation (theOther.myEquation),
|
||||
myFlags (theOther.myFlags),
|
||||
myIsOn (theOther.myIsOn),
|
||||
myIsCapping (theOther.myIsCapping),
|
||||
myEquationMod (0),
|
||||
myAspectMod (0)
|
||||
myAspect (defaultAspect()),
|
||||
myPlane (theOther.myPlane),
|
||||
myEquation (theOther.myEquation),
|
||||
myFlags (theOther.myFlags),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (theOther.myIsOn),
|
||||
myIsCapping (theOther.myIsCapping)
|
||||
{
|
||||
makeId();
|
||||
*myAspect = *theOther.CappingAspect();
|
||||
@@ -94,16 +97,16 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
|
||||
: myAspect (defaultAspect()),
|
||||
myEquation (),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False),
|
||||
: myAspect (defaultAspect()),
|
||||
myPlane (thePlane),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod(0)
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
makeId();
|
||||
SetEquation (thePlane);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -112,6 +115,7 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
|
||||
{
|
||||
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
|
||||
myEquation = theEquation;
|
||||
myEquationMod++;
|
||||
}
|
||||
@@ -122,6 +126,7 @@ void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
|
||||
{
|
||||
myPlane = thePlane;
|
||||
thePlane.Coefficients (myEquation[0],
|
||||
myEquation[1],
|
||||
myEquation[2],
|
||||
@@ -147,18 +152,6 @@ void Graphic3d_ClipPlane::SetCapping (const Standard_Boolean theIsOn)
|
||||
myIsCapping = theIsOn;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ToPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
gp_Pln Graphic3d_ClipPlane::ToPlane() const
|
||||
{
|
||||
return gp_Pln (myEquation[0],
|
||||
myEquation[1],
|
||||
myEquation[2],
|
||||
myEquation[3]);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Clone
|
||||
// purpose :
|
||||
|
@@ -16,16 +16,15 @@
|
||||
#ifndef _Graphic3d_ClipPlane_HeaderFile
|
||||
#define _Graphic3d_ClipPlane_HeaderFile
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_CappingFlags.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
|
||||
class gp_Pln;
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
//! Container for properties describing graphic driver clipping planes.
|
||||
//! It is up to application to create instances of this class and specify its
|
||||
@@ -114,10 +113,9 @@ public:
|
||||
return myIsCapping;
|
||||
}
|
||||
|
||||
//! Get geometrical definition. The plane is built up
|
||||
//! from the equation clipping plane equation vector.
|
||||
//! @return geometrical definition of clipping plane.
|
||||
Standard_EXPORT gp_Pln ToPlane() const;
|
||||
//! Get geometrical definition.
|
||||
//! @return geometrical definition of clipping plane
|
||||
const gp_Pln& ToPlane() const { return myPlane; }
|
||||
|
||||
//! Clone plane. Virtual method to simplify copying procedure if plane
|
||||
//! class is redefined at application level to add specific fields to it
|
||||
@@ -228,12 +226,13 @@ private:
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
|
||||
TCollection_AsciiString myId; //!< resource id
|
||||
gp_Pln myPlane; //!< plane definition
|
||||
Equation myEquation; //!< plane equation vector
|
||||
unsigned int myFlags; //!< capping flags
|
||||
Standard_Boolean myIsOn; //!< state of the clipping plane
|
||||
Standard_Boolean myIsCapping; //!< state of graphic driver capping
|
||||
unsigned int myEquationMod; //!< modification counter for equation
|
||||
unsigned int myAspectMod; //!< modification counter of aspect
|
||||
Standard_Boolean myIsOn; //!< state of the clipping plane
|
||||
Standard_Boolean myIsCapping; //!< state of graphic driver capping
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -130,7 +130,7 @@ public:
|
||||
virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) = 0;
|
||||
|
||||
//! Returns the settings of a single Z layer.
|
||||
virtual Graphic3d_ZLayerSettings ZLayerSettings (const Graphic3d_ZLayerId theLayerId) = 0;
|
||||
virtual const Graphic3d_ZLayerSettings& ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const = 0;
|
||||
|
||||
//! Returns view associated with the window if it is exists and is activated.
|
||||
//! Returns Standard_True if the view associated to the window exists.
|
||||
|
@@ -100,24 +100,9 @@ void Graphic3d_Structure::Clear (const Standard_Boolean theWithDestruction)
|
||||
//=======================================================================
|
||||
void Graphic3d_Structure::CalculateBoundBox()
|
||||
{
|
||||
Graphic3d_BndBox4d aBox;
|
||||
Graphic3d_BndBox3d aBox;
|
||||
addTransformed (aBox, Standard_True);
|
||||
if (aBox.IsValid())
|
||||
{
|
||||
Graphic3d_Vec4 aMinPt (RealToShortReal (aBox.CornerMin().x()),
|
||||
RealToShortReal (aBox.CornerMin().y()),
|
||||
RealToShortReal (aBox.CornerMin().z()),
|
||||
1.0f);
|
||||
Graphic3d_Vec4 aMaxPt (RealToShortReal (aBox.CornerMax().x()),
|
||||
RealToShortReal (aBox.CornerMax().y()),
|
||||
RealToShortReal (aBox.CornerMax().z()),
|
||||
1.0f);
|
||||
myCStructure->ChangeBoundingBox() = Graphic3d_BndBox4f (aMinPt, aMaxPt);
|
||||
}
|
||||
else
|
||||
{
|
||||
myCStructure->ChangeBoundingBox().Clear();
|
||||
}
|
||||
myCStructure->ChangeBoundingBox() = aBox;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@@ -968,28 +953,26 @@ void Graphic3d_Structure::SetTransformation (const Handle(Geom_Transformation)&
|
||||
//=============================================================================
|
||||
Bnd_Box Graphic3d_Structure::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||
{
|
||||
Graphic3d_BndBox4d aBox;
|
||||
Bnd_Box aResult;
|
||||
Graphic3d_BndBox3d aBox;
|
||||
addTransformed (aBox, theToIgnoreInfiniteFlag);
|
||||
if (aBox.IsValid())
|
||||
if (!aBox.IsValid())
|
||||
{
|
||||
aResult.Add (gp_Pnt (aBox.CornerMin().x(),
|
||||
aBox.CornerMin().y(),
|
||||
aBox.CornerMin().z()));
|
||||
aResult.Add (gp_Pnt (aBox.CornerMax().x(),
|
||||
aBox.CornerMax().y(),
|
||||
aBox.CornerMax().z()));
|
||||
return Bnd_Box();
|
||||
}
|
||||
|
||||
Standard_Real aLimMin = ShortRealFirst() + 1.0;
|
||||
Standard_Real aLimMax = ShortRealLast() - 1.0;
|
||||
gp_Pnt aMin = aResult.CornerMin();
|
||||
gp_Pnt aMax = aResult.CornerMax();
|
||||
if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin &&
|
||||
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();
|
||||
}
|
||||
Bnd_Box aResult;
|
||||
aResult.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
|
||||
aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
|
||||
|
||||
Standard_Real aLimMin = ShortRealFirst() + 1.0;
|
||||
Standard_Real aLimMax = ShortRealLast() - 1.0;
|
||||
gp_Pnt aMin = aResult.CornerMin();
|
||||
gp_Pnt aMax = aResult.CornerMax();
|
||||
if (aMin.X() < aLimMin && aMin.Y() < aLimMin && aMin.Z() < aLimMin
|
||||
&& 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;
|
||||
}
|
||||
@@ -1086,33 +1069,31 @@ Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
|
||||
//function : addTransformed
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox,
|
||||
void Graphic3d_Structure::getBox (Graphic3d_BndBox3d& theBox,
|
||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||
{
|
||||
Graphic3d_BndBox4f aBoxF = minMaxCoord();
|
||||
if (aBoxF.IsValid())
|
||||
{
|
||||
theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(),
|
||||
theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
|
||||
(Standard_Real )aBoxF.CornerMin().y(),
|
||||
(Standard_Real )aBoxF.CornerMin().z(),
|
||||
(Standard_Real )aBoxF.CornerMin().w()),
|
||||
Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMax().x(),
|
||||
(Standard_Real )aBoxF.CornerMin().z()),
|
||||
Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
|
||||
(Standard_Real )aBoxF.CornerMax().y(),
|
||||
(Standard_Real )aBoxF.CornerMax().z(),
|
||||
(Standard_Real )aBoxF.CornerMax().w()));
|
||||
(Standard_Real )aBoxF.CornerMax().z()));
|
||||
if (IsInfinite()
|
||||
&& !theToIgnoreInfiniteFlag)
|
||||
{
|
||||
const Graphic3d_Vec4d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
|
||||
if (aDiagVec.xyz().SquareModulus() >= 500000.0 * 500000.0)
|
||||
const Graphic3d_Vec3d aDiagVec = theBox.CornerMax() - theBox.CornerMin();
|
||||
if (aDiagVec.SquareModulus() >= 500000.0 * 500000.0)
|
||||
{
|
||||
// bounding borders of infinite line has been calculated as own point in center of this line
|
||||
theBox = Graphic3d_BndBox4d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
|
||||
theBox = Graphic3d_BndBox3d ((theBox.CornerMin() + theBox.CornerMax()) * 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d (RealFirst(), RealFirst(), RealFirst(), 1.0),
|
||||
Graphic3d_Vec4d (RealLast(), RealLast(), RealLast(), 1.0));
|
||||
theBox = Graphic3d_BndBox3d (Graphic3d_Vec3d (RealFirst(), RealFirst(), RealFirst()),
|
||||
Graphic3d_Vec3d (RealLast(), RealLast(), RealLast()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1123,10 +1104,10 @@ void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox,
|
||||
//function : addTransformed
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void Graphic3d_Structure::addTransformed (Graphic3d_BndBox4d& theBox,
|
||||
void Graphic3d_Structure::addTransformed (Graphic3d_BndBox3d& theBox,
|
||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||
{
|
||||
Graphic3d_BndBox4d aCombinedBox, aBox;
|
||||
Graphic3d_BndBox3d aCombinedBox, aBox;
|
||||
getBox (aCombinedBox, theToIgnoreInfiniteFlag);
|
||||
|
||||
for (Graphic3d_IndexedMapOfAddress::Iterator anIter (myDescendants); anIter.More(); anIter.Next())
|
||||
|
@@ -425,10 +425,10 @@ private:
|
||||
Standard_EXPORT Graphic3d_BndBox4f minMaxCoord() const;
|
||||
|
||||
//! Gets untransformed bounding box from structure.
|
||||
Standard_EXPORT void getBox (Graphic3d_BndBox4d& theBox, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
|
||||
Standard_EXPORT void getBox (Graphic3d_BndBox3d& theBox, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
|
||||
|
||||
//! Adds transformed (with myCStructure->Transformation) bounding box of structure to theBox.
|
||||
Standard_EXPORT void addTransformed (Graphic3d_BndBox4d& theBox, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
|
||||
Standard_EXPORT void addTransformed (Graphic3d_BndBox3d& theBox, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
|
||||
|
||||
//! Returns the manager to which <me> is associated.
|
||||
Standard_EXPORT Handle(Graphic3d_StructureManager) StructureManager() const;
|
||||
|
@@ -238,7 +238,7 @@ public:
|
||||
const NCollection_Mat4<T>& theWorldView,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight,
|
||||
BVH_Box<T, 4>& theBoundingBox) const;
|
||||
BVH_Box<T, 3>& theBoundingBox) const;
|
||||
|
||||
//! Compute transformation.
|
||||
//! Computed matrix can be applied to model world transformation
|
||||
@@ -408,26 +408,22 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
else
|
||||
{
|
||||
// Compute reference point for transformation in untransformed projection space.
|
||||
NCollection_Vec4<T> aRefPoint (static_cast<T> (myParams.Params3d.PntX),
|
||||
static_cast<T> (myParams.Params3d.PntY),
|
||||
static_cast<T> (myParams.Params3d.PntZ),
|
||||
static_cast<T> (1.0));
|
||||
|
||||
Graphic3d_TransformUtils::Translate<T> (theWorldView, aRefPoint.x(), aRefPoint.y(), aRefPoint.z());
|
||||
NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
|
||||
Graphic3d_TransformUtils::Translate (aWorldView, myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ);
|
||||
if ((myMode & Graphic3d_TMF_RotatePers) != 0)
|
||||
{
|
||||
// lock rotation by nullifying rotation component
|
||||
theWorldView.SetValue (0, 0, static_cast<T> (1));
|
||||
theWorldView.SetValue (1, 0, static_cast<T> (0));
|
||||
theWorldView.SetValue (2, 0, static_cast<T> (0));
|
||||
aWorldView.SetValue (0, 0, 1.0);
|
||||
aWorldView.SetValue (1, 0, 0.0);
|
||||
aWorldView.SetValue (2, 0, 0.0);
|
||||
|
||||
theWorldView.SetValue (0, 1, static_cast<T> (0));
|
||||
theWorldView.SetValue (1, 1, static_cast<T> (1));
|
||||
theWorldView.SetValue (2, 1, static_cast<T> (0));
|
||||
aWorldView.SetValue (0, 1, 0.0);
|
||||
aWorldView.SetValue (1, 1, 1.0);
|
||||
aWorldView.SetValue (2, 1, 0.0);
|
||||
|
||||
theWorldView.SetValue (0, 2, static_cast<T> (0));
|
||||
theWorldView.SetValue (1, 2, static_cast<T> (0));
|
||||
theWorldView.SetValue (2, 2, static_cast<T> (1));
|
||||
aWorldView.SetValue (0, 2, 0.0);
|
||||
aWorldView.SetValue (1, 2, 0.0);
|
||||
aWorldView.SetValue (2, 2, 1.0);
|
||||
}
|
||||
|
||||
if ((myMode & Graphic3d_TMF_ZoomPers) != 0)
|
||||
@@ -438,8 +434,9 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
|
||||
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
|
||||
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
|
||||
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
|
||||
Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
|
||||
}
|
||||
theWorldView.ConvertFrom (aWorldView);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -465,9 +462,9 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
|
||||
theBoundingBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||
|
||||
typename BVH_Box<T, 4>::BVH_VecNt aMin (aXmin, aYmin, aZmin, static_cast<T> (1.0));
|
||||
typename BVH_Box<T, 4>::BVH_VecNt aMax (aXmax, aYmax, aZmax, static_cast<T> (1.0));
|
||||
BVH_Box<T, 4> aBBox (aMin, aMax);
|
||||
typename BVH_Box<T, 3>::BVH_VecNt aMin (aXmin, aYmin, aZmin);
|
||||
typename BVH_Box<T, 3>::BVH_VecNt aMax (aXmax, aYmax, aZmax);
|
||||
BVH_Box<T, 3> aBBox (aMin, aMax);
|
||||
|
||||
Apply (theCamera, theProjection, theWorldView, theViewportWidth, theViewportHeight, aBBox);
|
||||
|
||||
@@ -486,7 +483,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
const NCollection_Mat4<T>& theWorldView,
|
||||
const Standard_Integer theViewportWidth,
|
||||
const Standard_Integer theViewportHeight,
|
||||
BVH_Box<T, 4>& theBoundingBox) const
|
||||
BVH_Box<T, 3>& theBoundingBox) const
|
||||
{
|
||||
NCollection_Mat4<T> aTPers = Compute (theCamera, theProjection, theWorldView, theViewportWidth, theViewportHeight);
|
||||
if (aTPers.IsIdentity()
|
||||
@@ -495,8 +492,8 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
return;
|
||||
}
|
||||
|
||||
const typename BVH_Box<T, 4>::BVH_VecNt& aMin = theBoundingBox.CornerMin();
|
||||
const typename BVH_Box<T, 4>::BVH_VecNt& aMax = theBoundingBox.CornerMax();
|
||||
const typename BVH_Box<T, 3>::BVH_VecNt& aMin = theBoundingBox.CornerMin();
|
||||
const typename BVH_Box<T, 3>::BVH_VecNt& aMax = theBoundingBox.CornerMax();
|
||||
|
||||
typename BVH_Box<T, 4>::BVH_VecNt anArrayOfCorners[8];
|
||||
anArrayOfCorners[0] = typename BVH_Box<T, 4>::BVH_VecNt (aMin.x(), aMin.y(), aMin.z(), static_cast<T> (1.0));
|
||||
@@ -514,7 +511,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
||||
typename BVH_Box<T, 4>::BVH_VecNt& aCorner = anArrayOfCorners[anIt];
|
||||
aCorner = aTPers * aCorner;
|
||||
aCorner /= aCorner.w();
|
||||
theBoundingBox.Add (aCorner);
|
||||
theBoundingBox.Add (aCorner.xyz());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,10 @@
|
||||
#ifndef _Graphic3d_ZLayerSettings_HeaderFile
|
||||
#define _Graphic3d_ZLayerSettings_HeaderFile
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <Geom_Transformation.hxx>
|
||||
#include <Graphic3d_PolygonOffset.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
enum Graphic3d_ZLayerSetting
|
||||
{
|
||||
@@ -30,58 +33,141 @@ struct Graphic3d_ZLayerSettings
|
||||
|
||||
//! Default settings.
|
||||
Graphic3d_ZLayerSettings()
|
||||
: DepthOffsetFactor (1.0f),
|
||||
DepthOffsetUnits (1.0f),
|
||||
Flags (Graphic3d_ZLayerDepthTest
|
||||
| Graphic3d_ZLayerDepthWrite
|
||||
| Graphic3d_ZLayerDepthClear),
|
||||
IsImmediate (false),
|
||||
UseEnvironmentTexture (true)
|
||||
{}
|
||||
: myIsImmediate (Standard_False),
|
||||
myUseEnvironmentTexture (Standard_True),
|
||||
myToEnableDepthTest (Standard_True),
|
||||
myToEnableDepthWrite(Standard_True),
|
||||
myToClearDepth (Standard_True) {}
|
||||
|
||||
//! Return user-provided name.
|
||||
const TCollection_AsciiString& Name() const { return myName; }
|
||||
|
||||
//! Set custom name.
|
||||
void SetName (const TCollection_AsciiString& theName) { myName = theName; }
|
||||
|
||||
//! Return the origin of all objects within the layer.
|
||||
const gp_XYZ& Origin() const { return myOrigin; }
|
||||
|
||||
//! Return the transformation to the origin.
|
||||
const Handle(Geom_Transformation)& OriginTransformation() const { return myOriginTrsf; }
|
||||
|
||||
//! Set the origin of all objects within the layer.
|
||||
void SetOrigin (const gp_XYZ& theOrigin)
|
||||
{
|
||||
myOrigin = theOrigin;
|
||||
myOriginTrsf.Nullify();
|
||||
if (!theOrigin.IsEqual (gp_XYZ(0.0, 0.0, 0.0), gp::Resolution()))
|
||||
{
|
||||
myOriginTrsf = new Geom_Transformation();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return true if this layer should be drawn after all normal (non-immediate) layers.
|
||||
Standard_Boolean IsImmediate() const { return myIsImmediate; }
|
||||
|
||||
//! Set the flag indicating the immediate layer, which should be drawn after all normal (non-immediate) layers.
|
||||
void SetImmediate (const Standard_Boolean theValue) { myIsImmediate = theValue; }
|
||||
|
||||
//! Return flag to allow/prevent environment texture mapping usage for specific layer.
|
||||
Standard_Boolean UseEnvironmentTexture() const { return myUseEnvironmentTexture; }
|
||||
|
||||
//! Set the flag to allow/prevent environment texture mapping usage for specific layer.
|
||||
void SetEnvironmentTexture (const Standard_Boolean theValue) { myUseEnvironmentTexture = theValue; }
|
||||
|
||||
//! Return true if depth test should be enabled.
|
||||
Standard_Boolean ToEnableDepthTest() const { return myToEnableDepthTest; }
|
||||
|
||||
//! Set if depth test should be enabled.
|
||||
void SetEnableDepthTest(const Standard_Boolean theValue) { myToEnableDepthTest = theValue; }
|
||||
|
||||
//! Return true depth values should be written during rendering.
|
||||
Standard_Boolean ToEnableDepthWrite() const { return myToEnableDepthWrite; }
|
||||
|
||||
//! Set if depth values should be written during rendering.
|
||||
void SetEnableDepthWrite (const Standard_Boolean theValue) { myToEnableDepthWrite = theValue; }
|
||||
|
||||
//! Return true if depth values should be cleared before drawing the layer.
|
||||
Standard_Boolean ToClearDepth() const { return myToClearDepth; }
|
||||
|
||||
//! Set if depth values should be cleared before drawing the layer.
|
||||
void SetClearDepth (const Standard_Boolean theValue) { myToClearDepth = theValue; }
|
||||
|
||||
//! Return glPolygonOffset() arguments.
|
||||
const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
|
||||
|
||||
//! Setup glPolygonOffset() arguments.
|
||||
void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams) { myPolygonOffset = theParams; }
|
||||
|
||||
//! Modify glPolygonOffset() arguments.
|
||||
Graphic3d_PolygonOffset& ChangePolygonOffset() { return myPolygonOffset; }
|
||||
|
||||
//! Returns true if theSetting is enabled.
|
||||
Standard_DEPRECATED("Deprecated method IsSettingEnabled() should be replaced by individual property getters")
|
||||
Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const
|
||||
{
|
||||
return (Flags & theSetting) == theSetting;
|
||||
switch (theSetting)
|
||||
{
|
||||
case Graphic3d_ZLayerDepthTest: return myToEnableDepthTest;
|
||||
case Graphic3d_ZLayerDepthWrite: return myToEnableDepthWrite;
|
||||
case Graphic3d_ZLayerDepthClear: return myToClearDepth;
|
||||
case Graphic3d_ZLayerDepthOffset: return myPolygonOffset.Mode != Aspect_POM_Off;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! Enables theSetting
|
||||
Standard_DEPRECATED("Deprecated method EnableSetting() should be replaced by individual property getters")
|
||||
void EnableSetting (const Graphic3d_ZLayerSetting theSetting)
|
||||
{
|
||||
Flags = Flags | theSetting;
|
||||
switch (theSetting)
|
||||
{
|
||||
case Graphic3d_ZLayerDepthTest: myToEnableDepthTest = Standard_True; return;
|
||||
case Graphic3d_ZLayerDepthWrite: myToEnableDepthWrite = Standard_True; return;
|
||||
case Graphic3d_ZLayerDepthClear: myToClearDepth = Standard_True; return;
|
||||
case Graphic3d_ZLayerDepthOffset: myPolygonOffset.Mode = Aspect_POM_Fill; return;
|
||||
}
|
||||
}
|
||||
|
||||
//! Disables theSetting
|
||||
Standard_DEPRECATED("Deprecated method DisableSetting() should be replaced by individual property getters")
|
||||
void DisableSetting (const Graphic3d_ZLayerSetting theSetting)
|
||||
{
|
||||
Flags = Flags & (~theSetting);
|
||||
switch (theSetting)
|
||||
{
|
||||
case Graphic3d_ZLayerDepthTest: myToEnableDepthTest = Standard_False; return;
|
||||
case Graphic3d_ZLayerDepthWrite: myToEnableDepthWrite = Standard_False; return;
|
||||
case Graphic3d_ZLayerDepthClear: myToClearDepth = Standard_False; return;
|
||||
case Graphic3d_ZLayerDepthOffset: myPolygonOffset.Mode = Aspect_POM_Off; return;
|
||||
}
|
||||
}
|
||||
|
||||
//! Sets minimal possible positive depth offset.
|
||||
//! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
|
||||
void SetDepthOffsetPositive()
|
||||
{
|
||||
DepthOffsetFactor = 1.f;
|
||||
DepthOffsetUnits = 1.f;
|
||||
EnableSetting (Graphic3d_ZLayerDepthOffset);
|
||||
myPolygonOffset.Mode = Aspect_POM_Fill;
|
||||
myPolygonOffset.Factor = 1.0f;
|
||||
myPolygonOffset.Units = 1.0f;
|
||||
}
|
||||
|
||||
//! Sets minimal possible negative depth offset.
|
||||
//! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
|
||||
void SetDepthOffsetNegative()
|
||||
{
|
||||
DepthOffsetFactor = 1.f;
|
||||
DepthOffsetUnits = -1.f;
|
||||
EnableSetting (Graphic3d_ZLayerDepthOffset);
|
||||
myPolygonOffset.Mode = Aspect_POM_Fill;
|
||||
myPolygonOffset.Factor = 1.0f;
|
||||
myPolygonOffset.Units =-1.0f;
|
||||
}
|
||||
|
||||
public:
|
||||
protected:
|
||||
|
||||
Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function
|
||||
Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function
|
||||
Standard_Integer Flags; //!< storage field for settings
|
||||
bool IsImmediate; //!< immediate layer will be drawn after all normal layers
|
||||
bool UseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer
|
||||
TCollection_AsciiString myName; //!< user-provided name
|
||||
Handle(Geom_Transformation) myOriginTrsf; //!< transformation to the origin
|
||||
gp_XYZ myOrigin; //!< the origin of all objects within the layer
|
||||
Graphic3d_PolygonOffset myPolygonOffset; //!< glPolygonOffset() arguments
|
||||
Standard_Boolean myIsImmediate; //!< immediate layer will be drawn after all normal layers
|
||||
Standard_Boolean myUseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer
|
||||
Standard_Boolean myToEnableDepthTest; //!< option to enable depth test
|
||||
Standard_Boolean myToEnableDepthWrite; //!< option to enable write depth values
|
||||
Standard_Boolean myToClearDepth; //!< option to clear depth values before drawing the layer
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user