diff --git a/src/STEPConstruct/STEPConstruct_ExternRefs.cxx b/src/STEPConstruct/STEPConstruct_ExternRefs.cxx index a390f3ce7c..f2c110efa3 100644 --- a/src/STEPConstruct/STEPConstruct_ExternRefs.cxx +++ b/src/STEPConstruct/STEPConstruct_ExternRefs.cxx @@ -66,6 +66,9 @@ #include #include #include +#include +#include +#include //======================================================================= //function : STEPConstruct_ExternRefs @@ -395,8 +398,23 @@ Standard_CString STEPConstruct_ExternRefs::FileName (const Standard_Integer num) } } } - if ( ! aCStringFileName || ! aCStringFileName[0] ) { - // try to find name direct from DocFile + Standard_CString oldFileName = 0; + // compute true path to the extern file + OSD_Path mainfile(WS()->LoadedFile()); + mainfile.SetName(""); + mainfile.SetExtension(""); + TCollection_AsciiString dpath; + mainfile.SystemName(dpath); + if (aCStringFileName && aCStringFileName[0]) { + TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, aCStringFileName); + if (fullname.Length() <= 0) fullname = aCStringFileName; + if (!OSD_File(fullname).Exists()) { + oldFileName = aCStringFileName; + aCStringFileName = 0; + } + } + if (!aCStringFileName || !aCStringFileName[0]) { + // try to find name of the directory from DocFile if ( !DocFile.IsNull() ) { Handle(TCollection_HAsciiString) aFilename = DocFile->Id(); if (!aFilename.IsNull() && !aFilename->IsEmpty()) @@ -407,10 +425,34 @@ Standard_CString STEPConstruct_ExternRefs::FileName (const Standard_Integer num) aCStringFileName = aFilename->ToCString(); } if ( ! aCStringFileName || ! aCStringFileName[0] ) { - return ""; + if (oldFileName) { + aCStringFileName = oldFileName; + } + else { + return ""; + } } - else - return aCStringFileName; + } + } + TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, aCStringFileName); + if (fullname.Length() <= 0) fullname = aCStringFileName; + if (!OSD_File(fullname).Exists()) { + if (oldFileName) { + aCStringFileName = oldFileName; + } + Handle(Transfer_TransientProcess) aTP = WS()->TransferReader()->TransientProcess(); + TCollection_AsciiString aMess("Can not read external file "); + aMess.AssignCat(aCStringFileName); + aTP->AddFail(DocFile, aMess.ToCString()); + } + else { + if (oldFileName && strcmp(oldFileName, aCStringFileName) != 0) { + Handle(Transfer_TransientProcess) aTP = WS()->TransferReader()->TransientProcess(); + TCollection_AsciiString aMess("External file with name from entity AEIA ("); + aMess.AssignCat(oldFileName); + aMess.AssignCat(") not existed => use file name from DocumentFile entity - "); + aMess.AssignCat(aCStringFileName); + aTP->AddWarning(DocFile, aMess.ToCString()); } } return aCStringFileName; diff --git a/tests/de/step_1/ZG4 b/tests/de/step_1/ZG4 index 58d6e4d3a2..f6d5b2d8c7 100644 --- a/tests/de/step_1/ZG4 +++ b/tests/de/step_1/ZG4 @@ -6,7 +6,7 @@ set filename trj4_xr1-ec-214.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 5 ) Warnings = 0 ( 0 ) Summary = 0 ( 5 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZG5 b/tests/de/step_1/ZG5 index 36d8920999..2bfdfc5838 100644 --- a/tests/de/step_1/ZG5 +++ b/tests/de/step_1/ZG5 @@ -6,7 +6,7 @@ set filename trj4_xr1-id-214.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 5 ) Warnings = 0 ( 0 ) Summary = 0 ( 5 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZG6 b/tests/de/step_1/ZG6 index 6a4de82ddb..bed27bf764 100644 --- a/tests/de/step_1/ZG6 +++ b/tests/de/step_1/ZG6 @@ -6,7 +6,7 @@ set filename trj4_xr1-pe-214.stp set ref_data { DATA : Faulties = 0 ( 7 ) Warnings = 0 ( 0 ) Summary = 0 ( 7 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 7 ) Warnings = 0 ( 0 ) Summary = 0 ( 7 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZZ3 b/tests/de/step_1/ZZ3 index b79a203f26..798aaf2fb4 100644 --- a/tests/de/step_1/ZZ3 +++ b/tests/de/step_1/ZZ3 @@ -6,7 +6,7 @@ set filename extref.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 11 ) Warnings = 0 ( 0 ) Summary = 0 ( 11 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZZ4 b/tests/de/step_1/ZZ4 index 0fa2ec127e..374b6491ed 100644 --- a/tests/de/step_1/ZZ4 +++ b/tests/de/step_1/ZZ4 @@ -6,7 +6,7 @@ set filename s1-id-214.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 8 ) Warnings = 0 ( 0 ) Summary = 0 ( 8 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZZ5 b/tests/de/step_1/ZZ5 index 480c0484fd..4bb2e94a31 100644 --- a/tests/de/step_1/ZZ5 +++ b/tests/de/step_1/ZZ5 @@ -7,7 +7,7 @@ set filename s1-pe-214-edited-update.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 9 ) Warnings = 0 ( 0 ) Summary = 0 ( 9 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZZ6 b/tests/de/step_1/ZZ6 index 4c66c58def..65485ff6b9 100644 --- a/tests/de/step_1/ZZ6 +++ b/tests/de/step_1/ZZ6 @@ -7,7 +7,7 @@ set filename s1-ec-214-update.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 8 ) Warnings = 0 ( 0 ) Summary = 0 ( 8 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZZ7 b/tests/de/step_1/ZZ7 index 4a197551cc..ffa9330b15 100644 --- a/tests/de/step_1/ZZ7 +++ b/tests/de/step_1/ZZ7 @@ -7,7 +7,7 @@ set filename s1-pe-214.stp set ref_data { DATA : Faulties = 0 ( 9 ) Warnings = 0 ( 0 ) Summary = 0 ( 9 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 9 ) Warnings = 0 ( 0 ) Summary = 0 ( 9 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 ) diff --git a/tests/de/step_1/ZZ8 b/tests/de/step_1/ZZ8 index aebc009f8c..485c3aed70 100644 --- a/tests/de/step_1/ZZ8 +++ b/tests/de/step_1/ZZ8 @@ -7,7 +7,7 @@ set filename s1-tc-214.stp set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 28 ) Summary = 0 ( 28 ) +TPSTAT : Faulties = 0 ( 8 ) Warnings = 0 ( 28 ) Summary = 0 ( 36 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 0 ( 0 ) FreeWire = 0 ( 0 )