Skip to content

editorGlobalsMeshElementAnchor

Class: MeshElementAnchor ‹Element, IElementSignature, ElementAnchor

A MeshElementAnchor points to a specific element of a Mesh and tries to find it when the Mesh changed using a three step approach (@see MeshElementAnchor._reFindElementOnMesh). Note: ElementAnchor is the Subclass itself which instantiates this template! Note: remember to bind this._adaptToChangedMesh in your subclass.

Type parameters

Element: MeshElement

IElementSignature

ElementAnchor: AbstractMeshAnchor

Hierarchy

MeshElementAnchor

MeshSurfaceAnchor

MeshEdgeAnchor

Implements

Index

Properties

Methods

Properties

Protected additionalElementContext

additionalElementContext: any

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:36

Additional information about the elements current context (not belonging to the elementSignature). Used to keep the anchor's context consistent after a mesh change. Eg a POSA tries to find it's orientation by looking at the direction of edges with the same surface at their twin.


Protected Readonly changeEventEmitter

changeEventEmitter: EventEmitterIMeshAnchorChangeEvent = new EventEmitter()

Inherited from AbstractMeshAnchor.changeEventEmitter

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:33


Protected element

element: Element = null

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:42

Last known identity of the element. Only null if the anchor has never been valid in its lifetime yet or is already destroyed.


Protected elementSignature

elementSignature: IElementSignature

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:29

A signature describing properties of the element without referencing it so we can find it if its identity changed


Protected isDestroyed

isDestroyed: boolean = false

Inherited from AbstractMeshAnchor.isDestroyed

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:24


Protected lastMeshAdaptionWasSuccessful

lastMeshAdaptionWasSuccessful: boolean = false

Inherited from AbstractMeshAnchor.lastMeshAdaptionWasSuccessful

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:31

During initialization, subclasses need to take care of setting this value to true, if the anchor became valid before the first meshChangeEvent was fired. Else, the anchor will stay invalid until the first meshChangeEvent is fired.


Protected mesh

mesh: Mesh | null

Inherited from AbstractMeshAnchor.mesh

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:23

Methods

Protected _adaptToChangedMesh

_adaptToChangedMesh(event: MeshChangeEvent, requiresExactMatch: boolean): object

Overrides AbstractMeshAnchor._adaptToChangedMesh

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:263

see AbstractMeshAnchor._adaptToChangedMesh

Parameters:

Name Type Description
event MeshChangeEvent -
requiresExactMatch boolean if true, will only adapt to elements in the mesh that match the signature perfectly

Returns: object


Protected Abstract _applyChangedScale

_applyChangedScale(scale: number): void

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:164

If the scale of the Mesh changed, update the element signature and local offsets

Parameters:

Name Type Description
scale number -

Returns: void


Protected _changeSelfToChosenCandidate

_changeSelfToChosenCandidate(chosenCandidate: IAbstractElementCandidate‹Element›, mirror?: IMirrorMapping): boolean

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:208

Now that it is decided which candidate this anchor will be pointing to, it should adjust it references to it.

Parameters:

Name Type Description
chosenCandidate IAbstractElementCandidate‹Element› the candidate the anchor should now point to
mirror? IMirrorMapping -

Returns: boolean

whether the anchor is still valid (...or became invalidated)


Protected _checkIfAnchorCanBeValid

_checkIfAnchorCanBeValid(): boolean

Overrides AbstractMeshAnchor._checkIfAnchorCanBeValid

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:194

Returns: boolean


Protected _createEvent

_createEvent(splitAnchors: ElementAnchor[], previousTarget: Mesh, __namedParameters: object): IMeshAnchorChangeEvent

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:224

Creates an appropriate MeshAnchorChangeEvent depending on how many additional anchors have been created

Parameters:

splitAnchors: ElementAnchor[]

if there are multiple equally good candidates, the rest of them should be split off using an anchor each. In this case, the event will be a MeshAnchorChange.SPLIT.

previousTarget: Mesh

-

__namedParameters: object

Name Type Description
mirror IMirrorMapping -
scale number -

Returns: IMeshAnchorChangeEvent


Protected Abstract _createSplitOffInstance

_createSplitOffInstance(mesh: Mesh, element: Element): ElementAnchor

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:145

Creates a new anchor instance for the element in case multiple elements are equally good as successors to the current element.

IMPORTANT: override this method in subclass to create correct class instance.

ToDo: _adaptToChangedMesh -> in-between-result -> _createInstances(inBetweenResult)

Parameters:

Name Type
mesh Mesh
element Element

Returns: ElementAnchor


Protected Abstract _extractAdditionalElementContextFromCurrentElement

_extractAdditionalElementContextFromCurrentElement(): void

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:158

Returns: void


Protected Abstract _extractSignatureFromCurrentElement

_extractSignatureFromCurrentElement(): IElementSignature

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:156

If _isElementValid() returns true, this method must be able extract a meaningful signature of the element

Returns: IElementSignature


Protected Abstract _findBySameIdentity

_findBySameIdentity(candidateMesh: Mesh): Array‹IAbstractElementCandidate‹Element››

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:116

First step: check if the identity of the element did not change.

Parameters:

Name Type Description
candidateMesh Mesh -

Returns: Array‹IAbstractElementCandidate‹Element››


Protected Abstract _findBySameSignature

_findBySameSignature(candidateMesh: Mesh): Array‹IAbstractElementCandidate‹Element›› | null

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:128

Second step: maybe the identity of the element changed but the signature is still the same.

Parameters:

Name Type Description
candidateMesh Mesh -

Returns: Array‹IAbstractElementCandidate‹Element›› | null


Protected Abstract _findBySameUID

_findBySameUID(candidateMesh: Mesh): Array‹IAbstractElementCandidate‹Element››

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:122

Second step: some elements have a uid which can be kept constant by the one modifying the element,

Parameters:

Name Type Description
candidateMesh Mesh -

Returns: Array‹IAbstractElementCandidate‹Element››


Protected Abstract _findBySimilarSignature

_findBySimilarSignature(candidateMesh: Mesh): Array‹IAbstractElementCandidate‹Element››

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:135

Third step: the identity of the element changed and there is no such element with the signature. Try to find the closest match (or return [] if nothing matches well.

Parameters:

Name Type Description
candidateMesh Mesh -

Returns: Array‹IAbstractElementCandidate‹Element››


Protected Abstract _getInstance

_getInstance(): MeshElementAnchor‹Element, IElementSignature, ElementAnchor›

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:110

Returns: MeshElementAnchor‹Element, IElementSignature, ElementAnchor›

a plain (subclass) instance. Will be initialized with values in clone()


Protected Abstract _isElementValid

_isElementValid(): boolean

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:151

Returns: boolean

true, if the current mesh+element combination allows for a valid anchor or false, if it prevents a valid anchor.


Protected _onMeshChange

_onMeshChange(meshEvent: MeshChangeEvent): void

Inherited from AbstractMeshAnchor._onMeshChange

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:127

Parameters:

Name Type
meshEvent MeshChangeEvent

Returns: void


Protected _performInitialLookup

_performInitialLookup(): void

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:173

When creating the anchor, there is the time span between setting signature/mesh and the first mesh change event where the anchor can already be valid (if the mesh is already filled with the correct data). To not falsely stay invalid, when either the element is set or the mesh is set, this initial lookup function needs to be called.

Afterwards, the anchor will simply evaluate it's validity after each meshChange event.

Returns: void


Protected _reFindElementOnMesh

_reFindElementOnMesh(candidateMesh: Mesh, requiresExactMatch: boolean, mirror?: IMirrorMapping): Array‹IAbstractElementCandidate‹Element››

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:321

Tries to find the equivalent (new) element on the given candidate mesh by employing a thee step process, each step getting more and more fuzzy.

Parameters:

Name Type Description
candidateMesh Mesh the mesh to analyze
requiresExactMatch boolean if true, only elements that match the stored signature perfectly are selected and no similar elements are considered.
mirror? IMirrorMapping optional map for _findByMirror

Returns: Array‹IAbstractElementCandidate‹Element››


Protected _refindSelfAndEmit

_refindSelfAndEmit(meshEvent: MeshChangeEvent, requiresExactMatch: boolean): void

Inherited from AbstractMeshAnchor._refindSelfAndEmit

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:134

Parameters:

Name Type Default
meshEvent MeshChangeEvent -
requiresExactMatch boolean false

Returns: void


Protected _setElement

_setElement(element: Element): void

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:363

Sets the (new) element this points to. For data consistency, also extracts the element's signature

Parameters:

Name Type
element Element

Returns: void


Protected _setMesh

_setMesh(newMesh: Mesh | null): void

Inherited from AbstractMeshAnchor._setMesh

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:115

Updates the mesh reference and event bindings.

This is protected as you should only change the mesh during initialization or updates handled in child classes - users should not be able to arbitrarily change the mesh and thus corrupt state.

Parameters:

Name Type
newMesh Mesh | null

Returns: void


Protected _setMeshAndElement

_setMeshAndElement(mesh: Mesh, element: Element): void

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:185

Parameters:

Name Type
mesh Mesh
element Element

Returns: void


clone

clone(): MeshElementAnchor‹Element, IElementSignature, ElementAnchor›

Implementation of IMeshAnchor

Overrides AbstractMeshAnchor.clone

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:66

Returns: MeshElementAnchor‹Element, IElementSignature, ElementAnchor›


destroy

destroy(): void

Implementation of IMeshAnchor

Overrides AbstractMeshAnchor.destroy

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:94

Returns: void


getChangeEventEmitter

getChangeEventEmitter(): IPublicEventEmitterInterfaceIMeshAnchorChangeEvent

Implementation of IMeshAnchor

Inherited from AbstractMeshAnchor.getChangeEventEmitter

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:81

Returns: IPublicEventEmitterInterfaceIMeshAnchorChangeEvent


Abstract getInMeshTarget

getInMeshTarget(): MeshElement

Implementation of IMeshAnchor

Inherited from AbstractMeshAnchor.getInMeshTarget

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:40

Usually, subclasses of MeshAnchor point to something more fine-granular inside the mesh than only the mesh itself.

Returns: MeshElement


getIsValid

getIsValid(): boolean

Implementation of IMeshAnchor

Inherited from AbstractMeshAnchor.getIsValid

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:62

Returns: boolean


getMesh

getMesh(): Mesh‹›

Implementation of IMeshAnchor

Inherited from AbstractMeshAnchor.getMesh

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:47

This should initialize the anchor with the necessary positionable arguments.

Returns: Mesh‹›


getTargets

getTargets(): [Mesh] | []

Implementation of IMeshAnchor

Inherited from AbstractMeshAnchor.getTargets

Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:54

Returns: [Mesh] | []

the target mesh this anchor points to or an empty list if the mesh is not set


initializeFromElement

initializeFromElement(mesh: Mesh, element: Element): this

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:50

If you have a valid mesh and element combination, you can initialize the anchor here. If the mesh may be invalid and become valid later, use initializeFromSignature()

Parameters:

Name Type Description
mesh Mesh -
element Element -

Returns: this


initializeFromSignature

initializeFromSignature(mesh: Mesh, signature: IElementSignature): void

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:81

The preferred way to initialize an anchor: set the mesh and the signature. The mesh does NOT need to be valid yet, it may also become valid later (but is expected to emit change events so that the anchor can react accordingly)

Parameters:

Name Type
mesh Mesh
signature IElementSignature

Returns: void


reFindElementOnMesh

reFindElementOnMesh(candidateMesh: Mesh, requiresExactMatch: boolean, mirror?: IMirrorMapping): Array‹IAbstractElementCandidate‹Element››

Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:99

Parameters:

Name Type
candidateMesh Mesh
requiresExactMatch boolean
mirror? IMirrorMapping

Returns: Array‹IAbstractElementCandidate‹Element››