0031175: Visualization - support dumping RED channel as grayscale image
authorkgv <kgv@opencascade.com>
Mon, 18 Nov 2019 11:00:01 +0000 (14:00 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 19 Nov 2019 07:37:54 +0000 (10:37 +0300)
Graphic3d_BufferType has been extended by Graphic3d_BT_Red.

src/Graphic3d/Graphic3d_BufferType.hxx
src/OpenGl/OpenGl_FrameBuffer.cxx
src/V3d/V3d_View.cxx
src/ViewerTest/ViewerTest.cxx

index d4e7c5b..8abedb9 100644 (file)
 #define _Graphic3d_BufferType_H__
 
 //! Define buffers available for dump
-typedef enum
+enum Graphic3d_BufferType
 {
   Graphic3d_BT_RGB,   //!< color buffer without alpha component
   Graphic3d_BT_RGBA,  //!< color buffer
-  Graphic3d_BT_Depth,  //!< depth buffer
-  Graphic3d_BT_RGB_RayTraceHdrLeft //!< left view HDR color buffer for Ray-Tracing
-} Graphic3d_BufferType;
+  Graphic3d_BT_Depth, //!< depth buffer
+  Graphic3d_BT_RGB_RayTraceHdrLeft, //!< left view HDR color buffer for Ray-Tracing
+  Graphic3d_BT_Red,   //!< color buffer, red channel
+};
 
 #endif // _Graphic3d_BufferType_H__
index 3380c17..a05e321 100644 (file)
@@ -779,11 +779,11 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
   {
   #if !defined(GL_ES_VERSION_2_0)
     case Image_Format_Gray:
-      aFormat = GL_DEPTH_COMPONENT;
+      aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED;
       aType   = GL_UNSIGNED_BYTE;
       break;
     case Image_Format_GrayF:
-      aFormat = GL_DEPTH_COMPONENT;
+      aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED;
       aType   = GL_FLOAT;
       break;
     case Image_Format_RGF:
index 1b63f49..4950ea4 100644 (file)
@@ -2700,6 +2700,7 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
         case Graphic3d_BT_RGBA:                aFormat = Image_Format_RGBA;  break;
         case Graphic3d_BT_Depth:               aFormat = Image_Format_GrayF; break;
         case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF;  break;
+        case Graphic3d_BT_Red:                 aFormat = Image_Format_Gray;  break;
       }
 
       if (!theImage.InitZero (aFormat, Standard_Size(aTargetSize.x()), Standard_Size(aTargetSize.y())))
index 6e2a972..e188566 100644 (file)
@@ -1157,6 +1157,10 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
       {
         aParams.BufferType = Graphic3d_BT_RGB;
       }
+      else if (aBufArg == "red")
+      {
+        aParams.BufferType = Graphic3d_BT_Red;
+      }
       else if (aBufArg == "depth")
       {
         aParams.BufferType = Graphic3d_BT_Depth;
@@ -1223,6 +1227,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     {
       aParams.BufferType = Graphic3d_BT_RGB;
     }
+    else if (anArg == "-red"
+          || anArg ==  "red")
+    {
+      aParams.BufferType = Graphic3d_BT_Red;
+    }
     else if (anArg == "-depth"
           || anArg ==  "depth")
     {
@@ -1303,6 +1312,7 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
     case Graphic3d_BT_RGBA:                aFormat = Image_Format_RGBA;  break;
     case Graphic3d_BT_Depth:               aFormat = Image_Format_GrayF; break;
     case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF;  break;
+    case Graphic3d_BT_Red:                 aFormat = Image_Format_Gray;  break;
   }
 
   switch (aStereoPair)