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

!A
!A NAME:
!A
!A 	Bicubic: Point Grid
!A
!A DESCRIPTION:
!A
!A 	This script will make a cubic 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 cubic curve through each row of points, and then generating
!A 	a cubic curve through each column of points.  The resulting grid is
!A 	then used to generate bicubic patches.
!A
!B INSTRUCTIONS:
!B
!B 	NUMBER POINTS PER ROW: Enter the number of points
!B 		to be included in each row.  All rows must
!B 		have the same number of points.
!B
!B 	NUMBER OF ROWS: Enter the number of rows in the grid
!B 		to be included.
!B
!B 	PICK POINT ROW # COL #: Pick the point to be used
!B 		in the specified position of the point grid.
!B 		Each point to be used must be picked.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: point grid ")

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

ActivateUndo
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(WsCubicSurfEnt,Group,"CUBIC SURFACE",Numberu,Numberv)

ActivateUndo
Stat= AdvanceUndoNumber("bicubic surface")
Stat= AddItemToUndo(WsUBCreateMode,Surf)
Stat=DeleteEntity(Group)

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

