Part: Allow to disable progress bar in brep string reader

This commit is contained in:
Yorik van Havre
2018-07-19 11:57:07 -03:00
parent cc0fb2a5a9
commit c93ff200ca
4 changed files with 16 additions and 10 deletions

View File

@@ -597,18 +597,21 @@ void TopoShape::importBrep(const char *FileName)
}
}
void TopoShape::importBrep(std::istream& str)
void TopoShape::importBrep(std::istream& str, int indicator)
{
try {
// read brep-file
BRep_Builder aBuilder;
TopoDS_Shape aShape;
#if OCC_VERSION_HEX >= 0x060300
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading BREP file...");
pi->Show();
BRepTools::Read(aShape,str,aBuilder,pi);
pi->EndScope();
if (indicator) {
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading BREP file...");
pi->Show();
BRepTools::Read(aShape,str,aBuilder,pi);
pi->EndScope();
} else
BRepTools::Read(aShape,str,aBuilder);
#else
BRepTools::Read(aShape,str,aBuilder);
#endif

View File

@@ -136,7 +136,7 @@ public:
void importIges(const char *FileName);
void importStep(const char *FileName);
void importBrep(const char *FileName);
void importBrep(std::istream&);
void importBrep(std::istream&, int indicator=1);
void importBinary(std::istream&);
void exportIges(const char *FileName) const;
void exportStep(const char *FileName) const;

View File

@@ -85,7 +85,9 @@ Sub-elements such as vertices, edges or faces are accessible as:
</Methode>
<Methode Name="importBrepFromString">
<Documentation>
<UserDocu>Load the shape from a string that keeps the content in BREP format.</UserDocu>
<UserDocu>Load the shape from a string that keeps the content in BREP format.
importBrepFromString(str,False) to not display a progress bar.
</UserDocu>
</Documentation>
</Methode>
<Methode Name="extrude" Const="true">

View File

@@ -513,13 +513,14 @@ PyObject* TopoShapePy::importBinary(PyObject *args)
PyObject* TopoShapePy::importBrepFromString(PyObject *args)
{
char* input;
if (!PyArg_ParseTuple(args, "s", &input))
int indicator=1;
if (!PyArg_ParseTuple(args, "s|i", &input, &indicator))
return NULL;
try {
// read brep
std::stringstream str(input);
getTopoShapePtr()->importBrep(str);
getTopoShapePtr()->importBrep(str,indicator);
}
catch (const Base::Exception& e) {
PyErr_SetString(PartExceptionOCCError,e.what());