puts "=========="
puts "OCC23766"
puts "=========="
puts ""
########################################################
# Shape orientation processing mechanism, redesign
########################################################

## test for keeping Orientation (cbf)

erase
NewDocument D BinOcaf

#1 - create box
NewCommand D
set B2 [AddObject D];			## add object
set F2 [AddFunction D $B2 Box];		## add function
BoxDX D $B2 190;			## set arguments of this function
BoxDY D $B2 290
BoxDZ D $B2 390
InitLogBook D;				## initialize (clean) internal maps of labels
AddDriver D Box Attach 	
ComputeFun D $F2;			## compute the function
GetShape D $F2:2 Box2;			## check result

#2 - make selections keeping orientation
explode Box2 F
explode Box2_1 E
explode Box2_3 E
don Box2_1_1 Box2_3_4
set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment
set Sel2 [AttachShape D Box2_3_4 ${B2} ${B2} 1]; ## set attachment

#3 - check orientation of the selected shapes
GetShape D 0:1:2:1:2 E1
set info1 [whatis E1]
## to be: E1 is a shape EDGE FORWARD Modified Orientable
if { [regexp "FORWARD" $info1] != 1 } {
    puts "Error: orientation of E1 is incorrect"
} else {
    puts "OK: orientation of E1 is correct"
}

GetShape D 0:1:3:1:2 E2
set info2 [whatis E2]
## to be: E2 is a shape EDGE REVERSED Modified Orientable
if { [regexp "REVERSED" $info2] != 1 } {
    puts "Error: orientation of E2 is incorrect"
} else {
    puts "OK: orientation of E2 is correct"
}

#4 -  test persistence: check orientation after retrieving (to be the same as before)
NewCommand D
set aTmpFile ${imagedir}/${casename}.cbf
SaveAs D $aTmpFile
Close D
##unset D
Open $aTmpFile D
file delete -force $aTmpFile

GetShape D 0:1:2:1:2 E1
set info3 [whatis E1]
## to be: E1 is a shape EDGE FORWARD Modified Orientable
if { [regexp "FORWARD" $info3] != 1 } {
    puts "Error: orientation of E1 is incorrect"
} else {
    puts "OK: orientation of E1 is correct"
}

GetShape D 0:1:3:1:2 E2
set info4 [whatis E2]
## to be: E2 is a shape EDGE REVERSED Modified Orientable
if { [regexp "REVERSED" $info4] != 1 } {
    puts "Error: orientation of E2 is incorrect"
} else {
    puts "OK: orientation of E2 is correct"
}
