
! script name: parasolids.d/faceisoclines
! solids: imprint isocline curves on faces.

!A
!A NAME:
!A
!A 	Face Isocline Curves
!A
!A DESCRIPTION:
!A
!A	This script will create isocline curves on a face. The isocline
!A	curves are the curves which correspond to the place on a face
!A	where tapered draft should start. 
!A
!A~ image location - images/pkisoclinecurves.gif
!A
!B INSTRUCTIONS:
!B
!B	ANGLE: Enter the draft angle. Measured from the vertical in 
!B			the current workplane.
!B
!B	PICK FACES: Apply, Unpick ,Clear   Pick the faces 
!B
!B OPTIONS:
!B
!B	The isocline curves are used when draft is to be put on a 
!B	solid for a mold or casting. Faces which are curved in z 
!B	need the isocline curves installed before tapered draft
!B	can be applied. The face is split in two by the isocline
!B	curve, taper is applied to the lower face with the isocline
!B	curve edge as the reference entity.
!B
!# see also - pksolids.d/pktaperface
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: face isocline curves ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
REAL Face_array(100)

ActivateUndo

Pick_color=2

Stat= GLPlotOn
Start:!
Num_faces= 0
Mark_group=CreateGroup("TEMPGROUP")

Stat= SetAngleEquals(Angle)
Angle=InputAngle("ANGLE")
IF ExitScript(Destination$) THEN Leave

Face_loop:!
Stat=SetInputFormat("a1",",A,U,C,")
E1=WPKPickEntity("PICK FACES: Apply, Unpick ,Clear ",WsPKPickFace,Answer$)
IF (ExitScript(Destination$)) THEN Leave

SELECT Answer$
CASE "A"
	GOSUB Apply_curves
	GOTO Start
CASE "U"
	Num_faces= Num_faces-1
	IF Num_faces<0 THEN Num_faces=0
	N1= GroupCount(Mark_group)
	E1= GroupElement(Mark_group,N1)
	Stat=RemoveFromGrp(Mark_group,N1)
	Stat= DeleteEntity(E1)
	N1= GroupCount(Mark_group)
	IF N1= 0 THEN 
		Stat= DeleteEntity(Ps)
	END IF
	PlotAll
	GOTO Face_loop
CASE "C"
	Stat= DeleteGroup(Mark_group,WsTrue)
	Stat= DeleteEntity(Ps)
	PlotAll
	GOTO Start
END SELECT

IF Num_faces= 99 THEN Start
IF NOT WPKIsEntity(E1) THEN Face_loop

UVpoint=LastUVSurfPick(E1)
IF NOT ValidGeometry(UVpoint) THEN Face_loop
U=XPointValue(UVpoint)
V=YPointValue(UVpoint)
Stat= DeleteEntity(UVPoint)

Face1= WPKEntityTag(E1)
FOR I= 1 TO Num_faces
	IF Face1= Face_array(I) THEN Face_loop
NEXT I
Num_faces= Num_faces+1
Face_array(Num_faces)= Face1
Pt= SurfParameterPt(E1,U,V)
Stat= SetColor(Pt,Pick_color,WsTrue)
Stat= AddToGroup(Mark_group,Pt)
GOTO Face_loop

Apply_curves:!
WPKClearErrorFlag
Stat= DeleteGroup(Mark_group,WsTrue)

WPKClearErrorFlag
E2= WPKFaceIsoclines(Num_faces,Face_array,Angle)

ActivateUndo
Stat= AdvanceUndoNumber("face isocline curves")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
RETURN


Leave:!
Stat= DeleteGroup(Mark_group,WsTrue)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
