1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0029901: Support save to and restore from Stream interface in TObj package

Storage and retrieval of a document by means of a stream is distributed to TObj model.
Modified files:
-TObj_Model.hxx, cxx - the virtual methods Load() and SaveAs() obtained a stream as an argument instead of a file name.
-TObj_Application.hxx, cxx - same extension: the virtual methods LoadDocument() and SaveDocument() use a stream to open and save a document.
-TObjDRAW.cxx - draw-commands TObjSave and TObjLoad are extended for -stream parameter, which allows usage of a file input or output stream instead of a file name.

A new test:
- bugs caf bug29901 - it creates a simple TObj-model, saves it on disk using a file stream, loads it by means of a file stream and checks the content.

Modified test:
- bugs caf bug28425 - just improved to proper manipulate a test-file on disk.
This commit is contained in:
vro
2020-12-11 18:13:25 +03:00
committed by bugmaster
parent c6685c65fd
commit a8d3a0b102
7 changed files with 402 additions and 101 deletions

View File

@@ -7,6 +7,8 @@ puts ""
############################################################
pload QAcommands
set aTestFileBin $imagedir/${casename}.cbf
set aTestFileXml $imagedir/${casename}.xml
vertex v 1 2 3
box b 10 20 30
@@ -21,9 +23,9 @@ if { [regexp "SOLID" $info] != 1 } {
} else {
puts "OK: order of shapes is correct"
}
SaveAs D1 test.cbf
SaveAs D1 ${aTestFileBin}
Close D1
Open test.cbf D2
Open ${aTestFileBin} D2
GetNewShapes D2 0:1 s
set info [whatis s_1]
if { [regexp "SOLID" $info] != 1 } {
@@ -43,9 +45,9 @@ if { [regexp "SOLID" $info] != 1 } {
} else {
puts "OK: order of shapes is correct"
}
SaveAs D1 test.xml
SaveAs D1 ${aTestFileXml}
Close D1
Open test.xml D2
Open ${aTestFileXml} D2
GetNewShapes D2 0:1 s
set info [whatis s_1]
if { [regexp "SOLID" $info] != 1 } {

46
tests/bugs/caf/bug29901 Normal file
View File

@@ -0,0 +1,46 @@
puts "============"
puts "0029901: Support save to and restore from Stream interface in TObj package"
puts "============"
set status 0
set BugNumber 29901
pload TOBJ
# Create a new document
TObjNew TD1
TObjAddObj TD1 obj1
TObjSetVal TD1 obj1 ${BugNumber}
# Save the document
set aFile $imagedir/${test_image}-[file tail [info script]].cbf
catch {[file delete ${aFile}]}
catch {TObjSave TD1 ${aFile} -stream}
if { ![file exists ${aFile}] } {
set status 1
puts "There is not ${aFile} file; TObjSave command: Error"
puts "bug${BugNumber}: ERROR"
} else {
puts "Save the document to ${aFile} file"
}
TObjClose TD1
unset TD1
# Restore the document
if [catch { TObjLoad TD2 ${aFile} -stream} catch_result] {
puts "bug${BugNumber}: ERROR"
}
# check stored single integer value
set retInt [TObjGetVal TD2 obj1 -i]
if { $retInt != ${BugNumber} } {
set status 1
puts "bug${BugNumber}: check stored single integer value; ERROR"
}
if { ${status} != 0 } {
puts "Faulty bug${BugNumber}"
} else {
puts "OK bug${BugNumber}"
}