Skip to content

Commit

Permalink
+ fixes #763: Bad IGS import
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 5, 2015
1 parent ab24e9d commit ee86871
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/Mod/Import/App/AppImportPy.cpp
Expand Up @@ -116,10 +116,16 @@ static PyObject * importer(PyObject *self, PyObject *args)
}
}
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");

try {
IGESControl_Controller::Init();
Interface_Static::SetIVal("read.surfacecurve.mode",3);
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);
Expand Down
11 changes: 11 additions & 0 deletions src/Mod/Import/Gui/AppImportGuiPy.cpp
Expand Up @@ -157,10 +157,16 @@ static PyObject * importer(PyObject *self, PyObject *args)
}
}
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");

try {
IGESControl_Controller::Init();
Interface_Static::SetIVal("read.surfacecurve.mode",3);
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);
Expand Down Expand Up @@ -509,9 +515,14 @@ static PyObject * ocaf(PyObject *self, PyObject *args)
pi->EndScope();
}
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
IGESControl_Controller::Init();
Interface_Static::SetIVal("read.surfacecurve.mode",3);
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);
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Part/App/ImportIges.cpp
Expand Up @@ -83,6 +83,10 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
if (aReader.ReadFile((const Standard_CString)FileName) != IFSelect_RetDone)
throw Base::Exception("Error in reading IGES");

// Ignore construction elements
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
aReader.SetReadVisible(Standard_True);

// check file conformity and output stats
aReader.PrintCheckLoad(Standard_True,IFSelect_GeneralInfo);

Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -573,6 +573,9 @@ void TopoShape::importIges(const char *FileName)
IGESControl_Controller::Init();
Interface_Static::SetIVal("read.surfacecurve.mode",3);
IGESControl_Reader aReader;
// Ignore construction elements
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
aReader.SetReadVisible(Standard_True);
if (aReader.ReadFile(encodeFilename(FileName).c_str()) != IFSelect_RetDone)
throw Base::Exception("Error in reading IGES");

Expand Down
25 changes: 21 additions & 4 deletions src/Mod/Part/Gui/DlgImportExportIges.ui
Expand Up @@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>445</width>
<height>270</height>
<width>515</width>
<height>349</height>
</rect>
</property>
<property name="windowTitle">
<string>IGES</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand Down Expand Up @@ -70,6 +70,22 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Import</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="checkSkipBlank">
<property name="text">
<string>Skip blank entities</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBoxHeader">
<property name="title">
<string>Header</string>
Expand Down Expand Up @@ -108,7 +124,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -126,6 +142,7 @@
<tabstops>
<tabstop>comboBoxUnits</tabstop>
<tabstop>checkBrepMode</tabstop>
<tabstop>checkSkipBlank</tabstop>
<tabstop>lineEditCompany</tabstop>
<tabstop>lineEditAuthor</tabstop>
<tabstop>lineEditProduct</tabstop>
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Part/Gui/DlgSettingsGeneral.cpp
Expand Up @@ -120,6 +120,9 @@ void DlgImportExportIges::saveSettings()
hGrp->SetBool("BrepMode", ui->checkBrepMode->isChecked());
Interface_Static::SetIVal("write.iges.brep.mode",ui->checkBrepMode->isChecked() ? 1 : 0);

// Import
hGrp->SetBool("SkipBlankEntities", ui->checkSkipBlank->isChecked());

// header info
hGrp->SetASCII("Company", ui->lineEditCompany->text().toLatin1());
hGrp->SetASCII("Author", ui->lineEditAuthor->text().toLatin1());
Expand All @@ -141,6 +144,9 @@ void DlgImportExportIges::loadSettings()
bool brep = hGrp->GetBool("BrepMode", value > 0);
ui->checkBrepMode->setChecked(brep);

// Import
ui->checkSkipBlank->setChecked(hGrp->GetBool("SkipBlankEntities", true));

// header info
ui->lineEditCompany->setText(QString::fromStdString(hGrp->GetASCII("Company",
Interface_Static::CVal("write.iges.header.company"))));
Expand Down

0 comments on commit ee86871

Please sign in to comment.