
! script name: dyn_solids.d/dyndisk
! 3dtopic: construct disk

!A
!A NAME:
!A
!A 	Dynamic Disk: Define
!A
!A DESCRIPTION:
!A
!A 	This script constructs a disk ( or a part of a disk ), which is
!A 	a plane with a circular boundary.
!A
!B INSTRUCTIONS:
!B
!B 	DISK RADIUS: Enter the radius of the disk to be constructed.
!B
!B 	STARTING ANGLE: Enter the starting angle of the disk.
!B
!B 	ANGULAR EXTENT: Enter the number of degrees and the
!B 		direction ( + CCW, - CW ) from the starting angle
!B 		to the ending angle.  The angular extent determines
!B 		the ending angle.
!B
!B 	ROTATION ANGLE: Enter the orientation angle of the
!B 		axis of the disk in the XY plane.
!B
!B 	X AXIS TILT ANGLE: This represents the angle of tilt
!B 		of the axis of the disk around the X axis.
!B
!B 	Y AXIS TILT ANGLE: This represents the angle of tilt
!B 		of the axis of the disk around the Y axis.
!B
!C NOTES:
!C
!C 	The U contours of a disk are the circles and the V contours are the
!C 	radial lines.
!C
!# see also - points.d/dyninput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: dynamic disk ")

DIM Destination$[256]
DIM Answer$[256]
REAL Params(0:10)

Units= CurrentUnits
IF Units= WsMetric THEN
        Radius= 25
ELSE
        Radius= 1
END IF


Stat= GLPlotOn
Start:!
Stat=SetPickMask(WsPickNoSurf)
ActivateUndo
Astart= 0
Angle= 180

Dynamic_length1= GetDefault(WsDynamicLength1)
Dynamic_length2= GetDefault(WsDynamicLength2)
Dynamic_angle1= GetDefault(WsDynamicAng1Incr)
Dynamic_angle2= GetDefault(WsDynamicAng2Incr)
Dynamic_data1= GetDefault(WsDynamicData1)
Dynamic_data2= GetDefault(WsDynamicData2)

Dynamic_radius= GetDefault(WsDynRadiusDefault)
Dynamic_angle= GetDefault(WsDynAngleDefault)

Stat= SetDefaults(WsDynamicLength1,Dynamic_radius)
Stat= SetDefaults(WsDynamicLength2,Dynamic_angle)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle)
Stat= SetDefaults(WsDynamicData1,Dynamic_angle)
Stat= SetDefaults(WsDynamicData2,Dynamic_angle)



Stat=SetInputFormat("n4b=","")
Stat=SetRadiusEquals(Radius)
Radius=InputRadius("DISK RADIUS")
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Astart)
Astart=InputAngle("STARTING ANGLE ( 0 90 180 270 ) ")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4b=","")
Stat=SetEqualsValue(Angle)
Disk_angle=GetValue("ANGULAR EXTENT ( 90 180 360 ) ",Answer$)
IF ExitScript(Destination$) THEN Leave

Tilt_angles:!
Stat=SetInputFormat("n4b=","")
Stat=SetAngleEquals(Zangle)
Zangle=InputAngle("ROTATION ANGLE ( 0 90 180 270 ) ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Xangle)
Xangle=InputAngle("X AXIS TILT ANGLE( 0 90 180 270 )  ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Yangle)
Yangle=InputAngle("Y AXIS TILT ANGLE( 0 90 180 270 )  ",WsSigned)
IF ExitScript(Destination$) THEN Leave


Place_disk:!
PlotOff
Pref= PointXYZ(0,0,0)
Pdest= CopyEntity(Pref)
Stat= MakeInvisible(Pref)
Stat= MakeInvisible(Pdest)
T1=AngleTransform(Pref,Xangle,Yangle,Zangle,WsWorkplaneVals)
E1=Disk(T1,Radius,Astart,Disk_angle)
Stat= MakeInvisible(E1)
PlotOn

Vnum= LastPickView
Params(0)= Radius
Params(1)= Astart
Params(2)= Disk_angle
Params(3)= Xangle
Params(4)= Yangle
Params(5)= Zangle
Num_params=6
Stat=SetInputFormat("n4b","")
Stat=DynamicEntity(Vnum,E1,Pref,Pdest,WsDynamicDisk,"PICK REFERENCE ",Params,Num_params)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteEntity(E1,WsTrue)
	Stat=DeleteEntity(Pdest,WsTrue)
        Stat=DeleteEntity(Pref,WsTrue)
        IF Destination$= "BACKUP" THEN Tilt_angles
        GOTO Leave
END IF

Stat=DeleteEntity(Pref)
Stat=DeleteEntity(Pdest)

WPKClearErrorFlag
S1=WPKMakeBsurf(E1)
Stat= DeleteEntity(E1,WsTrue)

ActivateUndo
Stat= AdvanceUndoNumber("disk sheet body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Place_disk

Leave:!
Stat=SetPickMask(WsPickGeometry)
Stat=SetInputFormat("n4","")
Stat= DeleteEntity(Pref)
Stat= DeleteEntity(Pdest)
Stat= SetDefaults(WsDynamicLength1,Dynamic_length1)
Stat= SetDefaults(WsDynamicLength2,Dynamic_length2)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle1)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle2)
Stat= SetDefaults(WsDynamicData1,Dynamic_data1)
Stat= SetDefaults(WsDynamicData2,Dynamic_data2)

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	LOAD Destination$
END IF
END

