File: SVMasterObjectImplB.mesa
Last edited by: Eric Bier on July 8, 1987 5:37:23 pm PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
Contents: Defines a simple set of objects which can be display with ray casting, line drawing, or shaded planar-surface approximation.
DIRECTORY
CoordSys, Imager, IO, PredefSweeps, Rope, SV2d, SV3d, SVAssembly, SVBasicTypes, SVBoundBox, SVBoundSphere, SVCastRays, SVDraw3d, SVFaces, SVMasterObject, SVModelTypes, SVObjectCast, SVPolygon2d, SVPolygon3d, SVScene, SVSceneTypes, SweepCast, SweepGeometry, TFI3d, TFO3d;
SVMasterObjectImplB:
CEDAR PROGRAM
IMPORTS CoordSys, IO, PredefSweeps, SVAssembly, SVBoundBox, SVBoundSphere, SVCastRays, SVDraw3d, SVMasterObject, SVPolygon2d, SVPolygon3d, SVScene, SweepCast, SweepGeometry, TFI3d, TFO3d
EXPORTS SVMasterObject =
BEGIN
OPEN SVSceneTypes;
GENERAL TYPES
BoundBox: TYPE = SVBasicTypes.BoundBox;
BoundHedron: TYPE = SVBasicTypes.BoundHedron;
Camera: TYPE = SVModelTypes.Camera;
Classification: TYPE = SVSceneTypes.Classification;
Composite: TYPE = SVSceneTypes.Composite;
Cone: TYPE = SVFaces.Cone;
ConeSurface: TYPE = REF ConeSurfaceObj;
ConeSurfaceObj: TYPE = SVObjectCast.ConeSurfaceObj;
CoordSystem: TYPE = SVModelTypes.CoordSystem;
Cylinder: TYPE = SVFaces.Cylinder;
DiskRing: TYPE = SVFaces.DiskRing;
DiskSurface: TYPE = REF DiskSurfaceObj;
DiskSurfaceObj: TYPE = SVObjectCast.DiskSurfaceObj;
LightSourceList: TYPE = SVModelTypes.LightSourceList;
LinearMesh: TYPE = REF LinearMeshRecord;
LinearMeshArray: TYPE = SweepGeometry.LinearMeshArray;
LinearMeshRecord: TYPE = SweepGeometry.LinearMeshRecord;
MasterObject: TYPE = SVSceneTypes.MasterObject;
MasterObjectClass: TYPE = SVSceneTypes.MasterObjectClass;
MasterObjectClassList: TYPE = SVSceneTypes.MasterObjectClassList;
MasterObjectClassObj: TYPE = SVSceneTypes.MasterObjectClassObj;
MasterObjectList: TYPE = SVSceneTypes.MasterObjectList;
Matrix4by4: TYPE = SV3d.Matrix4by4;
Path: TYPE = SV2d.Path;
PlanarSurface: TYPE = SVSceneTypes.PlanarSurface;
PlanarSurfaceList: TYPE = SVSceneTypes.PlanarSurfaceList;
Point2d: TYPE = SV2d.Point2d;
PointGenerator: TYPE = REF PointGeneratorObj;
PointGeneratorObj: TYPE = SVSceneTypes.PointGeneratorObj;
PointPairGenerator: TYPE = REF PointPairGeneratorObj;
PointPairGeneratorObj: TYPE = SVSceneTypes.PointPairGeneratorObj;
Poly3d: TYPE = SV3d.Poly3d;
Polygon: TYPE = SV2d.Polygon;
Primitive: TYPE = SVSceneTypes.Primitive;
Ray: TYPE = SVSceneTypes.Ray;
RectSurface: TYPE = REF RectSurfaceObj;
RectSurfaceObj: TYPE = SVObjectCast.RectSurfaceObj;
RevoFace: TYPE = SweepCast.RevoFace;
RevoluteMesh: TYPE = REF RevoluteMeshRecord;
RevoluteMeshArray: TYPE = SweepGeometry.RevoluteMeshArray;
RevoluteMeshRecord: TYPE = SweepGeometry.RevoluteMeshRecord;
Shape: TYPE = SVSceneTypes.Shape;
ShellSurface: TYPE = REF ShellSurfaceObj;
ShellSurfaceObj: TYPE = SVObjectCast.ShellSurfaceObj;
Slice: TYPE = SVSceneTypes.Slice;
SliceDescriptor: TYPE = SVSceneTypes.SliceDescriptor;
SubBoxesBody: TYPE = REF SubBoxesBodyObj;
SubBoxesBodyObj: TYPE = SweepCast.SubBoxesBodyObj;
SubSpheresBody: TYPE = REF SubSpheresBodyObj;
SubSpheresBodyObj: TYPE = SweepCast.SubSpheresBodyObj;
SurfaceArray: TYPE = REF SurfaceArrayObj;
SurfaceArrayObj: TYPE = SVSceneTypes.SurfaceArrayObj;
ToroidalMesh: TYPE = REF ToroidalMeshRecord;
ToroidalMeshRecord: TYPE = SweepGeometry.ToroidalMeshRecord;
ToroidalSurface: TYPE = REF ToroidalSurfaceObj;
ToroidalSurfaceObj: TYPE = SVObjectCast.ToroidalSurfaceObj;
TubeSurface: TYPE = REF TubeSurfaceObj;
TubeSurfaceObj: TYPE = SVObjectCast.TubeSurfaceObj;
GetHedronProc: TYPE = SVSceneTypes.GetHedronProc;
LineDrawProc: TYPE = SVSceneTypes.LineDrawProc;
NormalsDrawProc: TYPE = SVSceneTypes.NormalsDrawProc;
PreprocessProc: TYPE = SVSceneTypes.PreprocessProc;
RayCastProc: TYPE = SVSceneTypes.RayCastProc;
RayCastNoBBoxesProc: TYPE = SVSceneTypes.RayCastNoBBoxesProc;
RayCastBoundingSpheresProc: TYPE = SVSceneTypes.RayCastBoundingSpheresProc;
DrawPlanarSurfaceProc: TYPE = SVSceneTypes.DrawPlanarSurfaceProc;
DrawSubBoxesProc: TYPE = SVSceneTypes.DrawSubBoxesProc;
DrawSubSpheresProc: TYPE = SVSceneTypes.DrawSubSpheresProc;
FileinProc: TYPE = SVSceneTypes.FileinProc;
FileoutProc: TYPE = SVSceneTypes.FileoutProc;
FileoutPolyProc: TYPE = SVSceneTypes.FileoutPolyProc;
CountPlanarSurfacesProc: TYPE = SVSceneTypes.CountPlanarSurfacesProc;
GetPlanarSurfacesProc: TYPE = SVSceneTypes.GetPlanarSurfacesProc;
PointsInDescriptorProc: TYPE = SVSceneTypes.PointsInDescriptorProc;
NextPointProc: TYPE = SVSceneTypes.NextPointProc;
UpdateProc: TYPE = SVSceneTypes.UpdateProc;
GLOBAL VARIABLES
linClass, revoClass: MasterObjectClass;
LinSweepMakeMasterObject:
PUBLIC
PROC [name: Rope.
ROPE, linMesh: LinearMesh]
RETURNS [mo: MasterObject] = {
mainBody: REF ANY ← NIL;
lineBody: REF ANY ← linMesh;
shadeBody: REF ANY ← lineBody;
rayCastBody: REF ANY ← LinSweepGetRayCastBody[linMesh];
mo ← SVScene.CreateMasterObject[name, linClass, mainBody, lineBody, shadeBody, rayCastBody];
};
LinSweepUpdate:
PUBLIC
PROC [mo: MasterObject, updateData:
REF
ANY] = {
};
LinSweepBoundHedron:
PUBLIC
PROC [masterObject: MasterObject]
RETURNS [hedron: BoundHedron] = {
linMesh: LinearMesh ← NARROW[masterObject.lineBody];
vertCount: NAT ← 2*linMesh.len;
hedron ← SVBoundBox.CreateBoundHedron[vertCount];
FOR i: NAT IN[1..linMesh.len] DO
FOR j: NAT IN[1..2] DO
SVBoundBox.AddBoundHedronPoint[hedron, linMesh.array[i][j]];
ENDLOOP;
ENDLOOP;
};
LinSweepFaces: TYPE = SweepCast.LinSweepFaces;
LinSweepHint: TYPE = REF LinSweepHintObj;
LinSweepHintObj: TYPE = RECORD [linMesh: LinearMesh, faces: LinSweepFaces];
LinSweepGetRayCastBody:
PROC [linMesh: LinearMesh]
RETURNS [hint: LinSweepHint] = {
hint ← NEW[LinSweepHintObj];
hint.linMesh ← linMesh;
hint.faces ← SweepCast.MakeLinSweepFaces[linMesh];
};
GetLinSweepData:
PUBLIC
PROC
RETURNS [linMesh: LinearMesh] = {
linMesh ← PredefSweeps.GetUnitCube[];-- for now.
};
LinSweepRayCast:
PUBLIC
PROC [cameraPoint: Point2d, localRay: Ray, sliceD: SliceDescriptor, prim: Primitive]
RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: LinSweepHint ← NARROW[mo.rayCastBody];
class ← SweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces];
};
LinSweepRayCastNoBBoxes:
PUBLIC
PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive]
RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: LinSweepHint ← NARROW[mo.rayCastBody];
class ← SweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces];
};
LinSweepRayCastBoundingSpheres:
PUBLIC
PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive]
RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: LinSweepHint ← NARROW[mo.rayCastBody];
class ← SweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces];
};
LinSweepLineDraw:
PUBLIC
PROC[slice: Slice, dc: Imager.Context, camera: Camera] = {
localCS: CoordSystem ← slice.coordSys;
mo: MasterObject ← NARROW[slice.shape, Shape].mo;
linMesh: LinearMesh;
linMesh ← NARROW[mo.lineBody];
SweepGeometry.LineDrawLinearSweep[dc, linMesh, camera, localCS];
};
LinSweepDrawNormals:
PUBLIC
PROC[dc: Imager.Context, data:
REF
ANY, camera: Camera, localCS: CoordSystem] = {
linMesh: LinearMesh;
IF ISTYPE[data, LinearMesh]
THEN linMesh ← NARROW[data]
ELSE SIGNAL SVMasterObject.WrongTypeOfData;
SweepGeometry.DrawNormalsLinearSweep[dc, linMesh, camera, localCS];
};
LinSweepCountSurf:
PUBLIC
PROC [masterObject: MasterObject]
RETURNS [len:
NAT] = {
linMesh: LinearMesh ← NARROW[masterObject.shadeBody];
len ← SweepGeometry.CountPlanarSurfacesLinearSweep[linMesh];
};
LinSweepCountVert:
PUBLIC
PROC [masterObject: MasterObject]
RETURNS [len:
NAT] = {
linMesh: LinearMesh ← NARROW[masterObject.shadeBody];
len ← SweepGeometry.CountVerticesLinearSweep[linMesh];
};
LinSweepGetSurf:
PUBLIC
PROC [slice: Slice, camera: CoordSystem]
RETURNS [psl: PlanarSurfaceList] = {
shape: Shape ← NARROW[slice.shape];
masterObject: MasterObject ← shape.mo;
linMesh: LinearMesh ← NARROW[masterObject.shadeBody];
psl ← SweepGeometry.PlanarSurfacesLinearSweep[linMesh, slice, camera];
};
LinSweepDrawSurf:
PUBLIC
PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = {
SweepGeometry.DrawPlanarSurfaceLinearSweep[dc, ps, lightSources, camera];
};
LinearFileout:
PUBLIC
PROC [f:
IO.
STREAM, mo: MasterObject] = {
linMesh: LinearMesh ← NARROW[mo.lineBody];
lma: LinearMeshArray ← linMesh.array;
len: NAT ← linMesh.len;
f.PutF["name: %g\n",[rope[mo.name]]];
Assume that the defining contour has not been rotated. Output elements [i][1]
f.PutF["frontDepth: %g, backDepth: %g\n",[real[lma[1][1][3]]],[real[lma[1][2][3]]]];
f.PutF["DataPoints [%g]: ",[integer[len]]];
FOR i: NAT IN[1..len-1] DO
TFO3d.FileoutPoint3dAsPoint2d[f, lma[i][1]];
f.PutF[","];
ENDLOOP;
TFO3d.FileoutPoint3dAsPoint2d[f, lma[len][1]];
f.PutChar[IO.CR];
};
LinearFilein:
PUBLIC
PROC [f:
IO.
STREAM, name: Rope.
ROPE, version:
REAL]
RETURNS [mo: MasterObject] = {
count: NAT;
frontDepth, backDepth: REAL;
poly: Polygon;
instanceName: Rope.ROPE;
linMesh: LinearMesh;
TFI3d.ReadRope[f, "name:"];
instanceName ← TFI3d.ReadBlankAndWord[f];
TFI3d.ReadBlankAndRope[f, "frontDepth:"];
frontDepth ← TFI3d.ReadBlankAndReal[f];
TFI3d.ReadBlankAndRope[f, ","];
TFI3d.ReadBlankAndRope[f, "backDepth:"];
backDepth ← TFI3d.ReadBlankAndReal[f];
TFI3d.ReadBlankAndRope[f, "DataPoints ["];
count ← TFI3d.ReadNAT[f];
TFI3d.ReadBlankAndRope[f, "]:"];
TFI3d.ReadBlank[f];
poly ← SVPolygon2d.CreatePoly[count];
FOR i:
NAT
IN[1..count-1]
DO
poly ← SVPolygon2d.PutPolyPoint[poly, i-1, TFI3d.ReadPoint2d[f]];
TFI3d.ReadBlankAndRope[f, ","];
TFI3d.ReadBlank[f];
ENDLOOP;
poly ← SVPolygon2d.PutPolyPoint[poly, count-1, TFI3d.ReadPoint2d[f]];
TFI3d.ReadBlank[f];
linMesh ← SweepGeometry.LinearSweep[poly, frontDepth, backDepth];
mo ← LinSweepMakeMasterObject[name, linMesh];
};
LinearFileoutPoly:
PUBLIC
PROC [f:
IO.
STREAM, mo: MasterObject] = {
linMesh: LinearMesh ← NARROW[mo.shadeBody];
SweepGeometry.PolyListLinear[f, linMesh];
};
RevoSweepRec: TYPE = REF RevoSweepRecObj;
RevoSweepRecObj:
TYPE =
RECORD [
path: Path
];
RevoSweepMakeMasterObject:
PUBLIC
PROC [name: Rope.
ROPE, path: Path, long:
NAT]
RETURNS [mo: MasterObject] = {
mainBody: RevoSweepRec ← NEW[RevoSweepRecObj ← [path: path]];
lineBody: REF ANY;
shadeBody: REF ANY;
rayCastBody: REF ANY;
revMesh: RevoluteMesh;
revMesh ← SweepGeometry.RevoluteSweep[path, long];
lineBody ← revMesh;
shadeBody ← lineBody;
rayCastBody ← RevoSweepGetRayCastBody[revMesh];
mo ← SVScene.CreateMasterObject[name, revoClass, mainBody, lineBody, shadeBody, rayCastBody];
};
RevoSweepUpdate:
PUBLIC
PROC [mo: MasterObject, updateData:
REF
ANY] = {
revMesh: RevoluteMesh;
mainBody: RevoSweepRec ← NARROW[mo.mainBody];
path: Path ← mainBody.path;
revMesh ← SweepGeometry.RevoluteSweep[path, PredefSweeps.GetLinesOfLongitude[]];
mo.lineBody ← revMesh;
mo.shadeBody ← mo.lineBody;
mo.rayCastBody ← RevoSweepGetRayCastBody[revMesh];
};
RevoSweepBoundHedron:
PUBLIC
PROC [masterObject: MasterObject]
RETURNS [hedron: BoundHedron] = {
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
vertCount: NAT ← revMesh.linesOfLatitude*6;-- hexagons*6
hex: Poly3d;
hedron ← SVBoundBox.CreateBoundHedron[vertCount];
FOR i: NAT IN[1..revMesh.linesOfLatitude] DO
the radius at this line of latitude is revMesh.array[i][revMesh.linesOfLongitude][1];
hex ← SVPolygon3d.CircumHexagon[revMesh.array[i][1][2],
revMesh.array[i][revMesh.linesOfLongitude][1]];
SVBoundBox.AddBoundHedronPoly[hedron, hex];
ENDLOOP;
};
RevoSweepHint: TYPE = REF RevoSweepHintObj;
RevoSweepHintObj:
TYPE =
RECORD [
boxes: SubBoxesBody,
spheres: SubSpheresBody];
RevoSweepFaces: TYPE = SweepCast.RevoSweepFaces;
RevoSweepRayCastBody: TYPE = REF RevoSweepRayCastBodyObj;
RevoSweepRayCastBodyObj: TYPE = RECORD [faces: RevoSweepFaces];
RevoSweepGetRayCastBody:
PROC [revMesh: RevoluteMesh]
RETURNS [rayCastBody: RevoSweepRayCastBody] = {
rayCastBody ← NEW[RevoSweepRayCastBodyObj];
rayCastBody.faces ← SweepCast.MakeRevoSweepFaces[revMesh];
};
RevoSweepRayCast:
PUBLIC
PROC [cameraPoint: Point2d, localRay: Ray, sliceD: SliceDescriptor, prim: Primitive]
RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
revoHint: RevoSweepHint ← NARROW[prim.hints];
RETURN[SweepCast.RevoCast[cameraPoint, localRay, prim, rayCastBody.faces, revoHint.boxes]];
prim.hints is a set of bounding boxes
};
RevoSweepRayCastNoBBoxes:
PUBLIC
PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive]
RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
RETURN[SweepCast.RevoCastNoBBoxes[localRay, prim, rayCastBody.faces]];
};
RevoSweepRayCastBoundingSpheres:
PUBLIC
PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive]
RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
revoHint: RevoSweepHint ← NARROW[prim.hints];
RETURN[SweepCast.RevoCastBoundSpheres[localRay, prim, rayCastBody.faces, revoHint.spheres]];
};
RevoSweepPreprocess:
PUBLIC
PROC [prim: Primitive, camera: Camera] = {
revoSweepHint: RevoSweepHint ← NEW[RevoSweepHintObj];
mo: MasterObject ← NARROW[prim.mo];
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
faces: RevoSweepFaces ← rayCastBody.faces;
boxes: SubBoxesBody;
spheres: SubSpheresBody;
worldCS: CoordSystem ← CoordSys.Parent[camera.coordSys];
revoSweepHint.boxes ← NEW[SubBoxesBodyObj[faces.len]];
revoSweepHint.spheres ← NEW[SubSpheresBodyObj[faces.len]];
boxes ← revoSweepHint.boxes;
spheres ← revoSweepHint.spheres;
FOR i:
NAT
IN[0..faces.len)
DO
WITH faces[i]
SELECT
FROM
cone: Cone => {
boxes[i] ← SVBoundBox.BoundBoxFromBoundHedron[cone.boundHedron, camera, prim.localCS];
spheres[i] ← SVBoundSphere.BoundSphereFromBoundHedron[cone.boundHedron, worldCS, prim.localCS];
};
ring: DiskRing=> {
boxes[i] ← SVBoundBox.BoundBoxFromBoundHedron[ring.boundHedron, camera, prim.localCS];
spheres[i] ← SVBoundSphere.BoundSphereFromBoundHedron[ring.boundHedron, worldCS, prim.localCS];
};
cyl: Cylinder=> {
boxes[i] ← SVBoundBox.BoundBoxFromBoundHedron[cyl.boundHedron, camera, prim.localCS];
spheres[i] ← SVBoundSphere.BoundSphereFromBoundHedron[cyl.boundHedron, worldCS, prim.localCS];
};
ENDCASE => ERROR;
ENDLOOP;
spheres.len ← faces.len;
boxes.len ← faces.len;
prim.hints ← revoSweepHint;
};
RevoSweepLineDraw:
PUBLIC
PROC[slice: Slice, dc: Imager.Context, camera: Camera] = {
localCS: CoordSystem ← slice.coordSys;
mo: MasterObject ← NARROW[slice.shape, Shape].mo;
revMesh: RevoluteMesh;
revMesh ← NARROW[mo.lineBody];
SweepGeometry.LineDrawRevoluteSweep[dc, revMesh, camera, localCS];
};
RevoSweepDrawNormals:
PUBLIC
PROC[dc: Imager.Context, data:
REF
ANY, camera: Camera, localCS: CoordSystem] = {
revMesh: RevoluteMesh;
IF ISTYPE[data, RevoluteMesh]
THEN revMesh ← NARROW[data]
ELSE SIGNAL SVMasterObject.WrongTypeOfData;
SweepGeometry.DrawNormalsRevoluteSweep[dc, revMesh, camera, localCS];
};
RevoSweepCountSurf:
PUBLIC
PROC [masterObject: MasterObject]
RETURNS [len:
NAT] = {
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
len ← SweepGeometry.CountPlanarSurfacesRevoluteSweep[revMesh];
};
RevoSweepCountVert:
PUBLIC
PROC [masterObject: MasterObject]
RETURNS [len:
NAT] = {
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
len ← SweepGeometry.CountVerticesRevoluteSweep[revMesh];
};
RevoSweepGetSurf:
PUBLIC
PROC [slice: Slice, camera: CoordSystem]
RETURNS [psl: PlanarSurfaceList] = {
shape: Shape ← NARROW[slice.shape];
masterObject: MasterObject ← shape.mo;
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
psl ← SweepGeometry.PlanarSurfacesRevoluteSweep[revMesh, slice, camera];
};
RevoSweepDrawSurf:
PUBLIC
PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera] = {
SweepGeometry.DrawPlanarSurfaceRevoluteSweep[dc, ps, lightSources, camera];
};
RevoSweepDrawSubBoxes:
PUBLIC
PROC [dc: Imager.Context, prim: Primitive, screenCS: CoordSystem] = {
revoHint: RevoSweepHint ← NARROW[prim.hints];
boxes: SubBoxesBody ← revoHint.boxes;
FOR i:
NAT
IN [0..boxes.len)
DO
SVBoundBox.DrawBoundBox[dc, boxes[i], screenCS];
ENDLOOP;
};
RevoSweepDrawSubSpheres:
PUBLIC
PROC [dc: Imager.Context, prim: Primitive, camera: Camera] = {
revoHint: RevoSweepHint ← NARROW[prim.hints];
spheres: SubSpheresBody ← revoHint.spheres;
FOR i:
NAT
IN [0..spheres.len)
DO
SVBoundSphere.DrawBoundSphere[dc, spheres[i], camera];
ENDLOOP;
};
RevoluteFileout:
PUBLIC
PROC [f:
IO.
STREAM, mo: MasterObject] = {
rma: RevoluteMeshArray;
revMesh: RevoluteMesh ← NARROW[mo.lineBody];
lat, long: NAT;
rma ← revMesh.array;
lat ← revMesh.linesOfLatitude;
long ← revMesh.linesOfLongitude;
assume that the defining contour has not been rotated. Output the [i][long] points
f.PutF["lat: %g, long: %g\npoints [%g]:\n", -- TAB
[integer[lat]],[integer[long]],[integer[lat]]];
FOR i:
NAT
IN[1..lat-1]
DO
TFO3d.FileoutPoint3dAsPoint2d[f, rma[i][long]];
f.PutF[","];
IF (i/3)*3 = i THEN f.PutF["\n"]; -- CR TAB
ENDLOOP;
TFO3d.FileoutPoint3dAsPoint2d[f, rma[lat][long]];
f.PutChar[IO.CR];
};
RevoluteFilein:
PUBLIC
PROC [f:
IO.
STREAM, name: Rope.
ROPE, version:
REAL]
RETURNS [mo: MasterObject] = {
lat, long, count: NAT;
path: Path;
TFI3d.ReadBlankAndRope[f, "lat:"];
lat ← TFI3d.ReadBlankAndNAT[f];
TFI3d.ReadBlankAndRope[f, ","];
TFI3d.ReadBlankAndRope[f, "long:"];
long ← TFI3d.ReadBlankAndNAT[f];
TFI3d.ReadBlankAndRope[f, "points"];
TFI3d.ReadBlankAndRope[f, "["];
count ← TFI3d.ReadBlankAndNAT[f];
TFI3d.ReadBlankAndRope[f, "]:"];
TFI3d.ReadBlank[f];
path ← SVPolygon2d.CreatePath[count];
FOR i:
NAT
IN[1..count-1]
DO
SVPolygon2d.PutPathPoint[path, i-1, TFI3d.ReadPoint2d[f]];
TFI3d.ReadBlankAndRope[f, ","];
TFI3d.ReadBlank[f];
ENDLOOP;
SVPolygon2d.PutPathPoint[path, lat-1, TFI3d.ReadPoint2d[f]];
TFI3d.ReadBlank[f];
mo ← RevoSweepMakeMasterObject[name, path, long];
};
RevoluteFileoutPoly:
PUBLIC
PROC [f:
IO.
STREAM, mo: MasterObject] = {
revMesh: RevoluteMesh ← NARROW[mo.shadeBody];
SweepGeometry.PolyListRevolute[f, revMesh];
};
Noop Procedures
A master object can use these entries if it doesn't implement one of these procedures
Fundamentals
NoOpGetHedron: PUBLIC GetHedronProc = {RETURN[NIL]};
Drawing
NoOpLineDraw: PUBLIC LineDrawProc = {}; -- don't draw anything
NoOpNormalsDraw: PUBLIC NormalsDrawProc = {}; -- don't draw anything
NoOpPreprocess: PUBLIC PreprocessProc = {}; -- don't preprocess anything
NoOpRayCast:
PUBLIC RayCastProc = {
class ← SVCastRays.GetClassFromPool[];
SVCastRays.MakeClassAMiss[class];
};
NoOpRayCastNoBBoxes:
PUBLIC RayCastNoBBoxesProc = {
class ← SVCastRays.GetClassFromPool[];
SVCastRays.MakeClassAMiss[class];
};
NoOpRayCastBoundingSpheres:
PUBLIC RayCastBoundingSpheresProc = {
class ← SVCastRays.GetClassFromPool[];
SVCastRays.MakeClassAMiss[class];
};
NoOpDrawPlanarSurface: PUBLIC DrawPlanarSurfaceProc = {}; -- don't draw anything
NoOpDrawSubBoxes: PUBLIC DrawSubBoxesProc = {}; -- don't draw anything
NoOpDrawSubSpheres: PUBLIC DrawSubSpheresProc = {}; -- don't draw anything
NoOpDrawSelectionFeedback: PUBLIC DrawSelectionFeedbackProc = {};
NoOpDrawAttractorFeedback:
PUBLIC DrawAttractorFeedbackProc = {
slice: Slice ← sliceD.slice;
pointGen: SVSceneTypes.PointGenerator;
IF dragInProgress AND selectedParts # NIL THEN {}
ELSE {
pointGen ← SVAssembly.PointsInDescriptor[sliceD];
FOR pointAndDone: SVSceneTypes.PointAndDone ← SVAssembly.NextPoint[pointGen], SVAssembly.NextPoint[pointGen]
UNTIL pointAndDone.done
DO
SVDraw3d.DrawCP[dc, pointAndDone.point, camera];
ENDLOOP;
};
};
Textual Description
NoOpDescribe: PUBLIC DescribeProc = {}; -- say nothing
NoOpDescribeHit: PUBLIC DescribeHitProc = {}; -- say nothing
NoOpFilein: PUBLIC FileinProc = {};
NoOpFileout: PUBLIC FileoutProc = {};
NoOpFileoutPoly: PUBLIC FileoutPolyProc = {};
Parts
NoOpCountPlanarSurfaces: PUBLIC CountSurfProc = {RETURN[0]};
NoOpGetPlanarSurfaces: PUBLIC GetSurfProc = {RETURN[NIL]};
NoOpEmptyParts:
PUBLIC EmptyPartsProc = {
RETURN[TRUE];
};
NoOpNewParts:
PUBLIC NewPartsProc = {
PROC [slice: Slice, hitData: REF ANY, hitPoint: Point3d, mode: SelectMode] RETURNS [sliceD: SliceDescriptor];
sliceD ← SVAssembly.DescriptorFromParts[slice, NIL];
};
NoOpUnionParts:
PUBLIC UnionPartsProc = {
};
NoOpDifferenceParts:
PUBLIC DifferencePartsProc = {
};
NoOpMovingParts:
PUBLIC MovingPartsProc = {
};
NoOpAugmentParts:
PUBLIC AugmentPartsProc = {
};
Part Generators
NoOpPointsInDescriptor:
PUBLIC PointsInDescriptorProc = {
pointGen: PointGenerator;
pointGen ←
NEW[PointGeneratorObj ← [
sliceD: sliceD,
toGo: 0,
index: 0,
classSpecific: NIL
]];
RETURN[pointGen];
};
NoOpNextPoint:
PUBLIC NextPointProc = {
pointAndDone.done ← TRUE;
pointAndDone.point ← [0,0,0];
};
NoOpPointPairsInDescriptor:
PUBLIC PointPairsInDescriptorProc = {
pointPairGen: PointPairGenerator;
pointPairGen ←
NEW[PointPairGeneratorObj ← [
sliceD: sliceD,
toGo: 0,
index: 0,
classSpecific: NIL
]];
RETURN[pointPairGen];
};
NoOpNextPointPair:
PUBLIC NextPointPairProc = {
pointPairAndDone.done ← TRUE;
pointPairAndDone.lo ← [0,0,0];
pointPairAndDone.hi ← [0,0,0];
};
HitTest
NoOpClosestPointToPoint:
PUBLIC ClosestPointToPointProc = {
PROC [sliceD: SliceDescriptor, testPoint: Point3d, criticalR: REAL] RETURNS [bestDist: REAL, pointWORLD: Point3d, hitData: REF ANY, success: BOOL];
success ← FALSE;
};
NoOpClosestPointToLine:
PUBLIC ClosestPointToLineProc = {
PROC [sliceD: SliceDescriptor, cameraPoint: Point2d, line3d: Line3d, criticalR: REAL, camera: Camera] RETURNS [bestDist: REAL, pointWORLD: Point3d, hitData: REF ANY, success: BOOL];
success ← FALSE;
};
NoOpClosestSegmentToPoint:
PUBLIC ClosestSegmentToPointProc = {
PROC [sliceD: SliceDescriptor, testPoint: Point3d, criticalR: REAL] RETURNS [bestDist: REAL, pointWORLD: Point3d, hitData: REF ANY, success: BOOL];
success ← FALSE;
};
NoOpClosestSegmentToLine:
PUBLIC ClosestSegmentToLineProc = {
PROC [sliceD: SliceDescriptor, cameraPoint: Point2d, line3d: Line3d, criticalR: REAL, camera: Camera] RETURNS [bestDist: REAL, pointWORLD: Point3d, hitData: REF ANY, success: BOOL];
success ← FALSE;
};
Miscellaneous
NoOpUpdate:
PUBLIC UpdateProc = {
Don't update anything.
};
Init:
PROC = {
linClass ←
NEW[MasterObjectClassObj ← [
name: "linearSweep",
update: LinSweepUpdate,
filein: LinearFilein,
fileout: LinearFileout,
fileoutPoly: LinearFileoutPoly,
rayCast: LinSweepRayCast,
rayCastNoBBoxes: LinSweepRayCastNoBBoxes,
rayCastBoundingSpheres: LinSweepRayCastBoundingSpheres,
getHedron: LinSweepBoundHedron,
preprocess: NoOpPreprocess,
lineDraw: LinSweepLineDraw,
normalsDraw: LinSweepDrawNormals,
countSurf: LinSweepCountSurf,
getSurf: LinSweepGetSurf,
pointsInDescriptor: NoOpPointsInDescriptor,
nextPoint: NoOpNextPoint,
drawSurf: LinSweepDrawSurf,
drawSubBoxes: NoOpDrawSubBoxes,
drawSubSpheres: NoOpDrawSubSpheres]];
revoClass ←
NEW[MasterObjectClassObj ← [
name: "revoluteSweep",
update: RevoSweepUpdate,
filein: RevoluteFilein,
fileout: RevoluteFileout,
fileoutPoly: RevoluteFileoutPoly,
rayCast: RevoSweepRayCast,
rayCastNoBBoxes: RevoSweepRayCastNoBBoxes,
rayCastBoundingSpheres: RevoSweepRayCastBoundingSpheres,
getHedron: RevoSweepBoundHedron,
preprocess: RevoSweepPreprocess,
lineDraw: RevoSweepLineDraw,
normalsDraw: RevoSweepDrawNormals,
countSurf: RevoSweepCountSurf,
getSurf: RevoSweepGetSurf,
pointsInDescriptor: NoOpPointsInDescriptor,
nextPoint: NoOpNextPoint,
drawSurf: RevoSweepDrawSurf,
drawSubBoxes: RevoSweepDrawSubBoxes,
drawSubSpheres: RevoSweepDrawSubSpheres]];
SVMasterObject.RegisterMasterObjectClass[linClass];
SVMasterObject.RegisterMasterObjectClass[revoClass];
};
Init[];
END.