From 6d53d9d50c3ca996ed68e058adef4fc3bb4e6b89 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Mar 2014 10:41:25 +0100 Subject: [PATCH] + allow to set deflection of a mesh with exportStl --- src/Mod/Part/App/TopoShape.cpp | 10 ++++++---- src/Mod/Part/App/TopoShape.h | 2 +- src/Mod/Part/App/TopoShapePyImp.cpp | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 6ef33e341233..31d8a3d49eeb 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -678,7 +678,7 @@ void TopoShape::write(const char *FileName) const } else if (File.hasExtension("stl")) { // read brep-file - exportStl(File.filePath().c_str()); + exportStl(File.filePath().c_str(),0); } else{ throw Base::Exception("Unknown extension"); @@ -754,11 +754,13 @@ void TopoShape::dump(std::ostream& out) const BRepTools::Dump(this->_Shape, out); } -void TopoShape::exportStl(const char *filename) const +void TopoShape::exportStl(const char *filename, double deflection) const { StlAPI_Writer writer; - //writer.RelativeMode() = false; - //writer.SetDeflection(0.1); + if (deflection > 0) { + writer.RelativeMode() = false; + writer.SetDeflection(deflection); + } QString fn = QString::fromUtf8(filename); writer.Write(this->_Shape,(const Standard_CString)fn.toLocal8Bit()); } diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 30a10ce82b51..2f9067b0486e 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -128,7 +128,7 @@ class PartExport TopoShape : public Data::ComplexGeoData void exportStep(const char *FileName) const; void exportBrep(const char *FileName) const; void exportBrep(std::ostream&) const; - void exportStl (const char *FileName) const; + void exportStl (const char *FileName, double deflection) const; void exportFaceSet(double, double, std::ostream&) const; void exportLineSet(std::ostream&) const; //@} diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index b146180ac133..8c70c50090e5 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -424,12 +424,13 @@ PyObject* TopoShapePy::importBrepFromString(PyObject *args) PyObject* TopoShapePy::exportStl(PyObject *args) { char* filename; - if (!PyArg_ParseTuple(args, "s", &filename)) + double deflection = 0; + if (!PyArg_ParseTuple(args, "s|d", &filename, &deflection)) return NULL; try { // write stl file - getTopoShapePtr()->exportStl(filename); + getTopoShapePtr()->exportStl(filename, deflection); } catch (const Base::Exception& e) { PyErr_SetString(PyExc_Exception,e.what());