]> OCCT Git - occt-copy.git/commitdiff
Auto Zfit for group with own transform persistent; improve performance in OpenGl... CR0_DMUReviewer_OCCT-751_CR23854_3
authorNatalia Ermolaeva <natalia.ermolaeva@opencascade.com>
Tue, 15 Jun 2021 07:25:17 +0000 (10:25 +0300)
committerNatalia Ermolaeva <natalia.ermolaeva@opencascade.com>
Tue, 15 Jun 2021 07:25:17 +0000 (10:25 +0300)
src/Graphic3d/Graphic3d_Group.cxx
src/Graphic3d/Graphic3d_Layer.cxx
src/OpenGl/OpenGl_Text.cxx

index 9ea7a7d29ba44608df87831f3cf0b38f15838e94..687dcf4d6032740e756ab04806b0e24136e4bc78 100644 (file)
@@ -458,6 +458,8 @@ void Graphic3d_Group::DumpJson (Standard_OStream& theOStream, Standard_Integer t
 
   OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, this)
 
+  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrsfPers.get())
+
   OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStructure)
   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBounds)
 
index 6b723c8f31118229743394c57927729b8727668c..7475a0e996b79226f78242625fe94b0d56dff408 100644 (file)
@@ -171,6 +171,38 @@ inline bool isInfiniteBndBox (const Graphic3d_BndBox3d& theBndBox)
       || Abs (theBndBox.CornerMin().z()) >= ShortRealLast();
 }
 
+// =======================================================================
+// function : updateBoundingBox
+// purpose  :
+// =======================================================================
+void updateBoundingBox(const Handle(Graphic3d_Camera)& theCamera,
+  const Graphic3d_Mat4d& aProjectionMat,
+  const Graphic3d_Mat4d& aWorldViewMat,
+  Standard_Integer theWindowWidth,
+  Standard_Integer theWindowHeight,
+  const Handle(Graphic3d_TransformPers)& aTrsfPers,
+  Graphic3d_BndBox3d& aBox,
+  Bnd_Box& aResBox)
+{
+  if (aTrsfPers.IsNull())
+  {
+    return;
+  }
+
+  if (!aBox.IsValid())
+  {
+    return;
+  }
+
+  aTrsfPers->Apply(theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
+  if (aBox.IsValid()
+    && !isInfiniteBndBox(aBox))
+  {
+    aResBox.Add(gp_Pnt(aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z()));
+    aResBox.Add(gp_Pnt(aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z()));
+  }
+}
+
 // =======================================================================
 // function : BoundingBox
 // purpose  :
@@ -268,26 +300,34 @@ Bnd_Box Graphic3d_Layer::BoundingBox (Standard_Integer theViewId,
     {
       continue;
     }
-    else if (aStructure->TransformPersistence().IsNull()
-         || !aStructure->TransformPersistence()->IsTrihedronOr2d())
+    for (Graphic3d_SequenceOfGroup::Iterator aGroupIter(aStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
     {
-      continue;
+      const Handle(Graphic3d_Group)& aGroup = aGroupIter.Value();
+      if (aGroup->TransformPersistence().IsNull())
+      {
+        continue;
+      }
+
+      const Graphic3d_BndBox4f& aBoxF = aGroup->BoundingBox();
+      Graphic3d_BndBox3d aBox = 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()));
+      updateBoundingBox(theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight,
+        aGroup->TransformPersistence(), aBox, aResBox);
     }
 
-    Graphic3d_BndBox3d aBox = aStructure->BoundingBox();
-    if (!aBox.IsValid())
+    if (aStructure->TransformPersistence().IsNull()
+     || !aStructure->TransformPersistence()->IsTrihedronOr2d())
     {
       continue;
     }
 
-    aStructure->TransformPersistence()->Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
-    if (aBox.IsValid()
-    && !isInfiniteBndBox (aBox))
-    {
-      aResBox.Add (gp_Pnt (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z()));
-      aResBox.Add (gp_Pnt (aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z()));
-    }
-  }
+    Graphic3d_BndBox3d aBox = aStructure->BoundingBox();
+    updateBoundingBox (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight,
+      aStructure->TransformPersistence(), aBox, aResBox);
 
   return aResBox;
 }
index a339305815e0bd3963f560be68457abf8278c5cf..54186306c55814b618423c9b3ff4e06152cbb8e4 100644 (file)
@@ -779,16 +779,16 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   }
 #if !defined(GL_ES_VERSION_2_0)
   // activate texture unit
-  GLint aTexEnvParam = GL_REPLACE;
+  ////GLint aTexEnvParam = GL_REPLACE;
   if (theCtx->core11 != NULL)
   {
     glDisable (GL_TEXTURE_1D);
     glEnable  (GL_TEXTURE_2D);
-    glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
-    if (aTexEnvParam != GL_REPLACE)
-    {
-      glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-    }
+    ////glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
+    ////if (aTexEnvParam != GL_REPLACE)
+    ////{
+    ////  glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+    ////}
   }
 #endif
 
@@ -856,12 +856,12 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
     theCtx->ApplyProjectionMatrix();
   }
 
-#if !defined(GL_ES_VERSION_2_0)
-  if (theCtx->core11 != NULL)
-  {
-    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
-  }
-#endif
+//#if !defined(GL_ES_VERSION_2_0)
+//  if (theCtx->core11 != NULL)
+//  {
+//    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
+//  }
+//#endif
 
   if (theTextAspect.Aspect()->TextDisplayType() == Aspect_TODT_DIMENSION)
   {