
! script name: surfaces.d/nurbgrid
! 3dtopic: construct nurb surface through a grid of points

!A
!A NAME:
!A
!A 	NURBS: Point Grid
!A
!A DESCRIPTION:
!A
!A 	This script will make a nurb surface through a grid of points.  This
!A 	type of surface begins with a grid of points in 3D space, where each
!A 	row must have the same number of points.  The surface is generated by
!A 	creating a nurb curve using the points in each row as the control
!A 	points, and then creating a nurb curve using the points in each column
!A 	as control points.
!A
!B INSTRUCTIONS:
!B
!B 	NUMBER POINTS PER ROW: Enter the number of points to be included in
!B 		each row.  All rows must have the same number of points.
!B
!B 	NUMBER OF ROWS: Enter the number of rows in the grid to be included.
!B
!B 	PICK POINT ROW # COL #: Pick the point to be used in the specified
!B 		position of the point grid.  Each point to be used must be
!B 		picked.
!B
!C NOTES:
!C
!C 	NURBS are influenced by the points, but may not actually pass through
!C 	all of the points.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: nurb surface through a grid of points ")

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

ActivateUndo
Bezier_surf= WsFalse
IF ARGC<2 THEN
        Bezier_surf= WsFalse
ELSE
        Bezier_surf= VAL(ARGV(1))
END IF

Group_loop:!
Group=CreateGroup("TEMPGROUP")

Point_loop:!
Stat=SetInputFormat("n0","")
Numberu=GetValue("NUMBER POINTS PER ROW",Answer$)
IF ExitScript(Destination$) THEN Leave

Numberv=GetValue("NUMBER OF ROWS",Answer$)
IF ExitScript(Destination$) THEN Leave

PRINT Numberv,Numberu

FOR J=1 TO Numberv
	Rows$=" ROW "&VAL$(J)
	FOR I=1 TO Numberu
		Cols$=" COL "&VAL$(I)
		Stat=SetInputFormat("a1",",P,")
		Pt=PickSpecificEnt("PICK POINT "&Rows$&Cols$,WsPickPoints)
		IF ExitScript(Destination$) THEN Leave
		Stat=AddToGroup(Group,Pt)
	NEXT I
NEXT J

surf=GridSurface(WsNurbSurfEnt,Group,"NURB SURFACE",Numberu,Numberv,Bezier_surf)

ActivateUndo
Stat= AdvanceUndoNumber("nurb surface")
Stat= AddItemToUndo(WsUBCreateMode,Surf)

Stat=DeleteEntity(Group)

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

