dgeoutils 2.3.7 → 2.4.2

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.
Files changed (39) hide show
  1. package/dist/{cjs/DCircle.d.ts → DCircle.d.ts} +0 -0
  2. package/dist/{es2015/DCircle.js → DCircle.js} +18 -14
  3. package/dist/{cjs/DLine.d.ts → DLine.d.ts} +0 -0
  4. package/dist/{es2015/DLine.js → DLine.js} +28 -24
  5. package/dist/{cjs/DNumbers.d.ts → DNumbers.d.ts} +0 -0
  6. package/dist/DNumbers.js +26 -0
  7. package/dist/{cjs/DPlane.d.ts → DPlane.d.ts} +0 -0
  8. package/dist/{es2015/DPlane.js → DPlane.js} +26 -22
  9. package/dist/{cjs/DPoint.d.ts → DPoint.d.ts} +0 -0
  10. package/dist/{es2015/DPoint.js → DPoint.js} +56 -52
  11. package/dist/{cjs/DPolygon.d.ts → DPolygon.d.ts} +1 -1
  12. package/dist/{es2015/DPolygon.js → DPolygon.js} +50 -42
  13. package/dist/{cjs/DPolygonLoop.d.ts → DPolygonLoop.d.ts} +0 -0
  14. package/dist/{es2015/DPolygonLoop.js → DPolygonLoop.js} +5 -1
  15. package/dist/{cjs/FastSearch.d.ts → FastSearch.d.ts} +0 -0
  16. package/dist/{es2015/FastSearch.js → FastSearch.js} +5 -1
  17. package/dist/{cjs/TraceMatrix.d.ts → TraceMatrix.d.ts} +0 -0
  18. package/dist/{es2015/TraceMatrix.js → TraceMatrix.js} +39 -35
  19. package/dist/esm/DPolygon.js +6 -1
  20. package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  21. package/dist/{cjs/index.js → index.js} +0 -0
  22. package/dist/umd/dgeoutils.js +7 -2
  23. package/dist/umd/dgeoutils.min.js +1 -1
  24. package/dist/umd/dgeoutils.min.js.map +1 -1
  25. package/dist/{cjs/utils.d.ts → utils.d.ts} +0 -0
  26. package/dist/{es2015/utils.js → utils.js} +41 -29
  27. package/package.json +5 -6
  28. package/dist/cjs/DCircle.js +0 -102
  29. package/dist/cjs/DLine.js +0 -310
  30. package/dist/cjs/DNumbers.js +0 -30
  31. package/dist/cjs/DPlane.js +0 -132
  32. package/dist/cjs/DPoint.js +0 -574
  33. package/dist/cjs/DPolygon.js +0 -1555
  34. package/dist/cjs/DPolygonLoop.js +0 -401
  35. package/dist/cjs/FastSearch.js +0 -53
  36. package/dist/cjs/TraceMatrix.js +0 -256
  37. package/dist/cjs/utils.js +0 -216
  38. package/dist/es2015/DNumbers.js +0 -22
  39. package/dist/es2015/index.js +0 -10
@@ -1,12 +1,15 @@
1
- import { DPoint } from './DPoint';
2
- import { DLine } from './DLine';
3
- import { DCircle } from './DCircle';
4
- import { DNumbers } from './DNumbers';
5
- import { io as jstsIo, operation } from 'jsts';
6
- import { DPolygonLoop } from './DPolygonLoop';
7
- import { isDefAndNotNull } from './utils';
8
- const { buffer: { BufferParameters: { CAP_ROUND, CAP_FLAT, CAP_SQUARE } } } = operation;
9
- export const MIN_POINTS_IN_VALID_POLYGON = 3;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DPolygon = exports.MIN_POINTS_IN_VALID_POLYGON = void 0;
4
+ const DPoint_1 = require("./DPoint");
5
+ const DLine_1 = require("./DLine");
6
+ const DCircle_1 = require("./DCircle");
7
+ const DNumbers_1 = require("./DNumbers");
8
+ const jsts_1 = require("jsts");
9
+ const DPolygonLoop_1 = require("./DPolygonLoop");
10
+ const utils_1 = require("./utils");
11
+ const { buffer: { BufferParameters: { CAP_ROUND, CAP_FLAT, CAP_SQUARE } } } = jsts_1.operation;
12
+ exports.MIN_POINTS_IN_VALID_POLYGON = 3;
10
13
  const APPROXIMATION_VALUE = 0.1;
11
14
  const MAX_CONVEX_ITERATIONS = 100;
12
15
  const CLOSE_TO_INTERSECTION_DISTANCE = 0.001;
@@ -23,8 +26,8 @@ const containCalculator = (poly, p) => {
23
26
  }
24
27
  let totalFi = 0;
25
28
  for (const [{ x, y }, { x: a, y: b }] of poly.loopPointsGenerator()()) {
26
- const line1 = new DLine(x - p.x, y - p.y, 0);
27
- const line2 = new DLine(a - p.x, b - p.y, 0);
29
+ const line1 = new DLine_1.DLine(x - p.x, y - p.y, 0);
30
+ const line2 = new DLine_1.DLine(a - p.x, b - p.y, 0);
28
31
  const fiDif = line1.findFi(line2);
29
32
  if (line1.vectorProduct(line2).c > 0) {
30
33
  totalFi += fiDif;
@@ -47,7 +50,7 @@ const containCalculator = (poly, p) => {
47
50
  }
48
51
  return result;
49
52
  };
50
- export class DPolygon {
53
+ class DPolygon {
51
54
  constructor(pPoints = []) {
52
55
  this.pPoints = pPoints;
53
56
  this.properties = {};
@@ -55,7 +58,7 @@ export class DPolygon {
55
58
  this.searchStore = {};
56
59
  }
57
60
  static arrayOfTrianglesToVertices(triangles, height) {
58
- return triangles.map((v) => (isDefAndNotNull(height) ? v
61
+ return triangles.map((v) => ((0, utils_1.isDefAndNotNull)(height) ? v
59
62
  .loop()
60
63
  .height(height)
61
64
  .run() : v)
@@ -64,7 +67,7 @@ export class DPolygon {
64
67
  }
65
68
  static minAreaRectangleSize(poly) {
66
69
  const { first, second, last } = poly.clone().open();
67
- return new DPoint(first.distance(second), first.distance(last));
70
+ return new DPoint_1.DPoint(first.distance(second), first.distance(last));
68
71
  }
69
72
  static toDash(poly) {
70
73
  let p = new DPolygon();
@@ -104,7 +107,7 @@ export class DPolygon {
104
107
  const [path, ...holes] = reg.groups.data
105
108
  .split('), (')
106
109
  .map((p) => new DPolygon(p.split(', ')
107
- .map((pares) => DPoint.parse(pares.split(' ').map(Number)))));
110
+ .map((pares) => DPoint_1.DPoint.parse(pares.split(' ').map(Number)))));
108
111
  if (holes && holes.length) {
109
112
  path.holes = holes;
110
113
  }
@@ -114,18 +117,18 @@ export class DPolygon {
114
117
  const regexp = /LINESTRING \((?<data>(?:(?!\)$).)*?)\)$/miu;
115
118
  const reg = regexp.exec(data);
116
119
  res = new DPolygon(reg.groups.data
117
- .split(', ').map((t) => DPoint.parse(t.split(' ').map(Number))));
120
+ .split(', ').map((t) => DPoint_1.DPoint.parse(t.split(' ').map(Number))));
118
121
  }
119
122
  if (data.indexOf('POINT') === 0) {
120
- res = new DPolygon([DPoint.parseFromWKT(data)]);
123
+ res = new DPolygon([DPoint_1.DPoint.parseFromWKT(data)]);
121
124
  }
122
125
  return res;
123
126
  }
124
127
  static createSquareBySize(size) {
125
- return new DPolygon([DPoint.zero(), size.clone().setX(0), size.clone(), size.clone().setY(0)]).close();
128
+ return new DPolygon([DPoint_1.DPoint.zero(), size.clone().setX(0), size.clone(), size.clone().setY(0)]).close();
126
129
  }
127
130
  loop() {
128
- return new DPolygonLoop(this);
131
+ return new DPolygonLoop_1.DPolygonLoop(this);
129
132
  }
130
133
  set points(p) {
131
134
  this.pPoints = p;
@@ -163,24 +166,24 @@ export class DPolygon {
163
166
  get extend() {
164
167
  const { minX, minY, maxX, maxY } = this;
165
168
  return new DPolygon([
166
- new DPoint(minX, minY),
167
- new DPoint(maxX, minY),
168
- new DPoint(maxX, maxY),
169
- new DPoint(minX, maxY),
170
- new DPoint(minX, minY)
169
+ new DPoint_1.DPoint(minX, minY),
170
+ new DPoint_1.DPoint(maxX, minY),
171
+ new DPoint_1.DPoint(maxX, maxY),
172
+ new DPoint_1.DPoint(minX, maxY),
173
+ new DPoint_1.DPoint(minX, minY)
171
174
  ]);
172
175
  }
173
176
  get size() {
174
177
  const { w, h } = this;
175
- return new DPoint(w, h);
178
+ return new DPoint_1.DPoint(w, h);
176
179
  }
177
180
  get leftTop() {
178
181
  const { minX, minY } = this;
179
- return new DPoint(minX, minY);
182
+ return new DPoint_1.DPoint(minX, minY);
180
183
  }
181
184
  get rightBottom() {
182
185
  const { maxX, maxY } = this;
183
- return new DPoint(maxX, maxY);
186
+ return new DPoint_1.DPoint(maxX, maxY);
184
187
  }
185
188
  get length() {
186
189
  return this.pPoints.length;
@@ -242,7 +245,7 @@ export class DPolygon {
242
245
  return p;
243
246
  }
244
247
  get valid() {
245
- return this.length > MIN_POINTS_IN_VALID_POLYGON;
248
+ return this.length > exports.MIN_POINTS_IN_VALID_POLYGON;
246
249
  }
247
250
  get first() {
248
251
  return this.at(0);
@@ -311,7 +314,7 @@ export class DPolygon {
311
314
  const p2 = p.first;
312
315
  const p3 = p.second;
313
316
  const d = p2.findInnerAngle(p1, p3);
314
- if (d > Math.PI || DNumbers.likeZero(DNumbers.rad2Deg(d)) || DNumbers.likePI(d) || DNumbers.like2PI(d)) {
317
+ if (d > Math.PI || DNumbers_1.DNumbers.likeZero(DNumbers_1.DNumbers.rad2Deg(d)) || DNumbers_1.DNumbers.likePI(d) || DNumbers_1.DNumbers.like2PI(d)) {
315
318
  p.removePart(-1, 1);
316
319
  }
317
320
  else {
@@ -328,7 +331,7 @@ export class DPolygon {
328
331
  const p2 = p.at(i);
329
332
  const p3 = p.at(i + 1);
330
333
  const d = p2.findInnerAngle(p1, p3);
331
- if (d > Math.PI || DNumbers.likeZero(DNumbers.rad2Deg(d)) || DNumbers.likePI(d) || DNumbers.like2PI(d)) {
334
+ if (d > Math.PI || DNumbers_1.DNumbers.likeZero(DNumbers_1.DNumbers.rad2Deg(d)) || DNumbers_1.DNumbers.likePI(d) || DNumbers_1.DNumbers.like2PI(d)) {
332
335
  p.removePart(--i, 1);
333
336
  }
334
337
  }
@@ -486,7 +489,7 @@ export class DPolygon {
486
489
  return false;
487
490
  }
488
491
  findIndex(a) {
489
- if (a instanceof DPoint) {
492
+ if (a instanceof DPoint_1.DPoint) {
490
493
  return this.points.findIndex((t) => t.equal(a));
491
494
  }
492
495
  return this.points.findIndex(a);
@@ -564,8 +567,8 @@ export class DPolygon {
564
567
  const poly = this.deintersection;
565
568
  let totalFi = 0;
566
569
  for (const [{ x, y }, { x: a, y: b }] of poly.loopPointsGenerator()()) {
567
- const line1 = new DLine(x - p.x, y - p.y, 0);
568
- const line2 = new DLine(a - p.x, b - p.y, 0);
570
+ const line1 = new DLine_1.DLine(x - p.x, y - p.y, 0);
571
+ const line2 = new DLine_1.DLine(a - p.x, b - p.y, 0);
569
572
  const fiDif = line1.findFi(line2);
570
573
  if (line1.vectorProduct(line2).c > 0) {
571
574
  totalFi += fiDif;
@@ -619,12 +622,12 @@ export class DPolygon {
619
622
  return this;
620
623
  }
621
624
  static parse(a) {
622
- return new DPolygon(a.map((r) => DPoint.parse(r)));
625
+ return new DPolygon(a.map((r) => DPoint_1.DPoint.parse(r)));
623
626
  }
624
627
  toArrayOfCoords() {
625
628
  return this.mapArray((r) => r.toCoords());
626
629
  }
627
- divideToPieces(piecesCount) {
630
+ divideToPieces(piecesCount, withAltitude = false) {
628
631
  const { fullLength } = this;
629
632
  const pieceLength = fullLength / piecesCount;
630
633
  let currentPieceLength = pieceLength;
@@ -635,12 +638,16 @@ export class DPolygon {
635
638
  currentPieceLength = pieceLength;
636
639
  }
637
640
  else if (d - currentPieceLength > 0) {
638
- const circle = new DCircle(p1, currentPieceLength);
641
+ const circle = new DCircle_1.DCircle(p1, currentPieceLength);
639
642
  const line = p1.findLine(p2);
640
643
  const intersectionPoint = line.intersectionWithCircle(circle)
641
644
  .filter((p) => line.inRange(p, CLOSE_TO_INTERSECTION_DISTANCE))[0];
642
645
  intersectionPoint.properties.pieceBorder = true;
643
646
  this.insertAfter(i, intersectionPoint);
647
+ if (withAltitude) {
648
+ const p1z = p1.z;
649
+ intersectionPoint.z = p1z - (p1z - p2.z) * (p1.distance(intersectionPoint) / d);
650
+ }
644
651
  currentPieceLength = pieceLength;
645
652
  }
646
653
  else {
@@ -847,13 +854,13 @@ export class DPolygon {
847
854
  return this.first.equal(this.last);
848
855
  }
849
856
  buffer(v, quadrantSegments = 64, type = DPolygon.CAP_ROUND) {
850
- const reader = new jstsIo.WKTReader();
857
+ const reader = new jsts_1.io.WKTReader();
851
858
  const { noHoles, closed } = this;
852
859
  const points = reader
853
860
  .read(noHoles.toWKT(closed ? DPolygon.WKT_POLYGON : DPolygon.WKT_LINESTRING))
854
861
  .buffer(v, quadrantSegments, type)
855
862
  .getCoordinates();
856
- return new DPolygon(points.map(({ x, y }) => new DPoint(x, y)));
863
+ return new DPolygon(points.map(({ x, y }) => new DPoint_1.DPoint(x, y)));
857
864
  }
858
865
  sideBuffers(v, quadrantSegments = 64) {
859
866
  const { first, last } = this;
@@ -946,7 +953,7 @@ export class DPolygon {
946
953
  }
947
954
  getJSTSGeometry(p, unionThis, unionThat) {
948
955
  const unionOrIntersection = unionThat === unionThis;
949
- const reader = new jstsIo.WKTReader();
956
+ const reader = new jsts_1.io.WKTReader();
950
957
  const a = reader.read(this.noHoles.toWKT());
951
958
  const b = reader.read(p.noHoles.toWKT());
952
959
  if (!unionOrIntersection) {
@@ -967,11 +974,11 @@ export class DPolygon {
967
974
  if (coordinates.length) {
968
975
  let result = coordinates.reduce((ak, { x, y }, index) => {
969
976
  const lastIndex = ak.length - 1;
970
- const t = new DPoint(x, y);
977
+ const t = new DPoint_1.DPoint(x, y);
971
978
  const { first } = ak[lastIndex];
972
979
  if (t.equal(first)) {
973
980
  if (coordinates[index + 1]) {
974
- const nextPoint = new DPoint(coordinates[index + 1].x, coordinates[index + 1].y);
981
+ const nextPoint = new DPoint_1.DPoint(coordinates[index + 1].x, coordinates[index + 1].y);
975
982
  if (ak[lastIndex].length > 1) {
976
983
  ak.push(new DPolygon([nextPoint]));
977
984
  }
@@ -981,7 +988,7 @@ export class DPolygon {
981
988
  ak[lastIndex].push(t);
982
989
  }
983
990
  return ak;
984
- }, [new DPolygon([new DPoint(coordinates[0].x, coordinates[0].y)])]);
991
+ }, [new DPolygon([new DPoint_1.DPoint(coordinates[0].x, coordinates[0].y)])]);
985
992
  if (unionThat && unionThis && result.length > 1) {
986
993
  for (const q of result) {
987
994
  for (const r of result) {
@@ -1029,6 +1036,7 @@ export class DPolygon {
1029
1036
  return null;
1030
1037
  }
1031
1038
  }
1039
+ exports.DPolygon = DPolygon;
1032
1040
  DPolygon.CAP_ROUND = CAP_ROUND;
1033
1041
  DPolygon.CAP_FLAT = CAP_FLAT;
1034
1042
  DPolygon.CAP_SQUARE = CAP_SQUARE;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DPolygonLoop = void 0;
1
4
  var LoopFunctions;
2
5
  (function (LoopFunctions) {
3
6
  LoopFunctions[LoopFunctions["getTileFromCoords"] = 0] = "getTileFromCoords";
@@ -167,7 +170,7 @@ const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg
167
170
  }
168
171
  return res;
169
172
  };
170
- export class DPolygonLoop {
173
+ class DPolygonLoop {
171
174
  constructor(parent) {
172
175
  this.parent = parent;
173
176
  this.pool = [];
@@ -390,3 +393,4 @@ export class DPolygonLoop {
390
393
  return this;
391
394
  }
392
395
  }
396
+ exports.DPolygonLoop = DPolygonLoop;
File without changes
@@ -1,4 +1,7 @@
1
- export class FastSearch {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastSearch = void 0;
4
+ class FastSearch {
2
5
  constructor() {
3
6
  this.searchStore = {};
4
7
  }
@@ -23,3 +26,4 @@ export class FastSearch {
23
26
  return this.searchStore[x][y][z || 'undefined'];
24
27
  }
25
28
  }
29
+ exports.FastSearch = FastSearch;
File without changes
@@ -1,12 +1,15 @@
1
- import { DPoint } from './DPoint';
2
- import { DPolygon, MIN_POINTS_IN_VALID_POLYGON } from './DPolygon';
3
- import { FastSearch } from './FastSearch';
4
- import { createArray } from './utils';
5
- export var TraceMatrixValues;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TraceMatrix = exports.TraceMatrixValues = void 0;
4
+ const DPoint_1 = require("./DPoint");
5
+ const DPolygon_1 = require("./DPolygon");
6
+ const FastSearch_1 = require("./FastSearch");
7
+ const utils_1 = require("./utils");
8
+ var TraceMatrixValues;
6
9
  (function (TraceMatrixValues) {
7
10
  TraceMatrixValues[TraceMatrixValues["f"] = 0] = "f";
8
11
  TraceMatrixValues[TraceMatrixValues["t"] = 1] = "t";
9
- })(TraceMatrixValues || (TraceMatrixValues = {}));
12
+ })(TraceMatrixValues = exports.TraceMatrixValues || (exports.TraceMatrixValues = {}));
10
13
  const getByPosition = (m, p, defaultValue = TraceMatrixValues.f) => {
11
14
  if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
12
15
  return defaultValue;
@@ -20,11 +23,11 @@ const setByPosition = (m, p, value) => {
20
23
  m[p.y][p.x] = value;
21
24
  return m[p.y][p.x];
22
25
  };
23
- export class TraceMatrix {
26
+ class TraceMatrix {
24
27
  constructor(size, f) {
25
28
  this.size = size;
26
29
  this.findGroupByIndex = (m, s) => {
27
- const res = new DPolygon();
30
+ const res = new DPolygon_1.DPolygon();
28
31
  if (s && getByPosition(m, s) === TraceMatrixValues.t) {
29
32
  res.push(s);
30
33
  let startIndex = 0;
@@ -34,7 +37,7 @@ export class TraceMatrix {
34
37
  const r = res.at(startIndex);
35
38
  for (let i = -1; i < 2; i++) {
36
39
  for (let j = -1; j < 2; j++) {
37
- const t = new DPoint(r.x + i, r.y + j);
40
+ const t = new DPoint_1.DPoint(r.x + i, r.y + j);
38
41
  if (getByPosition(marked, t, TraceMatrixValues.t) === TraceMatrixValues.f &&
39
42
  getByPosition(m, t, TraceMatrixValues.f) === TraceMatrixValues.t) {
40
43
  res.push(t);
@@ -56,7 +59,7 @@ export class TraceMatrix {
56
59
  const groups = [group];
57
60
  let groupSum = group.length;
58
61
  let allGroups = [...group.points];
59
- const fs = new FastSearch();
62
+ const fs = new FastSearch_1.FastSearch();
60
63
  fs.add(allGroups);
61
64
  while (groupSum < this.totalCountInMatrix(m)) {
62
65
  let mark = this.findMarked(m);
@@ -73,22 +76,22 @@ export class TraceMatrix {
73
76
  };
74
77
  this.traceGroup = (m, group) => {
75
78
  const traceDirections = [
76
- new DPoint(-1, -1),
77
- new DPoint(-1, 0),
78
- new DPoint(-1, 1),
79
- new DPoint(0, 1),
80
- new DPoint(1, 1),
81
- new DPoint(1, 0),
82
- new DPoint(1, -1),
83
- new DPoint(0, -1)
79
+ new DPoint_1.DPoint(-1, -1),
80
+ new DPoint_1.DPoint(-1, 0),
81
+ new DPoint_1.DPoint(-1, 1),
82
+ new DPoint_1.DPoint(0, 1),
83
+ new DPoint_1.DPoint(1, 1),
84
+ new DPoint_1.DPoint(1, 0),
85
+ new DPoint_1.DPoint(1, -1),
86
+ new DPoint_1.DPoint(0, -1)
84
87
  ];
85
88
  const left = (d) => (d + traceDirections.length + 1) % traceDirections.length;
86
89
  const right = (d) => (d + traceDirections.length - 1) % traceDirections.length;
87
90
  if (group.length < 2) {
88
91
  const t = group.at(0).clone();
89
- return new DPolygon([t, t, t]);
92
+ return new DPolygon_1.DPolygon([t, t, t]);
90
93
  }
91
- const points = new DPolygon();
94
+ const points = new DPolygon_1.DPolygon();
92
95
  let direction = 0;
93
96
  let prevDirection = Infinity;
94
97
  let p = group.at(0);
@@ -112,22 +115,22 @@ export class TraceMatrix {
112
115
  };
113
116
  this.createHoleMatrix = (group) => {
114
117
  const fullTraceDirections = [
115
- new DPoint(-1, 0),
116
- new DPoint(0, 1),
117
- new DPoint(1, 0),
118
- new DPoint(0, -1)
118
+ new DPoint_1.DPoint(-1, 0),
119
+ new DPoint_1.DPoint(0, 1),
120
+ new DPoint_1.DPoint(1, 0),
121
+ new DPoint_1.DPoint(0, -1)
119
122
  ];
120
123
  group.prepareToFastSearch();
121
124
  const tmpMatrix = TraceMatrix
122
125
  .createMatrix(this.size, (p) => group.fastHas(p) ? TraceMatrixValues.t : TraceMatrixValues.f);
123
- const startCoords = new DPolygon();
126
+ const startCoords = new DPolygon_1.DPolygon();
124
127
  for (let i = 0; i < this.size.w; i++) {
125
- startCoords.push(new DPoint(i, -1));
126
- startCoords.push(new DPoint(i, this.size.h));
128
+ startCoords.push(new DPoint_1.DPoint(i, -1));
129
+ startCoords.push(new DPoint_1.DPoint(i, this.size.h));
127
130
  }
128
131
  for (let i = 0; i < this.size.h; i++) {
129
- startCoords.push(new DPoint(-1, i));
130
- startCoords.push(new DPoint(this.size.w, i));
132
+ startCoords.push(new DPoint_1.DPoint(-1, i));
133
+ startCoords.push(new DPoint_1.DPoint(this.size.w, i));
131
134
  }
132
135
  while (startCoords.length) {
133
136
  const point = startCoords.pop();
@@ -151,7 +154,7 @@ export class TraceMatrix {
151
154
  const holeMatrixs = groups.map(this.createHoleMatrix);
152
155
  const holesGroups = holeMatrixs.map((m) => m && this.findAllGroupsInMatrix(m));
153
156
  const holesPaths = holesGroups.map((hg, index) => hg && hg.map((g) => this
154
- .traceGroup(holeMatrixs[index], g)).filter((r) => r.length > MIN_POINTS_IN_VALID_POLYGON));
157
+ .traceGroup(holeMatrixs[index], g)).filter((r) => r.length > DPolygon_1.MIN_POINTS_IN_VALID_POLYGON));
155
158
  return groups.map((g, index) => {
156
159
  const res = paths[index];
157
160
  if (holesGroups[index] && holesGroups[index].length) {
@@ -174,8 +177,8 @@ export class TraceMatrix {
174
177
  ini = true;
175
178
  continue;
176
179
  }
177
- if (getByPosition(m, new DPoint(i, j)) === TraceMatrixValues.t) {
178
- return new DPoint(i, j);
180
+ if (getByPosition(m, new DPoint_1.DPoint(i, j)) === TraceMatrixValues.t) {
181
+ return new DPoint_1.DPoint(i, j);
179
182
  }
180
183
  }
181
184
  }
@@ -186,7 +189,7 @@ export class TraceMatrix {
186
189
  const s = this.size;
187
190
  for (let i = 0; i < s.w; i++) {
188
191
  for (let j = 0; j < s.h; j++) {
189
- if (getByPosition(m, new DPoint(i, j))) {
192
+ if (getByPosition(m, new DPoint_1.DPoint(i, j))) {
190
193
  res++;
191
194
  }
192
195
  }
@@ -194,7 +197,8 @@ export class TraceMatrix {
194
197
  return res;
195
198
  }
196
199
  static createMatrix(size, f = () => TraceMatrixValues.f) {
197
- return createArray(size.h)
198
- .map((v, i) => createArray(size.w).map((v2, j) => f(new DPoint(j, i))));
200
+ return (0, utils_1.createArray)(size.h)
201
+ .map((v, i) => (0, utils_1.createArray)(size.w).map((v2, j) => f(new DPoint_1.DPoint(j, i))));
199
202
  }
200
203
  }
204
+ exports.TraceMatrix = TraceMatrix;
@@ -958,8 +958,9 @@ var DPolygon = (function () {
958
958
  DPolygon.prototype.toArrayOfCoords = function () {
959
959
  return this.mapArray(function (r) { return r.toCoords(); });
960
960
  };
961
- DPolygon.prototype.divideToPieces = function (piecesCount) {
961
+ DPolygon.prototype.divideToPieces = function (piecesCount, withAltitude) {
962
962
  var e_13, _a;
963
+ if (withAltitude === void 0) { withAltitude = false; }
963
964
  var fullLength = this.fullLength;
964
965
  var pieceLength = fullLength / piecesCount;
965
966
  var currentPieceLength = pieceLength;
@@ -976,6 +977,10 @@ var DPolygon = (function () {
976
977
  .filter(function (p) { return line_1.inRange(p, CLOSE_TO_INTERSECTION_DISTANCE); })[0];
977
978
  intersectionPoint.properties.pieceBorder = true;
978
979
  this_1.insertAfter(i, intersectionPoint);
980
+ if (withAltitude) {
981
+ var p1z = p1.z;
982
+ intersectionPoint.z = p1z - (p1z - p2.z) * (p1.distance(intersectionPoint) / d);
983
+ }
979
984
  currentPieceLength = pieceLength;
980
985
  }
981
986
  else {
File without changes
File without changes