G3dGrid.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Glassner, February 18, 1991 3:48 pm PST
Jules Bloomenthal July 15, 1992 4:04 pm PDT
DIRECTORY G3dBasic, G3dShape, G3dBox;
G3dGrid: CEDAR DEFINITIONS
~ BEGIN
Imported Types
Box:     TYPE ~ G3dBox.Box;
Shape:    TYPE ~ G3dShape.Shape;
NatSequence:   TYPE ~ G3dBasic.NatSequence;
Triple:    TYPE ~ G3dBasic.Triple;
New Types
Object:     TYPE ~ REF ObjectRep;
ObjectRep:    TYPE ~ RECORD [
type:       ATOM ¬ $Unknown,
index:       NAT ¬ 0,
clientData:     REF ¬ NIL
];
CellData:      TYPE ~ REF CellDataRep;
CellDataRep:    TYPE ~ RECORD [
box:       Box ¬ [],
objects:      ObjectSequence ¬ NIL
];
Grid3d:     TYPE ~ REF Grid3dRep;
Grid3dRep:    TYPE ~ RECORD [
xRes, yRes, zRes:   NAT ¬ 0,
box:       Box ¬ [],
cellData:      CellDataSequence ¬ NIL
];
ObjectSequence:   TYPE ~ REF ObjectSequenceRep;
ObjectSequenceRep:  TYPE ~ RECORD [
length:      CARDINAL ¬ 0,
element:      SEQUENCE maxLength: CARDINAL OF Object
];
CellDataSequence:  TYPE ~ REF CellDataSequenceRep;
CellDataSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ¬ 0,
element:      SEQUENCE maxLength: CARDINAL OF CellData
];
TripleList:    TYPE ~ LIST OF Triple;
Callback Proc Types
GridProc: TYPE ~ PROC [cellData: CellData, client: REF ANY]
RETURNS [CellData];
Passes the data describing this cell, and replaces the grid data with the returned value
TestGridProc: TYPE ~ PROC [cellData: CellData, client: REF ANY]
RETURNS [continue: BOOL ¬ TRUE];
Passes the data describing this cell. If continue, the enumeration continues.
Creation Procs
CreateGrid: PROC [box: Box, xRes: NAT ¬ 8, yRes, zRes: NAT ¬ 0] RETURNS [Grid3d];
Create and return a new grid with the given resolution, in the given box. The grid is a rectangular array of equally-spaced cells, with the specified resolutions on each axis. If either yRes or zRes are not given or are given as 0, the value of xRes is used instead. A resolution of 0 on any axis is illegal. This is a primitive call; use CreateGridFromShape to build a grid from a shape.
CreateGridFromShape: PROC [shape: Shape, xRes: NAT ¬ 8, yRes, zRes: NAT ¬ 0] RETURNS [Grid3d];
Create a new grid, and add into it all the surfaces in the shape. See the comments for CreateGrid above for the last three arguments.
Polygon Insertion and Deletion Procs
InsertNatsIntoGrid: PROC [shape: Shape, grid: Grid3d, nats: NatSequence, surfID: INT, clientData: REF ¬ NIL];
Insert a polygon into the grid. The nats are vertex indices into the shape, the ID is the reference number of the polygon, and clientData will be stored with the surface.
InsertSurfaceIntoGrid: PUBLIC PROC [shape: Shape, grid: Grid3d, surfID: INT, clientData: REF ¬ NIL];
Convenience procedure to insert the identified surface into the grid.
InsertTripleListIntoGrid: PUBLIC PROC [vertices: TripleList, grid: Grid3d, surfID: INT, clientData: REF ¬ NIL];
Convenience procedure to insert the vertexList into the grid.
RemoveSurfaceFromGrid: PROC [grid: Grid3d, surfID: INT];
Delete all references to the polygon with this surface id from the grid.
Grid Visiting Procs
VisitGrid: PROC [grid: Grid3d, proc: GridProc, client: REF ANY ¬ NIL];
Call the client procedure for every cell in the grid. The value returned by the proc is stored as the new value for that cell.
TestGrid: PROC [grid: Grid3d, proc: TestGridProc, client: REF ANY ¬ NIL];
Call the client procedure for every cell in the grid. If the client proc returns FALSE, stop the enumeration. Cell contents are not changed.
Utility Procs
CopyGrid: PROC [grid: Grid3d] RETURNS [Grid3d];
Return a copy of the grid.
Auxiliary Procs
I don't think clients should ever need these. But heck, this is a new interface, so they're here in case I've forgotten something important. If you ever use one of these let me know, otherwise I'll elide them from the interface at some convenient future date (today is 14 Feb 91).
GridIndexFromXYZ: PROC [grid: Grid3d, x, y, z: INT] RETURNS [INT];
Return the index for this cell; -1 is returned if out of bounds.
Traditional support for ObjectSequences.
CopyObjectSequence: PROC [objects: ObjectSequence] RETURNS [ObjectSequence];
AddToObjectSequence: PROC [objects: ObjectSequence, object: Object] RETURNS [ObjectSequence];
LengthenObjectSequence: PROC [objects: ObjectSequence, amount: REAL ¬ 1.3] RETURNS [ObjectSequence];
Traditional support for CellDataSequences.
CopyCellDataSequence: PROC [cells: CellDataSequence] RETURNS [CellDataSequence];
AddToCellDataSequence: PROC [cells: CellDataSequence, cell: CellData] RETURNS [CellDataSequence];
LengthenCellDataSequence: PROC [cells: CellDataSequence, amount: REAL ¬ 1.3] RETURNS [CellDataSequence];
END.