1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0032752: Visualization, TKOpenGl - extend V3d_View::ToPixMap() options with Z-layer

Added option to dump only a selection of zlayer's content.
Changed zlayers redraw and render method for selection of layers to render.
Added filters for layer parsing.
Modified vdump command.
Added test with multiple dumps for comparison.
Added option to dump shadow maps.
This commit is contained in:
drochalo
2023-11-03 10:48:11 +00:00
committed by dpasukhi
parent 65d8eece35
commit 4c8faa5e2d
14 changed files with 365 additions and 58 deletions

View File

@@ -966,8 +966,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
ViewerTest_StereoPair aStereoPair = ViewerTest_SP_Single;
V3d_ImageDumpOptions aParams;
Handle(Graphic3d_Camera) aCustomCam;
aParams.BufferType = Graphic3d_BT_RGB;
aParams.StereoOptions = V3d_SDO_MONO;
aParams.BufferType = Graphic3d_BT_RGB;
aParams.StereoOptions = V3d_SDO_MONO;
aParams.TargetZLayerId = Graphic3d_ZLayerId_BotOSD;
aParams.IsSingleLayer = Standard_False;
aParams.LightName = "";
for (; anArgIter < theArgNb; ++anArgIter)
{
TCollection_AsciiString anArg (theArgVec[anArgIter]);
@@ -998,6 +1001,31 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
{
aParams.BufferType = Graphic3d_BT_Depth;
}
else if (aBufArg == "shadowmap")
{
if (++anArgIter >= theArgNb)
{
Message::SendFail() << "Error: missing light name for shadowmap dump";
return 1;
}
aParams.BufferType = Graphic3d_BT_ShadowMap;
aParams.LightName = theArgVec[anArgIter];
Standard_Boolean isLightFound = Standard_False;
for (V3d_ListOfLightIterator aLightIter(aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next())
{
Handle(V3d_Light) aLight = aLightIter.Value();
if (aLight->Name() == aParams.LightName)
{
isLightFound = Standard_True;
break;
}
}
if (!isLightFound)
{
Message::SendFail() << "Error: couldn't find light '" << aParams.LightName << "'";
return 1;
}
}
else
{
Message::SendFail() << "Error: unknown buffer '" << aBufArg << "'";
@@ -1105,6 +1133,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
{
aParams.BufferType = Graphic3d_BT_Depth;
}
else if (anArg == "-shadowmap"
|| anArg == "shadowmap")
{
aParams.BufferType = Graphic3d_BT_ShadowMap;
}
else if (anArg == "-width"
|| anArg == "width"
|| anArg == "sizex")
@@ -1147,6 +1180,39 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
}
aParams.TileSize = Draw::Atoi (theArgVec[anArgIter]);
}
else if (anArg == "-grouplayer")
{
if (++anArgIter >= theArgNb)
{
Message::SendFail() << "Error: integer value is expected right after 'grouplayer'";
return 1;
}
Graphic3d_ZLayerId aZLayer = (Graphic3d_ZLayerId)Draw::Atoi (theArgVec[anArgIter]);
if (!ViewerTest::ParseZLayer (theArgVec[anArgIter], aZLayer) ||
aZLayer == Graphic3d_ZLayerId_UNKNOWN)
{
Message::SendFail() << "Error: invalid layer " << aZLayer << ".";
return 1;
}
aParams.TargetZLayerId = aZLayer;
}
else if (anArg == "-singlelayer")
{
if (++anArgIter >= theArgNb)
{
Message::SendFail() << "Error: integer value is expected right after 'singlelayer'";
return 1;
}
Graphic3d_ZLayerId aZLayer = (Graphic3d_ZLayerId)Draw::Atoi (theArgVec[anArgIter]);
if (!ViewerTest::ParseZLayer (theArgVec[anArgIter], aZLayer) ||
aZLayer == Graphic3d_ZLayerId_UNKNOWN)
{
Message::SendFail() << "Error: invalid layer " << aZLayer << ".";
return 1;
}
aParams.TargetZLayerId = aZLayer;
aParams.IsSingleLayer = Standard_True;
}
else
{
Message::SendFail() << "Error: unknown argument '" << theArgVec[anArgIter] << "'";
@@ -1174,6 +1240,7 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
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;
case Graphic3d_BT_ShadowMap: aFormat = Image_Format_GrayF; break;
}
const bool wasImmUpdate = aView->SetImmediateUpdate (false);
@@ -1194,8 +1261,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
else if (aPixMap.SizeX() != Standard_Size(aParams.Width)
|| aPixMap.SizeY() != Standard_Size(aParams.Height))
{
theDI << "Fail: dumped dimensions " << (Standard_Integer )aPixMap.SizeX() << "x" << (Standard_Integer )aPixMap.SizeY()
<< " are lesser than requested " << aParams.Width << "x" << aParams.Height << "\n";
if (aParams.BufferType != Graphic3d_BT_ShadowMap)
{
theDI << "Fail: dumped dimensions " << (Standard_Integer)aPixMap.SizeX() << "x" << (Standard_Integer)aPixMap.SizeY()
<< " are lesser than requested " << aParams.Width << "x" << aParams.Height << "\n";
}
}
break;
}
@@ -6784,6 +6854,9 @@ vdump <filename>.png [-width Width -height Height]
[-stereo mono|left|right|blend|sideBySide|overUnder=mono]
[-xrPose base|head|handLeft|handRight=base]
[-tileSize Size=0]
[-grouplayer zlayerId]
[-singlelayer zlayerId]
[-buffer shadowmap lightname]
Dumps content of the active view into image file.
)" /* [vdump] */);