Skip to content

editor › Globals › SvgNester

Class: SvgNester

This Nester divides the given polygons into those that fit into the exportSettings.materialSize and those that don't using _separateOversizePolygons. They are then separately nested using SvgNest instances. When either one is finished, it triggers a check whether the other one has already finished and if so, it calls the callback function of the promise returned in the original nest call: completionPromise.

All of this is started with nest, which receives a list of polygons and returns the completionPromise.

Hierarchy

↳ Nester

↳ SvgNester

Index

Constructors

Properties

Methods

Object literals

Constructors

constructor

+ new SvgNester(groupRepresentationsMap: Map‹PlateGroup, IPlateGroup2DRepresentations›, materialSize?: [number, number], cancelToken?: CancelToken, maxSheets?: number): SvgNester

Overrides Nester.constructor

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:82

Parameters:

Name Type Description
groupRepresentationsMap Map‹PlateGroup, IPlateGroup2DRepresentations› a Map that maps PlateGroups to different 2D representations of them
materialSize? [number, number] the desired page size
cancelToken? CancelToken if provided, the nester will stop nesting if the token is cancelled
maxSheets? number -

Returns: SvgNester

Properties

Protected Readonly cancelToken

• cancelToken: any

Inherited from Nester.cancelToken

Defined in src/modules/kyub.core.svgObjExporter/src/export/Nester.ts:21


Private Readonly completionPromise

• completionPromise: ExternalControlPromise‹IPage[]› = new ExternalControlPromise()

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:82

The resolve callback for the promise returned in our nest method


Private Readonly debugLevel

• debugLevel: DebugLevel‹› = getDebugLevel("svgExport")

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:58

DebugLevel instance for this class


Private fittingNestingProgress

• fittingNestingProgress: number = 0

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:75


Private fittingNestingResult

• fittingNestingResult: IPage[] | null = null

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:68

The result of the fitting part nesting


Private fittingPercentage

• fittingPercentage: number = 1

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:77


Protected groupRepresentationsMap

• groupRepresentationsMap: Map‹PlateGroup, IPlateGroup2DRepresentations›

Inherited from Nester.groupRepresentationsMap

Defined in src/modules/kyub.core.svgObjExporter/src/export/Nester.ts:18


Protected height

• height: number

Inherited from Nester.height

Defined in src/modules/kyub.core.svgObjExporter/src/export/Nester.ts:20


Protected Readonly hintEventEmitter

• hintEventEmitter: EventEmitter‹object› = new EventEmitter<{ message: string; newExportSettings?; }>()

Inherited from PipelineEventsEmitter.hintEventEmitter

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:20


Private Optional maxSheets

• maxSheets? : number

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:93


Private oversizeNestingProgress

• oversizeNestingProgress: number = 0

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:76


Private oversizeNestingResult

• oversizeNestingResult: IPage[] | null = null

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:63

The result of the oversize part nesting


Protected Readonly progressEventEmitter

• progressEventEmitter: EventEmitter‹object› = new EventEmitter<{ stage: string; progress: number; }>()

Inherited from PipelineEventsEmitter.progressEventEmitter

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:12


Private svgNests

• svgNests: any[] = []

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:73

The SvgNest instances


Protected Readonly warningEventEmitter

• warningEventEmitter: EventEmitter‹object› = new EventEmitter<{ code: string; message: string; }>()

Inherited from PipelineEventsEmitter.warningEventEmitter

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:16


Protected width

• width: number

Inherited from Nester.width

Defined in src/modules/kyub.core.svgObjExporter/src/export/Nester.ts:19

Methods

Private _checkIsFinished

▸ _checkIsFinished(): void

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:283

Check whether both the fittingNestingResult and oversizeNestingResult have been set and if so call the finish callback

Returns: void


Private _convertPlacements

▸ _convertPlacements(placements: Placement[][], plateGroups: PlateGroup[], pageSize: object, sizeChanged: boolean): IPage[]

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:366

Convert placements from SvgNest to the expected pages structure

Parameters:

▪ placements: Placement[][]

the placements SvgNest produced

▪ plateGroups: PlateGroup[]

the plate groups that svgnest worked with so the group indices are correct

▪ pageSize: object

size of the pages the placements are on

Name Type
height number
width number

▪ sizeChanged: boolean

whether the size of the plates was changed from the user's requested size

Returns: IPage[]


Private _createOnRenderCallback

▸ _createOnRenderCallback(svgNest: SvgNest, plateGroups: PlateGroup[], onFinishCallback: function, debugInfoTag: string, pageSize: Vector2, sizeChanged: boolean): (Anonymous function)

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:301

Create a properly parametrized svgNest-onRender callback

Parameters:

▪ svgNest: SvgNest

the svg nester that runs the nesting this callback is for

▪ plateGroups: PlateGroup[]

the plate groups that are being nested

▪ onFinishCallback: function

the callback that should be called if the nesting has finished

▸ (placements: IPage[]): void

Parameters:

Name Type
placements IPage[]

▪ debugInfoTag: string

info tag for debug messages

▪ pageSize: Vector2

the page size the nester should place parts on

▪ sizeChanged: boolean

Whether the size changed

Returns: (Anonymous function)


Private _fitsWithinDefaultBin

▸ _fitsWithinDefaultBin(aabb: AABB): boolean

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:336

Returns true iff the given aabb fits in the plate size we want to nest all parts in

Parameters:

Name Type Description
aabb AABB the aabb that should fit

Returns: boolean


Private _getOversizeBin

▸ _getOversizeBin(polygons: MultiPolygon[]): Vector2

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:263

Calculate the minimum size within which all oversized parts will fit, guaranteed

Parameters:

Name Type Description
polygons MultiPolygon[] the oversize polygons that need to be placed

Returns: Vector2


Private _nestPolygonList

▸ _nestPolygonList(polygonList: MultiPolygon[], svgNest: SvgNest, onProgressFunction: function, onRenderFunction: function, binSize: Vector2): void

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:235

Nest a list of polygons by starting a SvgNest instance

Parameters:

▪ polygonList: MultiPolygon[]

list of polygons to nest

▪ svgNest: SvgNest

the SvgNest instance to start

▪ onProgressFunction: function

the onProgress callback for the svgNest instance

▸ (progress: number): void

Parameters:

Name Type
progress number

▪ onRenderFunction: function

the onRender callback for the svgNest instance

▸ (placements: any, svg: any, fillPercent: number, placedParts: number, totalParts: number): void

Parameters:

Name Type
placements any
svg any
fillPercent number
placedParts number
totalParts number

▪ binSize: Vector2

the binsize the svgNester should work with

Returns: void


Protected _onHint

▸ _onHint(hint: any): void

Inherited from PipelineEventsEmitter._onHint

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:45

Parameters:

Name Type
hint any

Returns: void


Protected _onProgress

▸ _onProgress(): void

Overrides PipelineEventsEmitter._onProgress

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:173

Update the overall progress using fitting and oversize nesting progress

Returns: void


Protected _onWarning

▸ _onWarning(warning: object): void

Inherited from PipelineEventsEmitter._onWarning

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:41

Parameters:

▪ warning: object

Name Type
code string
message string

Returns: void


Private _separateOversizePolygons

▸ _separateOversizePolygons(groupRepresentationsMap: Map‹PlateGroup, IPlateGroup2DRepresentations›): object

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:193

Separate all polygons that should be nested into those that fit in the default bin (i.e. page) size and those that do not

Parameters:

Name Type
groupRepresentationsMap Map‹PlateGroup, IPlateGroup2DRepresentations›

Returns: object

the sorted lists, with the polygon+cutoutPolygon lists converted into an object


Private _setPageSizesForOversizedPolygons

▸ _setPageSizesForOversizedPolygons(nestingResults: IPage[]): Promise‹void›

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:352

Parameters:

Name Type Description
nestingResults IPage[] The placements of each PlateGroup on its plate

Returns: Promise‹void›


Private _stop

▸ _stop(): void

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:183

Stop all nesting processes

Returns: void


getHeight

▸ getHeight(): number

Inherited from Nester.getHeight

Defined in src/modules/kyub.core.svgObjExporter/src/export/Nester.ts:52

Returns: number


getHintEventEmitter

▸ getHintEventEmitter(): IPublicEventEmitterInterface‹object›

Inherited from PipelineEventsEmitter.getHintEventEmitter

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:33

Returns: IPublicEventEmitterInterface‹object›


getProgressEventEmitter

▸ getProgressEventEmitter(): IPublicEventEmitterInterface‹object›

Inherited from PipelineEventsEmitter.getProgressEventEmitter

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:25

Returns: IPublicEventEmitterInterface‹object›


getWarningEventEmitter

▸ getWarningEventEmitter(): IPublicEventEmitterInterface‹object›

Inherited from PipelineEventsEmitter.getWarningEventEmitter

Defined in src/modules/kyub.core.svgObjExporter/src/PipelineEventsEmitter.ts:29

Returns: IPublicEventEmitterInterface‹object›


getWidth

▸ getWidth(): number

Inherited from Nester.getWidth

Defined in src/modules/kyub.core.svgObjExporter/src/export/Nester.ts:48

Returns: number


nest

▸ nest(spacing: number): Promise‹IPage[] | null›

Overrides Nester.nest

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:100

Parameters:

Name Type Default
spacing number 0

Returns: Promise‹IPage[] | null›

Object literals

Private config

▪ config: object

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:43

SvgNest configuration object

clipperScale

• clipperScale: number = 10000000

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:44

curveTolerance

• curveTolerance: number = 0.3

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:45

exploreConcave

• exploreConcave: false = false

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:46

mutationRate

• mutationRate: number = 10

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:47

populationSize

• populationSize: number = 10

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:48

rotations

• rotations: number = 4

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:49

spacing

• spacing: number = 0

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:50

useHoles

• useHoles: false = false

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:51

useRotations

• useRotations: number = 2

Defined in src/modules/kyub.core.svgObjExporter/src/export/SvgNester.ts:52