@geode/opengeodeweb-front 12.2.0-rc.3 → 12.2.0-rc.5
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/.build/tests/browser/helpers/object_trees/common.js +3 -1
- package/.build/tests/browser/helpers/object_trees/model_tree_bar.js +41 -0
- package/.build/tests/browser/helpers/wait_for_action_settled.js +2 -2
- package/.build/tests/browser/suites/index.js +2 -0
- package/.build/tests/browser/suites/model/collections.js +1 -1
- package/.build/tests/browser/suites/object_tree/controls.js +2 -1
- package/.build/tests/browser/suites/object_tree/model_tree_bar.js +81 -0
- package/app/components/ClippingPlanes.vue +1 -1
- package/app/components/FactorFilterPanel.vue +1 -1
- package/app/components/Launcher.vue +3 -2
- package/app/components/ThresholdFilter.vue +1 -2
- package/app/components/Viewer/Basemap/CropOptions.vue +7 -8
- package/app/components/Viewer/Basemap/OpacityOptions.vue +7 -8
- package/app/components/Viewer/ContextMenu/CircularItems.vue +6 -43
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +1 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +14 -16
- package/app/components/Viewer/EdgedCurve/PointsOptions.vue +5 -4
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +10 -13
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -11
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +16 -13
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +28 -31
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +9 -11
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +1 -1
- package/app/components/Viewer/Grid/2D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Grid/3D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/FacetsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Image/ImageOptions.vue +10 -13
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +17 -1
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +2 -2
- package/app/components/Viewer/ObjectTree/Base/Controls.vue +26 -2
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +6 -8
- package/app/components/Viewer/ObjectTree/Box.vue +30 -5
- package/app/components/Viewer/ObjectTree/Layout.vue +183 -54
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +10 -15
- package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +3 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +28 -31
- package/app/components/Viewer/Scene/BackgroundOptions.vue +4 -7
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +4 -7
- package/app/components/Viewer/Scene/TextOptions.vue +4 -7
- package/app/components/Viewer/Solid/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Solid/PointsOptions.vue +5 -4
- package/app/components/Viewer/Solid/PolygonsOptions.vue +6 -4
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Surface/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Surface/PointsOptions.vue +6 -4
- package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -11
- package/app/components/Viewer/Surface/Triangulated/TrianglesOptions.vue +5 -4
- package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +6 -4
- package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +6 -4
- package/app/composables/circular_menu.ts +45 -0
- package/app/composables/hover_highlight.ts +1 -1
- package/app/composables/model_menu_context.ts +7 -11
- package/app/composables/model_tree.ts +3 -3
- package/app/composables/model_tree_drag.ts +56 -0
- package/app/composables/project_manager_helpers/types.ts +2 -3
- package/app/composables/use_adaptive_styles.ts +15 -8
- package/app/composables/use_overlapping_picker.ts +7 -19
- package/app/composables/viewer_context_menu.ts +2 -1
- package/app/composables/virtual_tree.ts +7 -1
- package/app/stores/api.ts +6 -59
- package/app/stores/app.ts +21 -55
- package/app/stores/back.ts +86 -145
- package/app/stores/camera_manager.ts +12 -25
- package/app/stores/cloud.ts +21 -101
- package/app/stores/crs.ts +3 -2
- package/app/stores/data.ts +66 -409
- package/app/stores/data_style.ts +99 -93
- package/app/stores/feedback.ts +57 -53
- package/app/stores/infra.ts +61 -101
- package/app/stores/treeview.ts +39 -30
- package/app/stores/viewer.ts +9 -29
- package/app/stores/viewer_helpers/actions.ts +1 -23
- package/app/utils/backend_lifecycle.ts +155 -0
- package/app/utils/import_item.ts +5 -4
- package/app/utils/threshold_sources.ts +3 -2
- package/app/utils/treeview.ts +25 -1
- package/app/utils/viewer_object_type.ts +21 -0
- package/internal/database/base_database.ts +2 -1
- package/internal/database/database.ts +90 -7
- package/internal/database/queries.ts +45 -0
- package/internal/database/tables/camera_positions.ts +11 -1
- package/internal/database/tables/data.ts +20 -1
- package/internal/database/tables/data_style.ts +3 -1
- package/internal/database/tables/model_component_datastyle.ts +3 -1
- package/internal/database/tables/model_component_type_datastyle.ts +3 -1
- package/internal/database/tables/model_components.ts +12 -1
- package/internal/database/tables/model_components_relation.ts +11 -1
- package/internal/database/tables/scene_style.ts +3 -1
- package/internal/database/tables/treeview_config.ts +31 -0
- package/internal/stores/data/items.ts +110 -0
- package/internal/stores/data/model/collections.ts +107 -0
- package/internal/stores/data/model/components.ts +129 -0
- package/internal/stores/data/model/mesh_components.ts +134 -0
- package/internal/stores/data/model/relations.ts +76 -0
- package/internal/stores/data/model/types.ts +14 -0
- package/internal/stores/data/registration.ts +54 -0
- package/internal/stores/data/snapshot.ts +83 -0
- package/internal/stores/data/types.ts +26 -0
- package/internal/stores/data_style/model/common_mutations.ts +47 -77
- package/internal/stores/data_style/model/selection.ts +3 -10
- package/internal/stores/data_style/scene.ts +2 -2
- package/internal/stores/data_style/state.ts +10 -8
- package/internal/stores/data_style/state_shared.ts +10 -7
- package/internal/stores/hybrid_viewer/brightness.ts +36 -19
- package/internal/stores/hybrid_viewer/highlight.ts +9 -14
- package/internal/stores/hybrid_viewer/scene.ts +1 -1
- package/internal/stores/microservice.ts +192 -0
- package/package.json +1 -1
- package/tests/browser/helpers/data/helpers/attribute.ts +2 -1
- package/tests/browser/helpers/object_trees/common.ts +4 -0
- package/tests/browser/helpers/object_trees/model_tree_bar.ts +78 -0
- package/tests/browser/helpers/wait_for_action_settled.ts +2 -3
- package/tests/browser/suites/model/collections.ts +2 -1
- package/tests/browser/suites/object_tree/controls.ts +3 -0
- package/tests/browser/suites/object_tree/model_tree_bar.ts +125 -0
- package/app/stores/data_helpers/collections.ts +0 -122
- package/app/stores/data_helpers/mesh.ts +0 -167
- package/app/stores/data_helpers/relations.ts +0 -94
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { type FormattedComponent, type ModelComponentRecord, useDataMesh } from "./mesh.js";
|
|
2
|
-
import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
|
|
3
|
-
import type { ModelComponentRelationRecord } from "./relations.js";
|
|
4
|
-
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
5
|
-
import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
|
|
6
|
-
import type { Ref } from "vue";
|
|
7
|
-
import { getTable } from "@ogw_internal/database/database.js";
|
|
8
|
-
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
9
|
-
import { pluralize } from "@ogw_front/utils/string";
|
|
10
|
-
import { useObservable } from "@vueuse/rxjs";
|
|
11
|
-
|
|
12
|
-
interface CollectionComponent extends FormattedComponent {
|
|
13
|
-
readonly children: readonly FormattedComponent[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type CollectionComponentGroup = ReadonlyTreeGroup<CollectionComponent>;
|
|
17
|
-
|
|
18
|
-
// oxlint-disable-next-line eslint/max-lines-per-function
|
|
19
|
-
export function useDataCollections(): {
|
|
20
|
-
hasCollectionComponents: typeof hasCollectionComponents;
|
|
21
|
-
getAllCollectionComponents: typeof getAllCollectionComponents;
|
|
22
|
-
fetchAllCollectionComponents: typeof fetchAllCollectionComponents;
|
|
23
|
-
formatedCollectionComponents: typeof formatedCollectionComponents;
|
|
24
|
-
refFormatedCollectionComponents: typeof refFormatedCollectionComponents;
|
|
25
|
-
} {
|
|
26
|
-
const model_components_db = getTable<ModelComponentRecord>("model_components");
|
|
27
|
-
const model_components_relation_db = getTable<ModelComponentRelationRecord>(
|
|
28
|
-
"model_components_relation",
|
|
29
|
-
);
|
|
30
|
-
const { getAllMeshComponents } = useDataMesh();
|
|
31
|
-
|
|
32
|
-
async function hasCollectionComponents(modelId: ModelId): Promise<boolean> {
|
|
33
|
-
const count = await model_components_db
|
|
34
|
-
.where("data_id")
|
|
35
|
-
.equals(modelId)
|
|
36
|
-
.and((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
|
|
37
|
-
.count();
|
|
38
|
-
return count > 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function getAllCollectionComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
42
|
-
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
43
|
-
return items
|
|
44
|
-
.filter((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
|
|
45
|
-
.map((component: ModelComponentRecord) => ({
|
|
46
|
-
id: component.geode_id,
|
|
47
|
-
geode_id: component.geode_id,
|
|
48
|
-
title: component.name,
|
|
49
|
-
category: component.type,
|
|
50
|
-
viewer_id: Number(component.viewer_id),
|
|
51
|
-
is_active: component.is_active,
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function fetchAllCollectionComponents(
|
|
56
|
-
modelId: ModelId,
|
|
57
|
-
): Promise<Record<string, CollectionComponent[]>> {
|
|
58
|
-
const components = await getAllCollectionComponents(modelId);
|
|
59
|
-
const relations = await model_components_relation_db.where("data_id").equals(modelId).toArray();
|
|
60
|
-
const allMeshComponents = await getAllMeshComponents(modelId);
|
|
61
|
-
const meshComponentsById: Record<string, FormattedComponent> = {};
|
|
62
|
-
for (const meshComponent of allMeshComponents) {
|
|
63
|
-
meshComponentsById[meshComponent.id] = meshComponent;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const byType: Record<string, CollectionComponent[]> = {};
|
|
67
|
-
for (const component of components) {
|
|
68
|
-
byType[component.category] ??= [];
|
|
69
|
-
const itemRelations = relations.filter(
|
|
70
|
-
(relation: ModelComponentRelationRecord) =>
|
|
71
|
-
relation.parent === component.id && relation.type === "collection",
|
|
72
|
-
);
|
|
73
|
-
const children = itemRelations
|
|
74
|
-
.map((relation: ModelComponentRelationRecord) => meshComponentsById[relation.child])
|
|
75
|
-
.filter((child): child is FormattedComponent => Boolean(child));
|
|
76
|
-
byType[component.category]?.push({
|
|
77
|
-
...component,
|
|
78
|
-
children,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return byType;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async function formatedCollectionComponents(
|
|
85
|
-
modelId: ModelId,
|
|
86
|
-
): Promise<CollectionComponentGroup[]> {
|
|
87
|
-
const byType = await fetchAllCollectionComponents(modelId);
|
|
88
|
-
const collectionTypes = Object.keys(byType);
|
|
89
|
-
|
|
90
|
-
return collectionTypes
|
|
91
|
-
.filter((type) => (byType[type]?.length ?? 0) > 0)
|
|
92
|
-
.map((type) => ({
|
|
93
|
-
id: type,
|
|
94
|
-
title: pluralize(type),
|
|
95
|
-
children: byType[type] ?? [],
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function refFormatedCollectionComponents(
|
|
100
|
-
modelId: ModelId,
|
|
101
|
-
): Ref<CollectionComponentGroup[] | undefined> {
|
|
102
|
-
return useObservable(
|
|
103
|
-
liveObservable(async () => {
|
|
104
|
-
const groups = await formatedCollectionComponents(modelId);
|
|
105
|
-
return groups;
|
|
106
|
-
}),
|
|
107
|
-
{
|
|
108
|
-
initialValue: undefined,
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
hasCollectionComponents,
|
|
115
|
-
getAllCollectionComponents,
|
|
116
|
-
fetchAllCollectionComponents,
|
|
117
|
-
formatedCollectionComponents,
|
|
118
|
-
refFormatedCollectionComponents,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export type { CollectionComponent, CollectionComponentGroup };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import type { DataIdentified, GeodeIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
2
|
-
import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
|
|
3
|
-
import type { Table } from "dexie";
|
|
4
|
-
import type { ViewerId } from "@geode/opengeodeweb-viewer/schema_types";
|
|
5
|
-
import { database } from "@ogw_internal/database/database.js";
|
|
6
|
-
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
7
|
-
import { useObservable } from "@vueuse/rxjs";
|
|
8
|
-
|
|
9
|
-
interface ModelComponentRecord extends DataIdentified, GeodeIdentified {
|
|
10
|
-
type: string;
|
|
11
|
-
viewer_id: string | number;
|
|
12
|
-
name: string;
|
|
13
|
-
is_active: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface FormattedComponent extends Readonly<GeodeIdentified> {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly title: string;
|
|
19
|
-
readonly category: string;
|
|
20
|
-
readonly viewer_id: ViewerId;
|
|
21
|
-
readonly is_active: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type FormattedComponentGroup = ReadonlyTreeGroup<FormattedComponent>;
|
|
25
|
-
|
|
26
|
-
function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedComponent {
|
|
27
|
-
return {
|
|
28
|
-
id: meshComponent.geode_id,
|
|
29
|
-
geode_id: meshComponent.geode_id,
|
|
30
|
-
title: meshComponent.name,
|
|
31
|
-
category: meshComponent.type,
|
|
32
|
-
viewer_id: Math.trunc(Number(meshComponent.viewer_id)),
|
|
33
|
-
is_active: meshComponent.is_active,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// oxlint-disable-next-line eslint/max-lines-per-function
|
|
38
|
-
function useDataMesh(): {
|
|
39
|
-
formatedMeshComponents: typeof formatedMeshComponents;
|
|
40
|
-
refFormatedMeshComponents: typeof refFormatedMeshComponents;
|
|
41
|
-
getMeshComponentsByType: typeof getMeshComponentsByType;
|
|
42
|
-
getAllMeshComponents: typeof getAllMeshComponents;
|
|
43
|
-
fetchAllMeshComponents: typeof fetchAllMeshComponents;
|
|
44
|
-
getMeshComponentGeodeIds: typeof getMeshComponentGeodeIds;
|
|
45
|
-
getCornersGeodeIds: typeof getCornersGeodeIds;
|
|
46
|
-
getLinesGeodeIds: typeof getLinesGeodeIds;
|
|
47
|
-
getSurfacesGeodeIds: typeof getSurfacesGeodeIds;
|
|
48
|
-
getBlocksGeodeIds: typeof getBlocksGeodeIds;
|
|
49
|
-
} {
|
|
50
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- database's table map is dynamically typed at runtime.
|
|
51
|
-
const model_components_db = database.model_components as unknown as Table<
|
|
52
|
-
ModelComponentRecord,
|
|
53
|
-
string
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
async function formatedMeshComponents(modelId: ModelId): Promise<FormattedComponentGroup[]> {
|
|
57
|
-
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
58
|
-
const componentTitles: Record<string, string> = {
|
|
59
|
-
Corner: "Corners",
|
|
60
|
-
Line: "Lines",
|
|
61
|
-
Surface: "Surfaces",
|
|
62
|
-
Block: "Blocks",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const componentsByType: Record<string, ModelComponentRecord[]> = {};
|
|
66
|
-
for (const component_item of items) {
|
|
67
|
-
if (componentTitles[component_item.type] !== undefined) {
|
|
68
|
-
componentsByType[component_item.type] ??= [];
|
|
69
|
-
componentsByType[component_item.type]?.push(component_item);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return Object.keys(componentTitles)
|
|
74
|
-
.filter((type) => componentsByType[type])
|
|
75
|
-
.map((type) => ({
|
|
76
|
-
id: type,
|
|
77
|
-
title: componentTitles[type] ?? type,
|
|
78
|
-
children: (componentsByType[type] ?? []).map((item: ModelComponentRecord) =>
|
|
79
|
-
toFormattedComponent(item),
|
|
80
|
-
),
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function refFormatedMeshComponents(modelId: ModelId): Ref<FormattedComponentGroup[] | undefined> {
|
|
85
|
-
return useObservable(
|
|
86
|
-
liveObservable(async () => {
|
|
87
|
-
const components = await formatedMeshComponents(modelId);
|
|
88
|
-
return components;
|
|
89
|
-
}),
|
|
90
|
-
{
|
|
91
|
-
initialValue: undefined,
|
|
92
|
-
},
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function getMeshComponentsByType(
|
|
97
|
-
modelId: ModelId,
|
|
98
|
-
type: string,
|
|
99
|
-
): Promise<FormattedComponent[]> {
|
|
100
|
-
const components = await model_components_db
|
|
101
|
-
.where("[data_id+type]")
|
|
102
|
-
.equals([modelId, type])
|
|
103
|
-
.toArray();
|
|
104
|
-
return components.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function getAllMeshComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
108
|
-
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
109
|
-
return items.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function fetchAllMeshComponents(
|
|
113
|
-
modelId: ModelId,
|
|
114
|
-
): Promise<Record<string, FormattedComponent[]>> {
|
|
115
|
-
const components = await getAllMeshComponents(modelId);
|
|
116
|
-
const byType: Record<string, FormattedComponent[]> = {};
|
|
117
|
-
for (const component of components) {
|
|
118
|
-
byType[component.category] ??= [];
|
|
119
|
-
byType[component.category]?.push(component);
|
|
120
|
-
}
|
|
121
|
-
return byType;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async function getMeshComponentGeodeIds(modelId: ModelId, type: string): Promise<string[]> {
|
|
125
|
-
const components = await model_components_db
|
|
126
|
-
.where("[data_id+type]")
|
|
127
|
-
.equals([modelId, type])
|
|
128
|
-
.toArray();
|
|
129
|
-
return components.map((component: ModelComponentRecord) => component.geode_id);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async function getCornersGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
133
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Corner");
|
|
134
|
-
return geodeIds;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async function getLinesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
138
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Line");
|
|
139
|
-
return geodeIds;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async function getSurfacesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
143
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Surface");
|
|
144
|
-
return geodeIds;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function getBlocksGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
148
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Block");
|
|
149
|
-
return geodeIds;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
formatedMeshComponents,
|
|
154
|
-
refFormatedMeshComponents,
|
|
155
|
-
getMeshComponentsByType,
|
|
156
|
-
getAllMeshComponents,
|
|
157
|
-
fetchAllMeshComponents,
|
|
158
|
-
getMeshComponentGeodeIds,
|
|
159
|
-
getCornersGeodeIds,
|
|
160
|
-
getLinesGeodeIds,
|
|
161
|
-
getSurfacesGeodeIds,
|
|
162
|
-
getBlocksGeodeIds,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export { toFormattedComponent, useDataMesh };
|
|
167
|
-
export type { ModelComponentRecord, FormattedComponent, FormattedComponentGroup };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { DataIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
2
|
-
import {
|
|
3
|
-
type FormattedComponent,
|
|
4
|
-
type ModelComponentRecord,
|
|
5
|
-
toFormattedComponent,
|
|
6
|
-
} from "./mesh.js";
|
|
7
|
-
import { Dexie } from "dexie";
|
|
8
|
-
import { getTable } from "@ogw_internal/database/database.js";
|
|
9
|
-
|
|
10
|
-
interface ComponentRelations {
|
|
11
|
-
readonly boundaries: readonly FormattedComponent[];
|
|
12
|
-
readonly internals: readonly FormattedComponent[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface ModelComponentRelationRecord extends DataIdentified {
|
|
16
|
-
parent: string;
|
|
17
|
-
child: string;
|
|
18
|
-
type: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const RELATION_KEYS: Readonly<Record<string, keyof ComponentRelations>> = {
|
|
22
|
-
boundary: "boundaries",
|
|
23
|
-
internal: "internals",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type MutableComponentRelations = { [Key in keyof ComponentRelations]: FormattedComponent[] };
|
|
27
|
-
|
|
28
|
-
function groupRelationsByParent(
|
|
29
|
-
relations: readonly ModelComponentRelationRecord[],
|
|
30
|
-
components: readonly FormattedComponent[],
|
|
31
|
-
): Record<string, ComponentRelations> {
|
|
32
|
-
const componentsById = new Map(components.map((component) => [component.id, component]));
|
|
33
|
-
const byParent: Record<string, MutableComponentRelations> = {};
|
|
34
|
-
for (const relation of relations) {
|
|
35
|
-
const key = RELATION_KEYS[relation.type];
|
|
36
|
-
const child = componentsById.get(relation.child);
|
|
37
|
-
if (key !== undefined && child !== undefined) {
|
|
38
|
-
byParent[relation.parent] ??= { boundaries: [], internals: [] };
|
|
39
|
-
byParent[relation.parent]?.[key].push(child);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return byParent;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function useDataRelations(): {
|
|
46
|
-
getComponentRelations: typeof getComponentRelations;
|
|
47
|
-
fetchAllComponentRelations: typeof fetchAllComponentRelations;
|
|
48
|
-
} {
|
|
49
|
-
const model_components_db = getTable<ModelComponentRecord>("model_components");
|
|
50
|
-
const model_components_relation_db = getTable<ModelComponentRelationRecord>(
|
|
51
|
-
"model_components_relation",
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
async function getRelatedComponents(
|
|
55
|
-
modelId: ModelId,
|
|
56
|
-
relations: readonly ModelComponentRelationRecord[],
|
|
57
|
-
type: string,
|
|
58
|
-
): Promise<FormattedComponent[]> {
|
|
59
|
-
const keys = relations
|
|
60
|
-
.filter((relation) => relation.type === type)
|
|
61
|
-
.map((relation) => [modelId, relation.child]);
|
|
62
|
-
const components = await model_components_db.where("[data_id+geode_id]").anyOf(keys).toArray();
|
|
63
|
-
return components.map((component) => toFormattedComponent(component));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function getComponentRelations(
|
|
67
|
-
modelId: ModelId,
|
|
68
|
-
componentId: string,
|
|
69
|
-
): Promise<ComponentRelations> {
|
|
70
|
-
const relations = await model_components_relation_db
|
|
71
|
-
.where("[data_id+parent+child]")
|
|
72
|
-
.between([modelId, componentId, Dexie.minKey], [modelId, componentId, Dexie.maxKey])
|
|
73
|
-
.toArray();
|
|
74
|
-
const [boundaries, internals] = await Promise.all([
|
|
75
|
-
getRelatedComponents(modelId, relations, "boundary"),
|
|
76
|
-
getRelatedComponents(modelId, relations, "internal"),
|
|
77
|
-
]);
|
|
78
|
-
return { boundaries, internals };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// The boundaries and internals of every component of the model, among the given components:
|
|
82
|
-
// The caller already holds them, so only the relations are read
|
|
83
|
-
async function fetchAllComponentRelations(
|
|
84
|
-
modelId: ModelId,
|
|
85
|
-
components: readonly FormattedComponent[],
|
|
86
|
-
): Promise<Record<string, ComponentRelations>> {
|
|
87
|
-
const relations = await model_components_relation_db.where("data_id").equals(modelId).toArray();
|
|
88
|
-
return groupRelationsByParent(relations, components);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { getComponentRelations, fetchAllComponentRelations };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export type { ComponentRelations, ModelComponentRelationRecord };
|