mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
0026792: Visualization, Graphic3d - Z-fit support for transform persistence is missing after removing Visual3d_View
Add missing code for z-fit support for zoom, rotate persistent object. Fixed wrong statement that should enable frustum culling optimization for zoom, rotate persistent object. Added non-regression test case for z-clipping of transform persistent objects.
This commit is contained in:
@@ -401,53 +401,6 @@ void Graphic3d_CView::DisplayedStructures (Graphic3d_MapOfStructure& theStructur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Auxiliary method for MinMaxValues() method
|
|
||||||
inline void addStructureBndBox (const Handle(Graphic3d_Structure)& theStruct,
|
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag,
|
|
||||||
Bnd_Box& theBndBox)
|
|
||||||
{
|
|
||||||
if (!theStruct->IsVisible())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (theStruct->IsInfinite()
|
|
||||||
&& !theToIgnoreInfiniteFlag)
|
|
||||||
{
|
|
||||||
// XMin, YMin .... ZMax are initialized by means of infinite line data
|
|
||||||
const Bnd_Box aBox = theStruct->MinMaxValues (Standard_False);
|
|
||||||
if (!aBox.IsWhole()
|
|
||||||
&& !aBox.IsVoid())
|
|
||||||
{
|
|
||||||
theBndBox.Add (aBox);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only non-empty and non-infinite structures
|
|
||||||
// are taken into account for calculation of MinMax
|
|
||||||
if (theStruct->IsEmpty()
|
|
||||||
|| theStruct->TransformPersistenceMode() != Graphic3d_TMF_None)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// "FitAll" operation ignores object with transform persistence parameter
|
|
||||||
const Bnd_Box aBox = theStruct->MinMaxValues (theToIgnoreInfiniteFlag);
|
|
||||||
|
|
||||||
// To prevent float overflow at camera parameters calculation and further
|
|
||||||
// rendering, bounding boxes with at least one vertex coordinate out of
|
|
||||||
// float range are skipped by view fit algorithms
|
|
||||||
if (Abs (aBox.CornerMax().X()) >= ShortRealLast() ||
|
|
||||||
Abs (aBox.CornerMax().Y()) >= ShortRealLast() ||
|
|
||||||
Abs (aBox.CornerMax().Z()) >= ShortRealLast() ||
|
|
||||||
Abs (aBox.CornerMin().X()) >= ShortRealLast() ||
|
|
||||||
Abs (aBox.CornerMin().Y()) >= ShortRealLast() ||
|
|
||||||
Abs (aBox.CornerMin().Z()) >= ShortRealLast())
|
|
||||||
return;
|
|
||||||
|
|
||||||
theBndBox.Add (aBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : MinMaxValues
|
// function : MinMaxValues
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -472,20 +425,69 @@ Bnd_Box Graphic3d_CView::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
|
|||||||
{
|
{
|
||||||
Bnd_Box aResult;
|
Bnd_Box aResult;
|
||||||
const Standard_Integer aViewId = Identification();
|
const Standard_Integer aViewId = Identification();
|
||||||
|
|
||||||
|
Handle(Graphic3d_Camera) aCamera = Camera();
|
||||||
|
Standard_Integer aWinWidth = 0;
|
||||||
|
Standard_Integer aWinHeight = 0;
|
||||||
|
if (IsDefined())
|
||||||
|
{
|
||||||
|
Window()->Size (aWinWidth, aWinHeight);
|
||||||
|
}
|
||||||
|
|
||||||
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
|
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
|
||||||
{
|
{
|
||||||
const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key();
|
const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key();
|
||||||
if (!aStructIter.Value()->IsVisible())
|
if (!aStructure->IsVisible() || aStructure->IsEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (!aStructIter.Value()->CStructure()->ViewAffinity.IsNull()
|
else if (!aStructure->CStructure()->ViewAffinity.IsNull()
|
||||||
&& !aStructIter.Value()->CStructure()->ViewAffinity->IsVisible (aViewId))
|
&& !aStructure->CStructure()->ViewAffinity->IsVisible (aViewId))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
addStructureBndBox (aStructure, theToIgnoreInfiniteFlag, aResult);
|
// "FitAll" operation ignores object with transform persistence parameter
|
||||||
|
if (aStructure->TransformPersistence().Flags)
|
||||||
|
{
|
||||||
|
// Panning and 2d persistence apply changes to projection or/and its translation components.
|
||||||
|
// It makes them incompatible with z-fitting algorithm. Ignored by now.
|
||||||
|
if (!theToIgnoreInfiniteFlag ||
|
||||||
|
(aStructure->TransformPersistence().Flags & Graphic3d_TMF_2d) ||
|
||||||
|
(aStructure->TransformPersistence().Flags & Graphic3d_TMF_PanPers))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bnd_Box aBox = aStructure->MinMaxValues (theToIgnoreInfiniteFlag);
|
||||||
|
|
||||||
|
if (aBox.IsWhole() || aBox.IsVoid())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aStructure->TransformPersistence().Flags != Graphic3d_TMF_None)
|
||||||
|
{
|
||||||
|
const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
|
||||||
|
const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
|
||||||
|
aStructure->TransformPersistence().Apply (aProjectionMat, aWorldViewMat, aWinWidth, aWinHeight, aBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
// To prevent float overflow at camera parameters calculation and further
|
||||||
|
// rendering, bounding boxes with at least one vertex coordinate out of
|
||||||
|
// float range are skipped by view fit algorithms
|
||||||
|
if (Abs (aBox.CornerMax().X()) >= ShortRealLast() ||
|
||||||
|
Abs (aBox.CornerMax().Y()) >= ShortRealLast() ||
|
||||||
|
Abs (aBox.CornerMax().Z()) >= ShortRealLast() ||
|
||||||
|
Abs (aBox.CornerMin().X()) >= ShortRealLast() ||
|
||||||
|
Abs (aBox.CornerMin().Y()) >= ShortRealLast() ||
|
||||||
|
Abs (aBox.CornerMin().Z()) >= ShortRealLast())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
aResult.Add (aBox);
|
||||||
}
|
}
|
||||||
return aResult;
|
return aResult;
|
||||||
}
|
}
|
||||||
|
@@ -163,7 +163,8 @@ public:
|
|||||||
|| IsForHighlight
|
|| IsForHighlight
|
||||||
|| IsMutable
|
|| IsMutable
|
||||||
|| Is2dText
|
|| Is2dText
|
||||||
|| TransformPersistence.Flags != 0;
|
|| (TransformPersistence.Flags & Graphic3d_TMF_2d) != 0
|
||||||
|
|| (TransformPersistence.Flags & Graphic3d_TMF_PanPers) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! This method releases GL resources without actual elements destruction.
|
//! This method releases GL resources without actual elements destruction.
|
||||||
|
21
tests/bugs/vis/bug26792
Normal file
21
tests/bugs/vis/bug26792
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
puts "================================================================"
|
||||||
|
puts "CR26792"
|
||||||
|
puts "Visualization, Graphic3d - Z-fit support for transform persistence is missing after removing Visual3d_View"
|
||||||
|
puts "================================================================"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vclear
|
||||||
|
vaxo
|
||||||
|
|
||||||
|
box b 100 100 100
|
||||||
|
vdisplay b -trsfPers zoom
|
||||||
|
vzoom 0.01
|
||||||
|
vzfit
|
||||||
|
|
||||||
|
checkcolor 204 184 1.0 1.0 0.0
|
||||||
|
checkcolor 232 205 1.0 1.0 0.0
|
||||||
|
checkcolor 262 182 1.0 1.0 0.0
|
||||||
|
checkcolor 233 184 1.0 1.0 0.0
|
||||||
|
|
||||||
|
set only_screen 1
|
Reference in New Issue
Block a user