mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0027245: DRAW command to test binary persistence for shapes
- Added new static methods Read and Write in BinTools class to store/retrieve a shape in binary format. - Added new draw commands "binsave" and "binrestore" - Added test cases to test the new methods. - Updated documantation with desription of the new BinTools class methods and corresponding BRepTools class methods.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepTools_ShapeSet.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <BinTools.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <DBRep_DrawableShape.hxx>
|
||||
#include <Draw.hxx>
|
||||
@@ -1274,6 +1275,51 @@ static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// binsave
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer binsave(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n <= 2) return 1;
|
||||
|
||||
TopoDS_Shape aShape = DBRep::Get (a[1]);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
di << a[1] << " is not a shape";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!BinTools::Write (aShape, a[2]))
|
||||
{
|
||||
di << "Cannot write to the file " << a[2];
|
||||
return 1;
|
||||
}
|
||||
|
||||
di << a[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// binrestore
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer binrestore(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n <= 2) return 1;
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
if (!BinTools::Read (aShape, a[1]))
|
||||
{
|
||||
di << "Cannot read from the file " << a[1];
|
||||
return 1;
|
||||
}
|
||||
|
||||
DBRep::Set (a[2], aShape);
|
||||
di << a[2];
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BasicCommands
|
||||
//purpose :
|
||||
@@ -1326,6 +1372,13 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands)
|
||||
|
||||
// Add command for DRAW-specific ProgressIndicator
|
||||
theCommands.Add ( "XProgress","XProgress [+|-t] [+|-g]: switch on/off textual and graphical mode of Progress Indicator",XProgress,"DE: General");
|
||||
|
||||
theCommands.Add("binsave", "binsave shape filename\n"
|
||||
"\t\tsave the shape in the binary format file",
|
||||
__FILE__, binsave, g);
|
||||
theCommands.Add("binrestore", "binrestore filename shape\n"
|
||||
"\t\trestore the shape from the binary format file",
|
||||
__FILE__, binrestore, g);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user