editor › Globals › MeshSurfaceAnchor
Class: MeshSurfaceAnchor
A mesh surface anchor always points to the (conceptually) same surface in a mesh
ToDo: extend test suite + implement fuzzy re-finding
Hierarchy
↳ MeshElementAnchor‹MeshSurface, ISurfaceSignature, MeshSurfaceAnchor›
↳ MeshSurfaceAnchor
Implements
Index
Properties
- additionalElementContext
- changeEventEmitter
- element
- elementSignature
- isDestroyed
- lastMeshAdaptionWasSuccessful
- mesh
Methods
- _adaptToChangedMesh
- _applyChangedScale
- _changeSelfToChosenCandidate
- _checkIfAnchorCanBeValid
- _createEvent
- _createSplitOffInstance
- _determineMatchingPoints
- _distanceToAssemblySignature
- _extractAdditionalElementContextFromCurrentElement
- _extractSignatureFromCurrentElement
- _findByMirror
- _findBySameIdentity
- _findBySameSignature
- _findBySameUID
- _findBySimilarSignature
- _findSurfacesInProximity
- _findSurfacesWithSharedPoints
- _getAssemblySpaceSignature
- _getInstance
- _getSurfacesWithSimilarNormal
- _isElementValid
- _onMeshChange
- _performInitialLookup
- _reFindElementOnMesh
- _refindSelfAndEmit
- _setElement
- _setMesh
- _setMeshAndElement
- clone
- destroy
- getChangeEventEmitter
- getInMeshTarget
- getIsValid
- getMesh
- getSignature
- getSurface
- getTargets
- initializeFromElement
- initializeFromSignature
- reFindElementOnMesh
- setFromPointOnSurface
Properties
Protected additionalElementContext
• additionalElementContext: any
Inherited from MeshElementAnchor.additionalElementContext
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: EventEmitter‹IMeshAnchorChangeEvent› = new EventEmitter
Inherited from AbstractMeshAnchor.changeEventEmitter
Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:33
Protected element
• element: MeshSurface = null
Inherited from MeshElementAnchor.element
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: ISurfaceSignature = null
Overrides MeshElementAnchor.elementSignature
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:52
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
Inherited from MeshElementAnchor._adaptToChangedMesh
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
-
event? : IMeshAnchorChangeEvent
-
invalid: boolean
Protected _applyChangedScale
▸ _applyChangedScale(scale: number): void
Overrides MeshElementAnchor._applyChangedScale
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:320
Parameters:
| Name | Type |
|---|---|
scale |
number |
Returns: void
Protected _changeSelfToChosenCandidate
▸ _changeSelfToChosenCandidate(chosenCandidate: IAbstractElementCandidate‹MeshSurface›, mirror?: IMirrorMapping): boolean
Inherited from MeshElementAnchor._changeSelfToChosenCandidate
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‹MeshSurface› | 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
Inherited from MeshElementAnchor._checkIfAnchorCanBeValid
Overrides AbstractMeshAnchor._checkIfAnchorCanBeValid
Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:194
Returns: boolean
Protected _createEvent
▸ _createEvent(splitAnchors: MeshSurfaceAnchor[], previousTarget: Mesh, __namedParameters: object): IMeshAnchorChangeEvent
Inherited from MeshElementAnchor._createEvent
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: MeshSurfaceAnchor[]
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 _createSplitOffInstance
▸ _createSplitOffInstance(mesh: Mesh, surface: MeshSurface): MeshSurfaceAnchor
Overrides MeshElementAnchor._createSplitOffInstance
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:140
Creates a new hint instance for a surface in case multiple surfaces are equally good as successors to the current surface.
IMPORTANT: override this method in subclass to create correct class instance.
ToDo: Probably better implemented in abstract class ToDo: _adaptToChangedMesh -> in-between-result -> _createInstances(inBetweenResult) ToDo: to force subclasses to implement + override / make it more clear
Parameters:
| Name | Type |
|---|---|
mesh |
Mesh |
surface |
MeshSurface |
Returns: MeshSurfaceAnchor
Protected _determineMatchingPoints
▸ _determineMatchingPoints(candidateMesh: Mesh, candidateSurface: MeshSurface): Vector3[]
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:265
Parameters:
| Name | Type |
|---|---|
candidateMesh |
Mesh |
candidateSurface |
MeshSurface |
Returns: Vector3[]
Private _distanceToAssemblySignature
▸ _distanceToAssemblySignature(assemblyPoint: Vector3, assemblySpaceSignature: ISurfaceSignature): number
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:370
Computes the minimum distance of a point (assembly space) to the outline of an ISurfaceSignature (assembly space).
Parameters:
| Name | Type | Description |
|---|---|---|
assemblyPoint |
Vector3 | - |
assemblySpaceSignature |
ISurfaceSignature | - |
Returns: number
Protected _extractAdditionalElementContextFromCurrentElement
▸ _extractAdditionalElementContextFromCurrentElement(): void
Overrides MeshElementAnchor._extractAdditionalElementContextFromCurrentElement
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:122
Returns: void
Protected _extractSignatureFromCurrentElement
▸ _extractSignatureFromCurrentElement(): ISurfaceSignature
Overrides MeshElementAnchor._extractSignatureFromCurrentElement
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:108
Do not extract the signature when the surface is degenerated (normal with length 0 doesn't help us). Rather keep the old signature.
Returns: ISurfaceSignature
Protected _findByMirror
▸ _findByMirror(successor: Mesh, mirror: IMirrorMapping): Array‹IAbstractElementCandidate‹MeshSurface››
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:186
Parameters:
| Name | Type |
|---|---|
successor |
Mesh |
mirror |
IMirrorMapping |
Returns: Array‹IAbstractElementCandidate‹MeshSurface››
Protected _findBySameIdentity
▸ _findBySameIdentity(candidateMesh: Mesh): ISurfaceCandidate[]
Overrides MeshElementAnchor._findBySameIdentity
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:154
Easy case - we still have the same identity NOTICE: this can produce unexpected results: if we have a CSG operation that splits up a surface in two equally possible successors and keeps one surface with same identity, this line will always only choose one surface. This is okay as long as we assume "if the same surface identity remains, it always wins"
Parameters:
| Name | Type | Description |
|---|---|---|
candidateMesh |
Mesh | - |
Returns: ISurfaceCandidate[]
Protected _findBySameSignature
▸ _findBySameSignature(candidateMesh: Mesh): ISurfaceCandidate[]
Overrides MeshElementAnchor._findBySameSignature
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:204
Try to find a surface with same normal and same outline points
Parameters:
| Name | Type | Description |
|---|---|---|
candidateMesh |
Mesh | - |
Returns: ISurfaceCandidate[]
Protected _findBySameUID
▸ _findBySameUID(candidateMesh: Mesh): Array‹IAbstractElementCandidate‹MeshSurface››
Overrides MeshElementAnchor._findBySameUID
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:166
Also returns the surface with the same uid but different identity. The anchor also follows the surface when it moved and has a different identity but we know where it needs to go.
Parameters:
| Name | Type | Description |
|---|---|---|
candidateMesh |
Mesh | - |
Returns: Array‹IAbstractElementCandidate‹MeshSurface››
Protected _findBySimilarSignature
▸ _findBySimilarSignature(candidateMesh: Mesh): ISurfaceCandidate[]
Overrides MeshElementAnchor._findBySimilarSignature
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:286
Tries to find matching surfaces based on a similar (= within some ° similarity) normal and similar outline points. Assigns probability values based on the similarity to the original surface.
Parameters:
| Name | Type | Description |
|---|---|---|
candidateMesh |
Mesh | - |
Returns: ISurfaceCandidate[]
Private _findSurfacesInProximity
▸ _findSurfacesInProximity(candidateMesh: Mesh, maxDistance: number): ISurfaceCandidate[]
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:324
Parameters:
| Name | Type |
|---|---|
candidateMesh |
Mesh |
maxDistance |
number |
Returns: ISurfaceCandidate[]
Protected _findSurfacesWithSharedPoints
▸ _findSurfacesWithSharedPoints(candidateMesh: Mesh, minimalMatchingPointsCount?: number, normalDifferenceTolerance?: number): ISurfaceCandidate[]
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:213
Parameters:
| Name | Type |
|---|---|
candidateMesh |
Mesh |
minimalMatchingPointsCount? |
number |
normalDifferenceTolerance? |
number |
Returns: ISurfaceCandidate[]
Protected _getAssemblySpaceSignature
▸ _getAssemblySpaceSignature(signature: ISurfaceSignature): ISurfaceSignature
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:311
Transforms the surface signature into assembly space so that it can be compared with other meshes
Parameters:
| Name | Type |
|---|---|
signature |
ISurfaceSignature |
Returns: ISurfaceSignature
Protected _getInstance
▸ _getInstance(): MeshSurfaceAnchor
Overrides MeshElementAnchor._getInstance
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:100
Returns: MeshSurfaceAnchor
Protected _getSurfacesWithSimilarNormal
▸ _getSurfacesWithSimilarNormal(candidateMesh: Mesh, allowedAngleDifference?: number): MeshSurface[]
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:247
Parameters:
| Name | Type |
|---|---|
candidateMesh |
Mesh |
allowedAngleDifference? |
number |
Returns: MeshSurface[]
Protected _isElementValid
▸ _isElementValid(): boolean
Overrides MeshElementAnchor._isElementValid
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:126
Returns: boolean
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
Inherited from MeshElementAnchor._performInitialLookup
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‹MeshSurface››
Overrides MeshElementAnchor._reFindElementOnMesh
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:176
Parameters:
| Name | Type |
|---|---|
candidateMesh |
Mesh |
requiresExactMatch |
boolean |
mirror? |
IMirrorMapping |
Returns: Array‹IAbstractElementCandidate‹MeshSurface››
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: MeshSurface): void
Inherited from MeshElementAnchor._setElement
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 |
MeshSurface |
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: MeshSurface): void
Inherited from MeshElementAnchor._setMeshAndElement
Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:185
Parameters:
| Name | Type |
|---|---|
mesh |
Mesh |
element |
MeshSurface |
Returns: void
clone
▸ clone(): MeshElementAnchor‹MeshSurface, ISurfaceSignature, MeshSurfaceAnchor›
Implementation of IMeshAnchor
Inherited from MeshElementAnchor.clone
Overrides AbstractMeshAnchor.clone
Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:66
Returns: MeshElementAnchor‹MeshSurface, ISurfaceSignature, MeshSurfaceAnchor›
destroy
▸ destroy(): void
Implementation of IMeshAnchor
Inherited from MeshElementAnchor.destroy
Overrides AbstractMeshAnchor.destroy
Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:94
Returns: void
getChangeEventEmitter
▸ getChangeEventEmitter(): IPublicEventEmitterInterface‹IMeshAnchorChangeEvent›
Implementation of IMeshAnchor
Inherited from AbstractMeshAnchor.getChangeEventEmitter
Defined in src/model/data/Concepts/Anchors/AbstractMeshAnchor.ts:81
Returns: IPublicEventEmitterInterface‹IMeshAnchorChangeEvent›
getInMeshTarget
▸ getInMeshTarget(): MeshElement
Implementation of IMeshAnchor
Overrides AbstractMeshAnchor.getInMeshTarget
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:88
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‹›
getSignature
▸ getSignature(): ISurfaceSignature
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:96
Returns: ISurfaceSignature
getSurface
▸ getSurface(): MeshSurface
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:92
Returns: MeshSurface
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: MeshSurface): this
Inherited from MeshElementAnchor.initializeFromElement
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 |
MeshSurface | - |
Returns: this
initializeFromSignature
▸ initializeFromSignature(mesh: Mesh, signature: ISurfaceSignature): void
Inherited from MeshElementAnchor.initializeFromSignature
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 |
ISurfaceSignature |
Returns: void
reFindElementOnMesh
▸ reFindElementOnMesh(candidateMesh: Mesh, requiresExactMatch: boolean, mirror?: IMirrorMapping): Array‹IAbstractElementCandidate‹MeshSurface››
Inherited from MeshElementAnchor.reFindElementOnMesh
Defined in src/model/data/Concepts/Anchors/MeshElementAnchor.ts:99
Parameters:
| Name | Type |
|---|---|
candidateMesh |
Mesh |
requiresExactMatch |
boolean |
mirror? |
IMirrorMapping |
Returns: Array‹IAbstractElementCandidate‹MeshSurface››
setFromPointOnSurface
▸ setFromPointOnSurface(mesh: Mesh, point: ReadonlyVector3, normal?: ReadonlyVector3): void
Defined in src/model/data/Concepts/Anchors/MeshSurfaceAnchor.ts:64
Find a surface in the given mesh by specifying a point in the surface (holes don't matter for now) Be aware that this method throws an exception if it does not find the surface. For edgepoints we check separately (because of numerical errors).
ToDo: make static
Parameters:
| Name | Type | Description |
|---|---|---|
mesh |
Mesh | - |
point |
ReadonlyVector3 | a point in a surface (not on the edge). In mesh coordinates. |
normal? |
ReadonlyVector3 | Optionally specify the normal for ambiguous cases. In mesh coordinates. |
Returns: void