
! script name: vsolids.d/revolution
! var_topic: generate solid of revolution by rotating contour about an axis

!A
!A NAME:
!A
!A 	Revolution	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script generates a solid of revolution by rotating a contour
!A 	about an axis.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick the contour to be used to generate a solid of
!B 		revolution.
!B
!B 	STARTING ANGLE: Enter the starting angle of the solid of revolution.
!B
!B 	ANGULAR EXTENT: Enter the number of degrees and the direction
!B 		( + CCW, - CW) from the starting angle to the ending angle.
!B 		The angular extent determines the ending angle.
!B
!B 	PICK AXIS LINE: Pick the line to be used as the axis of the revolution.
!B
!B 	ORIENTATION POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the
!B 		orientation point of the revolution.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!C NOTES:
!C
!C 	The U contours of a revolution are the contour and the V contours
!C 	are the circles.
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: revolution ")

DIM Destination$[256]
DIM Answer$[256]
DIM Orient_pt$[256]
DIM Axis_line$[256]
DIM Contour$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Angle_var$[256]
DIM Sangle_var$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
Cloop:!
Pick_contour: !
stat= SetInputFormat("a1",",P,")
Stat= SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR ",0)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Contour) THEN Pick_contour1
IF NOT ValidDependency(Contour) THEN Pick_contour1
Stat= EntityNameCheck(Contour,Contour$)

Stat= SetPickMask(WsPickAll)
Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)


stat= SetAngleEquals(0)
Astart=InputAngle("STARTING ANGLE ( 0 90 180 270) ")
IF (ExitScript(Destination$)) THEN Leave
No_sangle_var= LastVariableInput(Sangle_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(180)
Angle= GetValue("ANGULAR EXTENT ( 90 180 360 ) ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)


Pick_line:Axis_line=PickSpecificEnt("PICK AXIS LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Axis_line) THEN Pick_line
IF NOT ValidDependency(Axis_line) THEN Pick_line
Stat= EntityNameCheck(Axis_line,Axis_line$)


stat= SetInputFormat("n4","")
E1=PickEntity("ORIENTATION POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Line_loop
IF NOT ValidDependency(E1) THEN Line_loop
T= LastPickPara
Pick_return= CurrPickReturn
Stat= EntityNameCheck(E1,Orient_pt$)


Stat= GenerateVarName(WsRevolutionEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("REVOLUTION: Axis line")
Stat= SetRecDelLastExec
SELECT Pick_return
CASE WsGeometryEnd
        Pt= ParameterReturnPt(Orient_pt$,T,WsGeometryEnd)
CASE WsGeometryMid
        Pt= ParameterReturnPt(Orient_pt$,T,WsGeometryMid)
CASE WsGeomCenter
        Pt= ParameterReturnPt(Orient_pt$,T,WsGeomCenter)
END SELECT
T1= RevAxisTransform(Axis_line$,Pt)
IF No_sangle_var THEN
	IF No_angle_var THEN
        	V1= FreeParameter("Start angle",Astart)
        	V2= FreeParameter("Angle",Angle)
		R1= Revolution(T1,Contour$,Axis_line$,V1,V2)
	ELSE
        	V1= FreeParameter("Start angle",Astart)
		R1= Revolution(T1,Contour$,Axis_line$,V1,Angle_var$)
	END IF
ELSE
	IF No_angle_var THEN
        	V2= FreeParameter("Angle",Angle)
		R1= Revolution(T1,Contour$,Axis_line$,Sangle_var$,V2)
	ELSE
		R1= Revolution(T1,Contour$,Axis_line$,Sangle_var$,Angle_var$)
	END IF
END IF
Stat= NameEntity(R1,Name$)
Stat= DeleteEntity(Pt)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(R1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("revolution")
	Stat= AddItemToUndo(WsUBCreateMode,R1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Cloop

Leave:!

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
