
! script name: v3dextend.d/ccontvectext
! var_topic: vector extend contour with bicubic surface

!A
!A NAME:
!A
!A 	Vector Extend Contour: Bicubic	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will create a new bicubic surface by extending a contour
!A 	the specified vector displacement.
!A
!B INSTRUCTIONS:
!B
!B 	X SHIFT: Enter the amount of X shift.
!B
!B 	Y SHIFT: Enter the amount of Y shift.
!B
!B 	Z SHIFT: Enter the amount of Z shift.
!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 vector extension")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]
DIM Contour$[256]
DIM X_var$[256]
DIM Y_var$[256]
DIM Z_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=","")
stat= SetEqualsValue(Xshift)
Xshift= GetValue("X SHIFT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_x_var= LastVariableInput(x_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Yshift)
Yshift= GetValue("Y SHIFT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_y_var= LastVariableInput(y_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Zshift)
Zshift= GetValue("Z SHIFT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_z_var= LastVariableInput(z_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=1

Stat= GenerateVarName(WsCubicSurfEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("BICUBIC: Vector contour extension")
Stat= SetRecDelLastExec
V1= FreeParameter("Direction",Dir1)
V2= FreeParameter("Tolerance",Tol)
IF No_x_var THEN
        V3= FreeParameter("Xshift",Xshift)
ELSE
        V3= FreeParameter("Xshift",X_var$)
END IF
IF No_y_var THEN
        V4= FreeParameter("Yshift",Yshift)
ELSE
        V4= FreeParameter("Yshift",Y_var$)
END IF
IF No_z_var THEN
        V5= FreeParameter("Zshift",Zshift)
ELSE
        V5= FreeParameter("Zshift",Z_var$)
END IF
IF No_patch_var THEN
        V6= FreeParameter("Patch width",Patch_width)
ELSE
        V6= 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)
Shift_vector= PointXYZ(V3,V4,V5)
S1=ExtendContour(WsVector,WsCubicSurfEnt,Contour$,V1,Shift_vector,V6,V6,V2,Proj_Center,Proj_Vector,Plane_normal)
Stat= NameEntity(S1,Name$)
Stat=DeleteEntityList(Proj_Vector,Proj_Center,Plane_normal,Shift_vector)
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=DeleteEntity(Shift_vector)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
