BrepTools::Dump to string

This commit is contained in:
Sebastian Hoogen 2014-02-18 00:53:13 +01:00 committed by wmayer
parent 5f7ed33c40
commit 3986c887c3
4 changed files with 38 additions and 2 deletions

View File

@ -737,11 +737,16 @@ void TopoShape::exportBrep(const char *filename) const
throw Base::Exception("Writing of BREP failed");
}
void TopoShape::exportBrep(std::ostream& out)
void TopoShape::exportBrep(std::ostream& out) const
{
BRepTools::Write(this->_Shape, out);
}
void TopoShape::dump(std::ostream& out) const
{
BRepTools::Dump(this->_Shape, out);
}
void TopoShape::exportStl(const char *filename) const
{
StlAPI_Writer writer;

View File

@ -119,6 +119,7 @@ public:
//@{
void read(const char *FileName);
void write(const char *FileName) const;
void dump(std::ostream& out) const;
void importIges(const char *FileName);
void importStep(const char *FileName);
void importBrep(const char *FileName);
@ -126,7 +127,7 @@ public:
void exportIges(const char *FileName) const;
void exportStep(const char *FileName) const;
void exportBrep(const char *FileName) const;
void exportBrep(std::ostream&);
void exportBrep(std::ostream&) const;
void exportStl (const char *FileName) const;
void exportFaceSet(double, double, std::ostream&) const;
void exportLineSet(std::ostream&) const;

View File

@ -48,6 +48,11 @@ Sub-elements such as vertices, edges or faces are accessible as:
<UserDocu>Export the content of this shape to a string in BREP format. BREP is a CasCade native format.</UserDocu>
</Documentation>
</Methode>
<Methode Name="dumpToString" Const="true">
<Documentation>
<UserDocu>Dump information about the shape to a string.</UserDocu>
</Documentation>
</Methode>
<Methode Name="exportStl" Const="true">
<Documentation>
<UserDocu>Export the content of this shape to an STL mesh file.</UserDocu>

View File

@ -314,6 +314,31 @@ PyObject* TopoShapePy::exportBrep(PyObject *args)
Py_Return;
}
PyObject* TopoShapePy::dumpToString(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
try {
std::stringstream str;
getTopoShapePtr()->dump(str);
return Py::new_reference_to(Py::String(str.str()));
}
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_Exception,e.what());
return NULL;
}
catch (const std::exception& e) {
PyErr_SetString(PyExc_Exception,e.what());
return NULL;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
}
PyObject* TopoShapePy::exportBrepToString(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))