# ============= OCAF ============================
# Naming
#
# Testing purpose: Naming selection mechanism 
#
# Test case: E1 (ShapeOrientation is not used)
#
# 1. Create Box B2
# 2. Create Cylinder Cyl
# 3. Cut (B2, Cyl)
# 4. Make Fillet
# 5. Make selection for all sub-shapes
# 6. Modify B2
# 7. Recompute modeling functions
# 8. Recompute selections
# ===============================================

erase 
Close D 

NewDocument D BinOcaf
isos 12
#1 - create box using more flexible set of commands
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 Cyl	
ComputeFun D $F2;			## compute the function
GetShape D $F2:2 Box2;			## check result
whatis Box2
GetReference D $B2;			## refers to result NS

#2 
NewCommand D
explode Box2 F
explode Box2_1 E
set Sel1 [AttachShape D Box2_1_1 ${B2} ${B2} 1]; ## set attachment
AddDriver D Attach Cyl
set Cyl [AddCyl D 30 315 ${Sel1}]
ComputeFun D $Cyl:1

#3 => cut
NewCommand D
AddDriver D Cut
set CS [AddCut D $B2 $Cyl]
ComputeFun D $CS
GetShape D $CS:2 S

#4 => Fillet
NewCommand D
explode S F
explode S_1 E
set Sel2 [AttachShape D S_1_1 ${B2} ${B2} 1]; ## set attachment for using in Fillet
AddDriver D Fillet
set Fill [AddFillet D $B2 25 $Sel2 0]
ComputeFun D $Fill
GetShape D $Fill:2 S


#5 test selection
NewCommand D
set SL [TestSingleSelection D $B2 0]
set SL2 [TestMultipleSelection D $B2 0]

#6 modification
NewCommand D
BoxDX D $B2 290

#7 recomputation modeling functions
NewCommand D
InitLogBook D;		## to be initialized before any recomputation of impacted functions set (if attachments are presented)
ComputeFun D $F2;	
ComputeFun D $Sel1:1
ComputeFun D $Cyl:1
ComputeFun D $CS
ComputeFun D $Sel2:1
ComputeFun D $Fill
GetShape D $Fill:2 S
don S

#8 Recompute selections
SolveFlatFrom D $SL
NewCommand D
