PAL12003: Problem when importing IGS geometry. Export to IGES 5.3 (supporting BRep) introduced in GUI.

This commit is contained in:
jfa 2006-03-27 08:43:05 +00:00
parent 9af6cf04a1
commit fef01ebcd4
11 changed files with 96 additions and 53 deletions

View File

@ -1,5 +1,5 @@
Import: BREP|IGES|STEP Import: BREP|IGES|STEP
Export: BREP|IGES|STEP Export: BREP|IGES|IGES_5_3|STEP
BREP.Import: libBREPImport.so BREP.Import: libBREPImport.so
BREP.Export: libBREPExport.so BREP.Export: libBREPExport.so
@ -8,6 +8,10 @@ BREP.Pattern: BREP Files ( *.brep )
IGES.Import: libIGESImport.so IGES.Import: libIGESImport.so
IGES.Export: libIGESExport.so IGES.Export: libIGESExport.so
IGES.Pattern: IGES Files ( *.iges *.igs ) IGES.Pattern: IGES Files ( *.iges *.igs )
IGES.ExportPattern: IGES 5.1 Files ( *.iges *.igs )
IGES_5_3.Export: libIGESExport.so
IGES_5_3.Pattern: IGES 5.3 Files ( *.iges *.igs )
STEP.Import: libSTEPImport.so STEP.Import: libSTEPImport.so
STEP.Export: libSTEPExport.so STEP.Export: libSTEPExport.so

View File

@ -44,7 +44,9 @@
extern "C" extern "C"
{ {
SALOME_WNT_EXPORT SALOME_WNT_EXPORT
int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) int Export(const TopoDS_Shape& theShape,
const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& /*theFormatName*/)
{ {
MESSAGE("Export BREP into file " << theFileName.ToCString()); MESSAGE("Export BREP into file " << theFileName.ToCString());

View File

@ -46,6 +46,7 @@ extern "C"
{ {
SALOME_WNT_EXPORT SALOME_WNT_EXPORT
TopoDS_Shape Import (const TCollection_AsciiString& theFileName, TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& /*theFormatName*/,
TCollection_AsciiString& theError) TCollection_AsciiString& theError)
{ {
MESSAGE("Import BREP from file " << theFileName); MESSAGE("Import BREP from file " << theFileName);

View File

@ -48,7 +48,9 @@
#define UnLoadLib( handle ) dlclose( handle ); #define UnLoadLib( handle ) dlclose( handle );
#endif #endif
typedef int (*funcPoint)(const TopoDS_Shape&, const TCollection_AsciiString&); typedef int (*funcPoint)(const TopoDS_Shape&,
const TCollection_AsciiString&,
const TCollection_AsciiString&);
//======================================================================= //=======================================================================
//function : GetID //function : GetID
@ -90,9 +92,10 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const
aFunction->SetValue(aShape); aFunction->SetValue(aShape);
// retrieve the file and format names // retrieve the file and format names
TCollection_AsciiString aFileName = aCI.GetFileName(); TCollection_AsciiString aFileName = aCI.GetFileName();
TCollection_AsciiString aLibName = aCI.GetPluginName(); TCollection_AsciiString aFormatName = aCI.GetFormatName();
if (aFileName.IsEmpty() || aLibName.IsEmpty()) TCollection_AsciiString aLibName = aCI.GetPluginName();
if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty())
return 0; return 0;
// load plugin library // load plugin library
@ -105,7 +108,7 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const
return 0; return 0;
// perform the export // perform the export
int res = fp( aShape, aFileName ); int res = fp( aShape, aFileName, aFormatName );
// unload plugin library // unload plugin library
UnLoadLib( anExportLib ); UnLoadLib( anExportLib );

View File

@ -25,6 +25,7 @@
#define EXP_ARG_REF 1 #define EXP_ARG_REF 1
#define EXP_ARG_FILE 2 #define EXP_ARG_FILE 2
#define EXP_ARG_PLUG 3 #define EXP_ARG_PLUG 3
#define EXP_ARG_FORM 4
class GEOMImpl_IImportExport class GEOMImpl_IImportExport
{ {
@ -36,15 +37,21 @@ class GEOMImpl_IImportExport
Handle(GEOM_Function) GetOriginal() { return _func->GetReference(EXP_ARG_REF); } Handle(GEOM_Function) GetOriginal() { return _func->GetReference(EXP_ARG_REF); }
void SetFileName(const TCollection_AsciiString& theFileName) { _func->SetString(EXP_ARG_FILE, theFileName); } void SetFileName(const TCollection_AsciiString& theFileName)
{ _func->SetString(EXP_ARG_FILE, theFileName); }
TCollection_AsciiString GetFileName() { return _func->GetString(EXP_ARG_FILE); } TCollection_AsciiString GetFileName() { return _func->GetString(EXP_ARG_FILE); }
void SetPluginName(const TCollection_AsciiString& theFormatName) void SetPluginName(const TCollection_AsciiString& thePluginLibName)
{ _func->SetString(EXP_ARG_PLUG, theFormatName); } { _func->SetString(EXP_ARG_PLUG, thePluginLibName); }
TCollection_AsciiString GetPluginName() { return _func->GetString(EXP_ARG_PLUG); } TCollection_AsciiString GetPluginName() { return _func->GetString(EXP_ARG_PLUG); }
void SetFormatName(const TCollection_AsciiString& theFormatName)
{ _func->SetString(EXP_ARG_FORM, theFormatName); }
TCollection_AsciiString GetFormatName() { return _func->GetString(EXP_ARG_FORM); }
private: private:
Handle(GEOM_Function) _func; Handle(GEOM_Function) _func;

View File

@ -140,16 +140,17 @@ void GEOMImpl_IInsertOperations::Export
//Check if the function is set correctly //Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return; if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return;
//Set parameters
GEOMImpl_IImportExport aCI (aFunction);
aCI.SetOriginal(aRefFunction);
aCI.SetFileName(theFileName);
Handle(TCollection_HAsciiString) aHLibName; Handle(TCollection_HAsciiString) aHLibName;
if (!IsSupported(Standard_False, theFormatName, aHLibName)) { if (!IsSupported(Standard_False, theFormatName, aHLibName)) {
return; return;
} }
TCollection_AsciiString aLibName = aHLibName->String(); TCollection_AsciiString aLibName = aHLibName->String();
//Set parameters
GEOMImpl_IImportExport aCI (aFunction);
aCI.SetOriginal(aRefFunction);
aCI.SetFileName(theFileName);
aCI.SetFormatName(theFormatName);
aCI.SetPluginName(aLibName); aCI.SetPluginName(aLibName);
//Perform the Export //Perform the Export
@ -195,15 +196,16 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
//Check if the function is set correctly //Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result; if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result;
//Set parameters
GEOMImpl_IImportExport aCI (aFunction);
aCI.SetFileName(theFileName);
Handle(TCollection_HAsciiString) aHLibName; Handle(TCollection_HAsciiString) aHLibName;
if (!IsSupported(Standard_True, theFormatName, aHLibName)) { if (!IsSupported(Standard_True, theFormatName, aHLibName)) {
return result; return result;
} }
TCollection_AsciiString aLibName = aHLibName->String(); TCollection_AsciiString aLibName = aHLibName->String();
//Set parameters
GEOMImpl_IImportExport aCI (aFunction);
aCI.SetFileName(theFileName);
aCI.SetFormatName(theFormatName);
aCI.SetPluginName(aLibName); aCI.SetPluginName(aLibName);
//Perform the Import //Perform the Import
@ -261,14 +263,18 @@ Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators
// Read Patterns for each supported format // Read Patterns for each supported format
int j = 1, len = theFormats->Length(); int j = 1, len = theFormats->Length();
for (; j <= len; j++) { for (; j <= len; j++) {
TCollection_AsciiString aPattern; TCollection_AsciiString aKey, aPattern;
TCollection_AsciiString aKey (theFormats->Value(j)); aKey = theFormats->Value(j) + ".ImportPattern";
aKey += ".Pattern";
if (myResMgr->Find(aKey.ToCString())) if (myResMgr->Find(aKey.ToCString()))
aPattern = myResMgr->Value(aKey.ToCString()); aPattern = myResMgr->Value(aKey.ToCString());
else { else {
aPattern = theFormats->Value(j); aKey = theFormats->Value(j) + ".Pattern";
aPattern += " Files ( *.* )"; if (myResMgr->Find(aKey.ToCString()))
aPattern = myResMgr->Value(aKey.ToCString());
else {
aPattern = theFormats->Value(j);
aPattern += " Files ( *.* )";
}
} }
thePatterns->Append(aPattern); thePatterns->Append(aPattern);
} }
@ -310,14 +316,18 @@ Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators
// Read Patterns for each supported format // Read Patterns for each supported format
int j = 1, len = theFormats->Length(); int j = 1, len = theFormats->Length();
for (; j <= len; j++) { for (; j <= len; j++) {
TCollection_AsciiString aPattern; TCollection_AsciiString aKey, aPattern;
TCollection_AsciiString aKey (theFormats->Value(j)); aKey = theFormats->Value(j) + ".ExportPattern";
aKey += ".Pattern";
if (myResMgr->Find(aKey.ToCString())) if (myResMgr->Find(aKey.ToCString()))
aPattern = myResMgr->Value(aKey.ToCString()); aPattern = myResMgr->Value(aKey.ToCString());
else { else {
aPattern = theFormats->Value(j); aKey = theFormats->Value(j) + ".Pattern";
aPattern += " Files ( *.* )"; if (myResMgr->Find(aKey.ToCString()))
aPattern = myResMgr->Value(aKey.ToCString());
else {
aPattern = theFormats->Value(j);
aPattern += " Files ( *.* )";
}
} }
thePatterns->Append(aPattern); thePatterns->Append(aPattern);
} }

View File

@ -50,7 +50,9 @@
#define UnLoadLib( handle ) dlclose( handle ); #define UnLoadLib( handle ) dlclose( handle );
#endif #endif
typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&, TCollection_AsciiString&); typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
const TCollection_AsciiString&,
TCollection_AsciiString&);
//======================================================================= //=======================================================================
//function : GetID //function : GetID
@ -84,9 +86,10 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
//Standard_Integer aType = aFunction->GetType(); //Standard_Integer aType = aFunction->GetType();
// retrieve the file and plugin library names // retrieve the file and plugin library names
TCollection_AsciiString aFileName = aCI.GetFileName(); TCollection_AsciiString aFileName = aCI.GetFileName();
TCollection_AsciiString aLibName = aCI.GetPluginName(); TCollection_AsciiString aFormatName = aCI.GetFormatName();
if (aFileName.IsEmpty() || aLibName.IsEmpty()) TCollection_AsciiString aLibName = aCI.GetPluginName();
if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty())
return 0; return 0;
// load plugin library // load plugin library
@ -100,7 +103,7 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
// perform the import // perform the import
TCollection_AsciiString anError; TCollection_AsciiString anError;
TopoDS_Shape aShape = fp( aFileName, anError ); TopoDS_Shape aShape = fp( aFileName, aFormatName, anError );
// unload plugin library // unload plugin library
UnLoadLib( anImportLib ); UnLoadLib( anImportLib );

View File

@ -46,26 +46,35 @@
extern "C" extern "C"
{ {
SALOME_WNT_EXPORT SALOME_WNT_EXPORT
int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) int Export(const TopoDS_Shape& theShape,
const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName)
{ {
MESSAGE("Export IGES into file " << theFileName.ToCString()); MESSAGE("Export IGES into file " << theFileName.ToCString());
try try
{ {
//VRV: OCC 4.0 migration // define, whether to write only faces (5.1 IGES format)
IGESControl_Controller::Init(); // or shells and solids also (5.3 IGES format)
IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"), int aBrepMode = 0;
Interface_Static::IVal("XSTEP.iges.writebrep.mode")); if (theFormatName.IsEqual("IGES_5_3"))
//VRV: OCC 4.0 migration aBrepMode = 1;
ICW.AddShape( theShape ); // initialize writer
ICW.ComputeModel(); IGESControl_Controller::Init();
if ( ICW.Write( theFileName.ToCString() ) ) //IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
return 1; // Interface_Static::IVal("write.iges.brep.mode"));
} IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"), aBrepMode);
catch(Standard_Failure)
{ // perform shape writing
//THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM); ICW.AddShape( theShape );
} ICW.ComputeModel();
if ( ICW.Write( theFileName.ToCString() ) )
return 1;
}
catch(Standard_Failure)
{
//THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM);
}
return 0; return 0;
} }
} }

View File

@ -46,6 +46,7 @@ extern "C"
{ {
SALOME_WNT_EXPORT SALOME_WNT_EXPORT
TopoDS_Shape Import (const TCollection_AsciiString& theFileName, TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& /*theFormatName*/,
TCollection_AsciiString& theError) TCollection_AsciiString& theError)
{ {
IGESControl_Reader aReader; IGESControl_Reader aReader;

View File

@ -46,7 +46,9 @@
extern "C" extern "C"
{ {
SALOME_WNT_EXPORT SALOME_WNT_EXPORT
int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) int Export(const TopoDS_Shape& theShape,
const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& /*theFormatName*/)
{ {
MESSAGE("Export STEP into file " << theFileName.ToCString()); MESSAGE("Export STEP into file " << theFileName.ToCString());

View File

@ -52,6 +52,7 @@ extern "C"
{ {
SALOME_WNT_EXPORT SALOME_WNT_EXPORT
TopoDS_Shape Import (const TCollection_AsciiString& theFileName, TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& /*theFormatName*/,
TCollection_AsciiString& theError) TCollection_AsciiString& theError)
{ {
MESSAGE("Import STEP model from file " << theFileName.ToCString()); MESSAGE("Import STEP model from file " << theFileName.ToCString());