Skip to content

editor › Globals › CompositeModel

Class: CompositeModel

This class represents the model (data structures only). "The model" means all assemblies, plates etc. visible in kyub at any given time; however, if an undo, reset or similar is executed, the old CompositeModel instance may be replaced with a new one. Based on the data structure, a visualization is generated.

Hierarchy

  • any

↳ CompositeModel

Index

Properties

Methods

Properties

Private assemblies

• assemblies: Assembly[] = []

Defined in src/model/data/CompositeModel.ts:35


Private boxelQueue

• boxelQueue: BoxelQueue‹› = new BoxelQueue()

Defined in src/model/data/CompositeModel.ts:31


Private editor

• editor: Editor | null = null

Defined in src/model/data/CompositeModel.ts:39


Private Readonly modelElementChangeEventEmitter

• modelElementChangeEventEmitter: EventEmitter‹void› = new EventEmitter()

Defined in src/model/data/CompositeModel.ts:47


Private nestingComponent

• nestingComponent: ManualNestingComponent | null = null

Defined in src/model/data/CompositeModel.ts:45

A component encapsulating the state of a manual nesting for this composite model i.e. a placement of every plate onto a given material sheet in 2D.


Private physicalObjects

• physicalObjects: Set‹PhysicalObject› = new Set()

Defined in src/model/data/CompositeModel.ts:33


Private properties

• properties: Map‹string, AggregatedPrimitive› = new Map([["backgroundName", ""]])

Defined in src/model/data/CompositeModel.ts:37

Methods

Private _addAssembly

▸ _addAssembly(assembly: Assembly): void

Defined in src/model/data/CompositeModel.ts:352

Parameters:

Name Type
assembly Assembly

Returns: void


Private _addPhysicalObject

▸ _addPhysicalObject(physicalObject: PhysicalObject): void

Defined in src/model/data/CompositeModel.ts:333

Stores array reference and links events

Parameters:

Name Type Description
physicalObject PhysicalObject -

Returns: void


Private _getAllowedEvents

▸ _getAllowedEvents(): string[]

Defined in src/model/data/CompositeModel.ts:392

Available events are: - 'objectAdd' (physicalObject) - 'objectRemove' (physicalObject) - 'jointAdd' (joint) - 'jointRemove' (joint) - 'assemblyAdd' (assembly) - 'assemblyRemove' (assembly) - 'assemblyMerge' (mergedAssembly, oldAndEmptySecondAssembly) - 'assemblySplit' (oldAssembly, newlyCreatedSecondAssembly) - 'assemblyChange' (assembly) - 'propertyChange' (key, newValue)

Returns: string[]


_getProperties

▸ _getProperties(): Map‹string, AggregatedPrimitive›

Defined in src/model/data/CompositeModel.ts:131

Returns: Map‹string, AggregatedPrimitive›


Private _onAssemblyChange

▸ _onAssemblyChange(event: any): void

Defined in src/model/data/CompositeModel.ts:449

Parameters:

Name Type
event any

Returns: void


Private _onAssemblyEmpty

▸ _onAssemblyEmpty(emptyAssembly: any): void

Defined in src/model/data/CompositeModel.ts:412

Removes the assembly when it becomes empty

Parameters:

Name Type Description
emptyAssembly any -

Returns: void


Private _onAssemblyMerge

▸ _onAssemblyMerge(mergedAssembly: any, oldAndEmptySecondAssembly: any): void

Defined in src/model/data/CompositeModel.ts:423

Removes obsolete assembly if two assemblies are merged

Parameters:

Name Type Description
mergedAssembly any -
oldAndEmptySecondAssembly any -

Returns: void


Private _onAssemblySplit

▸ _onAssemblySplit(oldAssembly: any, newlyCreatedSecondAssembly: any): void

Defined in src/model/data/CompositeModel.ts:436

Adds an additional assembly if they have been split up

Parameters:

Name Type Description
oldAssembly any -
newlyCreatedSecondAssembly any -

Returns: void


Private _onJointAdd

▸ _onJointAdd(callingPhysicalObject: any, joint: any): void

Defined in src/model/data/CompositeModel.ts:476

Just emit the event for those who need

Parameters:

Name Type Description
callingPhysicalObject any -
joint any -

Returns: void


Private _onJointRemove

▸ _onJointRemove(callingPhysicalObject: any, joint: any): void

Defined in src/model/data/CompositeModel.ts:486

Just emit the event for those who need

Parameters:

Name Type Description
callingPhysicalObject any -
joint any -

Returns: void


Private _printAssemblyOverview

▸ _printAssemblyOverview(): void

Defined in src/model/data/CompositeModel.ts:490

Returns: void


Private _removeAssembly

▸ _removeAssembly(assembly: any): void

Defined in src/model/data/CompositeModel.ts:369

Parameters:

Name Type
assembly any

Returns: void


addAssembly

▸ addAssembly(assembly: Assembly): void

Defined in src/model/data/CompositeModel.ts:189

Adds an assembly and all referenced physical objects to the model

Parameters:

Name Type Description
assembly Assembly -

Returns: void


addPhysicalObject

▸ addPhysicalObject(physicalObject: PhysicalObject): void

Defined in src/model/data/CompositeModel.ts:170

Add a physical object to this composite model

Parameters:

Name Type Description
physicalObject PhysicalObject the physical object to add

Returns: void


destroy

▸ destroy(): void

Defined in src/model/data/CompositeModel.ts:313

Returns: void


disableManualNesting

▸ disableManualNesting(): void

Defined in src/model/data/CompositeModel.ts:153

Returns: void


displayUserMessage

▸ displayUserMessage(msg: string): void

Defined in src/model/data/CompositeModel.ts:305

Parameters:

Name Type
msg string

Returns: void


enableManualNesting

▸ enableManualNesting(sheets: Polygon[]): Promise‹void›

Defined in src/model/data/CompositeModel.ts:144

Enables the manual nesting view with a given list of sheet polygons. If the view was enabled before, position and rotatio of plates will be kept as long as the model and given sheets stayed the same.

Parameters:

Name Type Description
sheets Polygon[] Polygon representations of material sheets that will be used in manual nesting view.

Returns: Promise‹void›


findModelElement

▸ findModelElement‹DesiredType›(desiredType: any, interactionData: IInteractionData, maxDistance: number, strategy: FindModelElementReturnStrategy): FoundModelElements‹DesiredType›

Defined in src/model/data/CompositeModel.ts:66

Queries the realizers of all model elements in this' assemblies for instances of desiredType. DesiredType will be enforced but not checked on the elementfield of the results.

Type parameters:

▪ DesiredType

Parameters:

Name Type Default Description
desiredType any - Which class the elementfield in the results should be members of. Used to tell the realizer what to look for, not for any typechecking. Might be a IModelElement, Mesh, MeshElement, MeshAnnotation or similar. Have a look at the expected realizer's implementation.
interactionData IInteractionData - Used for computing distances and taking shortcuts when searching for best or first. Won't be changed.
maxDistance number 20 Elements with distances greater than maxDistance are ignored. Metric is up to the realizers.
strategy FindModelElementReturnStrategy FindModelElementReturnStrategy.FIRST What to return, see IModelElementRealizer

Returns: FoundModelElements‹DesiredType›

An array of elements with their realizer and distances.


getAssemblies

▸ getAssemblies(): Assembly[]

Defined in src/model/data/CompositeModel.ts:284

Returns all assemblies currently existing in this model

Returns: Assembly[]


getBackgroundName

▸ getBackgroundName(): AggregatedPrimitive

Defined in src/model/data/CompositeModel.ts:118

Returns: AggregatedPrimitive


getBoxelQueue

▸ getBoxelQueue(): BoxelQueue

Defined in src/model/data/CompositeModel.ts:106

Returns: BoxelQueue


getModelElementChangeEventEmitter

▸ getModelElementChangeEventEmitter(): IPublicEventEmitterInterface‹void›

Defined in src/model/data/CompositeModel.ts:49

Returns: IPublicEventEmitterInterface‹void›


getNestingComponent

▸ getNestingComponent(): ManualNestingComponent

Defined in src/model/data/CompositeModel.ts:162

Returns: ManualNestingComponent


getPhysicalObjects

▸ getPhysicalObjects(): Set‹PhysicalObject›

Defined in src/model/data/CompositeModel.ts:277

Returns all physical object children of this model

Returns: Set‹PhysicalObject›


getProperty

▸ getProperty(key: string): AggregatedPrimitive

Defined in src/model/data/CompositeModel.ts:127

Parameters:

Name Type
key string

Returns: AggregatedPrimitive


getWorldAABB

▸ getWorldAABB(): AABB

Defined in src/model/data/CompositeModel.ts:291

Returns: AABB

maximum bounding box in world coordinates of all assemblies contained in this model


manualNestingEnabled

▸ manualNestingEnabled(): boolean

Defined in src/model/data/CompositeModel.ts:158

Returns: boolean


removeAssembly

▸ removeAssembly(assembly: Assembly): void

Defined in src/model/data/CompositeModel.ts:253

Removes the assembly and all physical objects it contains from the composite model. The internal state of the assembly will not be touched.

Parameters:

Name Type Description
assembly Assembly the assembly to be removed

Returns: void


removePhysicalObject

▸ removePhysicalObject(physicalObject: PhysicalObject, deleteObjectFromAssembly: boolean, moveToWorld: boolean): void

Defined in src/model/data/CompositeModel.ts:209

Removes a physical object from this composite model as well as all connected joints First, all joints are cleared, and second, the object is being removed from its assembly and model.

Parameters:

Name Type Default Description
physicalObject PhysicalObject - the physical object to be removed
deleteObjectFromAssembly boolean true (optional) if the object should be removed from its assembly and isolated
moveToWorld boolean true (optional) moves the physical object from the assembly to world, if false then it only gets removed

Returns: void


setBackgroundName

▸ setBackgroundName(backgroundName: string): void

Defined in src/model/data/CompositeModel.ts:114

Parameters:

Name Type Description
backgroundName string Background which the model belongs to (used to restore backgroundObjects)

Returns: void


setBoxelQueue

▸ setBoxelQueue(boxelQueue: BoxelQueue): void

Defined in src/model/data/CompositeModel.ts:98

WARNING: Only to be used by the deserialization!

Parameters:

Name Type
boxelQueue BoxelQueue

Returns: void


setEditor

▸ setEditor(editor: Editor): void

Defined in src/model/data/CompositeModel.ts:135

Parameters:

Name Type
editor Editor

Returns: void


setNestingComponent

▸ setNestingComponent(nestingComponent: ManualNestingComponent): void

Defined in src/model/data/CompositeModel.ts:102

Parameters:

Name Type
nestingComponent ManualNestingComponent

Returns: void


setProperty

▸ setProperty(key: string, value: AggregatedPrimitive): void

Defined in src/model/data/CompositeModel.ts:122

Parameters:

Name Type
key string
value AggregatedPrimitive

Returns: void