Skip to content
Snippets Groups Projects
Commit 6cad77ba authored by samuel.hayden's avatar samuel.hayden
Browse files

Added IGES support

parent 38e6c93b
No related branches found
No related tags found
No related merge requests found
...@@ -11,4 +11,7 @@ typedef std::unordered_map<std::string, FileExt> ExtensionFinder; ...@@ -11,4 +11,7 @@ typedef std::unordered_map<std::string, FileExt> ExtensionFinder;
static const ExtensionFinder fileExtensions = { static const ExtensionFinder fileExtensions = {
{ ".stp", STEP }, { ".stp", STEP },
{ ".step", STEP }, { ".step", STEP },
{ ".iges", IGES },
{ ".igs", IGES },
{ ".ige", IGES },
}; };
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "Message_PrinterOStream.hxx" #include "Message_PrinterOStream.hxx"
#include "STEPControl_Writer.hxx" #include "STEPControl_Writer.hxx"
#include "IGESControl_Writer.hxx"
CADwriter::CADwriter(const std::string& savepath) CADwriter::CADwriter(const std::string& savepath)
{ {
...@@ -11,8 +12,10 @@ CADwriter::CADwriter(const std::string& savepath) ...@@ -11,8 +12,10 @@ CADwriter::CADwriter(const std::string& savepath)
switch (ext) switch (ext)
{ {
case FileExt::STEP: case FileExt::STEP:
case FileExt::IGES:
_saveType = ext; _saveType = ext;
break; break;
default: default:
_saveType = FileExt::STEP; _saveType = FileExt::STEP;
_savepath += ".stp"; _savepath += ".stp";
...@@ -29,6 +32,9 @@ void CADwriter::write(const TopoDS_Shape& saveshape) ...@@ -29,6 +32,9 @@ void CADwriter::write(const TopoDS_Shape& saveshape)
case STEP: case STEP:
writeSTEP(saveshape); writeSTEP(saveshape);
return; return;
case IGES:
writeIGES(saveshape);
return;
default: default:
_errors.push(ErrorCodes::UnknownError); _errors.push(ErrorCodes::UnknownError);
_errorMsgs.push("File Extension not defined"); _errorMsgs.push("File Extension not defined");
...@@ -73,3 +79,22 @@ void CADwriter::writeSTEP(const TopoDS_Shape& saveshape) ...@@ -73,3 +79,22 @@ void CADwriter::writeSTEP(const TopoDS_Shape& saveshape)
_errorMsgs.push("Unknown error occured while exporting"); _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");
}
}
...@@ -17,6 +17,7 @@ private: ...@@ -17,6 +17,7 @@ private:
FileExt determineExtension(const std::string& savepath); FileExt determineExtension(const std::string& savepath);
void writeSTEP(const TopoDS_Shape& saveshape); void writeSTEP(const TopoDS_Shape& saveshape);
void writeIGES(const TopoDS_Shape& saveshape);
public: public:
CADwriter() CADwriter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment