<> <> <> DIRECTORY CSG, GraphicsColor, Rope, SVBoundBox; CSGImpl: PROGRAM IMPORTS SVBoundBox EXPORTS CSG = BEGIN BoundBox: TYPE = REF BoundBoxObj; BoundBoxObj: TYPE = SVBoundBox.BoundBoxObj; Classification: TYPE = REF ClassificationObj; ClassificationObj: TYPE = CSG.ClassificationObj; Color: TYPE = GraphicsColor.Color; Primitive: TYPE = REF PrimitiveObj; PrimitiveObj: TYPE = CSG.PrimitiveObj; PointSetOp: TYPE = CSG.PointSetOp;-- {union, intersection, difference}; Composite: TYPE = REF CompositeObj; CompositeObj: TYPE = CSG.CompositeObj; CSGTree: TYPE = REF CSGTreeObj; CSGTreeObj: TYPE = CSG.CSGTreeObj; <> <> CopyClass: PUBLIC PROC [class: Classification] RETURNS [copy: Classification] = { copy _ NEW[ClassificationObj]; copy.count _ class.count; copy.params _ class.params; copy.surfaces _ class.surfaces; copy.primitives _ class.primitives; copy.classifs _ class.classifs; copy.normals _ class.normals; }; MakeCompositeCell: PUBLIC PROC [name: Rope.ROPE, operation: PointSetOp, LeftSolidPtr: REF ANY, RightSolidPtr: REF ANY] RETURNS [c: Composite] = { c _ NEW[CompositeObj _ [name, operation, LeftSolidPtr, RightSolidPtr]]; }; MakeCSGTree: PUBLIC PROC [son: REF ANY, backgroundColor: Color, shadows: BOOL] RETURNS [tree: CSGTree] = { name: Rope.ROPE; IF son = NIL THEN name _ "Empty Scene" ELSE { WITH son SELECT FROM prim: Primitive => name _ prim.name; comp: Composite => name _ comp.name; ENDCASE => ERROR; }; tree _ NEW[CSGTreeObj _ [name, son, backgroundColor, shadows]]; }; CombineBoundBoxes: PUBLIC PROC [bb1, bb2: BoundBox, op: PointSetOp] RETURNS [newBB: BoundBox] = { <> SELECT op FROM union => newBB _ SVBoundBox.UnionCombineBoundBoxes[bb1, bb2]; intersection => newBB _ SVBoundBox.IntersectionCombineBoundBoxes[bb1, bb2]; difference => newBB _ SVBoundBox.DifferenceCombineBoundBoxes[bb1, bb2]; ENDCASE => ERROR; }; END.