@itwin/core-backend 5.1.0-dev.37 → 5.1.0-dev.38
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.
|
@@ -6,7 +6,7 @@ import { assert, expect } from "chai";
|
|
|
6
6
|
import { BentleyStatus, Id64, IModelStatus } from "@itwin/core-bentley";
|
|
7
7
|
import { Angle, AngleSweep, Arc3d, Box, ClipMaskXYZRangePlanes, ClipPlane, ClipPlaneContainment, ClipPrimitive, ClipShape, ClipVector, ConvexClipPlaneSet, CurveCollection, CurvePrimitive, Geometry, IndexedPolyface, InterpolationCurve3d, InterpolationCurve3dOptions, LineSegment3d, LineString3d, Loop, Matrix3d, Plane3dByOriginAndUnitNormal, Point2d, Point3d, Point3dArray, PointString3d, PolyfaceBuilder, Range2d, Range3d, SolidPrimitive, Sphere, StrokeOptions, Transform, Vector3d, YawPitchRollAngles, } from "@itwin/core-geometry";
|
|
8
8
|
import { AreaPattern, BackgroundFill, BRepGeometryOperation, Code, ColorByName, ColorDef, ElementGeometry, ElementGeometryOpcode, FillDisplay, GeometryClass, GeometryParams, GeometryStreamBuilder, GeometryStreamFlags, GeometryStreamIterator, Gradient, ImageGraphicCorners, IModel, LinePixels, LineStyle, MassPropertiesOperation, Placement3d, TextString, ThematicGradientMode, ThematicGradientSettings, ViewFlags, } from "@itwin/core-common";
|
|
9
|
-
import { _nativeDb, DefinitionModel, deleteElementTree, GeometryPart, LineStyleDefinition, PhysicalObject, Subject } from "../../core-backend";
|
|
9
|
+
import { _nativeDb, DefinitionModel, deleteElementTree, GeometryPart, LineStyleDefinition, PhysicalObject, SubCategory, Subject } from "../../core-backend";
|
|
10
10
|
import { createBRepDataProps } from "../GeometryTestUtil";
|
|
11
11
|
import { IModelTestUtils } from "../IModelTestUtils";
|
|
12
12
|
import { Timer } from "../TestUtils";
|
|
@@ -933,6 +933,54 @@ describe("GeometryStream", () => {
|
|
|
933
933
|
assert.isTrue(usageInfo.geometryPartIds.includes(partId));
|
|
934
934
|
assert.isTrue(usageInfo.usedIds.includes(partId));
|
|
935
935
|
});
|
|
936
|
+
it("create GeometricElement3d with material and sub-category", async () => {
|
|
937
|
+
const seedElement = imodel.elements.getElement("0x1d");
|
|
938
|
+
assert.exists(seedElement);
|
|
939
|
+
const subCategory = SubCategory.create(imodel, seedElement.category, "testSubCat", { weight: 2 });
|
|
940
|
+
const subCategoryId = imodel.elements.insertElement(subCategory.toJSON());
|
|
941
|
+
imodel.saveChanges();
|
|
942
|
+
const params = new GeometryParams(seedElement.category);
|
|
943
|
+
params.subCategoryId = subCategoryId;
|
|
944
|
+
params.materialId = "0x5";
|
|
945
|
+
const shape = Loop.create(LineString3d.create(Point3d.create(0, 0, 0), Point3d.create(1, 0, 0), Point3d.create(1, 1, 0), Point3d.create(0, 1, 0), Point3d.create(0, 0, 0)));
|
|
946
|
+
// Test flatbuffer roundtrip...
|
|
947
|
+
const builderF = new ElementGeometry.Builder();
|
|
948
|
+
builderF.appendGeometryParamsChange(params);
|
|
949
|
+
builderF.appendGeometryQuery(shape);
|
|
950
|
+
const elementPropsF = createPhysicalElementProps(seedElement);
|
|
951
|
+
elementPropsF.elementGeometryBuilderParams = { entryArray: builderF.entries };
|
|
952
|
+
const newIdF = imodel.elements.insertElement(elementPropsF);
|
|
953
|
+
assert.isTrue(Id64.isValidId64(newIdF));
|
|
954
|
+
imodel.saveChanges();
|
|
955
|
+
const onGeometry = (info) => {
|
|
956
|
+
assert.isTrue(undefined !== info.entryArray);
|
|
957
|
+
const it = new ElementGeometry.Iterator(info);
|
|
958
|
+
for (const entry of it) {
|
|
959
|
+
if (ElementGeometry.isGeometryQueryEntry(entry.value)) {
|
|
960
|
+
assert.isTrue(params.subCategoryId === entry.geomParams.subCategoryId && params.materialId === entry.geomParams.materialId);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
;
|
|
964
|
+
};
|
|
965
|
+
const status = imodel.elementGeometryRequest({ elementId: newIdF, onGeometry });
|
|
966
|
+
assert(IModelStatus.Success === status);
|
|
967
|
+
// Test JSON roundtrip...
|
|
968
|
+
const builderJ = new GeometryStreamBuilder();
|
|
969
|
+
builderJ.appendGeometryParamsChange(params);
|
|
970
|
+
builderJ.appendGeometry(shape);
|
|
971
|
+
const elementPropsJ = createPhysicalElementProps(seedElement);
|
|
972
|
+
elementPropsJ.geom = builderJ.geometryStream;
|
|
973
|
+
const newIdJ = imodel.elements.insertElement(elementPropsJ);
|
|
974
|
+
assert.isTrue(Id64.isValidId64(newIdJ));
|
|
975
|
+
imodel.saveChanges();
|
|
976
|
+
const value = imodel.elements.getElementProps({ id: newIdJ, wantGeometry: true });
|
|
977
|
+
assert.isDefined(value.geom);
|
|
978
|
+
const itLocal = new GeometryStreamIterator(value.geom, value.category);
|
|
979
|
+
for (const entry of itLocal) {
|
|
980
|
+
assert.equal(entry.primitive.type, "geometryQuery");
|
|
981
|
+
assert.isTrue(params.subCategoryId === entry.geomParams.subCategoryId && params.materialId === entry.geomParams.materialId);
|
|
982
|
+
}
|
|
983
|
+
});
|
|
936
984
|
it("create GeometricElement3d from world coordinate text using a newly added font", async () => {
|
|
937
985
|
// Set up element to be placed in iModel
|
|
938
986
|
const seedElement = imodel.elements.getElement("0x1d");
|