]> OCCT Git - occt-copy.git/commitdiff
0029873: Data Exchange - STEPCAFControl_Reader::Transfer() returns TRUE even when...
authorskl <skl@opencascade.com>
Tue, 10 Jul 2018 11:45:11 +0000 (14:45 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 13 Jul 2018 13:38:07 +0000 (16:38 +0300)
Output information about failure during reading of external file has been added (it can be checked by using Draw command "tpstat").
If the reader cannot find an external file at the first found location
(using entity APPLIED_EXTERNAL_IDENTIFICATION_ASSIGNMENT) it checks other information about file path
(using entity DOCUMENT_FILE related with the above-mentioned entity) and uses a new location for import of the external file.

src/STEPConstruct/STEPConstruct_ExternRefs.cxx
tests/de/step_1/ZG4
tests/de/step_1/ZG5
tests/de/step_1/ZG6
tests/de/step_1/ZZ3
tests/de/step_1/ZZ4
tests/de/step_1/ZZ5
tests/de/step_1/ZZ6
tests/de/step_1/ZZ7
tests/de/step_1/ZZ8

index a390f3ce7ccb1ed1a75ffb2ec49743cf39382c0e..f2c110efa30b31f901014a1a5be3eb07a3932dc9 100644 (file)
@@ -66,6 +66,9 @@
 #include <StepShape_ShapeRepresentation.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <XSControl_WorkSession.hxx>
+#include <XSControl_TransferReader.hxx>
+#include <OSD_File.hxx>
+#include <OSD_Path.hxx>
 
 //=======================================================================
 //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;
index 58d6e4d3a2c202c56d281ac4bddf65eb83439990..f6d5b2d8c7966b66e4aae4bd999961e0e0c20f38 100644 (file)
@@ -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 ) 
index 36d8920999faa07adb9d871c16a434961fe4566a..2bfdfc5838f55dc76511b588599cdd17bf646fa0 100644 (file)
@@ -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 ) 
index 6a4de82ddb1252fbdbac9939f815134c6581ca71..bed27bf76460e01d87e7da3bc9b5e6180720e055 100644 (file)
@@ -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 ) 
index b79a203f26beede1e9528fab37e371b44093c512..798aaf2fb4863a03fb8ad16e79bab1b361e4f31b 100644 (file)
@@ -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 ) 
index 0fa2ec127ec31a56316f57f0086e7093c4479056..374b6491ed858af490cac433f9c43114ff092ba1 100644 (file)
@@ -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 ) 
index 480c0484fd8a12d0933e8e333c2cce5ee4302af9..4bb2e94a312db5a9cc0ee0f89aa70f575cca9991 100644 (file)
@@ -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 ) 
index 4c66c58def8c362246697877273a7549d9dd4c9e..65485ff6b9f50e1a1d4940bf0bf6dcf04cf519d1 100644 (file)
@@ -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 ) 
index 4a197551ccc072bd8893bdd4fed81e0a99c202b4..ffa9330b15037ea8156b63bd8736de1c7e3825f4 100644 (file)
@@ -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 ) 
index aebc009f8c45bd79e86d0d42bd268c07606e989b..485c3aed7038abf433545b252b75b9dfc8d0e054 100644 (file)
@@ -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 )