@equinor/esv-intersection 3.0.0-beta.5 → 3.0.0-beta.6

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.
@@ -38,12 +38,13 @@ import {
38
38
  defaultTubingOptions,
39
39
  defaultInternalLayerOptions,
40
40
  Perforation,
41
- getPerforationsThatStartAtHoleDiameter,
42
- getPerforationsThatSTartAtCasingDiameter,
43
41
  PerforationOptions,
44
42
  defaultPerforationOptions,
45
43
  Completion,
46
44
  OutlineClosure,
45
+ hasPacking,
46
+ hasFracLines,
47
+ hasSpikes,
47
48
  } from './schematicInterfaces';
48
49
  import {
49
50
  CasingRenderObject,
@@ -59,9 +60,11 @@ import {
59
60
  prepareCasingRenderObject,
60
61
  createCementPlugTexture,
61
62
  createComplexRopeSegmentsForPerforation,
62
- createPerforationTexture,
63
+ createPerforationPackingTexture,
63
64
  PerforationShape,
64
65
  createCementSqueezeTexture,
66
+ createPerforationFracLineTexture,
67
+ createPerforationSpikeTexture,
65
68
  } from '../datautils/schematicShapeGenerator';
66
69
  import { OnUpdateEvent, OnRescaleEvent, OnUnmountEvent } from '../interfaces';
67
70
  import { convertColor } from '../utils/color';
@@ -357,6 +360,8 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
357
360
  this.addChild(graphics);
358
361
  }
359
362
 
363
+ private perforationRopeAndTextureReferences: { rope: ComplexRope; texture: Texture }[] = [];
364
+
360
365
  public preRender(): void {
361
366
  if (!this.data || !this.referenceSystem) {
362
367
  return;
@@ -365,19 +370,6 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
365
370
  const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
366
371
  const { holeSizes, casings, cements, completion, symbols, pAndA, perforations } = this.data;
367
372
 
368
- const shouldStartAtHoleDiameter = getPerforationsThatStartAtHoleDiameter(perforations);
369
-
370
- const shouldStartAtCasingDiameter = getPerforationsThatSTartAtCasingDiameter(perforations);
371
-
372
- if (this.internalLayerVisibility.perforationLayerId) {
373
- shouldStartAtHoleDiameter.forEach((perforation) => {
374
- const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
375
- const otherPerforations = perforations.filter((p) => p.id !== perforation.id);
376
- const widestPerfShapeDiameter = perfShapes.reduce((widest, perfShape) => (perfShape.diameter > widest ? perfShape.diameter : widest), 0);
377
- this.drawComplexRope(perfShapes, this.createPerforationTexture(perforation, widestPerfShapeDiameter, otherPerforations));
378
- });
379
- }
380
-
381
373
  this.updateSymbolCache(symbols);
382
374
 
383
375
  holeSizes.sort((a: HoleSize, b: HoleSize) => b.diameter - a.diameter);
@@ -433,6 +425,84 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
433
425
  ),
434
426
  );
435
427
 
428
+ this.perforationRopeAndTextureReferences.forEach(({ rope, texture }) => {
429
+ rope.destroy({
430
+ children: true,
431
+ texture: true,
432
+ baseTexture: true,
433
+ });
434
+ texture.destroy(true);
435
+ });
436
+ this.perforationRopeAndTextureReferences = [];
437
+
438
+ if (this.internalLayerVisibility.perforationLayerId) {
439
+ const { perforationOptions } = this.options as SchematicLayerOptions<T>;
440
+ const packings = perforations.filter(hasPacking);
441
+ const fracLines = perforations.filter(hasFracLines);
442
+ const spikes = perforations.filter(hasSpikes);
443
+ packings.forEach((perforation) => {
444
+ const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
445
+ const perfShapesByDiameter: { [key: number]: ComplexRopeSegment[] } = perfShapes.reduce(
446
+ (dict: { [key: number]: ComplexRopeSegment[] }, ps) => {
447
+ if (!dict[ps.diameter]) {
448
+ dict[ps.diameter] = [];
449
+ }
450
+ dict[ps.diameter] = [...dict[ps.diameter], ps];
451
+ return dict;
452
+ },
453
+ {},
454
+ );
455
+ Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
456
+ const texture = createPerforationPackingTexture(perforation, perfShapesWithSameDiameter[0], perforationOptions);
457
+ const rope = this.drawComplexRope(perfShapesWithSameDiameter, texture);
458
+ this.perforationRopeAndTextureReferences.push({ rope, texture });
459
+ });
460
+ });
461
+
462
+ fracLines.forEach((perforation) => {
463
+ const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
464
+ const thiccPerfShapes = perfShapes.map((ps) => ({ ...ps, diameter: ps.diameter * 3 }));
465
+ const perfShapesByDiameter: { [key: number]: ComplexRopeSegment[] } = thiccPerfShapes.reduce(
466
+ (dict: { [key: number]: ComplexRopeSegment[] }, ps) => {
467
+ if (!dict[ps.diameter]) {
468
+ dict[ps.diameter] = [];
469
+ }
470
+ dict[ps.diameter] = [...dict[ps.diameter], ps];
471
+ return dict;
472
+ },
473
+ {},
474
+ );
475
+ Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
476
+ perfShapesWithSameDiameter.forEach((perfShape) => {
477
+ const texture = createPerforationFracLineTexture(perforation, perfShape, perforationOptions);
478
+ const rope = this.drawComplexRope([perfShape], texture);
479
+ this.perforationRopeAndTextureReferences.push({ rope, texture });
480
+ });
481
+ });
482
+ });
483
+ spikes.forEach((perforation) => {
484
+ const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
485
+ const thiccPerfShapes = perfShapes.map((ps) => ({ ...ps, diameter: ps.diameter * 3 }));
486
+ const perfShapesByDiameter: { [key: number]: ComplexRopeSegment[] } = thiccPerfShapes.reduce(
487
+ (dict: { [key: number]: ComplexRopeSegment[] }, ps) => {
488
+ if (!dict[ps.diameter]) {
489
+ dict[ps.diameter] = [];
490
+ }
491
+ dict[ps.diameter] = [...dict[ps.diameter], ps];
492
+ return dict;
493
+ },
494
+ {},
495
+ );
496
+ Object.values(perfShapesByDiameter).forEach((perfShapesWithSameDiameter) => {
497
+ perfShapesWithSameDiameter.forEach((perfShape) => {
498
+ const texture = createPerforationSpikeTexture(perforation, perforations, perfShape, perforationOptions);
499
+ const rope = this.drawComplexRope([perfShape], texture);
500
+ this.perforationRopeAndTextureReferences.push({ rope, texture });
501
+ });
502
+ });
503
+ });
504
+ }
505
+
436
506
  if (this.internalLayerVisibility.completionLayerId) {
437
507
  completion.forEach(
438
508
  foldCompletion(
@@ -457,15 +527,6 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
457
527
  }
458
528
  });
459
529
  }
460
-
461
- if (this.internalLayerVisibility.perforationLayerId) {
462
- shouldStartAtCasingDiameter.forEach((perforation) => {
463
- const perfShapes = this.createPerforationShape(perforation, casings, holeSizes);
464
- const otherPerforations = perforations.filter((p) => p.id !== perforation.id);
465
- const widestPerfShapeDiameter = perfShapes.reduce((widest, perfShape) => (perfShape.diameter > widest ? perfShape.diameter : widest), 0);
466
- this.drawComplexRope(perfShapes, this.createPerforationTexture(perforation, widestPerfShapeDiameter, otherPerforations));
467
- });
468
- }
469
530
  }
470
531
 
471
532
  private updateSymbolCache(symbols: { [key: string]: string }) {
@@ -524,11 +585,6 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
524
585
  return this.cementPlugTextureCache;
525
586
  }
526
587
 
527
- private createPerforationTexture(perforation: Perforation, widestPerfShapeDiameter: number, otherPerforations: Perforation[]): Texture {
528
- const { perforationOptions } = this.options as SchematicLayerOptions<T>;
529
- return createPerforationTexture(perforation, widestPerfShapeDiameter, otherPerforations, perforationOptions);
530
- }
531
-
532
588
  private prepareSymbolRenderObject = (component: CompletionSymbol | PAndASymbol): SymbolRenderObject => {
533
589
  const { exaggerationFactor } = this.options as SchematicLayerOptions<T>;
534
590
 
@@ -660,7 +716,16 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
660
716
  return result.filter((item) => item !== undefined).sort((a, b) => a.zIndex - b.zIndex);
661
717
  }
662
718
 
663
- private drawComplexRope(intervals: ComplexRopeSegment[], texture: Texture): void {
719
+ /**
720
+ *
721
+ * @param intervals
722
+ * @param texture
723
+ * optionally fetch the exaggerationFactor from a different options prop
724
+ * options.perforationOptions for example
725
+ * @param getExaggerationFactor
726
+ * @returns
727
+ */
728
+ private drawComplexRope(intervals: ComplexRopeSegment[], texture: Texture): ComplexRope {
664
729
  if (intervals.length === 0) {
665
730
  return null;
666
731
  }
@@ -669,6 +734,8 @@ export class SchematicLayer<T extends SchematicData> extends PixiLayer<T> {
669
734
  const rope = new ComplexRope(texture, intervals, exaggerationFactor);
670
735
 
671
736
  this.addChild(rope);
737
+
738
+ return rope;
672
739
  }
673
740
 
674
741
  private static getOutlineClosureType = (index: number, maxIndex: number): OutlineClosure => {
@@ -143,10 +143,6 @@ export interface Perforation {
143
143
  * is the perforation open or sealed?
144
144
  */
145
145
  isOpen: boolean;
146
- /**
147
- * Referenced Casing ids
148
- */
149
- referenceIds: string[];
150
146
  }
151
147
 
152
148
  export const foldPerforationSubKind = <T>(
@@ -184,41 +180,78 @@ export const foldPerforationSubKind = <T>(
184
180
  }
185
181
  };
186
182
 
187
- export const getPerforationsThatStartAtHoleDiameter = (perforations: Perforation[]) =>
188
- perforations.filter((perf) =>
189
- foldPerforationSubKind(
190
- {
191
- Perforation: () => true,
192
- OpenHoleGravelPack: () => true,
193
- OpenHoleFracPack: () => false,
194
- CasedHoleFracturation: () => false,
195
- CasedHoleGravelPack: () => false,
196
- CasedHoleFracPack: () => false,
197
- },
198
- perf.subKind,
199
- ),
183
+ export const shouldPerforationStartAtHoleDiameter = (perf: Perforation) =>
184
+ foldPerforationSubKind(
185
+ {
186
+ Perforation: () => true,
187
+ OpenHoleGravelPack: () => true,
188
+ OpenHoleFracPack: () => false,
189
+ CasedHoleFracturation: () => false,
190
+ CasedHoleGravelPack: () => false,
191
+ CasedHoleFracPack: () => false,
192
+ },
193
+ perf.subKind,
200
194
  );
201
195
 
202
- export const getPerforationsThatSTartAtCasingDiameter = (perforations: Perforation[]) =>
203
- perforations.filter((perf) =>
204
- foldPerforationSubKind(
205
- {
206
- Perforation: () => false,
207
- OpenHoleGravelPack: () => false,
208
- OpenHoleFracPack: () => true,
209
- CasedHoleFracturation: () => true,
210
- CasedHoleGravelPack: () => true,
211
- CasedHoleFracPack: () => true,
212
- },
213
- perf.subKind,
214
- ),
196
+ export const shouldPerforationStartAtCasingDiameter = (perf: Perforation) =>
197
+ foldPerforationSubKind(
198
+ {
199
+ Perforation: () => false,
200
+ OpenHoleGravelPack: () => false,
201
+ OpenHoleFracPack: () => true,
202
+ CasedHoleFracturation: () => true,
203
+ CasedHoleGravelPack: () => true,
204
+ CasedHoleFracPack: () => true,
205
+ },
206
+ perf.subKind,
215
207
  );
216
208
 
217
- export function hasGravelPack(perf: Perforation): boolean {
218
- return foldPerforationSubKind(
209
+ export const hasPacking = (perf: Perforation): boolean =>
210
+ foldPerforationSubKind(
219
211
  {
220
212
  Perforation: () => false,
221
213
  OpenHoleGravelPack: () => true,
214
+ OpenHoleFracPack: () => true,
215
+ CasedHoleFracturation: () => false,
216
+ CasedHoleGravelPack: () => true,
217
+ CasedHoleFracPack: () => true,
218
+ },
219
+ perf.subKind,
220
+ );
221
+
222
+ export function hasFracLines(perf: Perforation): boolean {
223
+ return foldPerforationSubKind(
224
+ {
225
+ Perforation: () => false,
226
+ OpenHoleGravelPack: () => false,
227
+ OpenHoleFracPack: () => true,
228
+ CasedHoleFracturation: () => true,
229
+ CasedHoleGravelPack: () => false,
230
+ CasedHoleFracPack: () => true,
231
+ },
232
+ perf.subKind,
233
+ );
234
+ }
235
+
236
+ export function hasSpikes(perf: Perforation): boolean {
237
+ return foldPerforationSubKind(
238
+ {
239
+ Perforation: () => true,
240
+ OpenHoleGravelPack: () => false,
241
+ OpenHoleFracPack: () => false,
242
+ CasedHoleFracturation: () => false,
243
+ CasedHoleGravelPack: () => false,
244
+ CasedHoleFracPack: () => false,
245
+ },
246
+ perf.subKind,
247
+ );
248
+ }
249
+
250
+ export function isSubkindCasedHoleGravelPack(perf: Perforation): boolean {
251
+ return foldPerforationSubKind(
252
+ {
253
+ Perforation: () => false,
254
+ OpenHoleGravelPack: () => false,
222
255
  OpenHoleFracPack: () => false,
223
256
  CasedHoleFracturation: () => false,
224
257
  CasedHoleGravelPack: () => true,
@@ -353,11 +386,13 @@ export interface PerforationOptions {
353
386
  yellow: string;
354
387
  grey: string;
355
388
  red: string;
389
+ outline: string;
356
390
  transparent: string;
357
391
  spikeWidth: number;
392
+ spikeLength: number;
358
393
  packingOpacity: number;
359
394
  fracLineLength: number;
360
- fracLineHalfWidth: number;
395
+ fracLineCurve: number;
361
396
  scalingFactor: number;
362
397
  }
363
398
 
@@ -366,12 +401,14 @@ export const defaultPerforationOptions: PerforationOptions = {
366
401
  yellow: '#FFFC00',
367
402
  grey: 'gray',
368
403
  red: '#FF5050',
404
+ outline: 'black',
369
405
  transparent: 'rgba(255, 255, 255, 0)',
370
- spikeWidth: 25,
406
+ spikeWidth: 50,
407
+ spikeLength: 50,
371
408
  packingOpacity: 0.5,
372
- fracLineHalfWidth: 10,
409
+ fracLineCurve: 10,
373
410
  fracLineLength: 25,
374
- scalingFactor: 4,
411
+ scalingFactor: 25,
375
412
  };
376
413
 
377
414
  export interface CementOptions {