static void StlAPI_WriteBinary(const void* filepath) { if (!BmkBRep::inputShape.IsNull()) { StlAPI_Writer writer; writer.ASCIIMode() = Standard_False; const char* cfilepath = static_cast<const char*>(filepath); #if OCC_VERSION_HEX >= 0x060900 const StlAPI_ErrorStatus err = writer.Write(BmkBRep::inputShape, cfilepath); if (err != StlAPI_StatusOK) std::cerr << "StlAPI_Writer::Write() error: " << err << std::endl; #else writer.Write(BmkBRep::inputShape, cfilepath); #endif } }
int step2stl(char *in, char *out) { // Read from STEP STEPControl_Reader reader; IFSelect_ReturnStatus stat = reader.ReadFile(in); Standard_Integer NbRoots = reader.NbRootsForTransfer(); Standard_Integer NbTrans = reader.TransferRoots(); TopoDS_Shape Original_Solid = reader.OneShape(); // Write to STL StlAPI_Writer stlWriter = StlAPI_Writer(); // stlWriter.SetCoefficient(0.0001); stlWriter.ASCIIMode() = Standard_False; stlWriter.Write( Original_Solid, out); return 1; }
STLEXPORT_EXPORT int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFormatName) { MESSAGE("Export STL into file " << theFileName.ToCString()); try { StlAPI_Writer aWriter; bool aIsASCIIMode; aIsASCIIMode = (theFormatName.IsEqual("STL_ASCII")) ? true : false; aWriter.ASCIIMode() = aIsASCIIMode; aWriter.Write(theShape, theFileName.ToCString()) ; return 1; } catch(Standard_Failure) { //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STLExport", SALOME::BAD_PARAM); } return 0; }
/*! \brief Write a topologic shape to a file (binary STL format) * \param shape Topologic shape to write * \param fileName Path to the file to write */ void IO::writeBinaryStlFile(const TopoDS_Shape& shape, const QString& fileName) { StlAPI_Writer writer; writer.ASCIIMode() = Standard_False; writer.Write(shape, fileName.toAscii().data()); }