]> OCCT Git - occt-copy.git/commitdiff
0031579: Visualization - OpenGl_CappingAlgo performance on some clipping planes CR0_DMUReviewer_IR-2019-08-30_CR31786
authorsshutina <sshutina@opencascade.com>
Thu, 24 Sep 2020 17:11:59 +0000 (20:11 +0300)
committersshutina <sshutina@opencascade.com>
Thu, 24 Sep 2020 17:11:59 +0000 (20:11 +0300)
src/OpenGl/OpenGl_CappingAlgo.cxx

index 377f87023507ee8394e4d2c5039068b633124fe5..aec642db75d271c9f966c0faf90331072a7600ad 100755 (executable)
@@ -177,6 +177,35 @@ namespace
     theWorkspace->SetAllowFaceCulling (wasCullAllowed);
   }
 
+  bool isGroupClipped (const Handle(Graphic3d_Group)& theGroup, const Handle(OpenGl_Context)& theContext)
+  {
+    const Graphic3d_BndBox4f& aBoxF = theGroup->BoundingBox();
+    Graphic3d_BndBox3d aBBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
+                                                  (Standard_Real )aBoxF.CornerMin().y(),
+                                                  (Standard_Real )aBoxF.CornerMin().z()),
+                                 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
+                                                  (Standard_Real )aBoxF.CornerMax().y(),
+                                                  (Standard_Real )aBoxF.CornerMax().z()));
+
+    Standard_Boolean isClipped = false;
+    for (OpenGl_ClippingIterator aPlaneIt (theContext->Clipping()); aPlaneIt.More(); aPlaneIt.Next())
+    {
+      const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+      if (!aPlane->IsOn())
+      {
+        continue;
+      }
+
+      const Graphic3d_ClipState aBoxState = aPlane->ProbeBox (aBBox);
+      if (aBoxState == Graphic3d_ClipState_Out)
+      {
+        isClipped = true;
+        break;
+      }
+    }
+    return isClipped;
+  }
+
   //! Render capping for specific structure.
   static void renderCappingForStructure (StencilTestSentry& theStencilSentry,
                                          const Handle(OpenGl_Workspace)& theWorkspace,
@@ -207,6 +236,11 @@ namespace
         continue;
       }
 
+      if (isGroupClipped (aGroupIter.Value(), aContext))
+      {
+        continue;
+      }
+
       // clear stencil only if something has been actually drawn
       theStencilSentry.Init();