editor › Globals › MeshSurface
Class: MeshSurface
The MeshSurface represents one surface of a mesh and consists out of an outline (defined as one reference to a cycle of MeshHalfEdges) and optional holes.
An array of surfaces is the interchange format between Meshes and MeshImplementations and suffices to define arbitrary geometry.
Conceptually, surfaces should usually be flat, but are not constrained to it, as the edge's points can have arbitrary positions.
Hierarchy
- MeshSurface
Index
Constructors
Properties
Methods
- _assignSurface
- _cyclesEqual
- _getArrayPoints2D
- _getPoints2D
- _mapCycleToMeshPoints
- _mapCycleToPoints
- _mapCycleToReadonlyPoints
- distanceToPoint
- equals
- equalsUid
- getAdjacentSurfaces
- getAllCycles
- getAllHalfEdges
- getAllMeshPoints
- getAllPoints
- getAllPointsReadonly
- getArbitraryAlignedAABB2D
- getArea
- getCenter
- getFirstOutlinePoint
- getFirstOutlinePointReadonly
- getHoleCycles
- getHolePoints
- getHolePointsReadonly
- getNormal
- getOBB
- getOutlineCycle
- getOutlineLength
- getOutlinePoints
- getOutlinePointsReadonly
- getPlane
- getPointInPlane
- getUid
- intersectPlane
- isPlanar
- isPointInSurface
- isProjectedPointInSurface
- projectPoint
- removeHoleCycle
- replaceCycleEdgeIfNeeded
- shapeEquals
- toMeshPointPolygon3D
- toReadonlyVectorPolygon3D
- toVectorPolygon3D
- fromVectorCycles
- fromVectorPolygon
Constructors
constructor
+ new MeshSurface(outlineEdge: MeshHalfEdge, holeEdges: MeshHalfEdge[], uid: string): MeshSurface
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:75
Builds up a surface given an edge of an outline and one edge per hole. Assigns the surface property to all connected edges.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
outlineEdge |
MeshHalfEdge | - | - |
holeEdges |
MeshHalfEdge[] | [] | - |
uid |
string | PseudoRandomString.generate(10) | - |
Returns: MeshSurface
Properties
Private holesEdges
• holesEdges: MeshHalfEdge[] = []
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:69
One MeshHalfEdge per hole
Private outlineEdge
• outlineEdge: MeshHalfEdge = null
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:64
One MeshHalfEdge of the outline
Private Readonly uid
• uid: string = null
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:75
A unique identifier used for example by anchor to weaken the definition of identity so we have a way to communicate that a new surface with different identity is conceptually still the same.
Methods
Private _assignSurface
▸ _assignSurface(): void
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:609
Returns: void
Private _cyclesEqual
▸ _cyclesEqual(cycleA: MeshHalfEdge[], cycleB: MeshHalfEdge[], epsilon: number): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:605
Return true if the points of the cycles have almost the same positions. Start position of the cycle does not matter, order matters.
Parameters:
| Name | Type | Description |
|---|---|---|
cycleA |
MeshHalfEdge[] | - |
cycleB |
MeshHalfEdge[] | - |
epsilon |
number | - |
Returns: boolean
Private _getArrayPoints2D
▸ _getArrayPoints2D(): ArrayPoint2[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:589
Returns: ArrayPoint2[]
Private _getPoints2D
▸ _getPoints2D(): Vector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:584
Returns: Vector3[]
Private _mapCycleToMeshPoints
▸ _mapCycleToMeshPoints(edges: MeshHalfEdge[]): MeshPoint[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:623
Parameters:
| Name | Type |
|---|---|
edges |
MeshHalfEdge[] |
Returns: MeshPoint[]
Private _mapCycleToPoints
▸ _mapCycleToPoints(edges: MeshHalfEdge[]): Vector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:615
Parameters:
| Name | Type |
|---|---|
edges |
MeshHalfEdge[] |
Returns: Vector3[]
Private _mapCycleToReadonlyPoints
▸ _mapCycleToReadonlyPoints(edges: MeshHalfEdge[]): ReadonlyVector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:619
Parameters:
| Name | Type |
|---|---|
edges |
MeshHalfEdge[] |
Returns: ReadonlyVector3[]
distanceToPoint
▸ distanceToPoint(point: ReadonlyVector3, between: object, thickness: number): number
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:227
Computes the distance from the point to the plane of this surface.
Parameters:
▪ point: ReadonlyVector3
The point to get the distance to in mesh coordinates.
▪Default value between: object= { min: 0, max: Infinity }
(optional) Exit early if distance is smaller/greater than between.min/.max for sure.
| Name | Type |
|---|---|
max |
number |
min |
number |
▪Default value thickness: number= 0
(optional) if point is on the backside assume this thickness
Returns: number
equals
▸ equals(otherSurface: MeshSurface, epsilon: number): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:327
Tests if the other surface has the same outline and holes. While point/edge identity does not matter, the same order of holes and order/position of points is expected.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
otherSurface |
MeshSurface | - | the other surface |
epsilon |
number | maximumPositionEqualityDistance | - |
Returns: boolean
equalsUid
▸ equalsUid(otherSurface: MeshSurface): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:95
Parameters:
| Name | Type |
|---|---|
otherSurface |
MeshSurface |
Returns: boolean
getAdjacentSurfaces
▸ getAdjacentSurfaces(): MeshSurface[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:130
Returns: MeshSurface[]
all surfaces which are adjacent to this one
getAllCycles
▸ getAllCycles(): MeshHalfEdge[][]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:116
Returns: MeshHalfEdge[][]
OutlineCycle and all HoleCycles of the surface
getAllHalfEdges
▸ getAllHalfEdges(): MeshHalfEdge[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:123
Returns: MeshHalfEdge[]
all half edges, of outline and holes combined
getAllMeshPoints
▸ getAllMeshPoints(): MeshPoint[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:217
Returns: MeshPoint[]
all points, of outline and holes combined as meshPoints
getAllPoints
▸ getAllPoints(): Vector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:203
Returns: Vector3[]
all points, of outline and holes combined as Vector3
getAllPointsReadonly
▸ getAllPointsReadonly(): ReadonlyVector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:210
Returns: ReadonlyVector3[]
all points, of outline and holes combined as Vector3
getArbitraryAlignedAABB2D
▸ getArbitraryAlignedAABB2D(): AABB‹›
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:503
Returns an AABB, but does not guarantee anything about the alignment of it. TODO: This could be improved by trying to find a minimal AABB on different aligments (ObjectBoundingBox)
Returns: AABB‹›
Returns a bounding box of the surface. Throws on non-planar surfaces. Undefined behavior on non-planar surfaces.
getArea
▸ getArea(): number
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:419
Returns: number
Returns the area of the surfacePoints. Throws on nonPlanar-Surfaces.
getCenter
▸ getCenter(target?: Vector3): Vector3
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:280
Computes the center point of the plane by using geometric averages. In mesh-local coordinates.
Parameters:
| Name | Type |
|---|---|
target? |
Vector3 |
Returns: Vector3
getFirstOutlinePoint
▸ getFirstOutlinePoint(target?: Vector3): Vector3
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:143
Parameters:
| Name | Type |
|---|---|
target? |
Vector3 |
Returns: Vector3
getFirstOutlinePointReadonly
▸ getFirstOutlinePointReadonly(): ReadonlyVector3
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:147
Returns: ReadonlyVector3
getHoleCycles
▸ getHoleCycles(): MeshHalfEdge[][]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:109
Returns: MeshHalfEdge[][]
an array of MeshHalfEdge[], which represent the holes
getHolePoints
▸ getHolePoints(): Vector3[][]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:168
Returns: Vector3[][]
an array of arrays of vectors that describe the holes, in mesh-local coordinates
getHolePointsReadonly
▸ getHolePointsReadonly(): ReadonlyVectorCycle3D[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:175
Returns: ReadonlyVectorCycle3D[]
an array of arrays of vectors that describe the holes, in mesh-local coordinates
getNormal
▸ getNormal(target?: Vector3): Vector3
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:273
Computes the normal of the plane. This method has only been tested for planar surfaces. In mesh-local coordinates
Parameters:
| Name | Type |
|---|---|
target? |
Vector3 |
Returns: Vector3
getOBB
▸ getOBB(startingEdgeIndex: number): OBB
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:439
Get the OBB oriented at the first edge and the surface's normal. Throws on non-planar surfaces.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
startingEdgeIndex |
number | 0 | The x-axis of the OBB will be aligned with the direction of this section. Defaults to 0. |
Returns: OBB
a new OBB instance
getOutlineCycle
▸ getOutlineCycle(): MeshHalfEdge[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:102
Returns: MeshHalfEdge[]
an array of MeshHalfEdges that represent the outline
getOutlineLength
▸ getOutlineLength(): number
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:161
Returns the number of outline points / edges.
Returns: number
getOutlinePoints
▸ getOutlinePoints(): Vector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:139
Returns: Vector3[]
array of vectors that describe the outline, in mesh-local coordinates
getOutlinePointsReadonly
▸ getOutlinePointsReadonly(): ReadonlyVectorCycle3D
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:154
Returns: ReadonlyVectorCycle3D
array of vectors that describe the outline, in mesh-local coordinates
getPlane
▸ getPlane(target: Plane‹›): Plane
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:580
Get the plane of this surface. Throws on non-planar surfaces.
Parameters:
| Name | Type | Default |
|---|---|---|
target |
Plane‹› | new Plane() |
Returns: Plane
getPointInPlane
▸ getPointInPlane(target?: Vector3): Vector3
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:570
Return a point that lies in the plane of this MeshSurface. Throws on non-planar surfaces.
Parameters:
| Name | Type | Description |
|---|---|---|
target? |
Vector3 | - |
Returns: Vector3
getUid
▸ getUid(): string
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:91
Returns: string
intersectPlane
▸ intersectPlane(plane: any, ignoreSegmentsInPlane: boolean, tolerance: any): Vector3[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:510
Parameters:
| Name | Type | Default |
|---|---|---|
plane |
any | - |
ignoreSegmentsInPlane |
boolean | true |
tolerance |
any | maximumPositionEqualityDistance |
Returns: Vector3[]
isPlanar
▸ isPlanar(): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:426
Returns: boolean
Private isPointInSurface
▸ isPointInSurface(point: Vector3): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:316
Checks if a point lies within the MeshSurface
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Vector3 | in local coordinates |
Returns: boolean
Private isProjectedPointInSurface
▸ isProjectedPointInSurface(point: Vector3): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:302
Checks if a projected point lies within the MeshSurface
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Vector3 | in local coordinates |
Returns: boolean
projectPoint
▸ projectPoint(point: ReadonlyVector3): Vector3
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:289
Projects point onto the surface.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
ReadonlyVector3 | Point to project in mesh coordinates. |
Returns: Vector3
Projected point
removeHoleCycle
▸ removeHoleCycle(holeEdge: MeshHalfEdge): void
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:550
Given one edge of a hole, remove the hole.
Parameters:
| Name | Type | Description |
|---|---|---|
holeEdge |
MeshHalfEdge | any edge of the hole, no need for this to be the specific one we hold here |
Returns: void
replaceCycleEdgeIfNeeded
▸ replaceCycleEdgeIfNeeded(oldEdge: MeshHalfEdge, newEdge: MeshHalfEdge): void
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:535
Lazily replace an outdated edge only when we hold a direct reference to it (otherwise tracing the cycle is fine). Useful if we remove an edge but the surface still uses exactly this edge of the cycle and we want to get rid of it.
Parameters:
| Name | Type | Description |
|---|---|---|
oldEdge |
MeshHalfEdge | - |
newEdge |
MeshHalfEdge | - |
Returns: void
shapeEquals
▸ shapeEquals(otherSurface: MeshSurface, getIndexRotations?: false): boolean
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:359
Tests if this surface's outline can be rotated and translated to match otherSurface's. Compares per edge the dot product of the two previous directions and the length of the last direction.
Parameters:
| Name | Type | Description |
|---|---|---|
otherSurface |
MeshSurface | - |
getIndexRotations? |
false | Whether to return rotations or just the equality test result. |
Returns: boolean
Either whether the shapes equal or (getIndexRotation) all possible rotations (ie numbers the otherSurface's outlinePoints array must be right-rotated to match this').
▸ shapeEquals(otherSurface: MeshSurface, getIndexRotations?: true): number[]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:360
Parameters:
| Name | Type |
|---|---|
otherSurface |
MeshSurface |
getIndexRotations? |
true |
Returns: number[]
toMeshPointPolygon3D
▸ toMeshPointPolygon3D(): MeshPoint[][]
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:196
Returns: MeshPoint[][]
all points in the usual polygon format where an array of outlinepoints is followed by arrays of holepoints
toReadonlyVectorPolygon3D
▸ toReadonlyVectorPolygon3D(): ReadonlyVectorPolygon3D
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:189
Returns: ReadonlyVectorPolygon3D
all points in the usual polygon format where an array of outlinepoints is followed by arrays of holepoints
toVectorPolygon3D
▸ toVectorPolygon3D(): VectorPolygon3D
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:182
Returns: VectorPolygon3D
all points in the usual polygon format where an array of outlinepoints is followed by arrays of holepoints
Static fromVectorCycles
▸ fromVectorCycles(outlineCycle: ReadonlyVectorCycle3D, holeCycles: ReadonlyVectorCycle3D[], uid?: string): MeshSurface
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:47
Utility to just create an unconnected MeshSurface. Its edges will not have neighbors.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
outlineCycle |
ReadonlyVectorCycle3D | - | - |
holeCycles |
ReadonlyVectorCycle3D[] | [] | - |
uid? |
string | - |
Returns: MeshSurface
Static fromVectorPolygon
▸ fromVectorPolygon(polygon: ReadonlyVectorPolygon3D, uid?: string): MeshSurface
Defined in src/model/data/Concepts/Mesh/MeshSurface.ts:37
Utility to just create an unconnected MeshSurface. Its edges will not have neighbors.
Parameters:
| Name | Type | Description |
|---|---|---|
polygon |
ReadonlyVectorPolygon3D | - |
uid? |
string |
Returns: MeshSurface