@equinor/esv-intersection 3.0.0 → 3.0.3

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.
@@ -75,7 +75,7 @@ export interface Trajectory {
75
75
  points: number[][];
76
76
  offset: number;
77
77
  }
78
- export declare type BoundingBox = {
78
+ export type BoundingBox = {
79
79
  x: number;
80
80
  y: number;
81
81
  width: number;
@@ -2,11 +2,11 @@ import { ScaleLinear } from 'd3-scale';
2
2
  import { CanvasLayer } from './base/CanvasLayer';
3
3
  import { OnUpdateEvent, Annotation, OnRescaleEvent, BoundingBox } from '../interfaces';
4
4
  import { LayerOptions } from './base/Layer';
5
- export declare type Point = {
5
+ export type Point = {
6
6
  x: number;
7
7
  y: number;
8
8
  };
9
- export declare type Callout = {
9
+ export type Callout = {
10
10
  title: string;
11
11
  label: string;
12
12
  color: string;
@@ -1,5 +1,5 @@
1
1
  import { Mesh, IPoint, Renderer, Texture } from 'pixi.js';
2
- export declare type ComplexRopeSegment = {
2
+ export type ComplexRopeSegment = {
3
3
  points: IPoint[];
4
4
  diameter: number;
5
5
  };
@@ -2,7 +2,7 @@ import { SurfaceData, SurfaceLine } from '../datautils';
2
2
  import { OnUpdateEvent, OnRescaleEvent } from '../interfaces';
3
3
  import { LayerOptions } from './base';
4
4
  import { CanvasLayer } from './base/CanvasLayer';
5
- declare type SurfacePaths = {
5
+ type SurfacePaths = {
6
6
  color: string;
7
7
  path: Path2D;
8
8
  };
@@ -10,7 +10,7 @@ export interface OnImageLayerUpdateEvent<T> extends OnUpdateEvent<T> {
10
10
  x?: number;
11
11
  y?: number;
12
12
  }
13
- export declare type OnImageLayerRescaleEvent<T> = OnImageLayerUpdateEvent<T> & OnRescaleEvent;
13
+ export type OnImageLayerRescaleEvent<T> = OnImageLayerUpdateEvent<T> & OnRescaleEvent;
14
14
  export declare class ImageLayer<T> extends CanvasLayer<T> {
15
15
  img: HTMLImageElement;
16
16
  onMount(event: OnMountEvent): void;
@@ -1,8 +1,8 @@
1
1
  import { CanvasLayer, LayerOptions } from './base';
2
2
  import { OnUpdateEvent, OnRescaleEvent, OnMountEvent } from '../interfaces';
3
3
  import { ScaleLinear } from 'd3-scale';
4
- export declare type ReferenceLineType = 'wavy' | 'dashed' | 'solid';
5
- export declare type ReferenceLine = {
4
+ export type ReferenceLineType = 'wavy' | 'dashed' | 'solid';
5
+ export type ReferenceLine = {
6
6
  text?: string;
7
7
  lineType: ReferenceLineType;
8
8
  color: string;
@@ -1,12 +1,12 @@
1
1
  import { CanvasLayer } from './base/CanvasLayer';
2
2
  import { OnUpdateEvent, OnMountEvent, OnRescaleEvent } from '../interfaces';
3
- export declare type SeismicCanvasDataOptions = {
3
+ export type SeismicCanvasDataOptions = {
4
4
  x: number;
5
5
  y: number;
6
6
  width: number;
7
7
  height: number;
8
8
  };
9
- export declare type SeismicCanvasData = {
9
+ export type SeismicCanvasData = {
10
10
  image: CanvasImageSource | OffscreenCanvas;
11
11
  options: SeismicCanvasDataOptions;
12
12
  };
@@ -2,7 +2,7 @@ export declare function assertNever(x: never): never;
2
2
  /**
3
3
  * The closure type of the outline
4
4
  */
5
- export declare type OutlineClosure = 'None' | 'TopAndBottom' | 'Top' | 'Bottom';
5
+ export type OutlineClosure = 'None' | 'TopAndBottom' | 'Top' | 'Bottom';
6
6
  export interface HoleSize {
7
7
  kind: 'hole';
8
8
  id: string;
@@ -58,7 +58,7 @@ export interface CementPlug {
58
58
  referenceIds: string[];
59
59
  }
60
60
  export declare const isCementPlug: (item: PAndA) => item is CementSqueeze;
61
- export declare type PAndA = PAndASymbol | CementSqueeze | CementPlug;
61
+ export type PAndA = PAndASymbol | CementSqueeze | CementPlug;
62
62
  interface BaseCompletion {
63
63
  id: string;
64
64
  diameter: number;
@@ -75,7 +75,7 @@ export interface CompletionSymbol extends BaseCompletion {
75
75
  kind: 'completionSymbol';
76
76
  symbolKey: string;
77
77
  }
78
- export declare type Completion = Tubing | Screen | CompletionSymbol;
78
+ export type Completion = Tubing | Screen | CompletionSymbol;
79
79
  export declare const foldCompletion: <T>(fScreen: (obj: Screen) => T, fTubing: (obj: Tubing) => T, fSymbol: (obj: CompletionSymbol) => T) => (completion: Completion) => T;
80
80
  export interface Cement {
81
81
  kind: 'cement';
@@ -89,7 +89,7 @@ export interface Cement {
89
89
  /**
90
90
  * 'Open hole' and 'Open hole screen' are not included as they are not visualized and also not included in the ruleset
91
91
  */
92
- export declare type PerforationSubKind = 'Perforation' | 'Open hole gravel pack' | 'Open hole frac pack' | 'Cased hole frac pack' | 'Cased hole gravel pack' | 'Cased hole fracturation';
92
+ export type PerforationSubKind = 'Perforation' | 'Open hole gravel pack' | 'Open hole frac pack' | 'Cased hole frac pack' | 'Cased hole gravel pack' | 'Cased hole fracturation';
93
93
  export interface Perforation {
94
94
  kind: 'perforation';
95
95
  subKind: PerforationSubKind;
@@ -118,6 +118,7 @@ export declare function isSubkindCasedHoleGravelPack(perf: Perforation): boolean
118
118
  export declare function isSubKindPerforation(perf: Perforation): boolean;
119
119
  export declare function isSubKindCasedHoleFracPack(perf: Perforation): boolean;
120
120
  export declare function isOpenHoleFracPack(perf: Perforation): boolean;
121
+ export declare const isSubKindCasedHoleFracturation: (perf: Perforation) => boolean;
121
122
  export declare const intersect: (a: Perforation, b: Perforation) => boolean;
122
123
  export interface SchematicData {
123
124
  holeSizes: HoleSize[];
@@ -1,5 +1,5 @@
1
- import { Vector } from 'curve-interpolator/dist/src/interfaces';
2
- declare type fx = (n: number) => Vector;
1
+ import { Vector } from 'curve-interpolator/dist/src/core/interfaces';
2
+ type fx = (n: number) => Vector;
3
3
  export declare class ArcLength {
4
4
  /**
5
5
  * Calculate using an adaptive bisect method
@@ -1,4 +1,4 @@
1
- declare type fx = (n: number) => number;
1
+ type fx = (n: number) => number;
2
2
  export declare class RootFinder {
3
3
  /**
4
4
  * Find root using newthons method
@@ -1,6 +1,6 @@
1
1
  import * as PIXI from 'pixi.js';
2
2
  /** Define the dash: [dash length, gap size, dash size, gap size, ...] */
3
- export declare type Dashes = number[];
3
+ export type Dashes = number[];
4
4
  export interface DashLineOptions {
5
5
  dash?: Dashes;
6
6
  width?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/esv-intersection",
3
- "version": "3.0.0",
3
+ "version": "3.0.3",
4
4
  "description": "Intersection component package with testing and automatic documentation.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -47,29 +47,29 @@
47
47
  },
48
48
  "homepage": "https://github.com/equinor/esv-intersection#readme",
49
49
  "devDependencies": {
50
- "@storybook/addon-storysource": "^7.0.0-beta.25",
51
- "@storybook/html-vite": "^7.0.0-beta.25",
50
+ "@storybook/addon-storysource": "^7.0.2",
51
+ "@storybook/html-vite": "^7.0.2",
52
52
  "@types/d3": "^7.4.0",
53
53
  "@types/mock-raf": "^1.0.3",
54
- "@typescript-eslint/eslint-plugin": "^5.48.1",
55
- "@typescript-eslint/parser": "^5.48.1",
54
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
55
+ "@typescript-eslint/parser": "^5.57.0",
56
56
  "copyfiles": "^2.4.1",
57
- "eslint": "^8.31.0",
58
- "eslint-config-prettier": "^8.6.0",
57
+ "eslint": "^8.37.0",
58
+ "eslint-config-prettier": "^8.8.0",
59
59
  "eslint-plugin-prettier": "^4.2.1",
60
- "eslint-plugin-storybook": "^0.6.10",
60
+ "eslint-plugin-storybook": "^0.6.11",
61
61
  "mock-raf": "^1.0.1",
62
- "pixi.js": "^7.1.0",
63
- "prettier": "^2.8.2",
64
- "rimraf": "^3.0.2",
65
- "storybook": "^7.0.0-beta.25",
66
- "storybook-dark-mode": "^2.0.5",
67
- "tslib": "^2.4.1",
68
- "typedoc": "^0.23.24",
69
- "typescript": "^4.9.4",
70
- "vite": "^4.0.4",
71
- "vite-plugin-dts": "^1.7.1",
72
- "vitest": "^0.27.1",
62
+ "pixi.js": "^7.2.3",
63
+ "prettier": "^2.8.7",
64
+ "rimraf": "^5.0.0",
65
+ "storybook": "^7.0.2",
66
+ "storybook-dark-mode": "^3.0.0",
67
+ "tslib": "^2.5.0",
68
+ "typedoc": "^0.24.1",
69
+ "typescript": "^5.0.2",
70
+ "vite": "^4.2.1",
71
+ "vite-plugin-dts": "^2.1.0",
72
+ "vitest": "^0.30.0",
73
73
  "vitest-canvas-mock": "^0.2.2"
74
74
  },
75
75
  "peerDependencies": {
@@ -78,13 +78,12 @@
78
78
  "dependencies": {
79
79
  "@equinor/videx-math": "^1.1.0",
80
80
  "@equinor/videx-vector2": "^1.0.44",
81
- "curve-interpolator": "3.0.1",
82
- "d3-array": "^3.2.1",
81
+ "curve-interpolator": "3.1.1",
82
+ "d3-array": "^3.2.3",
83
83
  "d3-axis": "^3.0.0",
84
84
  "d3-scale": "^4.0.2",
85
85
  "d3-selection": "^3.0.0",
86
86
  "d3-shape": "^3.2.0",
87
- "d3-zoom": "^3.0.0",
88
- "jest-canvas-mock": "^2.4.0"
87
+ "d3-zoom": "^3.0.0"
89
88
  }
90
89
  }
@@ -1,7 +1,7 @@
1
1
  import Vector2 from '@equinor/videx-vector2';
2
2
  import { clamp } from '@equinor/videx-math';
3
3
  import { CurveInterpolator } from 'curve-interpolator';
4
- import { Vector } from 'curve-interpolator/dist/src/interfaces';
4
+ import { Vector } from 'curve-interpolator/dist/src/core/interfaces';
5
5
  import { CurveInterpolatorOptions } from 'curve-interpolator/dist/src/curve-interpolator';
6
6
 
7
7
  import { RootFinder } from '../utils/root-finder';
@@ -195,7 +195,7 @@ export class IntersectionReferenceSystem {
195
195
  return length + (displacementFromStart - this.displacement);
196
196
  }
197
197
 
198
- const ls = this.interpolators.curtain.lookupPositions(displacementFromStart, 0, 1);
198
+ const ls = this.interpolators.curtain.getIntersectsAsPositions(displacementFromStart, 0, 1);
199
199
  if (ls && ls.length) {
200
200
  return ls[0] * length + this._offset;
201
201
  }
@@ -21,6 +21,7 @@ import {
21
21
  isSubKindCasedHoleFracPack,
22
22
  isSubkindCasedHoleGravelPack,
23
23
  PerforationSubKind,
24
+ isSubKindCasedHoleFracturation,
24
25
  } from '../layers/schematicInterfaces';
25
26
  import { ComplexRopeSegment } from '../layers/CustomDisplayObjects/ComplexRope';
26
27
  import { createNormals, offsetPoints } from '../utils/vectorUtils';
@@ -652,6 +653,8 @@ const drawFracLines = (
652
653
  const offsetX = 0;
653
654
  const offsetY = startAt === 'diameter' ? 0 : spikeLength;
654
655
 
656
+ ctx.globalAlpha = perforationOptions.packingOpacity;
657
+
655
658
  const fracLines = () => {
656
659
  for (let i = -1; i < amountOfSpikes; i++) {
657
660
  const bottom: [number, number] = [i * spikeWidth + offsetX + spikeWidth / 2, canvas.height / 2 - fracLineLength - offsetY - fracLineLength];
@@ -693,7 +696,6 @@ const drawFracLines = (
693
696
  ctx.strokeStyle = perforationOptions.yellow;
694
697
  ctx.lineWidth = 6;
695
698
  ctx.save();
696
- ctx.globalAlpha = perforationOptions.packingOpacity;
697
699
  fracLines();
698
700
  ctx.restore();
699
701
  ctx.lineWidth = 1;
@@ -709,7 +711,7 @@ const drawSpikes = (
709
711
  extendedPerfShapeDiameter: number,
710
712
  perforationOptions: PerforationOptions,
711
713
  ) => {
712
- const amountOfSpikes = 10;
714
+ const amountOfSpikes = 4;
713
715
  const spikeWidth = canvas.width / amountOfSpikes;
714
716
  ctx.strokeStyle = perforationOptions.outline;
715
717
 
@@ -717,11 +719,10 @@ const drawSpikes = (
717
719
 
718
720
  ctx.lineWidth = 1;
719
721
  const spikeLength = diameter / 2;
720
- const offsetX = 0;
721
722
 
722
723
  // left spikes
723
724
  for (let i = 0; i <= amountOfSpikes; i++) {
724
- const left: [number, number] = [i * spikeWidth + offsetX, canvas.height / 2 - diameter / 2];
725
+ const left: [number, number] = [i * spikeWidth, canvas.height / 2 - diameter / 2];
725
726
  const bottom: [number, number] = [left[0] - spikeWidth / 2, left[1] - spikeLength];
726
727
  const right: [number, number] = [left[0] - spikeWidth, left[1]];
727
728
 
@@ -737,7 +738,7 @@ const drawSpikes = (
737
738
 
738
739
  // right spikes
739
740
  for (let i = 0; i <= amountOfSpikes; i++) {
740
- const left: [number, number] = [i * spikeWidth + offsetX, canvas.height / 2 + diameter / 2];
741
+ const left: [number, number] = [i * spikeWidth, canvas.height / 2 + diameter / 2];
741
742
  const bottom: [number, number] = [left[0] - spikeWidth / 2, left[1] + spikeLength];
742
743
  const right: [number, number] = [left[0] - spikeWidth, left[1]];
743
744
 
@@ -806,6 +807,10 @@ const createPerforationTexture = (canvas: HTMLCanvasElement) => {
806
807
  return texture;
807
808
  };
808
809
 
810
+ const compareIntersectingPerforationsBy =
811
+ (targetPerf: Perforation, comparedPerforations: Perforation[]) => (compareFunc: (comparedPerf: Perforation) => boolean) =>
812
+ comparedPerforations.some((perf) => compareFunc(perf) && intersect(targetPerf, perf));
813
+
809
814
  /**
810
815
  * @Perforation
811
816
  * If a perforation does not overlap with another perforations of type with gravel,
@@ -821,6 +826,9 @@ const createPerforationTexture = (canvas: HTMLCanvasElement) => {
821
826
  *
822
827
  * Cased Hole Gravel Pack:
823
828
  * Yellow gravel. Makes perforations of type "Perforation" yellow if overlapping and perforation are open.
829
+ *
830
+ * Cased Hole Fracturation:
831
+ * Makes perforations of type "Perforation" yellow if overlapping and perforation are open.
824
832
  */
825
833
  const createSubkindPerforationTexture = {
826
834
  packing: () => errorTexture(),
@@ -833,32 +841,25 @@ const createSubkindPerforationTexture = {
833
841
  ): Texture => {
834
842
  const { canvas, ctx } = createPerforationCanvas(perfShape, perforationOptions);
835
843
 
836
- const intersectionsWithCasedHoleGravel: boolean = otherPerforations.some(
837
- (perf) => isSubkindCasedHoleGravelPack(perf) && intersect(perforation, perf),
838
- );
844
+ const compareBy = compareIntersectingPerforationsBy(perforation, otherPerforations);
839
845
 
840
- const intersectionsWithCasedHoleFracPack: boolean = otherPerforations.some(
841
- (perf) => isSubKindCasedHoleFracPack(perf) && intersect(perforation, perf),
842
- );
846
+ const intersectionsWithCasedHoleGravel: boolean = compareBy(isSubkindCasedHoleGravelPack);
843
847
 
844
- const shouldDrawFracLines = intersectionsWithCasedHoleGravel || intersectionsWithCasedHoleFracPack;
848
+ const intersectsWithCasedHoleFracturation: boolean = compareBy(isSubKindCasedHoleFracturation);
845
849
 
846
- if (shouldDrawFracLines) {
847
- if (perforation.isOpen) {
848
- ctx.fillStyle = perforationOptions.yellow;
849
- ctx.strokeStyle = perforationOptions.yellow;
850
- } else {
851
- ctx.fillStyle = perforationOptions.grey;
852
- ctx.strokeStyle = perforationOptions.grey;
853
- }
850
+ const intersectionsWithCasedHoleFracPack: boolean = compareBy(isSubKindCasedHoleFracPack);
851
+
852
+ const intersectsWithPerforation = intersectionsWithCasedHoleGravel || intersectsWithCasedHoleFracturation || intersectionsWithCasedHoleFracPack;
853
+
854
+ const openPerforationSpikeColor = intersectsWithPerforation ? perforationOptions.yellow : perforationOptions.red;
855
+
856
+ ctx.globalAlpha = perforationOptions.packingOpacity;
857
+ if (perforation.isOpen) {
858
+ ctx.fillStyle = openPerforationSpikeColor;
859
+ ctx.strokeStyle = openPerforationSpikeColor;
854
860
  } else {
855
- if (perforation.isOpen) {
856
- ctx.fillStyle = perforationOptions.red;
857
- ctx.strokeStyle = perforationOptions.red;
858
- } else {
859
- ctx.fillStyle = perforationOptions.grey;
860
- ctx.strokeStyle = perforationOptions.grey;
861
- }
861
+ ctx.fillStyle = perforationOptions.grey;
862
+ ctx.strokeStyle = perforationOptions.grey;
862
863
  }
863
864
 
864
865
  drawSpikes(canvas, ctx, perfShape.diameter, perforationOptions);
@@ -577,11 +577,11 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
577
577
  const [dx1, dx2] = xScale.domain();
578
578
  const [dy1, dy2] = yScale.domain();
579
579
 
580
- let top = referenceSystem.interpolators.curtain.lookup(dy1, 1, 0) as number[][];
580
+ let top = referenceSystem.interpolators.curtain.getIntersects(dy1, 1, 0) as number[][];
581
581
  if (top.length === 0) {
582
582
  top = [referenceSystem.interpolators.curtain.getPointAt(0.0) as number[]];
583
583
  }
584
- let bottom = referenceSystem.interpolators.curtain.lookup(dy2, 1, 0) as number[][];
584
+ let bottom = referenceSystem.interpolators.curtain.getIntersects(dy2, 1, 0) as number[][];
585
585
  if (bottom.length === 0) {
586
586
  bottom = [referenceSystem.interpolators.curtain.getPointAt(1.0) as number[]];
587
587
  }
@@ -452,7 +452,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
452
452
  });
453
453
  });
454
454
 
455
- fracLines.forEach((perforation) => {
455
+ spikes.forEach((perforation) => {
456
456
  const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
457
457
  const thiccPerfShapes = perfShapes.map((ps) => ({ ...ps, diameter: ps.diameter * 3 }));
458
458
  const perfShapesByDiameter: { [key: number]: ComplexRopeSegment[] } = thiccPerfShapes.reduce(
@@ -467,13 +467,14 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
467
467
  );
468
468
  Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
469
469
  perfShapesWithSameDiameter.forEach((perfShape) => {
470
- const texture = createPerforationFracLineTexture(perforation, perfShape, perforationOptions);
470
+ const texture = createPerforationSpikeTexture(perforation, perforations, perfShape, perforationOptions);
471
471
  const rope = this.drawComplexRope([perfShape], texture);
472
472
  this.perforationRopeAndTextureReferences.push({ rope, texture });
473
473
  });
474
474
  });
475
475
  });
476
- spikes.forEach((perforation) => {
476
+
477
+ fracLines.forEach((perforation) => {
477
478
  const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
478
479
  const thiccPerfShapes = perfShapes.map((ps) => ({ ...ps, diameter: ps.diameter * 3 }));
479
480
  const perfShapesByDiameter: { [key: number]: ComplexRopeSegment[] } = thiccPerfShapes.reduce(
@@ -488,7 +489,7 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
488
489
  );
489
490
  Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
490
491
  perfShapesWithSameDiameter.forEach((perfShape) => {
491
- const texture = createPerforationSpikeTexture(perforation, perforations, perfShape, perforationOptions);
492
+ const texture = createPerforationFracLineTexture(perforation, perfShape, perforationOptions);
492
493
  const rope = this.drawComplexRope([perfShape], texture);
493
494
  this.perforationRopeAndTextureReferences.push({ rope, texture });
494
495
  });
@@ -303,6 +303,8 @@ export function isOpenHoleFracPack(perf: Perforation) {
303
303
  );
304
304
  }
305
305
 
306
+ export const isSubKindCasedHoleFracturation = (perf: Perforation): boolean => perf.subKind === 'Cased hole fracturation';
307
+
306
308
  export const intersect = (a: Perforation, b: Perforation): boolean => {
307
309
  return a.start < b.end && a.end > b.start;
308
310
  };
@@ -405,7 +407,7 @@ export const defaultPerforationOptions: PerforationOptions = {
405
407
  transparent: 'rgba(255, 255, 255, 0)',
406
408
  spikeWidth: 50,
407
409
  spikeLength: 50,
408
- packingOpacity: 0.5,
410
+ packingOpacity: 0.7,
409
411
  fracLineCurve: 10,
410
412
  fracLineLength: 25,
411
413
  scalingFactor: 25,
@@ -1,5 +1,5 @@
1
1
  import Vector2 from '@equinor/videx-vector2';
2
- import { Vector } from 'curve-interpolator/dist/src/interfaces';
2
+ import { Vector } from 'curve-interpolator/dist/src/core/interfaces';
3
3
 
4
4
  type fx = (n: number) => Vector;
5
5