23
#include "PreCompiled.h"
26
# include <BRep_Builder.hxx>
27
# include <IGESBasic_Group.hxx>
28
# include <IGESBasic_SingularSubfigure.hxx>
29
# include <IGESControl_Controller.hxx>
30
# include <IGESControl_Reader.hxx>
31
# include <IGESSolid_ManifoldSolid.hxx>
32
# include <Message_MsgFile.hxx>
33
# include <Standard_Version.hxx>
34
# include <TColStd_HSequenceOfTransient.hxx>
36
# include <TopoDS_Compound.hxx>
37
# include <TopoDS_Shape.hxx>
38
# include <Transfer_TransientProcess.hxx>
39
# include <XSControl_TransferReader.hxx>
40
# include <XSControl_WorkSession.hxx>
43
#include <App/Document.h>
44
#include <Base/Sequencer.h>
46
#include "ImportIges.h"
47
#include "PartFeature.h"
48
#include "ProgressIndicator.h"
53
int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
56
Base::FileInfo fi(FileName);
58
IGESControl_Controller::Init();
61
Message_MsgFile::LoadFromEnv("CSF_XSMessage","IGES");
64
Message_MsgFile::LoadFromEnv("CSF_SHMessageStd","SHAPEStd");
66
IGESControl_Reader aReader;
67
if (aReader.ReadFile((Standard_CString)FileName) != IFSelect_RetDone)
68
throw Base::FileException("Error in reading IGES");
72
aReader.SetReadVisible(Standard_True);
75
aReader.PrintCheckLoad(Standard_True,IFSelect_GeneralInfo);
77
std::string aName = fi.fileNamePure();
78
#if OCC_VERSION_HEX < 0x070500
79
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
80
pi->NewScope(100, "Reading IGES file...");
82
aReader.WS()->MapReader()->SetProgress(pi);
86
aReader.ClearShapes();
88
aReader.TransferRoots();
89
#if OCC_VERSION_HEX < 0x070500
94
Standard_Boolean emptyComp = Standard_True;
97
builder.MakeCompound(comp);
99
Standard_Integer nbShapes = aReader.NbShapes();
100
for (Standard_Integer i=1; i<=nbShapes; i++) {
101
TopoDS_Shape aShape = aReader.Shape(i);
102
if (!aShape.IsNull()) {
103
if (aShape.ShapeType() == TopAbs_SOLID ||
104
aShape.ShapeType() == TopAbs_COMPOUND ||
105
aShape.ShapeType() == TopAbs_SHELL) {
106
App::DocumentObject* obj = pcDoc->addObject("Part::Feature", aName.c_str());
107
static_cast<Part::Feature*>(obj)->Shape.setValue(aShape);
110
builder.Add(comp, aShape);
111
emptyComp = Standard_False;
116
std::string name = fi.fileNamePure();
117
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject
118
("Part::Feature", name.c_str()));
119
pcFeature->Shape.setValue(comp);
122
catch (Standard_Failure& e) {
123
throw Base::CADKernelError(e.GetMessageString());