1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
msv 63cdf48ec1 0029830: STEPCAFControl_Reader poor performance - quadratic dependence
Various performance improvements in STEP read/write algorithms:
- Search for the  label of a shape or component shape is improved using map mechanism instead of brute force iteration.
- Invariant FindEntities() is moved out of the loop in the method getStyledItem in STEPCAFControl/STEPCAFControl_Writer.cxx.
- A pointer to the end of binders chain is added in Transfer_Binder class to speed up adding a binder to the chain.
- Small fixes are added  to eliminate excess copying of handles, calls of handle DownCasts and so on.

Stack overflow is removed during destruction of STEP model with long chains of Transfer_Binder.
It is possible to use the Draw commands ReadStep and WriteStep to read/write from the session without accessing the disk file (use '.' for the file name).

Performance test cases for STEP reading/writing have been added.
2018-07-20 17:15:53 +03:00

106 lines
2.3 KiB
Plaintext

puts "========"
puts "0029830: Data Exchange, STEPCAFControl_Reader poor performance - quadratic dependence"
puts "========"
puts ""
set copy_cmd tcopy
if $use_sharing {
set copy_cmd copy
}
set dx 2
set dy 4
set dz 6
set nx0 20
set ny 10
set nz 10
if [info exists D] {Close D}
if [info exists D1] {Close D1}
for {set npass 1} {$npass <= 2} {incr npass} {
set nx [expr $nx0 * $npass]
puts "Creating assembly of $nx*$ny*$nz boxes"
plane a 0 0 0 1 0 0
mkface a a 0 3 0 2
shape co C
for {set i 0} {$i < $nx} {incr i} {
for {set j 0} {$j < $ny} {incr j} {
for {set k 0} {$k < $nz} {incr k} {
eval $copy_cmd a a1
ttranslate a1 $dx*$i $dy*$j $dz*$k
add a1 co
}
}
}
XNewDoc D
XAddShape D co
puts "Assigning colors to components"
set i 0
set j 0
set k 0
set shlist [explode co]
set lab [lindex [XFindComponent D co_1] 0]
set taglist [split $lab :]
foreach c $shlist {
set r [expr ($i%3)/3.]
set g [expr ($j%3)/3.]
set b [expr ($k%3)/3.]
set lab [join $taglist :]
XSetColor D $lab $r $g $b
incr k
if {$k%3 == 0} {
incr j
if {$j%3 == 0} {
incr i
}
}
set taglist "[lrange $taglist 0 end-1] [expr [lindex $taglist end] + 1]"
}
puts "Writing STEP model"
chrono cr1 restart
WriteStep D .
chrono cr1 stop
Close D
puts "Reading STEP model"
chrono cr2 restart
ReadStep D1 .
chrono cr2 stop
# check one solid with different locations
XGetOneShape result D1
if $use_sharing {
checknbshapes result -face 1
checknbshapes result -face [expr $nx*$ny*$nz] -t
} else {
checknbshapes result -face [expr $nx*$ny*$nz]
checknbshapes result -face [expr $nx*$ny*$nz] -t
}
if {$npass == 2} {
XShow D1
vfit
vsetdispmode 1
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
}
Close D1
set time_write_$npass [lindex [dchrono cr1 counter "WriteStep_$npass"] end]
set time_read_$npass [lindex [dchrono cr2 counter "ReadStep_$npass"] end]
}
puts "time_write_1=$time_write_1"
puts "time_write_2=$time_write_2"
puts "time_read_1=$time_read_1"
puts "time_read_2=$time_read_2"
set time_raise_write [expr $time_write_2 / $time_write_1]
set time_raise_read [expr $time_read_2 / $time_read_1]
puts "time_raise_write=$time_raise_write"
puts "time_raise_read=$time_raise_read"