0031505: Point Cloud Rendering - fix on-screen statistics about number of visible...
[occt.git] / src / OpenGl / OpenGl_FrameStats.cxx
index b34eb69..9828dd4 100644 (file)
@@ -92,6 +92,7 @@ void OpenGl_FrameStats::updateStatistics (const Handle(Graphic3d_CView)& theView
   const Graphic3d_RenderingParams::PerfCounters aBits = theView->RenderingParams().CollectedStats;
   const Standard_Boolean toCountMem     = (aBits & Graphic3d_RenderingParams::PerfCounters_EstimMem)  != 0;
   const Standard_Boolean toCountTris    = (aBits & Graphic3d_RenderingParams::PerfCounters_Triangles) != 0
+                                       || (aBits & Graphic3d_RenderingParams::PerfCounters_Lines)     != 0
                                        || (aBits & Graphic3d_RenderingParams::PerfCounters_Points)    != 0;
   const Standard_Boolean toCountElems   = (aBits & Graphic3d_RenderingParams::PerfCounters_GroupArrays) != 0 || toCountTris || toCountMem;
   const Standard_Boolean toCountGroups  = (aBits & Graphic3d_RenderingParams::PerfCounters_Groups)      != 0 || toCountElems;
@@ -207,7 +208,7 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
             const OpenGl_Group* aGroup = aGroupIter.Value();
             for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
             {
-              myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += aNodeIter->elem->EstimatedDataSize();
+              aNodeIter->elem->UpdateMemStats (myCountersTmp);
             }
           }
         }
@@ -227,92 +228,9 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
         {
           if (theToCountMem)
           {
-            myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += aNodeIter->elem->EstimatedDataSize();
-          }
-          if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
-          {
-            ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
-            if (aPrim->IsFillDrawMode())
-            {
-              ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled];
-              if (!theToCountTris)
-              {
-                continue;
-              }
-
-              const Handle(OpenGl_VertexBuffer)& anAttribs = aPrim->AttributesVbo();
-              if (anAttribs.IsNull()
-              || !anAttribs->IsValid())
-              {
-                continue;
-              }
-
-              const Handle(OpenGl_VertexBuffer)& anIndices = aPrim->IndexVbo();
-              const Standard_Integer aNbIndices = !anIndices.IsNull() ? anIndices->GetElemsNb() : anAttribs->GetElemsNb();
-              const Standard_Integer aNbBounds  = !aPrim->Bounds().IsNull() ? aPrim->Bounds()->NbBounds : 1;
-              switch (aPrim->DrawMode())
-              {
-                case GL_TRIANGLES:
-                {
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 3;
-                  break;
-                }
-                case GL_TRIANGLE_STRIP:
-                case GL_TRIANGLE_FAN:
-                {
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 2 * aNbBounds;
-                  break;
-                }
-                case GL_TRIANGLES_ADJACENCY:
-                {
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 6;
-                  break;
-                }
-                case GL_TRIANGLE_STRIP_ADJACENCY:
-                {
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds;
-                  break;
-                }
-              #if !defined(GL_ES_VERSION_2_0)
-                case GL_QUADS:
-                {
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 2;
-                  break;
-                }
-                case GL_QUAD_STRIP:
-                {
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2;
-                  break;
-                }
-              #endif
-              }
-            }
-            else if (aPrim->DrawMode() == GL_POINTS)
-            {
-              ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsPointNotCulled];
-              if (theToCountTris)
-              {
-                const Handle(OpenGl_VertexBuffer)& anAttribs = aPrim->AttributesVbo();
-                if (!anAttribs.IsNull()
-                  && anAttribs->IsValid())
-                {
-                  const Handle(OpenGl_VertexBuffer)& anIndices = aPrim->IndexVbo();
-                  const Standard_Integer aNbIndices = !anIndices.IsNull() ? anIndices->GetElemsNb() : anAttribs->GetElemsNb();
-                  myCountersTmp[Graphic3d_FrameStatsCounter_NbPointsNotCulled] += aNbIndices;
-                }
-              }
-            }
-            else
-            {
-              ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
-            }
-          }
-          else if (const OpenGl_Text* aText = dynamic_cast<const OpenGl_Text*> (aNodeIter->elem))
-          {
-            (void )aText;
-            ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
-            ++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsTextNotCulled];
+            aNodeIter->elem->UpdateMemStats (myCountersTmp);
           }
+          aNodeIter->elem->UpdateDrawStats (myCountersTmp, theToCountTris);
         }
       }
     }