
! script name: pksurfaces.d/pkfoursidecubic
! solids: construct a sheet body from a cubic surface on four curves

!A
!A NAME:
!A
!A 	Four Sided Spline Sheet Body
!A
!A DESCRIPTION:
!A
!A 	This script will construct a four sided cubic surface.  There must be
!A 	four sides which intersect in 3D space.  The four sided surface formed
!A 	may be thought of as a rubber rectangle in 2D space that has been
!A 	stretched, pushed, and pulled.
!A
!A~ image location - images/pkfoursides.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK U CONTOUR #1: Pick one of the sides to be used to determine
!B 		the U curves.
!B
!B 	PICK U CONTOUR #2: Pick the other side to be used to determine
!B 		the U curves.  The U contour #1 and the U contour #2 may NOT
!B 		be adjacent sides.
!B
!B 	PICK V CONTOUR #1: Pick one of the sides to be used to determine
!B 		the V curves.  The U and V contours may NOT be the same.
!B
!B
!B 	PICK V CONTOUR #2: Pick the other side to be used to determine
!B 		the V curves.  The V contour #1 and the V contour #2 may NOT
!B 		be adjacent sides.
!B
!B 	U PATCH WIDTH: Enter the patch width to be used for the U curves.
!B
!B 	V PATCH WIDTH: Enter the patch width to be used for the V curves.
!B
!C NOTES:
!C
!C 	Problems may occur from over patching.  Avoid over patching by giving
!C 	patch widths appropriate to the sections.  Remember, the patch widths
!C 	for U and V do not have to be the same.  When a corner point is used,
!C 	the patches converge at that point.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: sheet body from 4 curves ")

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

ActivateUndo
Patch_width=NamedVarVal("3D Default Patch",Ws3DSystemVars,0.5)

Stat= GLPlotOn
Upatch=Patch_width
Vpatch=Patch_width

Stat=SetInputFormat("n4","")
Pick_loop: !

Stat=SetPickMask(WsPickNoSurf)

Pick_u1:Stat=SetInputFormat("n0","")
UContour1=PickEntity("PICK U CONTOUR #1",Answer$)
IF ExitScript(Destination$) THEN Leave

IF NOT ValidContourEnt(UContour1) THEN Pick_u1
G1= ParentGroup(UContour1,0)
IF ValidGeometry(G1) THEN UContour1= G1
IF NOT ValidGeometry(UContour1) THEN Pick_u1
Stat=Highlight(UContour1,WsPickPen,WsDirArrowOff)

Pick_u2:Stat=SetInputFormat("n0","")
UContour2=PickEntity("PICK U CONTOUR #2",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidContourEnt(UContour2) THEN Pick_u2
G1= ParentGroup(UContour2,0)
IF ValidGeometry(G1) THEN UContour2= G1
IF NOT ValidGeometry(UContour2) THEN Pick_u2
Stat=Highlight(UContour2,WsPickPen,WsDirArrowOff)

Pick_v1:Stat=SetInputFormat("n0","")
VContour1=PickEntity("PICK V CONTOUR #1",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidContourEnt(VContour1) THEN Pick_v1
G1= ParentGroup(VContour1,0)
IF ValidGeometry(G1) THEN VContour1= G1
IF NOT ValidGeometry(VContour1) THEN Pick_v1
Stat=Highlight(VContour1,WsPickPen,WsDirArrowOff)

Pick_v2:Stat=SetInputFormat("n0","")
VContour2=PickEntity("PICK V CONTOUR #2",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidContourEnt(VContour2) THEN Pick_v2
G1= ParentGroup(VContour2,0)
IF ValidGeometry(G1) THEN VContour2= G1
IF NOT ValidGeometry(VContour2) THEN Pick_v2
Stat=Highlight(VContour2,WsPickPen,WsDirArrowOff)

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Upatch)
Upatch=GetValue("U PATCH WIDTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Vpatch)
Vpatch=GetValue("V PATCH WIDTH",Answer$)
IF ExitScript(Destination$) THEN Leave

WPKClearErrorFlag
Pkbody=WPKFourCurveSheet(WsCubicSurfEnt,UContour1,UContour2,VContour1,Vcontour2,Upatch,Vpatch)

ActivateUndo
Stat= AdvanceUndoNumber("four sided sheet body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_loop

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