From: kgv Date: Mon, 18 Nov 2019 11:00:01 +0000 (+0300) Subject: 0031175: Visualization - support dumping RED channel as grayscale image X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=858a361f1f4af5055a32336a1f9c4e92b3d174c9;p=occt-copy.git 0031175: Visualization - support dumping RED channel as grayscale image Graphic3d_BufferType has been extended by Graphic3d_BT_Red. --- diff --git a/src/Graphic3d/Graphic3d_BufferType.hxx b/src/Graphic3d/Graphic3d_BufferType.hxx index d4e7c5b6f4..8abedb9d17 100644 --- a/src/Graphic3d/Graphic3d_BufferType.hxx +++ b/src/Graphic3d/Graphic3d_BufferType.hxx @@ -15,12 +15,13 @@ #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__ diff --git a/src/OpenGl/OpenGl_FrameBuffer.cxx b/src/OpenGl/OpenGl_FrameBuffer.cxx index a3fa54f032..104d583b85 100644 --- a/src/OpenGl/OpenGl_FrameBuffer.cxx +++ b/src/OpenGl/OpenGl_FrameBuffer.cxx @@ -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: diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index af34004aa0..b16b00a442 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -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()))) diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 47604eff68..894a6f05a1 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -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)