]> OCCT Git - occt-copy.git/commitdiff
0031175: Visualization - support dumping RED channel as grayscale image
authorkgv <kgv@opencascade.com>
Mon, 18 Nov 2019 11:00:01 +0000 (14:00 +0300)
committermgn <mgn@opencascade.com>
Mon, 25 Nov 2019 09:57:57 +0000 (12:57 +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 d4e7c5b6f47e31b9a2bfd18d12ca5bb0369af69e..8abedb9d17dc9d99c2575deddc651b929980345b 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 a3fa54f032ab1216dea685dc84342e14c3cc7f8e..104d583b85a966b12cdc5525a9862926988c72ba 100644 (file)
@@ -874,11 +874,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_RGB:
index af34004aa0dc13d8996fd255936a9c41550fcacf..b16b00a442de42618db561a734c826f83777c8de 100644 (file)
@@ -2642,6 +2642,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 47604eff680c6ef16f7733a4c9551647367b959e..894a6f05a1e975ffe7d95a9c1a5afdbf8415f5f7 100644 (file)
@@ -1122,6 +1122,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;
@@ -1188,6 +1192,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")
     {
@@ -1268,6 +1277,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)