diff --git a/LatticeDehomogenization/src/fileExchange/CADExtensions.h b/LatticeDehomogenization/src/fileExchange/CADExtensions.h index 426e52f88775be71ae17374decba2c787c17640a..b5d1774b228f2a8778ba73b63b54f9c1adc4f9be 100644 --- a/LatticeDehomogenization/src/fileExchange/CADExtensions.h +++ b/LatticeDehomogenization/src/fileExchange/CADExtensions.h @@ -11,4 +11,7 @@ typedef std::unordered_map<std::string, FileExt> ExtensionFinder; static const ExtensionFinder fileExtensions = { { ".stp", STEP }, { ".step", STEP }, + { ".iges", IGES }, + { ".igs", IGES }, + { ".ige", IGES }, }; \ No newline at end of file diff --git a/LatticeDehomogenization/src/fileExchange/CADwriter.cpp b/LatticeDehomogenization/src/fileExchange/CADwriter.cpp index 72b84fb698455410b4c03bbab195809611396c97..7374b2c511a6f750dd40a597fa46655ef6166774 100644 --- a/LatticeDehomogenization/src/fileExchange/CADwriter.cpp +++ b/LatticeDehomogenization/src/fileExchange/CADwriter.cpp @@ -4,6 +4,7 @@ #include "Message_PrinterOStream.hxx" #include "STEPControl_Writer.hxx" +#include "IGESControl_Writer.hxx" CADwriter::CADwriter(const std::string& savepath) { @@ -11,8 +12,10 @@ CADwriter::CADwriter(const std::string& savepath) switch (ext) { case FileExt::STEP: + case FileExt::IGES: _saveType = ext; break; + default: _saveType = FileExt::STEP; _savepath += ".stp"; @@ -29,6 +32,9 @@ void CADwriter::write(const TopoDS_Shape& saveshape) case STEP: writeSTEP(saveshape); return; + case IGES: + writeIGES(saveshape); + return; default: _errors.push(ErrorCodes::UnknownError); _errorMsgs.push("File Extension not defined"); @@ -73,3 +79,22 @@ void CADwriter::writeSTEP(const TopoDS_Shape& saveshape) _errorMsgs.push("Unknown error occured while exporting"); } } + +void CADwriter::writeIGES(const TopoDS_Shape& saveshape) +{ + IGESControl_Writer writer("MM", 1); + Message::DefaultMessenger()->RemovePrinters(STANDARD_TYPE(Message_PrinterOStream)); + if (!writer.AddShape(saveshape)) + { + _errors.push(ErrorCodes::SaveFailed); + _errorMsgs.push("Unkown error occured while adding shape to IGES writer"); + return; + } + writer.ComputeModel(); + bool status = writer.Write(_savepath.c_str()); + if (status == false) + { + _errors.push(ErrorCodes::SaveFailed); + _errorMsgs.push("Unknown error occured while exporting"); + } +} diff --git a/LatticeDehomogenization/src/fileExchange/CADwriter.h b/LatticeDehomogenization/src/fileExchange/CADwriter.h index dc6c539c08b4c63d626be0f2865561139aef539e..b7f1c68b5a381d48b0192085f6fff4f2e3e989ef 100644 --- a/LatticeDehomogenization/src/fileExchange/CADwriter.h +++ b/LatticeDehomogenization/src/fileExchange/CADwriter.h @@ -17,6 +17,7 @@ private: FileExt determineExtension(const std::string& savepath); void writeSTEP(const TopoDS_Shape& saveshape); + void writeIGES(const TopoDS_Shape& saveshape); public: CADwriter()