GGMultiGravity.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Bier, January 26, 1987 3:35:30 pm PST
Contents: Performs hit testing similar to GGGravity. Instead of returning a single nearest feature, we return the N (or fewer) nearest features which are within a given tolerance distance from the test point. The algorithm used is described in [Cyan]<Gargoyle>Documentation>MultiGravity.tioga.
Pier, November 21, 1986 10:40:42 am PST
DIRECTORY
GGBasicTypes, GGInterfaceTypes;
GGMultiGravity: CEDAR DEFINITIONS =
BEGIN
Caret: TYPE = GGInterfaceTypes.Caret;
FeatureData: TYPE = GGInterfaceTypes.FeatureData;
GargoyleData: TYPE = GGInterfaceTypes.GargoyleData;
TriggerBag: TYPE = REF TriggerBagObj;
TriggerBagObj: TYPE = GGInterfaceTypes.TriggerBagObj;
ObjectBag: TYPE = REF ObjectBagObj;
ObjectBagObj: TYPE = GGInterfaceTypes.ObjectBagObj;
NearFeatures: TYPE = REF NearFeaturesObj;
NearFeaturesObj: TYPE = RECORD [
features: SEQUENCE len: NAT OF FeatureData];
NearPoints: TYPE = REF NearPointsObj;
NearPointsObj: TYPE = RECORD [
points: SEQUENCE len: NAT OF Point];
NearDistances: TYPE = REF NearDistancesObj;
NearDistancesObj: TYPE = RECORD [
distances: SEQUENCE len: NAT OF REAL];
Point: TYPE = GGBasicTypes.Point;
Map: PROC [testPoint: Point, criticalR: REAL, currentObjects: ObjectBag, activeObjects: TriggerBag, gargoyleData: GargoyleData, intersections: BOOL] RETURNS [resultPoint: Point, feature: FeatureData];
Dispatches to StrictDistance or InnerCircle as appropriate.
StrictDistance: PROC [testPoint: Point, criticalR: REAL, objectBag: ObjectBag, sceneBag: TriggerBag, gargoyleData: GargoyleData] RETURNS [resultPoint: Point, feature: FeatureData];
Calls MultiStrictDistance and picks a single "best" feature.
InnerCircle: PROC [testPoint: Point, criticalR: REAL, innerR: REAL, currentObjects: ObjectBag, activeObjects: TriggerBag, gargoyleData: GargoyleData, intersections: BOOL] RETURNS [resultPoint: Point, feature: FeatureData];
Calls MultiInnerCircle and picks a single "best" feature.
GoodCurve: TYPE = REF GoodCurveObj;
GoodCurveObj: TYPE = RECORD [
Fields Shared with GoodPoint
dist: REAL, -- the distance from point to testPoint
point: Point, -- the best point on this curve
featureData: FeatureData, -- this curve
hitData: REF ANY -- a description of this segment
];
GoodPointType: TYPE = {outline, slice, anchor, intersectionPoint, midpoint, none};
GoodPoint: TYPE = REF GoodPointObj;
GoodPointObj: TYPE = RECORD [
Fields Shared with GoodCurve
dist: REAL,
point: Point,
featureData: FeatureData, -- this point
hitData: REF ANY, -- a description of this point
Fields Describing the Point
type: GoodPointType ← none
];
NearPointsAndCurves: TYPE = REF NearPointsAndCurvesObj;
NearPointsAndCurvesObj: TYPE = RECORD [
things: SEQUENCE len: NAT OF REF ANY];
The REF ANY is either a GoodCurve or a GoodPoint
MultiMap: PUBLIC PROC [testPoint: Point, criticalR: REAL, currentObjects: ObjectBag, activeObjects: TriggerBag, gargoyleData: GargoyleData, intersections: BOOL] RETURNS [nearPointsAndCurves: NearPointsAndCurves, count: NAT];
Dispatches to MultiStrictDistance or MultiInnerCircle depending on the Gargoyle Gravity Type button in the user interface.
MultiStrictDistance: PROC [testPoint: Point, criticalR: REAL, currentObjects: ObjectBag, activeObjects: TriggerBag, gargoyleData: GargoyleData] RETURNS [nearPointsAndCurves: NearPointsAndCurves, count: NAT];
Returns up to n closest features, their closest points, and their distances from the testpoint. Features outside of the critical radius, criticalR, may or may not be included. The results will be located in features[0] .. features[count-1], points[0] .. points[count-1], and distances[0] .. distances[count-1].
MultiInnerCircle: PROC [testPoint: Point, criticalR: REAL, innerR: REAL, currentObjects: ObjectBag, activeObjects: TriggerBag, gargoyleData: GargoyleData, intersections: BOOL] RETURNS [nearPointsAndCurves: NearPointsAndCurves, count: NAT];
Returns up to n closest features, their closest points, and their distances from the testpoint. Features outside of the critical radius, criticalR, may or may not be included. The results will be located in features[0] .. features[count-1], points[0] .. points[count-1], and distances[0] .. distances[count-1]. If any points are within the critical radius criticalR, then only points (e.g. vertices, control points, and intersection points) will be mentioned. Otherwise, "features" will consist of a mixture of points and curves.
NewMultiGravityPool: PROC [] RETURNS [REF]; -- stored in GargoyleData; temporary storage pool used by GGMultiGravityImpl
END.