/
ProxyCurve.ts
116 lines (112 loc) · 4.92 KB
/
ProxyCurve.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Curve
*/
import { CurvePrimitive } from "../curve/CurvePrimitive";
import type { GeometryHandler, IStrokeHandler } from "../geometry3d/GeometryHandler";
import type { Plane3dByOriginAndUnitNormal } from "../geometry3d/Plane3dByOriginAndUnitNormal";
import type { Plane3dByOriginAndVectors } from "../geometry3d/Plane3dByOriginAndVectors";
import type { Ray3d } from "../geometry3d/Ray3d";
import type { Transform } from "../geometry3d/Transform";
import type { Point3d, Vector3d } from "../geometry3d/Point3dVector3d";
import type { Range1d, Range3d } from "../geometry3d/Range";
import type { OffsetOptions } from "./OffsetOptions";
import type { LineString3d } from "./LineString3d";
import type { StrokeOptions } from "./StrokeOptions";
/**
* A ProxyCurve is expected to be used as a base class for curve types that use some existing curve (the proxy)
* for evaluation and display but carry other defining data.
* * The ProxyCurve implements all required CurvePrimitive methods by dispatching to the proxy.
* * These methods presumably require support from the application class and are left abstract:
* * clone
* * curvePrimitiveType
* * isSameCurvePrimitiveType
* * isSameGeometryClass
* * tryTransformInPlace
* * reverseInPlace
*
* @public
*/
export abstract class ProxyCurve extends CurvePrimitive {
public dispatchToGeometryHandler(handler: GeometryHandler) {
return this._proxyCurve.dispatchToGeometryHandler(handler);
}
protected _proxyCurve: CurvePrimitive;
/** Constructor CAPTURES the proxyCurve pointer */
public constructor(proxyCurve: CurvePrimitive) {
super();
this._proxyCurve = proxyCurve;
}
/** Return the (pointer to) the proxy curve. */
public get proxyCurve(): CurvePrimitive {
return this._proxyCurve;
}
/** Implement by proxyCurve */
public computeStrokeCountForOptions(options?: StrokeOptions): number {
return this._proxyCurve.computeStrokeCountForOptions(options);
}
/** Implement by proxyCurve */
public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {
this._proxyCurve.emitStrokableParts(dest, options);
}
/** Return a deep clone. This override removes the undefined variant return. */
public abstract override clone(): ProxyCurve;
/** Return a transformed clone. */
public override cloneTransformed(transform: Transform): ProxyCurve | undefined {
const myClone = this.clone();
if (myClone.tryTransformInPlace(transform))
return myClone;
return undefined;
}
/** Implement by proxyCurve. Subclasses may eventually override this default implementation. */
public override clonePartialCurve(fractionA: number, fractionB: number): CurvePrimitive | undefined {
return this._proxyCurve.clonePartialCurve(fractionA, fractionB);
}
/** Implement by proxyCurve */
public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {
this._proxyCurve.emitStrokes(dest, options);
}
/** Implement by proxyCurve */
public extendRange(rangeToExtend: Range3d, transform?: Transform): void {
this._proxyCurve.extendRange(rangeToExtend, transform);
}
/** Implement by proxyCurve */
public override range(transform?: Transform, result?: Range3d): Range3d {
return this._proxyCurve.range(transform, result);
}
/** Implement by proxyCurve */
public fractionToPoint(fraction: number, result?: Point3d): Point3d {
return this._proxyCurve.fractionToPoint(fraction, result);
}
/** Implement by proxyCurve */
public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {
return this._proxyCurve.fractionToPointAndDerivative(fraction, result);
}
/** Implement by proxyCurve */
public fractionToPointAnd2Derivatives(
fraction: number, result?: Plane3dByOriginAndVectors,
): Plane3dByOriginAndVectors | undefined {
return this._proxyCurve.fractionToPointAnd2Derivatives(fraction, result);
}
/** Implement by proxyCurve */
public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {
return this._proxyCurve.isInPlane(plane);
}
/** Implement by proxyCurve */
public quickLength(): number {
return this._proxyCurve.quickLength();
}
/** Implement by proxyCurve */
public override constructOffsetXY(
offsetDistanceOrOptions: number | OffsetOptions,
): CurvePrimitive | CurvePrimitive[] | undefined {
return this._proxyCurve.constructOffsetXY(offsetDistanceOrOptions);
}
/** Implement by proxyCurve */
public override projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {
return this._proxyCurve.projectedParameterRange(ray, lowHigh);
}
}