0025935: Visualization, TKV3d, Exception when displaying shell in the viewer
authorvpa <vpa@opencascade.com>
Mon, 30 Mar 2015 09:28:26 +0000 (12:28 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 6 Apr 2015 14:23:35 +0000 (17:23 +0300)
Fixed processing of double precision numbers in Visual3d_View::MinMaxValues;
Test case for issue #25935.

src/AIS/AIS_Shape.cxx
src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx
src/Visual3d/Visual3d_View.cxx
tests/bugs/vis/bug25935 [new file with mode: 0644]

index 9026a2e..b8bfede 100644 (file)
@@ -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   "<<endl;
     if ( aMode == 0 ) {
+      aSelection->Clear();
       Bnd_Box B = BoundingBox();
       Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
       Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
index 783b98b..bf7f77e 100644 (file)
@@ -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));
 }
index 42cfb67..5220020 100644 (file)
@@ -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 (file)
index 0000000..8eeeb40
--- /dev/null
@@ -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