mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0032622: Draw Harness - writebrep "-version 3" is unrecognized
Fixed version range check. Added description of -normals argument.
This commit is contained in:
parent
0c9c466e9d
commit
c1638a8db8
@ -1456,12 +1456,7 @@ static Standard_Integer writebrep (Draw_Interpretor& theDI,
|
|||||||
aParam.LowerCase();
|
aParam.LowerCase();
|
||||||
if (aParam == "-binary")
|
if (aParam == "-binary")
|
||||||
{
|
{
|
||||||
isBinaryFormat = Standard_True;
|
isBinaryFormat = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
|
||||||
if (anArgIter + 1 < theNbArgs
|
|
||||||
&& Draw::ParseOnOff (theArgVec[anArgIter + 1], isBinaryFormat))
|
|
||||||
{
|
|
||||||
++anArgIter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (aParam == "-version"
|
else if (aParam == "-version"
|
||||||
&& anArgIter + 1 < theNbArgs)
|
&& anArgIter + 1 < theNbArgs)
|
||||||
@ -1476,26 +1471,12 @@ static Standard_Integer writebrep (Draw_Interpretor& theDI,
|
|||||||
else if (aParam == "-notriangles"
|
else if (aParam == "-notriangles"
|
||||||
|| aParam == "-triangles")
|
|| aParam == "-triangles")
|
||||||
{
|
{
|
||||||
isWithTriangles = Standard_True;
|
isWithTriangles = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
|
||||||
if (anArgIter + 1 < theNbArgs
|
|
||||||
&& Draw::ParseOnOff (theArgVec[anArgIter + 1], isWithTriangles))
|
|
||||||
{
|
|
||||||
++anArgIter;
|
|
||||||
}
|
|
||||||
if (aParam == "-notriangles")
|
|
||||||
{
|
|
||||||
isWithTriangles = !isWithTriangles;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (aParam == "-nonormals"
|
else if (aParam == "-nonormals"
|
||||||
|| aParam == "-normals")
|
|| aParam == "-normals")
|
||||||
{
|
{
|
||||||
isWithNormals = Standard_True;
|
isWithNormals = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
|
||||||
if (anArgIter + 1 < theNbArgs
|
|
||||||
&& Draw::ParseOnOff (theArgVec[anArgIter + 1], isWithNormals))
|
|
||||||
{
|
|
||||||
++anArgIter;
|
|
||||||
}
|
|
||||||
if (aParam == "-nonormals")
|
if (aParam == "-nonormals")
|
||||||
{
|
{
|
||||||
isWithNormals = !isWithNormals;
|
isWithNormals = !isWithNormals;
|
||||||
@ -1530,11 +1511,18 @@ static Standard_Integer writebrep (Draw_Interpretor& theDI,
|
|||||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI);
|
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI);
|
||||||
if (isBinaryFormat)
|
if (isBinaryFormat)
|
||||||
{
|
{
|
||||||
if (aVersion > BinTools_FormatVersion_VERSION_3)
|
if (aVersion > BinTools_FormatVersion_UPPER)
|
||||||
{
|
{
|
||||||
theDI << "Syntax error: unknown format version";
|
theDI << "Syntax error: unknown format version";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (isWithNormals
|
||||||
|
&& aVersion > 0
|
||||||
|
&& aVersion < BinTools_FormatVersion_VERSION_4)
|
||||||
|
{
|
||||||
|
theDI << "Error: vertex normals require binary format version 4 or later";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
BinTools_FormatVersion aBinToolsVersion = aVersion > 0
|
BinTools_FormatVersion aBinToolsVersion = aVersion > 0
|
||||||
? static_cast<BinTools_FormatVersion> (aVersion)
|
? static_cast<BinTools_FormatVersion> (aVersion)
|
||||||
@ -1547,11 +1535,18 @@ static Standard_Integer writebrep (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (aVersion > TopTools_FormatVersion_VERSION_2)
|
if (aVersion > TopTools_FormatVersion_UPPER)
|
||||||
{
|
{
|
||||||
theDI << "Syntax error: unknown format version";
|
theDI << "Syntax error: unknown format version";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (isWithNormals
|
||||||
|
&& aVersion > 0
|
||||||
|
&& aVersion < TopTools_FormatVersion_VERSION_3)
|
||||||
|
{
|
||||||
|
theDI << "Error: vertex normals require ascii format version 3 or later";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
TopTools_FormatVersion aTopToolsVersion = aVersion > 0
|
TopTools_FormatVersion aTopToolsVersion = aVersion > 0
|
||||||
? static_cast<TopTools_FormatVersion> (aVersion)
|
? static_cast<TopTools_FormatVersion> (aVersion)
|
||||||
@ -1729,14 +1724,16 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands)
|
|||||||
"\n\t\t +|-g : switch on/off graphical mode of Progress Indicator",
|
"\n\t\t +|-g : switch on/off graphical mode of Progress Indicator",
|
||||||
XProgress,"DE: General");
|
XProgress,"DE: General");
|
||||||
theCommands.Add("writebrep",
|
theCommands.Add("writebrep",
|
||||||
"writebrep shape filename [-binary=off] [-version Version=4] [-noTriangles=off]"
|
"writebrep shape filename [-binary {0|1}]=0 [-version Version]=4"
|
||||||
|
"\n\t\t: [-triangles {0|1}]=1 [-normals {0|1}]=0"
|
||||||
"\n\t\t: Save the shape in the ASCII (default) or binary format file."
|
"\n\t\t: Save the shape in the ASCII (default) or binary format file."
|
||||||
"\n\t\t: -binary write into the binary format (ASCII when unspecified)"
|
"\n\t\t: -binary write into the binary format (ASCII when unspecified)"
|
||||||
"\n\t\t: -version a number of format version to save;"
|
"\n\t\t: -version a number of format version to save;"
|
||||||
"\n\t\t: ASCII versions: 1, 2 and 3 (3 for ASCII when unspecified);"
|
"\n\t\t: ASCII versions: 1, 2 and 3 (3 for ASCII when unspecified);"
|
||||||
"\n\t\t: Binary versions: 1, 2, 3 and 4 (4 for Binary when unspecified)."
|
"\n\t\t: Binary versions: 1, 2, 3 and 4 (4 for Binary when unspecified)."
|
||||||
"\n\t\t: -noTriangles skip triangulation data (OFF when unspecified)."
|
"\n\t\t: -triangles write triangulation data (TRUE when unspecified)."
|
||||||
"\n\t\t: Ignored (always written) if face defines only triangulation (no surface).",
|
"\n\t\t: Ignored (always written) if face defines only triangulation (no surface)."
|
||||||
|
"\n\t\t: -normals include vertex normals while writing triangulation data (FALSE when unspecified).",
|
||||||
__FILE__, writebrep, g);
|
__FILE__, writebrep, g);
|
||||||
theCommands.Add("readbrep",
|
theCommands.Add("readbrep",
|
||||||
"readbrep filename shape"
|
"readbrep filename shape"
|
||||||
|
@ -551,39 +551,44 @@ static Standard_Integer DDocStd_PrintComments (Draw_Interpretor& di,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetStorageFormatVersion
|
//function : DDocStd_StorageFormatVersion
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
static Standard_Integer DDocStd_SetStorageFormatVersion (Draw_Interpretor& ,
|
static Standard_Integer DDocStd_StorageFormatVersion (Draw_Interpretor& theDI,
|
||||||
Standard_Integer nb,
|
Standard_Integer theNbArgs,
|
||||||
const char** a)
|
const char** theArgVec)
|
||||||
{
|
{
|
||||||
if (nb == 3)
|
if (theNbArgs != 2
|
||||||
|
&& theNbArgs != 3)
|
||||||
{
|
{
|
||||||
Handle(TDocStd_Document) D;
|
theDI << "Syntax error: wrong number of arguments";
|
||||||
if (!DDocStd::GetDocument(a[1], D)) return 1;
|
return 1;
|
||||||
const int version = atoi(a[2]);
|
|
||||||
D->ChangeStorageFormatVersion((TDocStd_FormatVersion) version);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
Handle(TDocStd_Document) aDoc;
|
||||||
//function : GetStorageFormatVersion
|
if (!DDocStd::GetDocument (theArgVec[1], aDoc))
|
||||||
//purpose :
|
{
|
||||||
//=======================================================================
|
theDI << "Syntax error: " << theArgVec[1] << " is not a document";
|
||||||
static Standard_Integer DDocStd_GetStorageFormatVersion (Draw_Interpretor& di,
|
return 1;
|
||||||
Standard_Integer nb,
|
}
|
||||||
const char** a)
|
|
||||||
{
|
if (theNbArgs == 2)
|
||||||
if (nb == 2) {
|
{
|
||||||
Handle(TDocStd_Document) D;
|
theDI << aDoc->StorageFormatVersion() << "\n";
|
||||||
if (!DDocStd::GetDocument(a[1], D)) return 1;
|
|
||||||
di << D->StorageFormatVersion() << "\n";
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
|
Standard_Integer aVerInt = 0;
|
||||||
|
if (!Draw::ParseInteger (theArgVec[2], aVerInt)
|
||||||
|
|| aVerInt < TDocStd_FormatVersion_LOWER
|
||||||
|
|| aVerInt > TDocStd_FormatVersion_UPPER)
|
||||||
|
{
|
||||||
|
theDI << "Syntax error: unknown version '" << theArgVec[2] << "' (valid range is " << TDocStd_FormatVersion_LOWER << ".." << TDocStd_FormatVersion_UPPER << ")";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
aDoc->ChangeStorageFormatVersion ((TDocStd_FormatVersion )aVerInt);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -656,12 +661,17 @@ void DDocStd::ApplicationCommands(Draw_Interpretor& theCommands)
|
|||||||
"PrintComments Doc",
|
"PrintComments Doc",
|
||||||
__FILE__, DDocStd_PrintComments, g);
|
__FILE__, DDocStd_PrintComments, g);
|
||||||
|
|
||||||
|
static const TCollection_AsciiString THE_SET_VER_HELP = TCollection_AsciiString() +
|
||||||
|
"StorageFormatVersion Doc [Version]"
|
||||||
|
"\n\t\t: Print or set storage format version within range " + int(TDocStd_FormatVersion_LOWER) + ".." + int(TDocStd_FormatVersion_UPPER) +
|
||||||
|
"\n\t\t: defined by TDocStd_FormatVersion enumeration.";
|
||||||
|
theCommands.Add("StorageFormatVersion", THE_SET_VER_HELP.ToCString(),
|
||||||
|
__FILE__, DDocStd_StorageFormatVersion, g);
|
||||||
theCommands.Add("GetStorageFormatVersion",
|
theCommands.Add("GetStorageFormatVersion",
|
||||||
"GetStorageFormatVersion Doc"
|
"GetStorageFormatVersion Doc"
|
||||||
"\nStorage format versions are defined in TDocStd_FormatVersion.hxx file by an enumeration",
|
"\n\t\t: Alias to StorageFormatVersion",
|
||||||
__FILE__, DDocStd_GetStorageFormatVersion, g);
|
__FILE__, DDocStd_StorageFormatVersion, g);
|
||||||
theCommands.Add("SetStorageFormatVersion",
|
theCommands.Add("SetStorageFormatVersion",
|
||||||
"SetStorageFormatVersion Doc Version"
|
"\n\t\t: Alias to StorageFormatVersion",
|
||||||
"\nStorage format versions are defined in TDocStd_FormatVersion.hxx file by an enumeration",
|
__FILE__, DDocStd_StorageFormatVersion, g);
|
||||||
__FILE__, DDocStd_SetStorageFormatVersion, g);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user