Skip to content

Commit b2e40ab

Browse files
committed
test hasBlankingFill
1 parent a0b69c0 commit b2e40ab

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

core/frontend/src/internal/webgl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export { MeshGraphic } from "./render/webgl/Mesh";
1616
export { PolylineGeometry } from "./render/webgl/Polyline";
1717
export { RenderOrder } from "./render/webgl/RenderFlags";
1818
export { FrameBuffer } from "./render/webgl/FrameBuffer";
19-
export { ExternalTextureLoader, ExternalTextureRequest, Texture2DHandle, TextureHandle } from "./render/webgl/Texture";
19+
export { ExternalTextureLoader, Texture2DHandle, TextureHandle } from "./render/webgl/Texture";
2020
export { FeatureOverrides } from "./render/webgl/FeatureOverrides";
2121
export { GL } from "./render/webgl/GL";

core/frontend/src/test/render/webgl/Graphic.test.ts

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
import { afterAll, beforeAll, describe, expect, it } from "vitest";
77
import { IModelApp } from "../../../IModelApp";
8-
import { EmptyLocalization, FeatureTable, PackedFeatureTable } from "@itwin/core-common";
8+
import { EmptyLocalization, Feature, FeatureTable, FillFlags, GraphicParams, PackedFeatureTable } from "@itwin/core-common";
99
import { RenderGraphic } from "../../../render/RenderGraphic";
1010
import { Point3d, Range3d, Transform } from "@itwin/core-geometry";
1111
import { GraphicBuilder } from "../../../render/GraphicBuilder";
1212
import { GraphicBranch } from "../../../render/GraphicBranch";
1313
import { GraphicType } from "../../../common/render/GraphicType";
14+
import { Graphic, GraphicOwner } from "../../../internal/webgl";
1415

1516
describe("Graphic", () => {
1617
beforeAll(async () => IModelApp.startup({ localization: new EmptyLocalization() }));
@@ -28,14 +29,16 @@ describe("Graphic", () => {
2829
return range;
2930
}
3031

31-
function createGraphic(populate: (builder: GraphicBuilder) => void): RenderGraphic {
32+
function createGraphic(populate: (builder: GraphicBuilder) => void): Graphic {
3233
const builder = IModelApp.renderSystem.createGraphic({
3334
type: GraphicType.Scene,
3435
computeChordTolerance: () => 0.001,
3536
});
3637

3738
populate(builder);
38-
return builder.finish();
39+
const graphic = builder.finish();
40+
expect(graphic).instanceof(Graphic);
41+
return graphic as Graphic;
3942
}
4043

4144
function unionRange(ranges: Range3d[]): Range3d {
@@ -47,13 +50,15 @@ describe("Graphic", () => {
4750
return range;
4851
}
4952

50-
function createBranch(graphics: RenderGraphic[], transform: Transform): RenderGraphic {
53+
function createBranch(graphics: RenderGraphic[], transform: Transform): Graphic {
5154
const branch = new GraphicBranch();
5255
for (const graphic of graphics) {
5356
branch.add(graphic);
5457
}
5558

56-
return IModelApp.renderSystem.createBranch(branch, transform);
59+
const graphic = IModelApp.renderSystem.createBranch(branch, transform);
60+
expect(graphic).instanceof(Graphic);
61+
return graphic as Graphic;
5762
}
5863

5964
it("computes range", () => {
@@ -102,4 +107,37 @@ describe("Graphic", () => {
102107
const batchBranch = createBranch([batch], Transform.createTranslationXYZ(-10, 20, 0));
103108
expectRange(batchBranch, new Range3d(-10, 20, 0, -9, 22, 3));
104109
});
110+
111+
it("determines whether or not it has blanking fill", () => {
112+
const point = createGraphic((b) => b.addPointString([new Point3d()]));
113+
const line = createGraphic((b) => b.addLineString([new Point3d(0, 0, 0), new Point3d(1, 1, 1)]));
114+
const shape = createGraphic((b) => b.addShape([new Point3d(0, 0, 0), new Point3d(1, 0, 0), new Point3d(1, 1, 0), new Point3d(0, 0, 0)]));
115+
const blankingShape = createGraphic((b) => {
116+
const params = new GraphicParams();
117+
params.fillFlags = FillFlags.Blanking;
118+
b.activateGraphicParams(params);
119+
b.addShape([new Point3d(0, 0, 0), new Point3d(1, 0, 0), new Point3d(1, 1, 0), new Point3d(0, 0, 0)]);
120+
});
121+
122+
expect(point.hasBlankingFill).to.be.false;
123+
expect(line.hasBlankingFill).to.be.false;
124+
expect(shape.hasBlankingFill).to.be.false;
125+
expect(blankingShape.hasBlankingFill).to.be.true;
126+
127+
const shapeOwner = IModelApp.renderSystem.createGraphicOwner(shape) as GraphicOwner;
128+
expect(shapeOwner.hasBlankingFill).to.be.false;
129+
const blankingOwner = IModelApp.renderSystem.createGraphicOwner(blankingShape) as GraphicOwner;
130+
expect(blankingOwner.hasBlankingFill).to.be.true;
131+
132+
const list = IModelApp.renderSystem.createGraphicList([blankingOwner, shapeOwner]) as Graphic;
133+
expect(list.hasBlankingFill).to.be.true;
134+
135+
const features = new FeatureTable(100);
136+
features.insert(new Feature("0x123"));
137+
const batch = IModelApp.renderSystem.createBatch(list, features.pack(), new Range3d(0, 0, 0, 1, 1, 1)) as Graphic;
138+
expect(batch.hasBlankingFill).to.be.true;
139+
140+
const branch = createBranch([batch], Transform.createIdentity());
141+
expect(branch.hasBlankingFill).to.be.true;
142+
});
105143
});

0 commit comments

Comments
 (0)