0031505: Point Cloud Rendering - fix on-screen statistics about number of visible...
[occt.git] / src / OpenGl / OpenGl_PrimitiveArray.cxx
index 97c28f2..38f0475 100644 (file)
@@ -777,6 +777,99 @@ Standard_Size OpenGl_PrimitiveArray::EstimatedDataSize() const
 }
 
 // =======================================================================
+// function : UpdateDrawStats
+// purpose  :
+// =======================================================================
+void OpenGl_PrimitiveArray::UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theStats,
+                                             bool theIsDetailed) const
+{
+  ++theStats[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
+  if (myIsFillType)
+  {
+    ++theStats[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled];
+  }
+  else if (myDrawMode == GL_POINTS)
+  {
+    ++theStats[Graphic3d_FrameStatsCounter_NbElemsPointNotCulled];
+  }
+  else
+  {
+    ++theStats[Graphic3d_FrameStatsCounter_NbElemsLineNotCulled];
+  }
+
+  if (!theIsDetailed
+  ||  myVboAttribs.IsNull()
+  || !myVboAttribs->IsValid())
+  {
+    return;
+  }
+
+  const Standard_Integer aNbIndices = !myVboIndices.IsNull() ? myVboIndices->GetElemsNb() : myVboAttribs->GetElemsNb();
+  const Standard_Integer aNbBounds  = !myBounds.IsNull() ? myBounds->NbBounds : 1;
+  switch (myDrawMode)
+  {
+    case GL_POINTS:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbPointsNotCulled] += aNbIndices;
+      break;
+    }
+    case GL_LINES:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices / 2;
+      break;
+    }
+    case GL_LINE_STRIP:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices - aNbBounds;
+      break;
+    }
+    case GL_LINES_ADJACENCY:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices / 4;
+      break;
+    }
+    case GL_LINE_STRIP_ADJACENCY:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbLinesNotCulled] += aNbIndices - 4 * aNbBounds;
+      break;
+    }
+    case GL_TRIANGLES:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 3;
+      break;
+    }
+    case GL_TRIANGLE_STRIP:
+    case GL_TRIANGLE_FAN:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 2 * aNbBounds;
+      break;
+    }
+    case GL_TRIANGLES_ADJACENCY:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 6;
+      break;
+    }
+    case GL_TRIANGLE_STRIP_ADJACENCY:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds;
+      break;
+    }
+  #if !defined(GL_ES_VERSION_2_0)
+    case GL_QUADS:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 2;
+      break;
+    }
+    case GL_QUAD_STRIP:
+    {
+      theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2;
+      break;
+    }
+  #endif
+  }
+}
+
+// =======================================================================
 // function : Render
 // purpose  :
 // =======================================================================