@maplat/tin 0.11.2 → 0.11.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.
- package/LICENSE +224 -224
- package/README.ja.md +218 -218
- package/README.md +219 -219
- package/dist/index.html +41 -41
- package/package.json +5 -4
- package/src/constrained-tin.ts +84 -84
- package/src/index.ts +41 -41
- package/src/kinks.ts +1039 -1039
- package/src/searchutils.ts +68 -68
- package/src/tin.ts +1027 -1027
- package/src/types/cdt2d.d.ts +4 -4
- package/src/types/constrainautor.d.ts +6 -6
- package/src/types/kinks.d.ts +49 -49
- package/src/types/tin.d.ts +54 -54
- package/src/vertexutils.ts +88 -88
package/src/searchutils.ts
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import type { Tins, Tri } from "@maplat/transform";
|
|
2
|
-
import type { PropertyTriKey } from "@maplat/transform";
|
|
3
|
-
|
|
4
|
-
type BiDirectionKey = "forw" | "bakw";
|
|
5
|
-
type TinsBD = { [key in BiDirectionKey]?: Tins };
|
|
6
|
-
type SearchTris = { [key in BiDirectionKey]: Tri };
|
|
7
|
-
export type SearchIndex = { [key: string]: SearchTris[] };
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 三角形のインデックスキーを計算する
|
|
11
|
-
* 三つの頂点のインデックスから、ソートされたキー配列を生成
|
|
12
|
-
*
|
|
13
|
-
* @param tri インデックスキーを計算する三角形
|
|
14
|
-
* @returns ソートされたキー配列
|
|
15
|
-
*/
|
|
16
|
-
function calcSearchKeys(tri: Tri): string[] {
|
|
17
|
-
const vtx = (["a", "b", "c"] as PropertyTriKey[]).map(
|
|
18
|
-
(key) => tri.properties![key].index,
|
|
19
|
-
);
|
|
20
|
-
return [
|
|
21
|
-
[0, 1],
|
|
22
|
-
[0, 2],
|
|
23
|
-
[1, 2],
|
|
24
|
-
[0, 1, 2],
|
|
25
|
-
]
|
|
26
|
-
.map((set) =>
|
|
27
|
-
set
|
|
28
|
-
.map((i) => vtx[i])
|
|
29
|
-
.sort()
|
|
30
|
-
.join("-")
|
|
31
|
-
)
|
|
32
|
-
.sort();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 検索インデックスに三角形を追加する
|
|
37
|
-
*
|
|
38
|
-
* @param searchIndex 検索インデックス
|
|
39
|
-
* @param tris 追加する三角形ペア
|
|
40
|
-
* @param tins (オプション)追加先の三角形群
|
|
41
|
-
* @throws キーの不一致エラー
|
|
42
|
-
*/
|
|
43
|
-
function insertSearchIndex(
|
|
44
|
-
searchIndex: SearchIndex,
|
|
45
|
-
tris: SearchTris,
|
|
46
|
-
tins?: TinsBD,
|
|
47
|
-
) {
|
|
48
|
-
const keys = calcSearchKeys(tris.forw);
|
|
49
|
-
const bakKeys = calcSearchKeys(tris.bakw);
|
|
50
|
-
if (JSON.stringify(keys) != JSON.stringify(bakKeys)) {
|
|
51
|
-
throw `${JSON.stringify(tris, null, 2)}\n${
|
|
52
|
-
JSON.stringify(
|
|
53
|
-
keys,
|
|
54
|
-
)
|
|
55
|
-
}\n${JSON.stringify(bakKeys)}`;
|
|
56
|
-
}
|
|
57
|
-
for (let i = 0; i < keys.length; i++) {
|
|
58
|
-
const key = keys[i];
|
|
59
|
-
if (!searchIndex[key]) searchIndex[key] = [];
|
|
60
|
-
searchIndex[key].push(tris);
|
|
61
|
-
}
|
|
62
|
-
if (tins) {
|
|
63
|
-
tins.forw!.features.push(tris.forw);
|
|
64
|
-
tins.bakw!.features.push(tris.bakw);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { insertSearchIndex };
|
|
1
|
+
import type { Tins, Tri } from "@maplat/transform";
|
|
2
|
+
import type { PropertyTriKey } from "@maplat/transform";
|
|
3
|
+
|
|
4
|
+
type BiDirectionKey = "forw" | "bakw";
|
|
5
|
+
type TinsBD = { [key in BiDirectionKey]?: Tins };
|
|
6
|
+
type SearchTris = { [key in BiDirectionKey]: Tri };
|
|
7
|
+
export type SearchIndex = { [key: string]: SearchTris[] };
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 三角形のインデックスキーを計算する
|
|
11
|
+
* 三つの頂点のインデックスから、ソートされたキー配列を生成
|
|
12
|
+
*
|
|
13
|
+
* @param tri インデックスキーを計算する三角形
|
|
14
|
+
* @returns ソートされたキー配列
|
|
15
|
+
*/
|
|
16
|
+
function calcSearchKeys(tri: Tri): string[] {
|
|
17
|
+
const vtx = (["a", "b", "c"] as PropertyTriKey[]).map(
|
|
18
|
+
(key) => tri.properties![key].index,
|
|
19
|
+
);
|
|
20
|
+
return [
|
|
21
|
+
[0, 1],
|
|
22
|
+
[0, 2],
|
|
23
|
+
[1, 2],
|
|
24
|
+
[0, 1, 2],
|
|
25
|
+
]
|
|
26
|
+
.map((set) =>
|
|
27
|
+
set
|
|
28
|
+
.map((i) => vtx[i])
|
|
29
|
+
.sort()
|
|
30
|
+
.join("-")
|
|
31
|
+
)
|
|
32
|
+
.sort();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 検索インデックスに三角形を追加する
|
|
37
|
+
*
|
|
38
|
+
* @param searchIndex 検索インデックス
|
|
39
|
+
* @param tris 追加する三角形ペア
|
|
40
|
+
* @param tins (オプション)追加先の三角形群
|
|
41
|
+
* @throws キーの不一致エラー
|
|
42
|
+
*/
|
|
43
|
+
function insertSearchIndex(
|
|
44
|
+
searchIndex: SearchIndex,
|
|
45
|
+
tris: SearchTris,
|
|
46
|
+
tins?: TinsBD,
|
|
47
|
+
) {
|
|
48
|
+
const keys = calcSearchKeys(tris.forw);
|
|
49
|
+
const bakKeys = calcSearchKeys(tris.bakw);
|
|
50
|
+
if (JSON.stringify(keys) != JSON.stringify(bakKeys)) {
|
|
51
|
+
throw `${JSON.stringify(tris, null, 2)}\n${
|
|
52
|
+
JSON.stringify(
|
|
53
|
+
keys,
|
|
54
|
+
)
|
|
55
|
+
}\n${JSON.stringify(bakKeys)}`;
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < keys.length; i++) {
|
|
58
|
+
const key = keys[i];
|
|
59
|
+
if (!searchIndex[key]) searchIndex[key] = [];
|
|
60
|
+
searchIndex[key].push(tris);
|
|
61
|
+
}
|
|
62
|
+
if (tins) {
|
|
63
|
+
tins.forw!.features.push(tris.forw);
|
|
64
|
+
tins.bakw!.features.push(tris.bakw);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { insertSearchIndex };
|