1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0032391: Draw Harness - missing syntax validation within vseldump

SelectMgr_SelectionImageFiller, SurfaceNormalFiller - pick results from SelectMgr_SortCriterion
instead of calling redundant Matches().
vseldump - added missing syntax error output on incorrect -type parameter.
This commit is contained in:
kgv 2021-05-25 00:08:05 +03:00 committed by bugmaster
parent 604aa3f4b3
commit df23a355c4
2 changed files with 23 additions and 19 deletions

View File

@ -339,15 +339,20 @@ namespace
} }
else else
{ {
const Handle(Select3D_SensitiveEntity)& aPickedEntity = myMainSel->PickedEntity (thePicked); const SelectMgr_SortCriterion& aPickedData = myMainSel->PickedData (thePicked);
SelectBasics_PickResult aPickResult; Graphic3d_Vec3 aNormal = aPickedData.Normal;
aPickedEntity->Matches (myMainSel->GetManager(), aPickResult);
Graphic3d_Vec3 aNormal = aPickResult.SurfaceNormal();
aNormal.Normalize(); aNormal.Normalize();
if (aNormal.Modulus() > 0.0f)
{
myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (aNormal.x() * 0.5f + 0.5f, myImage->SetPixelColor (theCol, theRow, Quantity_ColorRGBA (aNormal.x() * 0.5f + 0.5f,
aNormal.y() * 0.5f + 0.5f, aNormal.y() * 0.5f + 0.5f,
aNormal.z() * 0.5f + 0.5f, 1.0f)); aNormal.z() * 0.5f + 0.5f, 1.0f));
} }
else
{
myImage->SetPixelColor (theCol, theRow, Quantity_NOC_BLACK);
}
}
} }
}; };
} }

View File

@ -13673,12 +13673,6 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
Standard_Integer theArgsNb, Standard_Integer theArgsNb,
const char** theArgVec) const char** theArgVec)
{ {
if (theArgsNb < 2)
{
Message::SendFail() << "Syntax error: wrong number arguments for '" << theArgVec[0] << "'";
return 1;
}
const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext(); const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
const Handle(V3d_View)& aView = ViewerTest::CurrentView(); const Handle(V3d_View)& aView = ViewerTest::CurrentView();
if (aContext.IsNull()) if (aContext.IsNull())
@ -13700,7 +13694,7 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
{ {
if (++anArgIter >= theArgsNb) if (++anArgIter >= theArgsNb)
{ {
Message::SendFail ("Syntax error: wrong number parameters of flag '-depth'"); Message::SendFail ("Syntax error: wrong number parameters of flag '-type'");
return 1; return 1;
} }
@ -13713,7 +13707,7 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
aType = StdSelect_TypeOfSelectionImage_NormalizedDepth; aType = StdSelect_TypeOfSelectionImage_NormalizedDepth;
anImgFormat = Image_Format_GrayF; anImgFormat = Image_Format_GrayF;
} }
if (aValue == "depthinverted" else if (aValue == "depthinverted"
|| aValue == "normdepthinverted" || aValue == "normdepthinverted"
|| aValue == "normalizeddepthinverted" || aValue == "normalizeddepthinverted"
|| aValue == "inverted") || aValue == "inverted")
@ -13756,6 +13750,11 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
{ {
aType = StdSelect_TypeOfSelectionImage_SurfaceNormal; aType = StdSelect_TypeOfSelectionImage_SurfaceNormal;
} }
else
{
Message::SendFail() << "Syntax error: unknown type '" << aValue << "'";
return 1;
}
} }
else if (aParam == "-picked" else if (aParam == "-picked"
|| aParam == "-pickeddepth" || aParam == "-pickeddepth"
@ -15151,7 +15150,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
__FILE__, VSelectionProperties, group); __FILE__, VSelectionProperties, group);
theCommands.Add ("vseldump", theCommands.Add ("vseldump",
"vseldump file -type {depth|unnormDepth|object|owner|selMode|entity}=depth -pickedIndex Index=1" "vseldump file -type {depth|unnormDepth|object|owner|selMode|entity|surfNormal}=depth -pickedIndex Index=1"
"\n\t\t: [-xrPose base|head=base]" "\n\t\t: [-xrPose base|head=base]"
"\n\t\t: Generate an image based on detection results:" "\n\t\t: Generate an image based on detection results:"
"\n\t\t: depth normalized depth values" "\n\t\t: depth normalized depth values"