Skip to content

Commit

Permalink
+ allow to set deflection of a mesh with exportStl
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Mar 27, 2014
1 parent 9414c93 commit 6d53d9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Part/App/TopoShape.h
Expand Up @@ -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;
//@}
Expand Down
5 changes: 3 additions & 2 deletions src/Mod/Part/App/TopoShapePyImp.cpp
Expand Up @@ -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());
Expand Down

0 comments on commit 6d53d9d

Please sign in to comment.