
! script name: v3dslice.d/sliceapprox
! var_topic: set up data for approximations of slice curves

!A
!A NAME:
!A
!A 	Slice Approximation
!A
!A DESCRIPTION:
!A
!A 	This script will set up data for approximations of slice curves.
!A
!B INSTRUCTIONS:
!B
!B 	APPROXIMATION METHOD: 0 1 2 3 4 5 6:
!B
!B 		0 : Curve is line segments and point chains.
!B 		1 : Curve is approximating bspline curves of fixed degree.
!B 		2 : Curve is approximating bezier curves .
!B 		3 : Curve is by circular arcs.
!B 		4 : point chains smoothed .
!B 		5 : bsplines  smoothed .
!B 		6 : bezier smoothed .
!B
!B 	POLYNOMIAL DEGREE: Degree of approximating basis polynomials.
!B
!C NOTES:
!C
!C 	Methods 1,2 smooth the slice by approximating the curve by the
!C 	appropriate spline curve. The Bezier curve is the smoothest and
!C 	also the slowest and least accurate.
!C
!C 	Methods 4,5,6 smooth the slice data by generating points along
!C 	the curves and combining points which are close together. This
!C 	method must be used in conjunction with a relatively larger
!C 	finish allowance.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: slice curve approx data ")

DIM Destination$[256]
DIM Answer$[256]
DIM Title$[256]
DIM Label$[256]
DIM Namelist$[2560]

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
Start:!
Units= CurrentUnits
IF Units= WsMetric THEN 
	Tol= 0.125
ELSE
	Tol= 0.002
END IF

Pdeg= 3
Method= 1

Title$="SLICE CURVE APPROXIMATIONS"
Label$="METHOD SELECTED"
Namelist$="0  No Approximation,"
Namelist$=Namelist$&"1  Bspline Curve Approximation,"
Namelist$=Namelist$&"2  Bezier Curve Approximation,"
Namelist$=Namelist$&"3  Circular Arcs Approximation,"
Namelist$=Namelist$&"4  Point Blending,"
Namelist$=Namelist$&"5  Point Blending with Bspline Curves,"
Namelist$=Namelist$&"6  Point Blending with Bezier Curves,"

Stat=GeneralListBox(Title$,Label$,Namelist$)
Stat=SetEqualsValue(Method)
Stat=SetInputFormat("n0=","")
Method=GetValue("APPROXIMATION METHOD: 0 1 2 3 4 5 6  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Method< 0 OR Method> 6 THEN Start

LowerSelectBox

IF Method = 1 OR Method= 5 THEN
	Stat=SetEqualsValue(Pdeg)
	Stat=SetInputFormat("n0=","")
	Pdeg=GetValue("POLYNOMIAL DEGREE",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
END IF


RecordFunctionOn
Stat= RecordDescr("3D SETTING: Slice approximation data")
V1= FreeParameter("Method",Method)
V2= FreeParameter("Spline Polynomial degree",Pdeg)
V3= FreeParameter("Tolerance",Tol)
Stat= SliceCurveData(V1,V2,V3)
RecordFunctionOff
CloseVarRecord

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