brepjs-bim 0.27.0 → 0.27.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.
- package/README.md +3 -0
- package/dist/bcf/bcfTypes.d.ts +27 -0
- package/dist/bcf/bcfWrite.d.ts +1 -0
- package/dist/bcf/index.d.ts +1 -1
- package/dist/brepjs-bim.cjs +111 -23
- package/dist/brepjs-bim.js +111 -23
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,9 @@ stable GlobalIds derived from component key paths. Hand-authoring specs against
|
|
|
21
21
|
the low-level path (and covers elements the declarative route doesn't yet). See the
|
|
22
22
|
[Declarative Models guide](https://brepjs.dev/families/overview).
|
|
23
23
|
|
|
24
|
+
The [BIM examples](https://brepjs.dev/examples/#bim) are complete programs that you can read and run in
|
|
25
|
+
the browser.
|
|
26
|
+
|
|
24
27
|
## Scope
|
|
25
28
|
|
|
26
29
|
Parametric authoring of the common IFC4 building elements plus the data layers that make a model
|
package/dist/bcf/bcfTypes.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface BcfContainerData {
|
|
|
16
16
|
}
|
|
17
17
|
export interface BcfVersion {
|
|
18
18
|
readonly versionId: '3.0';
|
|
19
|
+
/** BCF 2.1's element, outside the 3.0 schema; written only when set. */
|
|
19
20
|
readonly detailedVersion?: string | undefined;
|
|
20
21
|
}
|
|
21
22
|
export interface BcfProject {
|
|
@@ -25,6 +26,7 @@ export interface BcfProject {
|
|
|
25
26
|
export interface BcfTopic {
|
|
26
27
|
readonly guid: string;
|
|
27
28
|
readonly title: string;
|
|
29
|
+
/** Required by the BCF 3.0 schema, as are `topicStatus`, `creationDate` and `creationAuthor`. */
|
|
28
30
|
readonly topicType?: string | undefined;
|
|
29
31
|
readonly topicStatus?: string | undefined;
|
|
30
32
|
readonly priority?: string | undefined;
|
|
@@ -58,6 +60,31 @@ export interface BcfViewpoint {
|
|
|
58
60
|
readonly snapshotFile?: string | undefined;
|
|
59
61
|
readonly index?: number | undefined;
|
|
60
62
|
readonly components?: BcfComponents | undefined;
|
|
63
|
+
/** Required by the BCF 3.0 schema in every viewpoint file. */
|
|
64
|
+
readonly camera?: BcfCamera | undefined;
|
|
65
|
+
}
|
|
66
|
+
/** A point or direction in model coordinates, in metres. */
|
|
67
|
+
export type BcfVector = readonly [number, number, number];
|
|
68
|
+
export type BcfCamera = BcfOrthogonalCamera | BcfPerspectiveCamera;
|
|
69
|
+
export interface BcfOrthogonalCamera {
|
|
70
|
+
readonly kind: 'ORTHOGONAL';
|
|
71
|
+
readonly viewPoint: BcfVector;
|
|
72
|
+
readonly direction: BcfVector;
|
|
73
|
+
readonly upVector: BcfVector;
|
|
74
|
+
/** The view's visible height, in metres. */
|
|
75
|
+
readonly viewToWorldScale: number;
|
|
76
|
+
/** Width over height of the view. */
|
|
77
|
+
readonly aspectRatio: number;
|
|
78
|
+
}
|
|
79
|
+
export interface BcfPerspectiveCamera {
|
|
80
|
+
readonly kind: 'PERSPECTIVE';
|
|
81
|
+
readonly viewPoint: BcfVector;
|
|
82
|
+
readonly direction: BcfVector;
|
|
83
|
+
readonly upVector: BcfVector;
|
|
84
|
+
/** Vertical field of view, in degrees. */
|
|
85
|
+
readonly fieldOfView: number;
|
|
86
|
+
/** Width over height of the view. */
|
|
87
|
+
readonly aspectRatio: number;
|
|
61
88
|
}
|
|
62
89
|
export interface BcfComponents {
|
|
63
90
|
readonly selection?: readonly BcfComponent[] | undefined;
|
package/dist/bcf/bcfWrite.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { BcfContainerData, BcfFiles } from './bcfTypes.js';
|
|
|
6
6
|
* - `bcf.version` — container version marker
|
|
7
7
|
* - `project.bcfp` — project metadata
|
|
8
8
|
* - `{topicGuid}/markup.bcf` — one markup file per topic (topic, comments, viewpoints)
|
|
9
|
+
* - `{topicGuid}/{viewpoint}.bcfv`: one visualization file per viewpoint (components, camera)
|
|
9
10
|
*
|
|
10
11
|
* `FLAG: BCF_ZIP_PACKAGING_ABSENT` — to produce an actual `.bcfzip`, ZIP these
|
|
11
12
|
* entries with an external library; no ZIP dependency is declared in the
|
package/dist/bcf/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { BcfColoring, BcfComment, BcfComponent, BcfComponents, BcfContainerData, BcfFiles, BcfProject, BcfTopic, BcfVersion, BcfViewpoint, BcfVisibility, } from './bcfTypes.js';
|
|
1
|
+
export type { BcfCamera, BcfColoring, BcfComment, BcfComponent, BcfComponents, BcfContainerData, BcfFiles, BcfOrthogonalCamera, BcfPerspectiveCamera, BcfProject, BcfTopic, BcfVector, BcfVersion, BcfViewpoint, BcfVisibility, } from './bcfTypes.js';
|
|
2
2
|
export { serializeBcfFiles } from './bcfWrite.js';
|
|
3
3
|
export { parseBcfFiles } from './bcfRead.js';
|
package/dist/brepjs-bim.cjs
CHANGED
|
@@ -7584,10 +7584,10 @@ function beamToSolid(spec) {
|
|
|
7584
7584
|
]);
|
|
7585
7585
|
if (!prismResult.ok) return (0, brepjs.err)(fromBrepError(prismResult.error, "BEAM_EXTRUDE_FAILED", "Failed to extrude beam profile"));
|
|
7586
7586
|
const prism = own(prismResult.value);
|
|
7587
|
-
return validateGeneratedSolid(own((0, brepjs.rotate)(prism,
|
|
7588
|
-
0,
|
|
7587
|
+
return validateGeneratedSolid(own((0, brepjs.rotate)(prism, 120, { axis: [
|
|
7589
7588
|
1,
|
|
7590
|
-
|
|
7589
|
+
1,
|
|
7590
|
+
1
|
|
7591
7591
|
] })), {
|
|
7592
7592
|
code: "BEAM_INVALID_SOLID",
|
|
7593
7593
|
message: "Extruded beam solid failed validity check"
|
|
@@ -9806,7 +9806,7 @@ var BimModel = class {
|
|
|
9806
9806
|
return localId;
|
|
9807
9807
|
}
|
|
9808
9808
|
};
|
|
9809
|
-
// \0@oxc-project+runtime@0.
|
|
9809
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/usingCtx.js
|
|
9810
9810
|
function _usingCtx() {
|
|
9811
9811
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
9812
9812
|
var n = Error();
|
|
@@ -30849,6 +30849,7 @@ function childText(node, tag) {
|
|
|
30849
30849
|
* - `bcf.version` — container version marker
|
|
30850
30850
|
* - `project.bcfp` — project metadata
|
|
30851
30851
|
* - `{topicGuid}/markup.bcf` — one markup file per topic (topic, comments, viewpoints)
|
|
30852
|
+
* - `{topicGuid}/{viewpoint}.bcfv`: one visualization file per viewpoint (components, camera)
|
|
30852
30853
|
*
|
|
30853
30854
|
* `FLAG: BCF_ZIP_PACKAGING_ABSENT` — to produce an actual `.bcfzip`, ZIP these
|
|
30854
30855
|
* entries with an external library; no ZIP dependency is declared in the
|
|
@@ -30860,13 +30861,15 @@ function serializeBcfFiles(data) {
|
|
|
30860
30861
|
files.set("project.bcfp", writeProject(data));
|
|
30861
30862
|
for (const topic of data.topics) {
|
|
30862
30863
|
files.set(`${topic.guid}/markup.bcf`, writeMarkup(topic));
|
|
30863
|
-
for (const viewpoint of topic.viewpoints) if (viewpoint
|
|
30864
|
+
for (const viewpoint of topic.viewpoints) if (hasVisualization(viewpoint)) files.set(`${topic.guid}/${bcfvName(viewpoint)}`, writeVisualizationInfo(viewpoint));
|
|
30864
30865
|
}
|
|
30865
30866
|
return files;
|
|
30866
30867
|
}
|
|
30867
30868
|
function writeVersion(data) {
|
|
30868
|
-
const
|
|
30869
|
-
if (data.version.detailedVersion
|
|
30869
|
+
const open = `<Version VersionId="${escapeXmlAttr(data.version.versionId)}"`;
|
|
30870
|
+
if (data.version.detailedVersion === void 0) return xmlDocument(`${open} />`);
|
|
30871
|
+
const lines = [`${open}>`];
|
|
30872
|
+
lines.push(` <DetailedVersion>${escapeXmlText(data.version.detailedVersion)}</DetailedVersion>`);
|
|
30870
30873
|
lines.push("</Version>");
|
|
30871
30874
|
return xmlDocument(lines.join("\n"));
|
|
30872
30875
|
}
|
|
@@ -30882,8 +30885,6 @@ function writeProject(data) {
|
|
|
30882
30885
|
function writeMarkup(topic) {
|
|
30883
30886
|
const lines = ["<Markup>"];
|
|
30884
30887
|
lines.push(...writeTopic(topic).map(indent(1)));
|
|
30885
|
-
for (const comment of topic.comments) lines.push(...writeComment(comment).map(indent(1)));
|
|
30886
|
-
for (const viewpoint of topic.viewpoints) lines.push(...writeViewpoint(viewpoint).map(indent(1)));
|
|
30887
30888
|
lines.push("</Markup>");
|
|
30888
30889
|
return xmlDocument(lines.join("\n"));
|
|
30889
30890
|
}
|
|
@@ -30896,7 +30897,7 @@ function writeTopic(topic) {
|
|
|
30896
30897
|
inner.push(`<Title>${escapeXmlText(topic.title)}</Title>`);
|
|
30897
30898
|
pushOptional(inner, "Priority", topic.priority);
|
|
30898
30899
|
pushOptionalNum(inner, "Index", topic.index);
|
|
30899
|
-
|
|
30900
|
+
pushList(inner, "Labels", (topic.labels ?? []).map((label) => [`<Label>${escapeXmlText(label)}</Label>`]));
|
|
30900
30901
|
pushOptional(inner, "CreationDate", topic.creationDate);
|
|
30901
30902
|
pushOptional(inner, "CreationAuthor", topic.creationAuthor);
|
|
30902
30903
|
pushOptional(inner, "ModifiedDate", topic.modifiedDate);
|
|
@@ -30904,7 +30905,9 @@ function writeTopic(topic) {
|
|
|
30904
30905
|
pushOptional(inner, "DueDate", topic.dueDate);
|
|
30905
30906
|
pushOptional(inner, "AssignedTo", topic.assignedTo);
|
|
30906
30907
|
pushOptional(inner, "Description", topic.description);
|
|
30907
|
-
|
|
30908
|
+
pushList(inner, "RelatedTopics", (topic.relatedTopics ?? []).map((related) => [`<RelatedTopic Guid="${escapeXmlAttr(related)}" />`]));
|
|
30909
|
+
pushList(inner, "Comments", topic.comments.map(writeComment));
|
|
30910
|
+
pushList(inner, "Viewpoints", topic.viewpoints.map(writeViewpoint));
|
|
30908
30911
|
lines.push(...inner.map(indent(1)));
|
|
30909
30912
|
lines.push("</Topic>");
|
|
30910
30913
|
return lines;
|
|
@@ -30915,34 +30918,63 @@ function writeComment(comment) {
|
|
|
30915
30918
|
inner.push(`<Date>${escapeXmlText(comment.date)}</Date>`);
|
|
30916
30919
|
inner.push(`<Author>${escapeXmlText(comment.author)}</Author>`);
|
|
30917
30920
|
inner.push(`<Comment>${escapeXmlText(comment.comment)}</Comment>`);
|
|
30921
|
+
if (comment.viewpointRef !== void 0) inner.push(`<Viewpoint Guid="${escapeXmlAttr(comment.viewpointRef)}" />`);
|
|
30918
30922
|
pushOptional(inner, "ModifiedDate", comment.modifiedDate);
|
|
30919
30923
|
pushOptional(inner, "ModifiedAuthor", comment.modifiedAuthor);
|
|
30920
|
-
if (comment.viewpointRef !== void 0) inner.push(`<Viewpoint Guid="${escapeXmlAttr(comment.viewpointRef)}" />`);
|
|
30921
30924
|
lines.push(...inner.map(indent(1)));
|
|
30922
30925
|
lines.push("</Comment>");
|
|
30923
30926
|
return lines;
|
|
30924
30927
|
}
|
|
30925
30928
|
function writeViewpoint(viewpoint) {
|
|
30926
|
-
const lines = [`<
|
|
30929
|
+
const lines = [`<ViewPoint Guid="${escapeXmlAttr(viewpoint.guid)}">`];
|
|
30927
30930
|
const inner = [];
|
|
30928
|
-
if (viewpoint
|
|
30931
|
+
if (hasVisualization(viewpoint)) inner.push(`<Viewpoint>${escapeXmlText(bcfvName(viewpoint))}</Viewpoint>`);
|
|
30929
30932
|
pushOptional(inner, "Snapshot", viewpoint.snapshotFile);
|
|
30930
30933
|
pushOptionalNum(inner, "Index", viewpoint.index);
|
|
30931
30934
|
lines.push(...inner.map(indent(1)));
|
|
30932
|
-
lines.push("</
|
|
30935
|
+
lines.push("</ViewPoint>");
|
|
30933
30936
|
return lines;
|
|
30934
30937
|
}
|
|
30938
|
+
function hasVisualization(viewpoint) {
|
|
30939
|
+
return viewpoint.components !== void 0 || viewpoint.camera !== void 0 || viewpoint.viewpointFile !== void 0;
|
|
30940
|
+
}
|
|
30935
30941
|
/** The .bcfv filename a viewpoint's Components are written to / referenced by. */
|
|
30936
30942
|
function bcfvName(viewpoint) {
|
|
30937
30943
|
return viewpoint.viewpointFile ?? `${viewpoint.guid}.bcfv`;
|
|
30938
30944
|
}
|
|
30939
|
-
/** Serializes a viewpoint's Components into a standalone BCF 3.0 .bcfv document. */
|
|
30945
|
+
/** Serializes a viewpoint's Components and camera into a standalone BCF 3.0 .bcfv document. */
|
|
30940
30946
|
function writeVisualizationInfo(viewpoint) {
|
|
30941
30947
|
const lines = [`<VisualizationInfo Guid="${escapeXmlAttr(viewpoint.guid)}">`];
|
|
30942
30948
|
if (viewpoint.components !== void 0) lines.push(...writeComponents(viewpoint.components).map(indent(1)));
|
|
30949
|
+
if (viewpoint.camera !== void 0) lines.push(...writeCamera(viewpoint.camera).map(indent(1)));
|
|
30943
30950
|
lines.push("</VisualizationInfo>");
|
|
30944
30951
|
return xmlDocument(lines.join("\n"));
|
|
30945
30952
|
}
|
|
30953
|
+
function writeCamera(camera) {
|
|
30954
|
+
const tag = camera.kind === "ORTHOGONAL" ? "OrthogonalCamera" : "PerspectiveCamera";
|
|
30955
|
+
const inner = [
|
|
30956
|
+
...writeVector("CameraViewPoint", camera.viewPoint),
|
|
30957
|
+
...writeVector("CameraDirection", camera.direction),
|
|
30958
|
+
...writeVector("CameraUpVector", camera.upVector)
|
|
30959
|
+
];
|
|
30960
|
+
if (camera.kind === "ORTHOGONAL") inner.push(`<ViewToWorldScale>${camera.viewToWorldScale}</ViewToWorldScale>`);
|
|
30961
|
+
else inner.push(`<FieldOfView>${camera.fieldOfView}</FieldOfView>`);
|
|
30962
|
+
inner.push(`<AspectRatio>${camera.aspectRatio}</AspectRatio>`);
|
|
30963
|
+
return [
|
|
30964
|
+
`<${tag}>`,
|
|
30965
|
+
...inner.map(indent(1)),
|
|
30966
|
+
`</${tag}>`
|
|
30967
|
+
];
|
|
30968
|
+
}
|
|
30969
|
+
function writeVector(tag, [x, y, z]) {
|
|
30970
|
+
return [
|
|
30971
|
+
`<${tag}>`,
|
|
30972
|
+
` <X>${x}</X>`,
|
|
30973
|
+
` <Y>${y}</Y>`,
|
|
30974
|
+
` <Z>${z}</Z>`,
|
|
30975
|
+
`</${tag}>`
|
|
30976
|
+
];
|
|
30977
|
+
}
|
|
30946
30978
|
function writeComponents(components) {
|
|
30947
30979
|
const lines = ["<Components>"];
|
|
30948
30980
|
const inner = [];
|
|
@@ -30974,7 +31006,10 @@ function writeVisibility(visibility) {
|
|
|
30974
31006
|
}
|
|
30975
31007
|
function writeColoring(coloring) {
|
|
30976
31008
|
const lines = [`<Color Color="${escapeXmlAttr(coloring.color)}">`];
|
|
30977
|
-
|
|
31009
|
+
const inner = ["<Components>"];
|
|
31010
|
+
for (const c of coloring.components) inner.push(...writeComponent(c).map(indent(1)));
|
|
31011
|
+
inner.push("</Components>");
|
|
31012
|
+
lines.push(...inner.map(indent(1)));
|
|
30978
31013
|
lines.push("</Color>");
|
|
30979
31014
|
return lines;
|
|
30980
31015
|
}
|
|
@@ -30996,6 +31031,13 @@ function pushOptional(target, tag, value) {
|
|
|
30996
31031
|
function pushOptionalNum(target, tag, value) {
|
|
30997
31032
|
if (value !== void 0) target.push(`<${tag}>${value}</${tag}>`);
|
|
30998
31033
|
}
|
|
31034
|
+
/** A wrapper element around `items`, each already written as lines; nothing when empty. */
|
|
31035
|
+
function pushList(target, tag, items) {
|
|
31036
|
+
if (items.length === 0) return;
|
|
31037
|
+
target.push(`<${tag}>`);
|
|
31038
|
+
for (const item of items) target.push(...item.map(indent(1)));
|
|
31039
|
+
target.push(`</${tag}>`);
|
|
31040
|
+
}
|
|
30999
31041
|
function indent(levels) {
|
|
31000
31042
|
const pad = " ".repeat(levels);
|
|
31001
31043
|
return (line) => `${pad}${line}`;
|
|
@@ -31057,8 +31099,10 @@ function parseMarkup(xml, files, dir) {
|
|
|
31057
31099
|
const markup = parseXml(xml);
|
|
31058
31100
|
const topicEl = findChild(markup, "Topic");
|
|
31059
31101
|
if (topicEl === void 0) throw new Error("markup.bcf is missing a <Topic> element");
|
|
31060
|
-
const
|
|
31061
|
-
const
|
|
31102
|
+
const commentsEl = findChild(topicEl, "Comments");
|
|
31103
|
+
const viewpointsEl = findChild(topicEl, "Viewpoints");
|
|
31104
|
+
const comments = (commentsEl !== void 0 ? findChildren(commentsEl, "Comment") : findChildren(markup, "Comment")).map(parseComment);
|
|
31105
|
+
const viewpoints = (viewpointsEl !== void 0 ? findChildren(viewpointsEl, "ViewPoint") : findChildren(markup, "Viewpoints")).map((el) => parseViewpoint(el, files, dir));
|
|
31062
31106
|
const topic = {
|
|
31063
31107
|
guid: topicEl.attrs["Guid"] ?? "",
|
|
31064
31108
|
title: childText(topicEl, "Title") ?? "",
|
|
@@ -31076,9 +31120,13 @@ function parseMarkup(xml, files, dir) {
|
|
|
31076
31120
|
assign(topic, "dueDate", childText(topicEl, "DueDate"));
|
|
31077
31121
|
assign(topic, "assignedTo", childText(topicEl, "AssignedTo"));
|
|
31078
31122
|
assign(topic, "description", childText(topicEl, "Description"));
|
|
31079
|
-
const labels = findChildren(topicEl, "Labels").
|
|
31123
|
+
const labels = findChildren(topicEl, "Labels").flatMap((l) => {
|
|
31124
|
+
const nested = findChildren(l, "Label");
|
|
31125
|
+
if (nested.length > 0) return nested.map((n) => n.text);
|
|
31126
|
+
return l.text !== "" ? [l.text] : [];
|
|
31127
|
+
});
|
|
31080
31128
|
if (labels.length > 0) topic.labels = labels;
|
|
31081
|
-
const related = findChildren(topicEl, "RelatedTopic").map((r) => r.attrs["Guid"]).filter((g) => g !== void 0);
|
|
31129
|
+
const related = findChildren(findChild(topicEl, "RelatedTopics") ?? topicEl, "RelatedTopic").map((r) => r.attrs["Guid"]).filter((g) => g !== void 0);
|
|
31082
31130
|
if (related.length > 0) topic.relatedTopics = related;
|
|
31083
31131
|
return topic;
|
|
31084
31132
|
}
|
|
@@ -31105,12 +31153,51 @@ function parseViewpoint(el, files, dir) {
|
|
|
31105
31153
|
else if (viewpoint.viewpointFile !== void 0) {
|
|
31106
31154
|
const bcfvXml = files.get(`${dir}${viewpoint.viewpointFile}`);
|
|
31107
31155
|
if (bcfvXml !== void 0) {
|
|
31108
|
-
const
|
|
31156
|
+
const visInfo = parseXml(bcfvXml);
|
|
31157
|
+
const visEl = findChild(visInfo, "Components");
|
|
31109
31158
|
if (visEl !== void 0) viewpoint.components = parseComponents(visEl);
|
|
31159
|
+
const camera = parseCamera(visInfo);
|
|
31160
|
+
if (camera !== void 0) viewpoint.camera = camera;
|
|
31110
31161
|
}
|
|
31111
31162
|
}
|
|
31112
31163
|
return viewpoint;
|
|
31113
31164
|
}
|
|
31165
|
+
function parseCamera(visInfo) {
|
|
31166
|
+
const ortho = findChild(visInfo, "OrthogonalCamera");
|
|
31167
|
+
const persp = findChild(visInfo, "PerspectiveCamera");
|
|
31168
|
+
const el = ortho ?? persp;
|
|
31169
|
+
if (el === void 0) return void 0;
|
|
31170
|
+
const frame = {
|
|
31171
|
+
viewPoint: parseVector(el, "CameraViewPoint"),
|
|
31172
|
+
direction: parseVector(el, "CameraDirection"),
|
|
31173
|
+
upVector: parseVector(el, "CameraUpVector"),
|
|
31174
|
+
aspectRatio: requiredNumber(el, "AspectRatio")
|
|
31175
|
+
};
|
|
31176
|
+
return ortho !== void 0 ? {
|
|
31177
|
+
kind: "ORTHOGONAL",
|
|
31178
|
+
...frame,
|
|
31179
|
+
viewToWorldScale: requiredNumber(el, "ViewToWorldScale")
|
|
31180
|
+
} : {
|
|
31181
|
+
kind: "PERSPECTIVE",
|
|
31182
|
+
...frame,
|
|
31183
|
+
fieldOfView: requiredNumber(el, "FieldOfView")
|
|
31184
|
+
};
|
|
31185
|
+
}
|
|
31186
|
+
function parseVector(camera, tag) {
|
|
31187
|
+
const el = findChild(camera, tag);
|
|
31188
|
+
if (el === void 0) throw new Error(`<${camera.tag}> is missing <${tag}>`);
|
|
31189
|
+
return [
|
|
31190
|
+
requiredNumber(el, "X"),
|
|
31191
|
+
requiredNumber(el, "Y"),
|
|
31192
|
+
requiredNumber(el, "Z")
|
|
31193
|
+
];
|
|
31194
|
+
}
|
|
31195
|
+
function requiredNumber(el, tag) {
|
|
31196
|
+
const text = childText(el, tag);
|
|
31197
|
+
const value = Number(text);
|
|
31198
|
+
if (text === void 0 || text === "" || !Number.isFinite(value)) throw new Error(`<${el.tag}> has no numeric <${tag}>`);
|
|
31199
|
+
return value;
|
|
31200
|
+
}
|
|
31114
31201
|
function parseComponents(el) {
|
|
31115
31202
|
const components = {};
|
|
31116
31203
|
const selectionEl = findChild(el, "Selection");
|
|
@@ -31122,9 +31209,10 @@ function parseComponents(el) {
|
|
|
31122
31209
|
return components;
|
|
31123
31210
|
}
|
|
31124
31211
|
function parseColoring(el) {
|
|
31212
|
+
const componentsEl = findChild(el, "Components") ?? el;
|
|
31125
31213
|
return {
|
|
31126
31214
|
color: el.attrs["Color"] ?? "",
|
|
31127
|
-
components: findChildren(
|
|
31215
|
+
components: findChildren(componentsEl, "Component").map(parseComponent)
|
|
31128
31216
|
};
|
|
31129
31217
|
}
|
|
31130
31218
|
function parseVisibility(el) {
|
package/dist/brepjs-bim.js
CHANGED
|
@@ -7562,10 +7562,10 @@ function beamToSolid(spec) {
|
|
|
7562
7562
|
]);
|
|
7563
7563
|
if (!prismResult.ok) return err(fromBrepError(prismResult.error, "BEAM_EXTRUDE_FAILED", "Failed to extrude beam profile"));
|
|
7564
7564
|
const prism = own(prismResult.value);
|
|
7565
|
-
return validateGeneratedSolid(own(rotate(prism,
|
|
7566
|
-
0,
|
|
7565
|
+
return validateGeneratedSolid(own(rotate(prism, 120, { axis: [
|
|
7567
7566
|
1,
|
|
7568
|
-
|
|
7567
|
+
1,
|
|
7568
|
+
1
|
|
7569
7569
|
] })), {
|
|
7570
7570
|
code: "BEAM_INVALID_SOLID",
|
|
7571
7571
|
message: "Extruded beam solid failed validity check"
|
|
@@ -9784,7 +9784,7 @@ var BimModel = class {
|
|
|
9784
9784
|
return localId;
|
|
9785
9785
|
}
|
|
9786
9786
|
};
|
|
9787
|
-
// \0@oxc-project+runtime@0.
|
|
9787
|
+
// \0@oxc-project+runtime@0.156.0/helpers/esm/usingCtx.js
|
|
9788
9788
|
function _usingCtx() {
|
|
9789
9789
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
9790
9790
|
var n = Error();
|
|
@@ -30827,6 +30827,7 @@ function childText(node, tag) {
|
|
|
30827
30827
|
* - `bcf.version` — container version marker
|
|
30828
30828
|
* - `project.bcfp` — project metadata
|
|
30829
30829
|
* - `{topicGuid}/markup.bcf` — one markup file per topic (topic, comments, viewpoints)
|
|
30830
|
+
* - `{topicGuid}/{viewpoint}.bcfv`: one visualization file per viewpoint (components, camera)
|
|
30830
30831
|
*
|
|
30831
30832
|
* `FLAG: BCF_ZIP_PACKAGING_ABSENT` — to produce an actual `.bcfzip`, ZIP these
|
|
30832
30833
|
* entries with an external library; no ZIP dependency is declared in the
|
|
@@ -30838,13 +30839,15 @@ function serializeBcfFiles(data) {
|
|
|
30838
30839
|
files.set("project.bcfp", writeProject(data));
|
|
30839
30840
|
for (const topic of data.topics) {
|
|
30840
30841
|
files.set(`${topic.guid}/markup.bcf`, writeMarkup(topic));
|
|
30841
|
-
for (const viewpoint of topic.viewpoints) if (viewpoint
|
|
30842
|
+
for (const viewpoint of topic.viewpoints) if (hasVisualization(viewpoint)) files.set(`${topic.guid}/${bcfvName(viewpoint)}`, writeVisualizationInfo(viewpoint));
|
|
30842
30843
|
}
|
|
30843
30844
|
return files;
|
|
30844
30845
|
}
|
|
30845
30846
|
function writeVersion(data) {
|
|
30846
|
-
const
|
|
30847
|
-
if (data.version.detailedVersion
|
|
30847
|
+
const open = `<Version VersionId="${escapeXmlAttr(data.version.versionId)}"`;
|
|
30848
|
+
if (data.version.detailedVersion === void 0) return xmlDocument(`${open} />`);
|
|
30849
|
+
const lines = [`${open}>`];
|
|
30850
|
+
lines.push(` <DetailedVersion>${escapeXmlText(data.version.detailedVersion)}</DetailedVersion>`);
|
|
30848
30851
|
lines.push("</Version>");
|
|
30849
30852
|
return xmlDocument(lines.join("\n"));
|
|
30850
30853
|
}
|
|
@@ -30860,8 +30863,6 @@ function writeProject(data) {
|
|
|
30860
30863
|
function writeMarkup(topic) {
|
|
30861
30864
|
const lines = ["<Markup>"];
|
|
30862
30865
|
lines.push(...writeTopic(topic).map(indent(1)));
|
|
30863
|
-
for (const comment of topic.comments) lines.push(...writeComment(comment).map(indent(1)));
|
|
30864
|
-
for (const viewpoint of topic.viewpoints) lines.push(...writeViewpoint(viewpoint).map(indent(1)));
|
|
30865
30866
|
lines.push("</Markup>");
|
|
30866
30867
|
return xmlDocument(lines.join("\n"));
|
|
30867
30868
|
}
|
|
@@ -30874,7 +30875,7 @@ function writeTopic(topic) {
|
|
|
30874
30875
|
inner.push(`<Title>${escapeXmlText(topic.title)}</Title>`);
|
|
30875
30876
|
pushOptional(inner, "Priority", topic.priority);
|
|
30876
30877
|
pushOptionalNum(inner, "Index", topic.index);
|
|
30877
|
-
|
|
30878
|
+
pushList(inner, "Labels", (topic.labels ?? []).map((label) => [`<Label>${escapeXmlText(label)}</Label>`]));
|
|
30878
30879
|
pushOptional(inner, "CreationDate", topic.creationDate);
|
|
30879
30880
|
pushOptional(inner, "CreationAuthor", topic.creationAuthor);
|
|
30880
30881
|
pushOptional(inner, "ModifiedDate", topic.modifiedDate);
|
|
@@ -30882,7 +30883,9 @@ function writeTopic(topic) {
|
|
|
30882
30883
|
pushOptional(inner, "DueDate", topic.dueDate);
|
|
30883
30884
|
pushOptional(inner, "AssignedTo", topic.assignedTo);
|
|
30884
30885
|
pushOptional(inner, "Description", topic.description);
|
|
30885
|
-
|
|
30886
|
+
pushList(inner, "RelatedTopics", (topic.relatedTopics ?? []).map((related) => [`<RelatedTopic Guid="${escapeXmlAttr(related)}" />`]));
|
|
30887
|
+
pushList(inner, "Comments", topic.comments.map(writeComment));
|
|
30888
|
+
pushList(inner, "Viewpoints", topic.viewpoints.map(writeViewpoint));
|
|
30886
30889
|
lines.push(...inner.map(indent(1)));
|
|
30887
30890
|
lines.push("</Topic>");
|
|
30888
30891
|
return lines;
|
|
@@ -30893,34 +30896,63 @@ function writeComment(comment) {
|
|
|
30893
30896
|
inner.push(`<Date>${escapeXmlText(comment.date)}</Date>`);
|
|
30894
30897
|
inner.push(`<Author>${escapeXmlText(comment.author)}</Author>`);
|
|
30895
30898
|
inner.push(`<Comment>${escapeXmlText(comment.comment)}</Comment>`);
|
|
30899
|
+
if (comment.viewpointRef !== void 0) inner.push(`<Viewpoint Guid="${escapeXmlAttr(comment.viewpointRef)}" />`);
|
|
30896
30900
|
pushOptional(inner, "ModifiedDate", comment.modifiedDate);
|
|
30897
30901
|
pushOptional(inner, "ModifiedAuthor", comment.modifiedAuthor);
|
|
30898
|
-
if (comment.viewpointRef !== void 0) inner.push(`<Viewpoint Guid="${escapeXmlAttr(comment.viewpointRef)}" />`);
|
|
30899
30902
|
lines.push(...inner.map(indent(1)));
|
|
30900
30903
|
lines.push("</Comment>");
|
|
30901
30904
|
return lines;
|
|
30902
30905
|
}
|
|
30903
30906
|
function writeViewpoint(viewpoint) {
|
|
30904
|
-
const lines = [`<
|
|
30907
|
+
const lines = [`<ViewPoint Guid="${escapeXmlAttr(viewpoint.guid)}">`];
|
|
30905
30908
|
const inner = [];
|
|
30906
|
-
if (viewpoint
|
|
30909
|
+
if (hasVisualization(viewpoint)) inner.push(`<Viewpoint>${escapeXmlText(bcfvName(viewpoint))}</Viewpoint>`);
|
|
30907
30910
|
pushOptional(inner, "Snapshot", viewpoint.snapshotFile);
|
|
30908
30911
|
pushOptionalNum(inner, "Index", viewpoint.index);
|
|
30909
30912
|
lines.push(...inner.map(indent(1)));
|
|
30910
|
-
lines.push("</
|
|
30913
|
+
lines.push("</ViewPoint>");
|
|
30911
30914
|
return lines;
|
|
30912
30915
|
}
|
|
30916
|
+
function hasVisualization(viewpoint) {
|
|
30917
|
+
return viewpoint.components !== void 0 || viewpoint.camera !== void 0 || viewpoint.viewpointFile !== void 0;
|
|
30918
|
+
}
|
|
30913
30919
|
/** The .bcfv filename a viewpoint's Components are written to / referenced by. */
|
|
30914
30920
|
function bcfvName(viewpoint) {
|
|
30915
30921
|
return viewpoint.viewpointFile ?? `${viewpoint.guid}.bcfv`;
|
|
30916
30922
|
}
|
|
30917
|
-
/** Serializes a viewpoint's Components into a standalone BCF 3.0 .bcfv document. */
|
|
30923
|
+
/** Serializes a viewpoint's Components and camera into a standalone BCF 3.0 .bcfv document. */
|
|
30918
30924
|
function writeVisualizationInfo(viewpoint) {
|
|
30919
30925
|
const lines = [`<VisualizationInfo Guid="${escapeXmlAttr(viewpoint.guid)}">`];
|
|
30920
30926
|
if (viewpoint.components !== void 0) lines.push(...writeComponents(viewpoint.components).map(indent(1)));
|
|
30927
|
+
if (viewpoint.camera !== void 0) lines.push(...writeCamera(viewpoint.camera).map(indent(1)));
|
|
30921
30928
|
lines.push("</VisualizationInfo>");
|
|
30922
30929
|
return xmlDocument(lines.join("\n"));
|
|
30923
30930
|
}
|
|
30931
|
+
function writeCamera(camera) {
|
|
30932
|
+
const tag = camera.kind === "ORTHOGONAL" ? "OrthogonalCamera" : "PerspectiveCamera";
|
|
30933
|
+
const inner = [
|
|
30934
|
+
...writeVector("CameraViewPoint", camera.viewPoint),
|
|
30935
|
+
...writeVector("CameraDirection", camera.direction),
|
|
30936
|
+
...writeVector("CameraUpVector", camera.upVector)
|
|
30937
|
+
];
|
|
30938
|
+
if (camera.kind === "ORTHOGONAL") inner.push(`<ViewToWorldScale>${camera.viewToWorldScale}</ViewToWorldScale>`);
|
|
30939
|
+
else inner.push(`<FieldOfView>${camera.fieldOfView}</FieldOfView>`);
|
|
30940
|
+
inner.push(`<AspectRatio>${camera.aspectRatio}</AspectRatio>`);
|
|
30941
|
+
return [
|
|
30942
|
+
`<${tag}>`,
|
|
30943
|
+
...inner.map(indent(1)),
|
|
30944
|
+
`</${tag}>`
|
|
30945
|
+
];
|
|
30946
|
+
}
|
|
30947
|
+
function writeVector(tag, [x, y, z]) {
|
|
30948
|
+
return [
|
|
30949
|
+
`<${tag}>`,
|
|
30950
|
+
` <X>${x}</X>`,
|
|
30951
|
+
` <Y>${y}</Y>`,
|
|
30952
|
+
` <Z>${z}</Z>`,
|
|
30953
|
+
`</${tag}>`
|
|
30954
|
+
];
|
|
30955
|
+
}
|
|
30924
30956
|
function writeComponents(components) {
|
|
30925
30957
|
const lines = ["<Components>"];
|
|
30926
30958
|
const inner = [];
|
|
@@ -30952,7 +30984,10 @@ function writeVisibility(visibility) {
|
|
|
30952
30984
|
}
|
|
30953
30985
|
function writeColoring(coloring) {
|
|
30954
30986
|
const lines = [`<Color Color="${escapeXmlAttr(coloring.color)}">`];
|
|
30955
|
-
|
|
30987
|
+
const inner = ["<Components>"];
|
|
30988
|
+
for (const c of coloring.components) inner.push(...writeComponent(c).map(indent(1)));
|
|
30989
|
+
inner.push("</Components>");
|
|
30990
|
+
lines.push(...inner.map(indent(1)));
|
|
30956
30991
|
lines.push("</Color>");
|
|
30957
30992
|
return lines;
|
|
30958
30993
|
}
|
|
@@ -30974,6 +31009,13 @@ function pushOptional(target, tag, value) {
|
|
|
30974
31009
|
function pushOptionalNum(target, tag, value) {
|
|
30975
31010
|
if (value !== void 0) target.push(`<${tag}>${value}</${tag}>`);
|
|
30976
31011
|
}
|
|
31012
|
+
/** A wrapper element around `items`, each already written as lines; nothing when empty. */
|
|
31013
|
+
function pushList(target, tag, items) {
|
|
31014
|
+
if (items.length === 0) return;
|
|
31015
|
+
target.push(`<${tag}>`);
|
|
31016
|
+
for (const item of items) target.push(...item.map(indent(1)));
|
|
31017
|
+
target.push(`</${tag}>`);
|
|
31018
|
+
}
|
|
30977
31019
|
function indent(levels) {
|
|
30978
31020
|
const pad = " ".repeat(levels);
|
|
30979
31021
|
return (line) => `${pad}${line}`;
|
|
@@ -31035,8 +31077,10 @@ function parseMarkup(xml, files, dir) {
|
|
|
31035
31077
|
const markup = parseXml(xml);
|
|
31036
31078
|
const topicEl = findChild(markup, "Topic");
|
|
31037
31079
|
if (topicEl === void 0) throw new Error("markup.bcf is missing a <Topic> element");
|
|
31038
|
-
const
|
|
31039
|
-
const
|
|
31080
|
+
const commentsEl = findChild(topicEl, "Comments");
|
|
31081
|
+
const viewpointsEl = findChild(topicEl, "Viewpoints");
|
|
31082
|
+
const comments = (commentsEl !== void 0 ? findChildren(commentsEl, "Comment") : findChildren(markup, "Comment")).map(parseComment);
|
|
31083
|
+
const viewpoints = (viewpointsEl !== void 0 ? findChildren(viewpointsEl, "ViewPoint") : findChildren(markup, "Viewpoints")).map((el) => parseViewpoint(el, files, dir));
|
|
31040
31084
|
const topic = {
|
|
31041
31085
|
guid: topicEl.attrs["Guid"] ?? "",
|
|
31042
31086
|
title: childText(topicEl, "Title") ?? "",
|
|
@@ -31054,9 +31098,13 @@ function parseMarkup(xml, files, dir) {
|
|
|
31054
31098
|
assign(topic, "dueDate", childText(topicEl, "DueDate"));
|
|
31055
31099
|
assign(topic, "assignedTo", childText(topicEl, "AssignedTo"));
|
|
31056
31100
|
assign(topic, "description", childText(topicEl, "Description"));
|
|
31057
|
-
const labels = findChildren(topicEl, "Labels").
|
|
31101
|
+
const labels = findChildren(topicEl, "Labels").flatMap((l) => {
|
|
31102
|
+
const nested = findChildren(l, "Label");
|
|
31103
|
+
if (nested.length > 0) return nested.map((n) => n.text);
|
|
31104
|
+
return l.text !== "" ? [l.text] : [];
|
|
31105
|
+
});
|
|
31058
31106
|
if (labels.length > 0) topic.labels = labels;
|
|
31059
|
-
const related = findChildren(topicEl, "RelatedTopic").map((r) => r.attrs["Guid"]).filter((g) => g !== void 0);
|
|
31107
|
+
const related = findChildren(findChild(topicEl, "RelatedTopics") ?? topicEl, "RelatedTopic").map((r) => r.attrs["Guid"]).filter((g) => g !== void 0);
|
|
31060
31108
|
if (related.length > 0) topic.relatedTopics = related;
|
|
31061
31109
|
return topic;
|
|
31062
31110
|
}
|
|
@@ -31083,12 +31131,51 @@ function parseViewpoint(el, files, dir) {
|
|
|
31083
31131
|
else if (viewpoint.viewpointFile !== void 0) {
|
|
31084
31132
|
const bcfvXml = files.get(`${dir}${viewpoint.viewpointFile}`);
|
|
31085
31133
|
if (bcfvXml !== void 0) {
|
|
31086
|
-
const
|
|
31134
|
+
const visInfo = parseXml(bcfvXml);
|
|
31135
|
+
const visEl = findChild(visInfo, "Components");
|
|
31087
31136
|
if (visEl !== void 0) viewpoint.components = parseComponents(visEl);
|
|
31137
|
+
const camera = parseCamera(visInfo);
|
|
31138
|
+
if (camera !== void 0) viewpoint.camera = camera;
|
|
31088
31139
|
}
|
|
31089
31140
|
}
|
|
31090
31141
|
return viewpoint;
|
|
31091
31142
|
}
|
|
31143
|
+
function parseCamera(visInfo) {
|
|
31144
|
+
const ortho = findChild(visInfo, "OrthogonalCamera");
|
|
31145
|
+
const persp = findChild(visInfo, "PerspectiveCamera");
|
|
31146
|
+
const el = ortho ?? persp;
|
|
31147
|
+
if (el === void 0) return void 0;
|
|
31148
|
+
const frame = {
|
|
31149
|
+
viewPoint: parseVector(el, "CameraViewPoint"),
|
|
31150
|
+
direction: parseVector(el, "CameraDirection"),
|
|
31151
|
+
upVector: parseVector(el, "CameraUpVector"),
|
|
31152
|
+
aspectRatio: requiredNumber(el, "AspectRatio")
|
|
31153
|
+
};
|
|
31154
|
+
return ortho !== void 0 ? {
|
|
31155
|
+
kind: "ORTHOGONAL",
|
|
31156
|
+
...frame,
|
|
31157
|
+
viewToWorldScale: requiredNumber(el, "ViewToWorldScale")
|
|
31158
|
+
} : {
|
|
31159
|
+
kind: "PERSPECTIVE",
|
|
31160
|
+
...frame,
|
|
31161
|
+
fieldOfView: requiredNumber(el, "FieldOfView")
|
|
31162
|
+
};
|
|
31163
|
+
}
|
|
31164
|
+
function parseVector(camera, tag) {
|
|
31165
|
+
const el = findChild(camera, tag);
|
|
31166
|
+
if (el === void 0) throw new Error(`<${camera.tag}> is missing <${tag}>`);
|
|
31167
|
+
return [
|
|
31168
|
+
requiredNumber(el, "X"),
|
|
31169
|
+
requiredNumber(el, "Y"),
|
|
31170
|
+
requiredNumber(el, "Z")
|
|
31171
|
+
];
|
|
31172
|
+
}
|
|
31173
|
+
function requiredNumber(el, tag) {
|
|
31174
|
+
const text = childText(el, tag);
|
|
31175
|
+
const value = Number(text);
|
|
31176
|
+
if (text === void 0 || text === "" || !Number.isFinite(value)) throw new Error(`<${el.tag}> has no numeric <${tag}>`);
|
|
31177
|
+
return value;
|
|
31178
|
+
}
|
|
31092
31179
|
function parseComponents(el) {
|
|
31093
31180
|
const components = {};
|
|
31094
31181
|
const selectionEl = findChild(el, "Selection");
|
|
@@ -31100,9 +31187,10 @@ function parseComponents(el) {
|
|
|
31100
31187
|
return components;
|
|
31101
31188
|
}
|
|
31102
31189
|
function parseColoring(el) {
|
|
31190
|
+
const componentsEl = findChild(el, "Components") ?? el;
|
|
31103
31191
|
return {
|
|
31104
31192
|
color: el.attrs["Color"] ?? "",
|
|
31105
|
-
components: findChildren(
|
|
31193
|
+
components: findChildren(componentsEl, "Component").map(parseComponent)
|
|
31106
31194
|
};
|
|
31107
31195
|
}
|
|
31108
31196
|
function parseVisibility(el) {
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,6 @@ export type { CobieModel, CobieJson, CobieExportMeta, CobieContactMeta, CobieCon
|
|
|
102
102
|
export { parseIdsXml, checkIdsData, checkIdsData as checkIds } from './ids/index.js';
|
|
103
103
|
export type { IdsDocument, IdsSpecification, IdsFacet, IdsRestriction, IdsCardinality, IdsCheckReport, IdsCheckResult, } from './ids/index.js';
|
|
104
104
|
export { serializeBcfFiles, parseBcfFiles } from './bcf/index.js';
|
|
105
|
-
export type { BcfColoring, BcfComment, BcfComponent, BcfComponents, BcfContainerData, BcfFiles, BcfProject, BcfTopic, BcfVersion, BcfViewpoint, BcfVisibility, } from './bcf/index.js';
|
|
105
|
+
export type { BcfCamera, BcfColoring, BcfComment, BcfComponent, BcfComponents, BcfContainerData, BcfFiles, BcfOrthogonalCamera, BcfPerspectiveCamera, BcfProject, BcfTopic, BcfVector, BcfVersion, BcfViewpoint, BcfVisibility, } from './bcf/index.js';
|
|
106
106
|
export { bcfError, idsError } from './errors/bimError.js';
|
|
107
107
|
export { familiesToBim, type FamiliesToBimOptions, type FamiliesBimResult, type ProxiedElement, } from './familiesAdapter.js';
|