puts "================"
puts "OCC1669"
puts "================"
puts ""
#################################################################
# Wrong name mapping of the instances of assembly into STEP file.
#################################################################

set BugNumber OCC1669

catch {pload OCAF}

XNewDoc SA

box b1 10 10 10
box b2 20 10 10
ttranslate b1 10 0 0
ttranslate b2 20 0 0
compound b1 b2 bl
copy bl nbl
ttranslate nbl 30 0 0
compound bl nbl ryad
copy ryad hryad
ttranslate hryad -10 0 10
copy ryad uryad
ttranslate uryad 0 0 20
compound ryad hryad uryad stena

XAddShape SA stena 1

SetName SA 0:1:1:1 Wall
SetName SA 0:1:1:2 Block-Array
SetName SA 0:1:1:3 Block
SetName SA 0:1:1:4 Half-Brick
SetName SA 0:1:1:5 Brick

SetName SA 0:1:1:1:1 base-array
SetName SA 0:1:1:1:2 next-array
SetName SA 0:1:1:1:3 top-array

SetName SA 0:1:1:2:1 left-block
SetName SA 0:1:1:2:2 right-block

SetName SA 0:1:1:3:1 half-brick
SetName SA 0:1:1:3:2 brick

catch { WriteStep SA $imagedir/${test_image}.stp }
catch { ReadStep D $imagedir/${test_image}.stp }

puts "Info: Now compare two documents SA and D"
#DFBrowse SA
#DFBrowse D

set NamesList1 {Wall Block-Array Block Half-Brick Brick}
set NamesList2 {base-array next-array top-array}
set NamesList3 {left-block right-block}
set NamesList4 {half-brick brick}

set status 0

for {set i 1} {$i <= 5} {incr i} {
    set name [ GetName D 0:1:1:$i ]
    set ref_name [lindex $NamesList1 $i-1]
    if { $name != $ref_name } {
       set status 1
       break
    }
}

if { $status != 1 } {
   for {set i 1} {$i <= 3} {incr i} {
        set name [ GetName D 0:1:1:1:$i ]
	set ref_name [lindex $NamesList2 $i-1]
    	if { $name != $ref_name } {
       	   set status 1
       	   break
    	}
   }
}

if { $status != 1 } {
   for {set i 1} {$i <= 2} {incr i} {
        set name [ GetName D 0:1:1:2:$i ]
	set ref_name [lindex $NamesList3 $i-1]
    	if { $name != $ref_name } {
       	   set status 1
       	   break
    	}
   }
}

if { $status != 1 } {
   for {set i 1} {$i <= 2} {incr i} {
        set name [ GetName D 0:1:1:3:$i ]
	set ref_name [lindex $NamesList4 $i-1]
    	if { $name != $ref_name } {
       	   set status 1
       	   break
    	}
   }
}

if { $status != 0 }  {
  puts "Faulty ${BugNumber}"
} else {
  puts "OK ${BugNumber}"
}
