File: SVMasterObjectImplB.mesa
Last edited by: Eric Bier on September 1, 1987 7:00:08 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
SVCoordSys, GGParseIn, Imager, IO, SVPredefSweeps, Rope, SV2d, SV3d, SVAssembly, SVBasicTypes, SVBoundBox, SVBoundSphere, SVCastRays, SVDraw3d, SVFaces, SVMasterObject, SVModelTypes, SVObjectCast, SVPolygon2d, SVPolygon3d, SVScene, SVSceneTypes, SVSweepCast, SVSweepGeometry, SVParseIn, SVParseOut;
SVMasterObjectImplB: CEDAR PROGRAM
IMPORTS SVCoordSys, GGParseIn, IO, SVPredefSweeps, SVAssembly, SVBoundBox, SVBoundSphere, SVCastRays, SVDraw3d, SVMasterObject, SVPolygon2d, SVPolygon3d, SVScene, SVSweepCast, SVSweepGeometry, SVParseIn, SVParseOut
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 = SVSweepGeometry.LinearMeshArray;
LinearMeshRecord: TYPE = SVSweepGeometry.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 = SVSweepCast.RevoFace;
RevoluteMesh: TYPE = REF RevoluteMeshRecord;
RevoluteMeshArray: TYPE = SVSweepGeometry.RevoluteMeshArray;
RevoluteMeshRecord: TYPE = SVSweepGeometry.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 = SVSweepCast.SubBoxesBodyObj;
SubSpheresBody: TYPE = REF SubSpheresBodyObj;
SubSpheresBodyObj: TYPE = SVSweepCast.SubSpheresBodyObj;
SurfaceArray: TYPE = REF SurfaceArrayObj;
SurfaceArrayObj: TYPE = SVSceneTypes.SurfaceArrayObj;
ToroidalMesh: TYPE = REF ToroidalMeshRecord;
ToroidalMeshRecord: TYPE = SVSweepGeometry.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 ANYNIL;
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 = SVSweepCast.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 ← SVSweepCast.MakeLinSweepFaces[linMesh];
};
GetLinSweepData: PUBLIC PROC RETURNS [linMesh: LinearMesh] = {
linMesh ← SVPredefSweeps.GetUnitCube[];-- for now.
};
LinSweepRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, sliceD: SliceDescriptor, prim: Primitive, positiveTOnly: BOOLTRUE] RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: LinSweepHint ← NARROW[mo.rayCastBody];
class ← SVSweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces, positiveTOnly];
};
LinSweepRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive, positiveTOnly: BOOLTRUE] RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: LinSweepHint ← NARROW[mo.rayCastBody];
class ← SVSweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces, positiveTOnly];
};
LinSweepRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive, positiveTOnly: BOOLTRUE] RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: LinSweepHint ← NARROW[mo.rayCastBody];
class ← SVSweepCast.LinCast[localRay, prim, rayCastBody.linMesh, rayCastBody.faces, positiveTOnly];
};
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];
SVSweepGeometry.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;
SVSweepGeometry.DrawNormalsLinearSweep[dc, linMesh, camera, localCS];
};
LinSweepCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = {
linMesh: LinearMesh ← NARROW[masterObject.shadeBody];
len ← SVSweepGeometry.CountPlanarSurfacesLinearSweep[linMesh];
};
LinSweepCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = {
linMesh: LinearMesh ← NARROW[masterObject.shadeBody];
len ← SVSweepGeometry.CountVerticesLinearSweep[linMesh];
};
LinSweepGetSurf: PUBLIC PROC [slice: Slice, camera: CoordSystem, eyeWorld: Point3d] RETURNS [psl: PlanarSurfaceList] = {
shape: Shape ← NARROW[slice.shape];
masterObject: MasterObject ← shape.mo;
linMesh: LinearMesh ← NARROW[masterObject.shadeBody];
psl ← SVSweepGeometry.PlanarSurfacesLinearSweep[linMesh, slice, camera];
};
LinSweepDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera, eyeWorld: Point3d, hiddenLine: BOOL] = {
SVSweepGeometry.DrawPlanarSurfaceLinearSweep[dc, ps, lightSources, camera, hiddenLine];
};
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
SVParseOut.FileoutPoint3dAsPoint2d[f, lma[i][1]];
f.PutF[","];
ENDLOOP;
SVParseOut.FileoutPoint3dAsPoint2d[f, lma[len][1]];
f.PutChar[IO.CR];
};
LinearFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE, csList: CoordSysList, defaultCS: CoordSystem, wdir: Rope.ROPE, version: REAL, feedback: FeedbackData] RETURNS [mo: MasterObject] = {
count: NAT;
frontDepth, backDepth: REAL;
poly: Polygon;
instanceName: Rope.ROPE;
linMesh: LinearMesh;
GGParseIn.ReadWRope[f, "name:"];
instanceName ← GGParseIn.ReadWWord[f];
GGParseIn.ReadWRope[f, "frontDepth:"];
frontDepth ← GGParseIn.ReadWReal[f];
GGParseIn.ReadWRope[f, ","];
GGParseIn.ReadWRope[f, "backDepth:"];
backDepth ← GGParseIn.ReadWReal[f];
GGParseIn.ReadWRope[f, "DataPoints ["];
count ← GGParseIn.ReadWNAT[f];
GGParseIn.ReadWRope[f, "]:"];
GGParseIn.ReadBlank[f];
poly ← SVPolygon2d.CreatePoly[count];
FOR i: NAT IN[1..count-1] DO
poly ← SVPolygon2d.PutPolyPoint[poly, i-1, SVParseIn.ReadPoint2d[f]];
GGParseIn.ReadWRope[f, ","];
GGParseIn.ReadBlank[f];
ENDLOOP;
poly ← SVPolygon2d.PutPolyPoint[poly, count-1, SVParseIn.ReadPoint2d[f]];
GGParseIn.ReadBlank[f];
linMesh ← SVSweepGeometry.LinearSweep[poly, frontDepth, backDepth];
mo ← LinSweepMakeMasterObject[name, linMesh];
};
LinearFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = {
linMesh: LinearMesh ← NARROW[mo.shadeBody];
SVSweepGeometry.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 ← SVSweepGeometry.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 ← SVSweepGeometry.RevoluteSweep[path, SVPredefSweeps.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 = SVSweepCast.RevoSweepFaces;
RevoSweepRayCastBody: TYPE = REF RevoSweepRayCastBodyObj;
RevoSweepRayCastBodyObj: TYPE = RECORD [faces: RevoSweepFaces];
RevoSweepGetRayCastBody: PROC [revMesh: RevoluteMesh] RETURNS [rayCastBody: RevoSweepRayCastBody] = {
rayCastBody ← NEW[RevoSweepRayCastBodyObj];
rayCastBody.faces ← SVSweepCast.MakeRevoSweepFaces[revMesh];
};
RevoSweepRayCast: PUBLIC PROC [cameraPoint: Point2d, localRay: Ray, sliceD: SliceDescriptor, prim: Primitive, positiveTOnly: BOOLTRUE] RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
revoHint: RevoSweepHint ← NARROW[prim.hints];
RETURN[SVSweepCast.RevoCast[cameraPoint, localRay, prim, rayCastBody.faces, revoHint.boxes, positiveTOnly]];
prim.hints is a set of bounding boxes
};
RevoSweepRayCastNoBBoxes: PUBLIC PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive, positiveTOnly: BOOLTRUE] RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
RETURN[SVSweepCast.RevoCastNoBBoxes[localRay, prim, rayCastBody.faces, positiveTOnly]];
};
RevoSweepRayCastBoundingSpheres: PUBLIC PROC [localRay: Ray, sliceD: SliceDescriptor, prim: Primitive, positiveTOnly: BOOLTRUE] RETURNS [class: Classification] = {
mo: MasterObject ← prim.mo;
rayCastBody: RevoSweepRayCastBody ← NARROW[mo.rayCastBody];
revoHint: RevoSweepHint ← NARROW[prim.hints];
RETURN[SVSweepCast.RevoCastBoundSpheres[localRay, prim, rayCastBody.faces, revoHint.spheres, positiveTOnly]];
};
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 ← SVCoordSys.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];
SVSweepGeometry.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;
SVSweepGeometry.DrawNormalsRevoluteSweep[dc, revMesh, camera, localCS];
};
RevoSweepCountSurf: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = {
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
len ← SVSweepGeometry.CountPlanarSurfacesRevoluteSweep[revMesh];
};
RevoSweepCountVert: PUBLIC PROC [masterObject: MasterObject] RETURNS [len: NAT] = {
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
len ← SVSweepGeometry.CountVerticesRevoluteSweep[revMesh];
};
RevoSweepGetSurf: PUBLIC PROC [slice: Slice, camera: CoordSystem, eyeWorld: Point3d] RETURNS [psl: PlanarSurfaceList] = {
shape: Shape ← NARROW[slice.shape];
masterObject: MasterObject ← shape.mo;
revMesh: RevoluteMesh ← NARROW[masterObject.shadeBody];
psl ← SVSweepGeometry.PlanarSurfacesRevoluteSweep[revMesh, slice, camera];
};
RevoSweepDrawSurf: PUBLIC PROC [dc: Imager.Context, ps: PlanarSurface, lightSources: LightSourceList, camera: Camera, eyeWorld: Point3d, hiddenLine: BOOL] = {
SVSweepGeometry.DrawPlanarSurfaceRevoluteSweep[dc, ps, lightSources, camera, hiddenLine];
};
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
SVParseOut.FileoutPoint3dAsPoint2d[f, rma[i][long]];
f.PutF[","];
IF (i/3)*3 = i THEN f.PutF["\n"]; -- CR TAB
ENDLOOP;
SVParseOut.FileoutPoint3dAsPoint2d[f, rma[lat][long]];
f.PutChar[IO.CR];
};
RevoluteFilein: PUBLIC PROC [f: IO.STREAM, name: Rope.ROPE, csList: CoordSysList, defaultCS: CoordSystem, wdir: Rope.ROPE, version: REAL, feedback: FeedbackData] RETURNS [mo: MasterObject] = {
lat, long, count: NAT;
path: Path;
GGParseIn.ReadWRope[f, "lat:"];
lat ← GGParseIn.ReadWNAT[f];
GGParseIn.ReadWRope[f, ","];
GGParseIn.ReadWRope[f, "long:"];
long ← GGParseIn.ReadWNAT[f];
GGParseIn.ReadWRope[f, "points"];
GGParseIn.ReadWRope[f, "["];
count ← GGParseIn.ReadWNAT[f];
GGParseIn.ReadWRope[f, "]:"];
GGParseIn.ReadBlank[f];
path ← SVPolygon2d.CreatePath[count];
FOR i: NAT IN[1..count-1] DO
SVPolygon2d.PutPathPoint[path, i-1, SVParseIn.ReadPoint2d[f]];
GGParseIn.ReadWRope[f, ","];
GGParseIn.ReadBlank[f];
ENDLOOP;
SVPolygon2d.PutPathPoint[path, lat-1, SVParseIn.ReadPoint2d[f]];
GGParseIn.ReadBlank[f];
mo ← RevoSweepMakeMasterObject[name, path, long];
};
RevoluteFileoutPoly: PUBLIC PROC [f: IO.STREAM, mo: MasterObject] = {
revMesh: RevoluteMesh ← NARROW[mo.shadeBody];
SVSweepGeometry.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, FALSE];
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]};
NoOpIsEmptyParts: PUBLIC IsEmptyPartsProc = {
RETURN[TRUE];
};
NoOpIsCompleteParts: PUBLIC IsCompletePartsProc = {
RETURN[FALSE];
};
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,
centroids: FALSE,
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.
};
Style
NoOpSetStrokeColor: PUBLIC SetStrokeColorProc = {
};
NoOpGetStrokeColor: PUBLIC GetStrokeColorProc = {
};
NoOpSetFillColor: PUBLIC SetFillColorProc = {
};
NoOpGetFillColor: PUBLIC GetFillColorProc = {
};
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.