
! script name: vdatatable.d/tminbdyrad
! var_topic: insert the minimum radius of a boundary into a table.

!A
!A NAME:
!A
!A 	Tables: Minimum Boundary Radius	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	Insert the minimum radius of a boundary into a table.
!A
!B INSTRUCTIONS:
!B
!B 	PICK AN ELEMENT OF BOUNDARY: Pick an element of the boundary
!B 		that defines the pocket.
!B
!B 	PICK ENTRY POSITION: Pick the position in the table for the minimum
!B 		radius to be entered.
!B
!C
!C      The switch Ext_sw can be used to control which boundary contours
!C      are used.
!C                      Ext_sw= 0  Inside Islands Only
!C                      Ext_sw= 1  Inside Islands and Outside Exterior
!C                      Ext_sw= 2  Outside Exterior Only
!C                      Ext_sw= 3  Inside Exterior and Outside Islands
!C                      Ext_sw= 4  Outside Islands Only
!C                      Ext_sw= 5  Inside Exterior Only
!C
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: min boundary radius into table")

DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Boundary$[256]
DIM Table$[256]
DIM Destination$[256]
DIM Format$[15]
DEG

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

A= GetDefault(WsPlacesAfter)
Format$= "decimal "&VAL$(A)


ActivateUndo
Start:!
Pick_loop:Stat=SetInputFormat("n4","")
Boundary_loop:!
Stat=SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR IN BOUNDARY")
IF (ExitScript(Destination$)) THEN Leave
Pocket_boundary= FindBoundary(Contour)
IF (NOT ValidDependency(Pocket_boundary)) THEN Start
Stat= EntityNameCheck(Pocket_boundary,Boundary$)
Stat= SetSelectedFlag(Pocket_boundary,WsTrue)
Stat= PlotEntity(Pocket_boundary)

stat= SetInputFormat("a1",",I,O,")
Stat=GetValue("  Inside or Outside ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="I" THEN
        Ext_sw= 3
ELSE
        Ext_sw= 1
END IF

Pick_entry:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK ENTRY POSITION")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Table1) THEN Pick_entry
T1= LastPickPara
Stat= EntityNameCheck(Table1,Table$)
R1=TableParaRow(Table1,T1)
C1=TableParaColumn(Table1,T1)

ActivateUndo
Stat= AdvanceUndoNumber("min bdy rad")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
RecordFunctionOn
Stat= RecordDescr("TABLE ENTRY: Minimum boundary radius")

V1= FreeParameter("Row",R1)
V2= FreeParameter("Column",C1)
V3= FreeParameter("Exterior sw",Ext_sw)
Stat= InsertIntoTable(Table$,MinBoundaryRadius(Boundary$,V3),Format$,V1,V2)
Stat= TableTextOrigin(Table$,V1,V2,WsRightCenter)

RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
Stat= SetSelectedFlag(Pocket_boundary,WsFalse)
Stat= PlotEntity(Table1)

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start


Leave:!
Stat= SetSelectedFlag(Pocket_boundary,WsFalse)
Stat= SetPickMask(WsPickAll)
stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
