
! script name: v3dextend.d/ccontcirext
! var_topic: extend contour with circular arc surface

!A
!A NAME:
!A
!A 	Circle Extend Contour: Bicubic	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will create a new bicubic surface by extending a contour
!A 	along a circular arc.
!A
!B INSTRUCTIONS:
!B
!B 	CIRCLE RADIUS: Enter the circle radius.
!B
!B 	EXTENSION ANGLE ( less than 180 ): Must be less than 180 deg.
!B
!B 	PATCH WIDTH ALONG EDGES: Enter the width of the patch to be used along
!B 		the edge.
!B
!B 	PICK CONTOUR: Pick the contour.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: cubic contour circle extension")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]
DIM Contour$[256]
DIM Radius_var$[256]
DIM Angle_var$[256]
DIM Name$[256]
DIM Patch_var$[256]


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

ActivateUndo
Patch_width=NamedVarVal("3D Default Patch",Ws3DSystemVars,0.25)
Tol=NamedVarVal("3D Fillet Tol",Ws3DSystemVars,0.005)

Start:!
stat= SetInputFormat("n4=","")
Radius= InputRadius("CIRCLE RADIUS")
IF (ExitScript(Destination$)) THEN Leave
No_radius_var= LastVariableInput(Radius_var$)
IF Radius=0 THEN Start
Radius= ABS(Radius)


Angle=InputAngle("EXTENSION ANGLE ( less than 180 )")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)


stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Patch_width)
V_width= GetValue("PATCH WIDTH ALONG EDGES",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_patch_var= LastVariableInput(Patch_var$)
U_width= V_width
Patch_width= V_width


Intersect2:!
Pick_contour:Stat=SetInputFormat("n0","")
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR ",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Pick_contour
Stat= EntityNameCheck(Contour,Contour$)
Stat=SetPickMask(WsPickGeometry)

Dir1=WsForward

Stat=DeleteEntity(Proj_Vector)
Stat=DeleteEntity(Proj_Center)
Stat=DeleteEntity(Plane_normal)

Stat= GenerateVarName(WsCubicSurfEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("BICUBIC: Contour circle extension")
Stat= SetRecDelLastExec
V1= FreeParameter("Direction",Dir1)
V2= FreeParameter("Tolerance",Tol)
IF No_radius_var THEN
        V3= FreeParameter("Radius",Radius)
ELSE
        V3= FreeParameter("Radius",Radius_var$)
END IF
IF No_angle_var THEN
        V4= FreeParameter("Angle",Angle)
ELSE
        V4= FreeParameter("Angle",Angle_var$)
END IF
IF No_patch_var THEN
        V5= FreeParameter("Patch width",Patch_width)
ELSE
        V5= FreeParameter("Patch width",Patch_var$)
END IF
Proj_Vector=PointXYZ(0.0,0.0,1.0)
Proj_Center=PointXYZ(0.0,0.0,1.0)
Plane_normal=PointXYZ(0.0,0.0,1.0)
S1=ExtendContour(WsCircleExt,WsCubicSurfEnt,Contour$,V1,V3,V5,V5,V2,Proj_Center,Proj_Vector,Plane_normal,V4)
Stat= NameEntity(S1,Name$)
Stat=DeleteEntityList(Proj_Vector,Proj_Center,Plane_normal)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(S1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("cubic ext surf")
	Stat= AddItemToUndo(WsUBCreateMode,S1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

GOTO Intersect2

Leave:!
Stat=SetPickMask(WsPickGeometry)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
