0031341: Visualization - Graphic3d_Layer::UpdateCulling() ignores Presentation range
authorkgv <kgv@opencascade.com>
Fri, 31 Jan 2020 21:50:04 +0000 (00:50 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 11 Feb 2020 15:42:13 +0000 (18:42 +0300)
Graphic3d_Layer::UpdateCulling() now takes into account BVH_Tree::EndPrimitive().
'vstatprofiler structs' now properly prints number of structures in case of no culling.

src/Graphic3d/Graphic3d_Layer.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/vis/bug31341 [new file with mode: 0644]

index a94e38a..2fb67ab 100644 (file)
@@ -557,14 +557,18 @@ void Graphic3d_Layer::UpdateCulling (Standard_Integer theViewId,
       }
       else
       {
-        Standard_Integer aIdx = aBVHTree->BegPrimitive (aNode);
-        const Graphic3d_CStructure* aStruct = isTrsfPers
-                                            ? myBVHPrimitivesTrsfPers.GetStructureById (aIdx)
-                                            : myBVHPrimitives.GetStructureById (aIdx);
-        if (aStruct->IsVisible (theViewId))
+        const Standard_Integer aStartIdx = aBVHTree->BegPrimitive (aNode);
+        const Standard_Integer anEndIdx  = aBVHTree->EndPrimitive (aNode);
+        for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
         {
-          aStruct->MarkAsNotCulled();
-          ++myNbStructuresNotCulled;
+          const Graphic3d_CStructure* aStruct = isTrsfPers
+                                              ? myBVHPrimitivesTrsfPers.GetStructureById (anIdx)
+                                              : myBVHPrimitives.GetStructureById (anIdx);
+          if (aStruct->IsVisible (theViewId))
+          {
+            aStruct->MarkAsNotCulled();
+            ++myNbStructuresNotCulled;
+          }
         }
         if (aHead < 0)
         {
index d1aa802..c2d8b0f 100644 (file)
@@ -12479,7 +12479,9 @@ static Standard_Integer VStatProfiler (Draw_Interpretor& theDI,
       else if (aFlag == "alllayers"
             || aFlag == "layers")     aParam = Graphic3d_RenderingParams::PerfCounters_Layers;
       else if (aFlag == "allstructs"
-            || aFlag == "structs")    aParam = Graphic3d_RenderingParams::PerfCounters_Structures;
+            || aFlag == "allstructures"
+            || aFlag == "structs"
+            || aFlag == "structures") aParam = Graphic3d_RenderingParams::PerfCounters_Structures;
       else if (aFlag == "groups")     aParam = Graphic3d_RenderingParams::PerfCounters_Groups;
       else if (aFlag == "allarrays"
             || aFlag == "fillarrays"
@@ -12548,13 +12550,20 @@ static Standard_Integer VStatProfiler (Draw_Interpretor& theDI,
       {
         theDI << searchInfo (aDict, "Rendered layers") << " ";
       }
-      else if (aFlag == "allstructs")
+      else if (aFlag == "allstructs"
+            || aFlag == "allstructures")
       {
         theDI << searchInfo (aDict, "Structs") << " ";
       }
-      else if (aFlag == "structs")
+      else if (aFlag == "structs"
+            || aFlag == "structures")
       {
-        theDI << searchInfo (aDict, "Rendered structs") << " ";
+        TCollection_AsciiString aRend = searchInfo (aDict, "Rendered structs");
+        if (aRend.IsEmpty()) // all structures rendered
+        {
+          aRend = searchInfo (aDict, "Structs");
+        }
+        theDI << aRend << " ";
       }
       else if (aFlag == "groups")
       {
@@ -14470,7 +14479,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n      '-exposure     value'       Exposure value for tone mapping (0.0 value disables the effect)"
     "\n      '-whitepoint   value'       White point value for filmic tone mapping"
     "\n      '-tonemapping  mode'        Tone mapping mode (disabled, filmic)"
-    "\n      '-perfCounters none|fps|cpu|layers|structures|groups|arrays|triagles|points"
+    "\n      '-perfCounters none|fps|cpu|layers|structures|groups|arrays|triangles|points"
     "\n      '              |gpuMem|frameTime|basic|extended|full|nofps|skipImmediate'"
     "\n                                  Show/hide performance counters (flags can be combined)"
     "\n      '-perfUpdateInterval nbSeconds' Performance counters update interval"
@@ -14485,7 +14494,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
   theCommands.Add("vstatprofiler",
     "\n vstatprofiler [fps|cpu|allLayers|layers|allstructures|structures|groups"
     "\n                |allArrays|fillArrays|lineArrays|pointArrays|textArrays"
-    "\n                |triagles|points|geomMem|textureMem|frameMem"
+    "\n                |triangles|points|geomMem|textureMem|frameMem"
     "\n                |elapsedFrame|cpuFrameAverage|cpuPickingAverage|cpuCullingAverage|cpuDynAverage"
     "\n                |cpuFrameMax|cpuPickingMax|cpuCullingMax|cpuDynMax]"
     "\n                [-noredraw]"
diff --git a/tests/bugs/vis/bug31341 b/tests/bugs/vis/bug31341
new file mode 100644 (file)
index 0000000..7678162
--- /dev/null
@@ -0,0 +1,23 @@
+puts "============="
+puts "0031341: Visualization - Graphic3d_Layer::UpdateCulling() ignores Presentation range"
+puts "============="
+
+pload MODELING VISUALIZATION
+# create big enough set of overlapped boxes, so that more than 1 structure appear on a leaf of BVH tree
+set aList {}
+for {set i 0} {$i < 2000} {incr i} { box b$i 2000-$i 2000-$i 2000-$i; lappend aList b$i }
+vclear
+vinit View1
+vtop
+vdefaults -autoTriang 0
+vdisplay -dispMode 0 {*}$aList
+
+vfit
+vzoom 5
+if { [vstatprofiler structs] != 1203 } { puts "Error: unexpected number of culled structures" }
+vdump $::imagedir/${::casename}_zoom.png
+
+vfit
+vzoom 0.9
+if { [vstatprofiler structs] != 2000 } { puts "Error: no culling is expected" }
+vdump $::imagedir/${::casename}.png