@equinor/esv-intersection 3.0.1 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2241 -1938
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +21 -22
- package/dist/components/axis.d.ts +0 -47
- package/dist/components/index.d.ts +0 -1
- package/dist/control/ExtendedCurveInterpolator.d.ts +0 -58
- package/dist/control/IntersectionReferenceSystem.d.ts +0 -96
- package/dist/control/LayerManager.d.ts +0 -76
- package/dist/control/MainController.d.ts +0 -154
- package/dist/control/ZoomPanHandler.d.ts +0 -158
- package/dist/control/index.d.ts +0 -5
- package/dist/control/interfaces.d.ts +0 -37
- package/dist/control/overlay.d.ts +0 -20
- package/dist/datautils/colortable.d.ts +0 -1
- package/dist/datautils/findsample.d.ts +0 -2
- package/dist/datautils/index.d.ts +0 -6
- package/dist/datautils/interfaces.d.ts +0 -63
- package/dist/datautils/picks.d.ts +0 -74
- package/dist/datautils/schematicShapeGenerator.d.ts +0 -59
- package/dist/datautils/seismicimage.d.ts +0 -45
- package/dist/datautils/surfacedata.d.ts +0 -10
- package/dist/datautils/trajectory.d.ts +0 -14
- package/dist/layers/CalloutCanvasLayer.d.ts +0 -60
- package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +0 -22
- package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts +0 -27
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +0 -20
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +0 -26
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +0 -17
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +0 -24
- package/dist/layers/GeomodelCanvasLayer.d.ts +0 -28
- package/dist/layers/GeomodelLabelsLayer.d.ts +0 -49
- package/dist/layers/GeomodelLayerV2.d.ts +0 -12
- package/dist/layers/GridLayer.d.ts +0 -29
- package/dist/layers/ImageCanvasLayer.d.ts +0 -20
- package/dist/layers/ReferenceLineLayer.d.ts +0 -29
- package/dist/layers/SchematicLayer.d.ts +0 -113
- package/dist/layers/SeismicCanvasLayer.d.ts +0 -18
- package/dist/layers/WellborePathLayer.d.ts +0 -17
- package/dist/layers/base/CanvasLayer.d.ts +0 -19
- package/dist/layers/base/HTMLLayer.d.ts +0 -13
- package/dist/layers/base/Layer.d.ts +0 -69
- package/dist/layers/base/PixiLayer.d.ts +0 -32
- package/dist/layers/base/SVGLayer.d.ts +0 -13
- package/dist/layers/base/index.d.ts +0 -5
- package/dist/layers/index.d.ts +0 -16
- package/dist/layers/schematicInterfaces.d.ts +0 -208
- package/dist/utils/arc-length.d.ts +0 -23
- package/dist/utils/binary-search.d.ts +0 -8
- package/dist/utils/color.d.ts +0 -5
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/root-finder.d.ts +0 -34
- package/dist/utils/text.d.ts +0 -14
- package/dist/utils/vectorUtils.d.ts +0 -15
- package/dist/vendor/pixi-dashed-line/index.d.ts +0 -57
- package/src/components/axis.ts +0 -247
- package/src/components/index.ts +0 -1
- package/src/control/ExtendedCurveInterpolator.ts +0 -155
- package/src/control/IntersectionReferenceSystem.ts +0 -391
- package/src/control/LayerManager.ts +0 -294
- package/src/control/MainController.ts +0 -296
- package/src/control/ZoomPanHandler.ts +0 -436
- package/src/control/index.ts +0 -5
- package/src/control/interfaces.ts +0 -42
- package/src/control/overlay.ts +0 -118
- package/src/datautils/colortable.ts +0 -14
- package/src/datautils/findsample.ts +0 -64
- package/src/datautils/index.ts +0 -6
- package/src/datautils/interfaces.ts +0 -68
- package/src/datautils/picks.ts +0 -328
- package/src/datautils/schematicShapeGenerator.ts +0 -1007
- package/src/datautils/seismicimage.ts +0 -180
- package/src/datautils/surfacedata.ts +0 -318
- package/src/datautils/trajectory.ts +0 -206
- package/src/layers/CalloutCanvasLayer.ts +0 -338
- package/src/layers/CustomDisplayObjects/ComplexRope.ts +0 -45
- package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +0 -190
- package/src/layers/CustomDisplayObjects/FixedWidthSimpleRope.ts +0 -41
- package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +0 -149
- package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +0 -39
- package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +0 -174
- package/src/layers/GeomodelCanvasLayer.ts +0 -176
- package/src/layers/GeomodelLabelsLayer.ts +0 -619
- package/src/layers/GeomodelLayerV2.ts +0 -110
- package/src/layers/GridLayer.ts +0 -145
- package/src/layers/ImageCanvasLayer.ts +0 -55
- package/src/layers/ReferenceLineLayer.ts +0 -185
- package/src/layers/SchematicLayer.ts +0 -871
- package/src/layers/SeismicCanvasLayer.ts +0 -46
- package/src/layers/WellborePathLayer.ts +0 -129
- package/src/layers/base/CanvasLayer.ts +0 -102
- package/src/layers/base/HTMLLayer.ts +0 -70
- package/src/layers/base/Layer.ts +0 -217
- package/src/layers/base/PixiLayer.ts +0 -190
- package/src/layers/base/SVGLayer.ts +0 -63
- package/src/layers/base/index.ts +0 -5
- package/src/layers/index.ts +0 -16
- package/src/layers/schematicInterfaces.ts +0 -470
- package/src/utils/arc-length.ts +0 -66
- package/src/utils/binary-search.ts +0 -26
- package/src/utils/color.ts +0 -22
- package/src/utils/index.ts +0 -1
- package/src/utils/root-finder.ts +0 -78
- package/src/utils/text.ts +0 -88
- package/src/utils/vectorUtils.ts +0 -67
- package/src/vendor/pixi-dashed-line/index.ts +0 -394
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
type fx = (n: number) => number;
|
|
2
|
-
export declare class RootFinder {
|
|
3
|
-
/**
|
|
4
|
-
* Find root using newthons method
|
|
5
|
-
* @param {Number} func f(x)
|
|
6
|
-
* @param {Number} precision Accuracy of result
|
|
7
|
-
* @param {Number} maxIterations Max number of iterations to use
|
|
8
|
-
* @param {Number} start Starting position
|
|
9
|
-
* @param {Number} minLimit Min limit of result
|
|
10
|
-
* @param {Number} maxLimit Max limit of result
|
|
11
|
-
*/
|
|
12
|
-
static newton(func: fx, precision?: number, maxIterations?: number, start?: number, minLimit?: number, maxLimit?: number): number;
|
|
13
|
-
/**
|
|
14
|
-
* Find root using bisect method
|
|
15
|
-
* @param {Number} func f(x)
|
|
16
|
-
* @param {Number} precision Accuracy of result
|
|
17
|
-
* @param {Number} maxIterations Max number of iterations to use
|
|
18
|
-
* @param {Number} start Starting position
|
|
19
|
-
* @param {Number} minLimit Min limit of result
|
|
20
|
-
* @param {Number} maxLimit Max limit of result
|
|
21
|
-
*/
|
|
22
|
-
static bisect(func: fx, precision?: number, maxIterations?: number, start?: number, minLimit?: number, maxLimit?: number): number;
|
|
23
|
-
/**
|
|
24
|
-
* Find root by trying available methods
|
|
25
|
-
* @param {Number} func f(x)
|
|
26
|
-
* @param {Number} precision Accuracy of result
|
|
27
|
-
* @param {Number} maxIterations Max number of iterations to use
|
|
28
|
-
* @param {Number} start Starting position
|
|
29
|
-
* @param {Number} minLimit Min limit of result
|
|
30
|
-
* @param {Number} maxLimit Max limit of result
|
|
31
|
-
*/
|
|
32
|
-
static findRoot(func: fx, precision?: number, maxIterations?: number, start?: number, minLimit?: number, maxLimit?: number): number;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
package/dist/utils/text.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BoundingBox } from '../interfaces';
|
|
2
|
-
import { ScaleLinear } from 'd3-scale';
|
|
3
|
-
export declare function pixelsPerUnit(x: ScaleLinear<number, number>): number;
|
|
4
|
-
export declare function calcSize(factor: number, min: number, max: number, x: ScaleLinear<number, number>): number;
|
|
5
|
-
export declare function isOverlappingHorizontally(r1: BoundingBox, r2: BoundingBox): boolean;
|
|
6
|
-
export declare function isOverlapping(r1: BoundingBox, r2: BoundingBox, horizontalPadding?: number, verticalPadding?: number): boolean;
|
|
7
|
-
export declare function getOverlap(r1: BoundingBox, r2: BoundingBox): {
|
|
8
|
-
dx: number;
|
|
9
|
-
dy: number;
|
|
10
|
-
};
|
|
11
|
-
export declare function getOverlapOffset(r1: BoundingBox, r2: BoundingBox, horizontalPadding?: number, verticalPadding?: number): {
|
|
12
|
-
dx: number;
|
|
13
|
-
dy: number;
|
|
14
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { IPoint, Point } from 'pixi.js';
|
|
2
|
-
import Vector2 from '@equinor/videx-vector2';
|
|
3
|
-
export declare const pointToVector: (p: IPoint) => Vector2;
|
|
4
|
-
export declare const pointToArray: (p: IPoint) => [number, number];
|
|
5
|
-
export declare const vectorToPoint: (v: Vector2) => Point;
|
|
6
|
-
export declare const vectorToArray: (v: Vector2) => [number, number];
|
|
7
|
-
export declare const arrayToPoint: (a: number[]) => Point;
|
|
8
|
-
export declare const arrayToVector: (a: number[]) => Vector2;
|
|
9
|
-
export declare const calcDist: (prev: [number, number], point: [number, number]) => number;
|
|
10
|
-
export declare const calcDistPoint: (prev: Point, point: Point) => number;
|
|
11
|
-
export declare const calcNormal: (p1: Point, p2: Point) => Point;
|
|
12
|
-
export declare const convertToUnitVector: (p: Point) => Point;
|
|
13
|
-
export declare const createNormals: (points: IPoint[]) => Vector2[];
|
|
14
|
-
export declare const offsetPoint: (point: IPoint, vector: Vector2, offset: number) => Point;
|
|
15
|
-
export declare const offsetPoints: (points: IPoint[], vectors: Vector2[], offset: number) => Point[];
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as PIXI from 'pixi.js';
|
|
2
|
-
/** Define the dash: [dash length, gap size, dash size, gap size, ...] */
|
|
3
|
-
export type Dashes = number[];
|
|
4
|
-
export interface DashLineOptions {
|
|
5
|
-
dash?: Dashes;
|
|
6
|
-
width?: number;
|
|
7
|
-
color?: number;
|
|
8
|
-
alpha?: number;
|
|
9
|
-
scale?: number;
|
|
10
|
-
useTexture?: boolean;
|
|
11
|
-
useDots?: boolean;
|
|
12
|
-
cap?: PIXI.LINE_CAP;
|
|
13
|
-
join?: PIXI.LINE_JOIN;
|
|
14
|
-
alignment?: number;
|
|
15
|
-
}
|
|
16
|
-
export declare class DashLine {
|
|
17
|
-
graphics: PIXI.Graphics;
|
|
18
|
-
/** current length of the line */
|
|
19
|
-
lineLength: number;
|
|
20
|
-
/** cursor location */
|
|
21
|
-
cursor: PIXI.Point;
|
|
22
|
-
/** desired scale of line */
|
|
23
|
-
scale: number;
|
|
24
|
-
private activeTexture;
|
|
25
|
-
private start;
|
|
26
|
-
private dashSize;
|
|
27
|
-
private dash;
|
|
28
|
-
private useTexture;
|
|
29
|
-
private options;
|
|
30
|
-
static dashTextureCache: Record<string, PIXI.Texture>;
|
|
31
|
-
/**
|
|
32
|
-
* Create a DashLine
|
|
33
|
-
* @param graphics
|
|
34
|
-
* @param [options]
|
|
35
|
-
* @param [options.useTexture=false] - use the texture based render (useful for very large or very small dashed lines)
|
|
36
|
-
* @param [options.dashes=[10,5] - an array holding the dash and gap (eg, [10, 5, 20, 5, ...])
|
|
37
|
-
* @param [options.width=1] - width of the dashed line
|
|
38
|
-
* @param [options.alpha=1] - alpha of the dashed line
|
|
39
|
-
* @param [options.color=0xffffff] - color of the dashed line
|
|
40
|
-
* @param [options.cap] - add a PIXI.LINE_CAP style to dashed lines (only works for useTexture: false)
|
|
41
|
-
* @param [options.join] - add a PIXI.LINE_JOIN style to the dashed lines (only works for useTexture: false)
|
|
42
|
-
* @param [options.alignment] - The alignment of any lines drawn (0.5 = middle, 1 = outer, 0 = inner)
|
|
43
|
-
*/
|
|
44
|
-
constructor(graphics: PIXI.Graphics, options?: DashLineOptions);
|
|
45
|
-
/** resets line style to enable dashed line (useful if lineStyle was changed on graphics element) */
|
|
46
|
-
setLineStyle(): void;
|
|
47
|
-
private static distance;
|
|
48
|
-
moveTo(x: number, y: number): this;
|
|
49
|
-
lineTo(x: number, y: number, closePath?: boolean): this;
|
|
50
|
-
closePath(): void;
|
|
51
|
-
drawCircle(x: number, y: number, radius: number, points?: number, matrix?: PIXI.Matrix): this;
|
|
52
|
-
drawEllipse(x: number, y: number, radiusX: number, radiusY: number, points?: number, matrix?: PIXI.Matrix): this;
|
|
53
|
-
drawPolygon(points: PIXI.Point[] | number[], matrix?: PIXI.Matrix): this;
|
|
54
|
-
drawRect(x: number, y: number, width: number, height: number, matrix?: PIXI.Matrix): this;
|
|
55
|
-
private adjustLineStyle;
|
|
56
|
-
private static getTexture;
|
|
57
|
-
}
|
package/src/components/axis.ts
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { axisRight, axisBottom } from 'd3-axis';
|
|
2
|
-
import { BaseType, Selection } from 'd3-selection';
|
|
3
|
-
import { ScaleLinear, scaleLinear } from 'd3-scale';
|
|
4
|
-
import { OnResizeEvent, OnRescaleEvent } from '../interfaces';
|
|
5
|
-
|
|
6
|
-
export type Options = {
|
|
7
|
-
offsetX: number;
|
|
8
|
-
offsetY: number;
|
|
9
|
-
visible: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export class Axis {
|
|
13
|
-
private mainGroup: Selection<SVGElement, unknown, null, undefined>;
|
|
14
|
-
private _scaleX: ScaleLinear<number, number>;
|
|
15
|
-
private _scaleY: ScaleLinear<number, number>;
|
|
16
|
-
private _showLabels = true;
|
|
17
|
-
private _labelXDesc: string;
|
|
18
|
-
private _labelYDesc: string;
|
|
19
|
-
private _unitOfMeasure: string;
|
|
20
|
-
private _offsetX: number = 0;
|
|
21
|
-
private _offsetY: number = 0;
|
|
22
|
-
private _flipX = false;
|
|
23
|
-
private _flipY = false;
|
|
24
|
-
private visible: boolean = true;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
mainGroup: Selection<SVGElement, unknown, null, undefined>,
|
|
28
|
-
showLabels = true,
|
|
29
|
-
labelXDesc: string,
|
|
30
|
-
labelYDesc: string,
|
|
31
|
-
unitOfMeasure: string,
|
|
32
|
-
options?: Options,
|
|
33
|
-
) {
|
|
34
|
-
this.mainGroup = mainGroup;
|
|
35
|
-
this._showLabels = showLabels;
|
|
36
|
-
this._labelXDesc = labelXDesc;
|
|
37
|
-
this._labelYDesc = labelYDesc;
|
|
38
|
-
this._unitOfMeasure = unitOfMeasure;
|
|
39
|
-
if (options && options.offsetX) {
|
|
40
|
-
this._offsetX = options.offsetX;
|
|
41
|
-
}
|
|
42
|
-
if (options && options.offsetX) {
|
|
43
|
-
this._offsetY = options.offsetY;
|
|
44
|
-
}
|
|
45
|
-
if (options && options.visible) {
|
|
46
|
-
this.visible = options.visible;
|
|
47
|
-
}
|
|
48
|
-
this.mainGroup.style('pointer-events', 'none');
|
|
49
|
-
|
|
50
|
-
this._scaleX = scaleLinear().domain([0, 1]).range([0, 1]);
|
|
51
|
-
this._scaleY = scaleLinear().domain([0, 1]).range([0, 1]);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private renderLabelx(): Selection<BaseType, unknown, null, undefined> {
|
|
55
|
-
const { _labelXDesc: labelXDesc, _unitOfMeasure: unitOfMeasure, _showLabels, _scaleX: scaleX } = this;
|
|
56
|
-
const [, width] = scaleX.range();
|
|
57
|
-
const gx = this.renderGx();
|
|
58
|
-
|
|
59
|
-
let labelx = gx.select('text.axis-labelx');
|
|
60
|
-
if (_showLabels) {
|
|
61
|
-
if (labelx.empty()) {
|
|
62
|
-
labelx = gx
|
|
63
|
-
.append('text')
|
|
64
|
-
.attr('class', 'axis-labelx')
|
|
65
|
-
.attr('fill', 'rgba(0,0,0,0.3)')
|
|
66
|
-
.style('text-anchor', 'middle')
|
|
67
|
-
.style('font-weight', '800')
|
|
68
|
-
.style('font-size', '10px')
|
|
69
|
-
.text(`${labelXDesc} (${unitOfMeasure})`);
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
labelx.remove();
|
|
73
|
-
}
|
|
74
|
-
labelx.attr('transform', `translate(${width / 2},-4)`);
|
|
75
|
-
return labelx;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private renderLabely(): Selection<BaseType, unknown, null, undefined> {
|
|
79
|
-
const { _labelYDesc: labelYDesc, _unitOfMeasure: unitOfMeasure, _showLabels, _scaleY } = this;
|
|
80
|
-
const [, height] = _scaleY.range();
|
|
81
|
-
const gy = this.renderGy();
|
|
82
|
-
|
|
83
|
-
let labely = gy.select('text.axis-labely');
|
|
84
|
-
if (_showLabels) {
|
|
85
|
-
if (labely.empty()) {
|
|
86
|
-
labely = gy
|
|
87
|
-
.append('text')
|
|
88
|
-
.attr('class', 'axis-labely')
|
|
89
|
-
.attr('fill', 'rgba(0,0,0,0.3)')
|
|
90
|
-
.style('text-anchor', 'middle')
|
|
91
|
-
.style('font-weight', '800')
|
|
92
|
-
.style('font-size', '10px')
|
|
93
|
-
.text(`${labelYDesc} (${unitOfMeasure})`);
|
|
94
|
-
}
|
|
95
|
-
labely.attr('transform', `translate(-10,${height / 2})rotate(90)`);
|
|
96
|
-
} else {
|
|
97
|
-
labely.remove();
|
|
98
|
-
}
|
|
99
|
-
return labely;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private renderGy(): Selection<BaseType, unknown, null, undefined> {
|
|
103
|
-
const { _scaleX, _scaleY } = this;
|
|
104
|
-
const yAxis = axisRight(_scaleY) as (selection: Selection<SVGSVGElement, unknown, null, undefined>) => void;
|
|
105
|
-
const [, width] = _scaleX.range();
|
|
106
|
-
const gy = this.createOrGet('y-axis');
|
|
107
|
-
gy.call(yAxis);
|
|
108
|
-
gy.attr('transform', `translate(${width},0)`);
|
|
109
|
-
|
|
110
|
-
return gy;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private renderGx(): Selection<BaseType, unknown, null, undefined> {
|
|
114
|
-
const { _scaleX, _scaleY } = this;
|
|
115
|
-
const xAxis = axisBottom(_scaleX) as (selection: Selection<SVGSVGElement, unknown, null, undefined>) => void;
|
|
116
|
-
const [, height] = _scaleY.range();
|
|
117
|
-
|
|
118
|
-
const gx = this.createOrGet('x-axis');
|
|
119
|
-
gx.attr('transform', `translate(0 ${height})`);
|
|
120
|
-
gx.call(xAxis);
|
|
121
|
-
return gx;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private createOrGet = (name: string): Selection<BaseType, unknown, null, undefined> => {
|
|
125
|
-
const { mainGroup } = this;
|
|
126
|
-
let res = mainGroup.select(`g.${name}`);
|
|
127
|
-
if (res.empty()) {
|
|
128
|
-
res = mainGroup.append('g').attr('class', name);
|
|
129
|
-
}
|
|
130
|
-
return res;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
render(): void {
|
|
134
|
-
this.renderLabelx();
|
|
135
|
-
this.renderLabely();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
onResize(event: OnResizeEvent): void {
|
|
139
|
-
this.mainGroup.attr('height', `${event.height}px`).attr('width', `${event.width}px`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
onRescale(event: OnRescaleEvent): void {
|
|
143
|
-
const { _scaleX, _scaleY, offsetX, offsetY } = this;
|
|
144
|
-
const { xScale, yScale } = event;
|
|
145
|
-
const xBounds = xScale.domain();
|
|
146
|
-
const yBounds = yScale.domain();
|
|
147
|
-
|
|
148
|
-
const xRange = xScale.range();
|
|
149
|
-
const yRange = yScale.range();
|
|
150
|
-
|
|
151
|
-
_scaleX.domain([xBounds[0] - offsetX, xBounds[1] - offsetX]).range(xRange);
|
|
152
|
-
_scaleY.domain([yBounds[0] - offsetY, yBounds[1] - offsetY]).range(yRange);
|
|
153
|
-
this.flipX(this._flipX);
|
|
154
|
-
this.flipY(this._flipY);
|
|
155
|
-
|
|
156
|
-
if (this.visible) {
|
|
157
|
-
this.render();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
show(): Axis {
|
|
162
|
-
this.visible = true;
|
|
163
|
-
this.mainGroup.attr('visibility', 'visible');
|
|
164
|
-
this.render();
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
hide(): Axis {
|
|
169
|
-
this.visible = false;
|
|
170
|
-
this.mainGroup.attr('visibility', 'hidden');
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
flipX(flipX: boolean): Axis {
|
|
175
|
-
this._flipX = flipX;
|
|
176
|
-
const domain = this._scaleX.domain();
|
|
177
|
-
const flip = flipX ? -1 : 1;
|
|
178
|
-
this._scaleX.domain([flip * domain[0], flip * domain[1]]);
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
flipY(flipY: boolean): Axis {
|
|
183
|
-
this._flipY = flipY;
|
|
184
|
-
const domain = this._scaleY.domain();
|
|
185
|
-
const flip = flipY ? -1 : 1;
|
|
186
|
-
this._scaleY.domain([flip * domain[0], flip * domain[1]]);
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
showLabels(): Axis {
|
|
191
|
-
this._showLabels = true;
|
|
192
|
-
this.render();
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
hideLabels(): Axis {
|
|
197
|
-
this._showLabels = false;
|
|
198
|
-
this.render();
|
|
199
|
-
return this;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
setLabelX(label: string): Axis {
|
|
203
|
-
this._labelXDesc = label;
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
setLabelY(label: string): Axis {
|
|
208
|
-
this._labelYDesc = label;
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
setUnitOfMeasure(uom: string): Axis {
|
|
213
|
-
this._unitOfMeasure = uom;
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
setLabels(labelX: string, labelY: string, unitOfMeasure: string): Axis {
|
|
218
|
-
this._labelXDesc = labelX;
|
|
219
|
-
this._labelYDesc = labelY;
|
|
220
|
-
this._unitOfMeasure = unitOfMeasure;
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
get offsetX(): number {
|
|
225
|
-
return this._offsetX;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
set offsetX(offset: number) {
|
|
229
|
-
this._offsetX = offset;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
get offsetY(): number {
|
|
233
|
-
return this._offsetY;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
set offsetY(offset: number) {
|
|
237
|
-
this._offsetY = offset;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
get scaleX(): ScaleLinear<number, number> {
|
|
241
|
-
return this._scaleX.copy();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
get scaleY(): ScaleLinear<number, number> {
|
|
245
|
-
return this._scaleY.copy();
|
|
246
|
-
}
|
|
247
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './axis';
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import Vector2 from '@equinor/videx-vector2';
|
|
2
|
-
import { clamp } from '@equinor/videx-math';
|
|
3
|
-
import { CurveInterpolator } from 'curve-interpolator';
|
|
4
|
-
import { Vector } from 'curve-interpolator/dist/src/interfaces';
|
|
5
|
-
import { CurveInterpolatorOptions } from 'curve-interpolator/dist/src/curve-interpolator';
|
|
6
|
-
|
|
7
|
-
import { RootFinder } from '../utils/root-finder';
|
|
8
|
-
import { ArcLength } from '../utils/arc-length';
|
|
9
|
-
import { BinarySearch } from '../utils/binary-search';
|
|
10
|
-
|
|
11
|
-
export class ExtendedCurveInterpolator extends CurveInterpolator {
|
|
12
|
-
arcLengthLookup: number[] = [];
|
|
13
|
-
|
|
14
|
-
constructor(points: Vector[], options?: CurveInterpolatorOptions) {
|
|
15
|
-
super(points, options);
|
|
16
|
-
this.findTForArcLength = this.findTForArcLength.bind(this);
|
|
17
|
-
this.findTByRootForArcLength = this.findTByRootForArcLength.bind(this);
|
|
18
|
-
this.findApproxTForArcLength = this.findApproxTForArcLength.bind(this);
|
|
19
|
-
this.findTQuickForArcLength = this.findTQuickForArcLength.bind(this);
|
|
20
|
-
this.generateArcLengthLookup = this.generateArcLengthLookup.bind(this);
|
|
21
|
-
this.getArcLength = this.getArcLength.bind(this);
|
|
22
|
-
this.getQuickArcLength = this.getQuickArcLength.bind(this);
|
|
23
|
-
this.getPointAtArcLength = this.getPointAtArcLength.bind(this);
|
|
24
|
-
this.getPointAt = this.getPointAt.bind(this);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Function which finds t value for arc length
|
|
29
|
-
* @param {Number} arcLength Target arc length
|
|
30
|
-
* @param {Number} tolerance Tolerance for result
|
|
31
|
-
* @param {Number} iterations Max number of iterations to use
|
|
32
|
-
*/
|
|
33
|
-
findTForArcLength(arcLength: number, options?: { approxT?: boolean; quickT?: boolean; normalizedLength?: number }): number {
|
|
34
|
-
// TODO: Ideally the CurveInterpolator should be able to provide t for curve length
|
|
35
|
-
let t;
|
|
36
|
-
if (options?.approxT) {
|
|
37
|
-
t = this.findApproxTForArcLength(arcLength, options?.normalizedLength);
|
|
38
|
-
} else if (options?.quickT) {
|
|
39
|
-
t = this.findTQuickForArcLength(arcLength);
|
|
40
|
-
} else {
|
|
41
|
-
t = this.findTByRootForArcLength(arcLength);
|
|
42
|
-
}
|
|
43
|
-
return t;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Function which finds t value for arc length by finding root
|
|
48
|
-
* @param {Number} arcLength Target arc length
|
|
49
|
-
* @param {Number} tolerance Tolerance for result
|
|
50
|
-
* @param {Number} iterations Max number of iterations to use
|
|
51
|
-
*/
|
|
52
|
-
findTByRootForArcLength(arcLength: number, tolerance = 0.01, iterations = 100): number {
|
|
53
|
-
if (arcLength <= 0) {
|
|
54
|
-
return 0.0;
|
|
55
|
-
}
|
|
56
|
-
if (arcLength >= this.length) {
|
|
57
|
-
return 1.0;
|
|
58
|
-
}
|
|
59
|
-
const t = RootFinder.findRoot((x) => arcLength - this.getQuickArcLength(0, x), tolerance, iterations, arcLength / this.length);
|
|
60
|
-
return t;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Function which finds t value for arc length by simple approximation
|
|
65
|
-
* @param {Number} arcLength Target arclength
|
|
66
|
-
*/
|
|
67
|
-
findApproxTForArcLength(arcLength: number, normalizedLength?: number): number {
|
|
68
|
-
const t = arcLength / (normalizedLength || this.length);
|
|
69
|
-
return t;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Function which finds t value for arc length using lookup table
|
|
74
|
-
* @param {Number} arcLength Target arclength
|
|
75
|
-
*/
|
|
76
|
-
findTQuickForArcLength(arcLength: number): number {
|
|
77
|
-
if (this.arcLengthLookup.length === 0) {
|
|
78
|
-
this.generateArcLengthLookup();
|
|
79
|
-
}
|
|
80
|
-
const index = BinarySearch.search(this.arcLengthLookup, arcLength);
|
|
81
|
-
const v1 = this.arcLengthLookup[index];
|
|
82
|
-
const v2 = this.arcLengthLookup[index + 1];
|
|
83
|
-
const t = (index + (arcLength - v1) / (v2 - v1)) / this.arcLengthLookup.length;
|
|
84
|
-
return t;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
generateArcLengthLookup(segments: number = 1000): void {
|
|
88
|
-
let lastPos = this.getPointAt(0);
|
|
89
|
-
let length = 0;
|
|
90
|
-
for (let i = 0; i < segments; i++) {
|
|
91
|
-
const pos = this.getPointAt(i / (segments - 1));
|
|
92
|
-
const delta = Vector2.distance(lastPos as number[], pos as number[]);
|
|
93
|
-
length += delta;
|
|
94
|
-
this.arcLengthLookup.push(length);
|
|
95
|
-
lastPos = pos;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Function calculating length along curve using interpolator.
|
|
101
|
-
* @param {Number} from t at start (default = 0)
|
|
102
|
-
* @param {Number} to t at end (default = 1)
|
|
103
|
-
*/
|
|
104
|
-
getArcLength(from = 0, to = 1): number {
|
|
105
|
-
if (from === 0 && to === 1) {
|
|
106
|
-
return this.length;
|
|
107
|
-
}
|
|
108
|
-
const tolerance = 0.002;
|
|
109
|
-
return ArcLength.bisect((t: number) => this.getPointAt(t), from, to, tolerance);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Function calculating length along curve using interpolator.
|
|
114
|
-
* @param {Number} from t at start (default = 0)
|
|
115
|
-
* @param {Number} to t at end (default = 1)
|
|
116
|
-
*/
|
|
117
|
-
getQuickArcLength(from = 0, to = 1): number {
|
|
118
|
-
let fromLength = 0;
|
|
119
|
-
let toLength = this.length;
|
|
120
|
-
if (this.arcLengthLookup.length === 0) {
|
|
121
|
-
this.generateArcLengthLookup();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (from !== 0) {
|
|
125
|
-
const fromIndex = Math.floor(from * this.arcLengthLookup.length);
|
|
126
|
-
const fromLl = this.arcLengthLookup[fromIndex];
|
|
127
|
-
const fromLh = this.arcLengthLookup[fromIndex + 1];
|
|
128
|
-
fromLength = fromLl + ((from * this.arcLengthLookup.length) % this.arcLengthLookup.length) * (fromLh - fromLl);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (to !== 1) {
|
|
132
|
-
const toIndex = Math.floor(to * this.arcLengthLookup.length);
|
|
133
|
-
const toLl = this.arcLengthLookup[toIndex];
|
|
134
|
-
const toLh = this.arcLengthLookup[toIndex + 1];
|
|
135
|
-
toLength = toLl + ((from * this.arcLengthLookup.length) % this.arcLengthLookup.length) * (toLh - toLl);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const totalLength = toLength - fromLength;
|
|
139
|
-
return totalLength;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Function getting a point at curve length.
|
|
144
|
-
* @param {Number} arcLength
|
|
145
|
-
*/
|
|
146
|
-
getPointAtArcLength(arcLength: number, options?: { approxT?: boolean; quickT?: boolean; normalizedLength?: number }): Vector {
|
|
147
|
-
const t = this.findTForArcLength(arcLength, options);
|
|
148
|
-
return this.getPointAt(t);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getPointAt(t: number): Vector {
|
|
152
|
-
const tl = clamp(t, 0, 1);
|
|
153
|
-
return super.getPointAt(tl);
|
|
154
|
-
}
|
|
155
|
-
}
|