
! script name: nurbs.d/bsinterpolate
! topic: Sample - construct bspline curve through group of points

!A
!A NAME:
!A
!A 	NURBS: Through Points
!A
!A DESCRIPTION:
!A
!A 	This script constructs a bspline curve through a group of points.
!A 	Makes single Entity. 
!A
!B INSTRUCTIONS:
!B
!B 	POINT #  ABS X,Y,Z: Enter the X,Y,Z coordinates of a point on the
!B 		bspline curve.  Remember, the order of the points is important.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B NOTES:
!B
!B 	Enter the last point twice to end the point input mode.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: nurbs: through points ")

DIM Answer$[256]
DIM Destination$[256]
DEG

ActivateUndo
Group_loop:!
Group=CreateGroup("TEMPGROUP")
Pt_count=1

Point_loop:!

Ploop:Pt=XyzInput("POINT #"&VAL$(Pt_count)&" ",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

IF Pt_count>1 THEN
	Dist=DistTwoPts(Pt,Plast)
	IF (Dist>0.0001) THEN
		Stat=AddToGroup(Group,Pt)
		Stat=SetLastPoint(Pt,WsXyzInput)
		Plast=Pt
		Pend=Pt
		Pt_count=Pt_count+1
		GOTO Point_loop
	END IF
ELSE
	Stat=AddToGroup(Group,Pt)
	Stat=SetLastPoint(Pt,WsXyzInput)
	Plast=Pt
	Pstart=Pt
	Pt_count=Pt_count+1
	GOTO Point_loop
END IF

PDeg= 3 ! degree of interpolating polynomials 

Spline_group=InterpolatePtGrp(Group,0,PDeg,8,0)
Stat=DeleteGroup(Group)
Stat=DeleteEntity(Pt)
ActivateUndo
Stat= AdvanceUndoNumber("bezier curve")
Stat= AddGroupToUndo(WsUBCreateMode,Spline_group,1,WsFalse)
GOTO Group_loop


Leave:!
Stat=DeleteEntity(Pt)
Stat=DeleteGroup(Group)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

