]> OCCT Git - occt.git/commitdiff
0031816: Data Exchange - RWMesh_MaterialMap::CopyTexture() copies glb file instead...
authorkgv <kgv@opencascade.com>
Thu, 1 Oct 2020 12:07:46 +0000 (15:07 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 2 Oct 2020 16:13:47 +0000 (19:13 +0300)
Image_Texture is now checked if it defines an additional offset within the file
to avoided copying an old glb file with embedded image files instead of extracting them.

src/RWMesh/RWMesh_MaterialMap.cxx
tests/de_mesh/gltf_write/lantern [new file with mode: 0644]

index edbc8d93f7d8048ece72ee85a6ab5bf554644e10..fcfb73ff3ed3f4db785c81e5ddbe2cabc9f256e5 100644 (file)
@@ -167,7 +167,9 @@ bool RWMesh_MaterialMap::CopyTexture (TCollection_AsciiString& theResTexture,
 
   TCollection_AsciiString aTexFileName;
   TCollection_AsciiString aTextureSrc = theTexture->FilePath();
-  if (!aTextureSrc.IsEmpty())
+  if (!aTextureSrc.IsEmpty()
+    && theTexture->FileOffset() <= 0
+    && theTexture->FileLength() <= 0)
   {
     TCollection_AsciiString aSrcTexFolder;
     OSD_Path::FolderAndFileFromPath (aTextureSrc, aSrcTexFolder, aTexFileName);
diff --git a/tests/de_mesh/gltf_write/lantern b/tests/de_mesh/gltf_write/lantern
new file mode 100644 (file)
index 0000000..fb9eaa2
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========"
+puts "0031816: Data Exchange - RWMesh_MaterialMap::CopyTexture() copies glb file instead of a texture inside it"
+puts "========"
+
+catch { Close D1 }
+ReadGltf D1 [locate_data_file bug30691_Lantern.glb]
+
+set aTmpGltfBase "${imagedir}/${casename}_tmp"
+set aTmpGltf "${aTmpGltfBase}.gltf"
+lappend occ_tmp_files $aTmpGltf
+lappend occ_tmp_files "${aTmpGltfBase}.bin"
+lappend occ_tmp_files "${aTmpGltfBase}_textures"
+
+WriteGltf D1 "$aTmpGltf"
+
+ReadGltf D "$aTmpGltf"
+XGetOneShape s D
+checknbshapes s -face 3 -compound 1
+checktrinfo s -tri 5394 -nod 4145