Skip to content

Commit

Permalink
BrepTools::Dump to string
Browse files Browse the repository at this point in the history
  • Loading branch information
5263 authored and wwmayer committed Mar 2, 2014
1 parent 5f7ed33 commit 3986c88
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Part/App/TopoShape.h
Expand Up @@ -119,14 +119,15 @@ class PartExport TopoShape : public Data::ComplexGeoData
//@{
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);
void importBrep(std::istream&);
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;
Expand Down
5 changes: 5 additions & 0 deletions src/Mod/Part/App/TopoShapePy.xml
Expand Up @@ -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>
Expand Down
25 changes: 25 additions & 0 deletions src/Mod/Part/App/TopoShapePyImp.cpp
Expand Up @@ -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, ""))
Expand Down

0 comments on commit 3986c88

Please sign in to comment.