Import: move IGES reader & writer to own classes
This commit is contained in:
@@ -30,12 +30,6 @@
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#endif
|
||||
#include <IGESCAFControl_Reader.hxx>
|
||||
#include <IGESCAFControl_Writer.hxx>
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESData_GlobalSection.hxx>
|
||||
#include <IGESData_IGESModel.hxx>
|
||||
#include <IGESToBRep_Actor.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <OSD_Exception.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
@@ -71,8 +65,10 @@
|
||||
|
||||
#include "ImportOCAF2.h"
|
||||
#include "ReaderGltf.h"
|
||||
#include "ReaderIges.h"
|
||||
#include "ReaderStep.h"
|
||||
#include "WriterGltf.h"
|
||||
#include "WriterIges.h"
|
||||
#include "WriterStep.h"
|
||||
|
||||
namespace Import
|
||||
@@ -188,40 +184,9 @@ private:
|
||||
}
|
||||
}
|
||||
else if (file.hasExtension({"igs", "iges"})) {
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/Part")
|
||||
->GetGroup("IGES");
|
||||
|
||||
try {
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Reader aReader;
|
||||
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
|
||||
aReader.SetReadVisible(
|
||||
hGrp->GetBool("SkipBlankEntities", true) ? Standard_True : Standard_False);
|
||||
aReader.SetColorMode(true);
|
||||
aReader.SetNameMode(true);
|
||||
aReader.SetLayerMode(true);
|
||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str()))
|
||||
!= IFSelect_RetDone) {
|
||||
throw Py::Exception(PyExc_IOError, "cannot read IGES file");
|
||||
}
|
||||
|
||||
#if OCC_VERSION_HEX < 0x070500
|
||||
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
|
||||
aReader.WS()->MapReader()->SetProgress(pi);
|
||||
pi->NewScope(100, "Reading IGES file...");
|
||||
pi->Show();
|
||||
#endif
|
||||
aReader.Transfer(hDoc);
|
||||
#if OCC_VERSION_HEX < 0x070500
|
||||
pi->EndScope();
|
||||
#endif
|
||||
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
|
||||
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
Import::ReaderIges reader(file);
|
||||
reader.read(hDoc);
|
||||
}
|
||||
catch (OSD_Exception& e) {
|
||||
Base::Console().Error("%s\n", e.GetMessageString());
|
||||
@@ -375,22 +340,8 @@ private:
|
||||
writer.write(hDoc);
|
||||
}
|
||||
else if (file.hasExtension({"igs", "iges"})) {
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Writer writer;
|
||||
IGESData_GlobalSection header = writer.Model()->GlobalSection();
|
||||
header.SetAuthorName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderAuthor()));
|
||||
header.SetCompanyName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderCompany()));
|
||||
header.SetSendName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderProduct()));
|
||||
writer.Model()->SetGlobalSection(header);
|
||||
writer.Transfer(hDoc);
|
||||
Standard_Boolean ret = writer.Write(name8bit.c_str());
|
||||
if (!ret) {
|
||||
PyErr_Format(PyExc_IOError, "Cannot open file '%s'", Utf8Name.c_str());
|
||||
throw Py::Exception();
|
||||
}
|
||||
Import::WriterIges writer(file);
|
||||
writer.write(hDoc);
|
||||
}
|
||||
else if (file.hasExtension({"glb", "gltf"})) {
|
||||
Import::WriterGltf writer(name8bit, file);
|
||||
|
||||
Reference in New Issue
Block a user