import { Core } from "./Core" ; import type { Segment , XEvent } from "../types" ; /** performing combination of polygons, so only deal with already-processed segments */ export class CombineCore extends Core { public combine ( segments1 , inverted1 , segments2 , inverted2 ) { segments1 . forEach ( ( seg ) => this . events . addSegment ( seg . copy ( ) , true ) ) ; segments2 . forEach ( ( seg ) => this . events . addSegment ( seg . copy ( ) , false ) ) ; return this . calculate ( inverted1 , inverted2 ) ; } protected mergeFill ( ev , eve ) { eve . seg . otherFill = ev . seg . fill ; } protected calculateFill ( ev , below , polyInverted1 , polyInverted2 ) { if ( ev . seg . otherFill === null ) { let inside ; if ( ! below ) { inside = ev . primary ? polyInverted2 : polyInverted1 ; } else { inside = ev . primary === below . primary ? below . seg . otherFill ! . above : below . seg . fill . above ; } ev . seg . otherFill = { above : inside , below : inside , } ; } } }