0000764: Serialize Shape to python String
This commit is contained in:
parent
bbafe9cb00
commit
013b5f0dce
|
@ -726,6 +726,11 @@ void TopoShape::exportBrep(const char *filename) const
|
|||
throw Base::Exception("Writing of BREP failed");
|
||||
}
|
||||
|
||||
void TopoShape::exportBrep(std::ostream& out)
|
||||
{
|
||||
BRepTools::Write(this->_Shape, out);
|
||||
}
|
||||
|
||||
void TopoShape::exportStl(const char *filename) const
|
||||
{
|
||||
StlAPI_Writer writer;
|
||||
|
|
|
@ -126,6 +126,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 exportStl (const char *FileName) const;
|
||||
void exportFaceSet(double, double, std::ostream&) const;
|
||||
void exportLineSet(std::ostream&) const;
|
||||
|
|
|
@ -43,6 +43,11 @@ Sub-elements such as vertices, edges or faces are accessible as:
|
|||
<UserDocu>Export the content of this shape to an BREP file. BREP is a CasCade native format.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="exportBrepToString" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Export the content of this shape to a string in BREP format. BREP is a CasCade native format.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="exportStl" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Export the content of this shape to an STL mesh file.</UserDocu>
|
||||
|
@ -53,6 +58,11 @@ Sub-elements such as vertices, edges or faces are accessible as:
|
|||
<UserDocu>Import the content to this shape of a string in BREP format.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="importBrepFromString">
|
||||
<Documentation>
|
||||
<UserDocu>Import the content to this shape from a string in BREP format.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="extrude" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Extrude the shape along a direction.</UserDocu>
|
||||
|
|
|
@ -311,6 +311,32 @@ PyObject* TopoShapePy::exportBrep(PyObject *args)
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* TopoShapePy::exportBrepToString(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
|
||||
try {
|
||||
// write brep file
|
||||
std::stringstream str;
|
||||
getTopoShapePtr()->exportBrep(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::importBrep(PyObject *args)
|
||||
{
|
||||
PyObject* input;
|
||||
|
@ -335,6 +361,34 @@ PyObject* TopoShapePy::importBrep(PyObject *args)
|
|||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* TopoShapePy::importBrepFromString(PyObject *args)
|
||||
{
|
||||
char* input;
|
||||
if (!PyArg_ParseTuple(args, "s", &input))
|
||||
return NULL;
|
||||
|
||||
try {
|
||||
// read brep
|
||||
std::stringstream str(input);
|
||||
getTopoShapePtr()->importBrep(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;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* TopoShapePy::exportStl(PyObject *args)
|
||||
{
|
||||
char* filename;
|
||||
|
|
Loading…
Reference in New Issue
Block a user