From 53a701974a6cdd375c9fcc91da70f50e89b319b2 Mon Sep 17 00:00:00 2001 From: vpa Date: Mon, 30 Mar 2015 12:28:26 +0300 Subject: [PATCH] 0025935: Visualization, TKV3d, Exception when displaying shell in the viewer Fixed processing of double precision numbers in Visual3d_View::MinMaxValues; Test case for issue #25935. --- src/AIS/AIS_Shape.cxx | 1 + src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx | 12 ++++---- src/Visual3d/Visual3d_View.cxx | 12 ++++++++ tests/bugs/vis/bug25935 | 29 +++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 tests/bugs/vis/bug25935 diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 9026a2e659..b8bfede8da 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -394,6 +394,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, } catch ( Standard_Failure ) { // cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<Clear(); Bnd_Box B = BoundingBox(); Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this); Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B); diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx index 783b98b6a5..bf7f77e3d6 100644 --- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx +++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx @@ -72,9 +72,9 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_R const Standard_Real theY, const Standard_Real theZ) { - return AddVertex (Standard_ShortReal (theX), - Standard_ShortReal (theY), - Standard_ShortReal (theZ)); + return AddVertex (RealToShortReal (theX), + RealToShortReal (theY), + RealToShortReal (theZ)); } inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& theVertex, @@ -87,7 +87,7 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& th inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Real theNX, const Standard_Real theNY, const Standard_Real theNZ) { - return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ), + return AddVertex (RealToShortReal (theX), RealToShortReal (theY), RealToShortReal (theZ), Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ)); } @@ -101,7 +101,7 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const gp_Pnt& inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Real theTX, const Standard_Real theTY) { - return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ), + return AddVertex (RealToShortReal (theX), RealToShortReal (theY), RealToShortReal (theZ), Standard_ShortReal (theTX), Standard_ShortReal (theTY)); } @@ -118,7 +118,7 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex (const Standard_R const Standard_Real theNX, const Standard_Real theNY, const Standard_Real theNZ, const Standard_Real theTX, const Standard_Real theTY) { - return AddVertex (Standard_ShortReal (theX), Standard_ShortReal (theY), Standard_ShortReal (theZ), + return AddVertex (RealToShortReal (theX), RealToShortReal (theY), RealToShortReal (theZ), Standard_ShortReal (theNX), Standard_ShortReal (theNY), Standard_ShortReal (theNZ), Standard_ShortReal (theTX), Standard_ShortReal (theTY)); } diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index 42cfb67ced..5220020ae4 100644 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -1714,6 +1714,18 @@ inline void addStructureBndBox (const Handle(Graphic3d_Structure)& theStruct, // "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); } diff --git a/tests/bugs/vis/bug25935 b/tests/bugs/vis/bug25935 new file mode 100644 index 0000000000..8eeeb401bf --- /dev/null +++ b/tests/bugs/vis/bug25935 @@ -0,0 +1,29 @@ +puts "============" +puts "CR25935" +puts "Visualization, TKV3d, Exception when displaying shell in the viewer" +puts "============" +puts "" + +pload VISUALIZATION MODELING + +restore [locate_data_file bug25935.brep] aShape +explode aShape Sh + +vinit + +# check displaying and selection of a sub-shell of the shape +vdisplay aShape_3 +vfit +vmoveto 214 200 +checkcolor 214 200 0 1 1 + +vremove -all + +# check displaying and selection of the whole shape +vdisplay aShape +vfit +vmoveto 192 211 +vmoveto 213 191 +vmoveto 205 205 +vmoveto 197 194 +checkcolor 205 205 0 1 1 -- 2.20.1