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