Meshes

Creating meshes

Note

The specification of its attributes determines the type of a mesh!

Tip

createmesh also "creates" a type. Use similar for creating empty meshes of identical type and clone(::Mesh) for (deep-)copying.

Note

@show mesh displays only a short summary, use @show PMesh.details(mesh) for a more information.

The Convenience API defines some useful types and mesh instances as template for use with similar (see PMesh.Types). It also provides methods that generate meshes that tessellate few simple geometric objects (see PMesh.Meshes). These may be useful for testing.

Inspecting meshes

Base.show outputs a very brief overview without attributes and type information. Use glimpse for a more detailed summary mesh contents.

@show mesh
glimpse(mesh)
PMesh.glimpseFunction
glimpse([io,] mesh)

Show a more detailed summary of the mesh than Base.show.

source

Copying attributes

Tip

copy! "converts" between Meshes of different type. Use, e.g., dst = copy!(similar(template), src).

Tip

copy! also copies attributes (possibly between meshes), and map! enables an additional mapping (e.g., a type conversion).

Base.copy!Method
src = createmesh(...)
dst = createmesh(...)       # possibly typeof(src) != typeof(dst)

dst = copy!(dst, src)

Copy mesh src into dst and return dst. (Any prior content of dst is removed.)

Source src and destination dst are both Mesh` but may be of different type (different type parameters, i.e., different attributes).

This method copies the state of src including the "used" state of elements:" src and dst share the same connectivity and respective elements share identical handles.

Note

For equal types of src and dst, copy! is equivalent to clone but less efficient.

This method Copies only attributes that are enabled for both, src and dst.

Tip

Use dst = copy!(similar(template), src) to create a copy of src of type typeof(template).

See also copytessellation!, copyattrs!

source
Base.copy!Method
copy!(dst, src, handles)

Copy all attributes defined by handles from source src to destination dst.

preconditions

Require attributes for same mesh elemets, i.e., dst and src are both vertex, face, half-edge or edge attributes.

Note

You copy attributes from a different meshe: dst and src are not required to be attributes of the same mesh. However, handles need to be valid for both.

Note

src may also be a mapped attribute (see Virtual attributes and PMeshAttributes).

Example

x1 = vattr(mesh1, Val(:x))
x2 = vattr(mesh2, Val(:x))

@assert collect(vertices(mesh1)) == collect(vertices(mesh2))

copy!(x1, x2, vertices(mesh1))

dblx2 = map(x -> 2x, x2)
copy!(x1, dblx2, vertices(mesh1))   # mapped attribute

See also map!

source
Base.map!Method
map!(f, dst, src, handles)

Map and copy all attributes defined by handles from source src to destination dst.

This is short for

copy!(dst, map(f, src), handles)

See also copy!, Virtual attributes

source
PMesh.copyattrs!Method
copyattrs(dst, src)

Copy user-defined vertex, face, half-edge and edge attributes from mesh src to dst and return dst.

precondition

Requires identical tessellation of src and dst: call copyattrs! after [copytessellation!]!

Note

Copies only attributes that are enabled for both, src and dst. Also, internal attributes that define the element state (_flags) or connectivity (_link) are ignored.

Utility:

copyattrs(dst::ManagedAttributes, src::ManagedAttributes)

Helper that copies PMeshAttributes.ManagedAttributes attributes from src to dst.

precondition

Attributes must have equal length (n_total).

See also copytessellation!, copyattrs!, copyvattrs!, copyfattrs!, copyhattrs!, copyeattrs!

source
PMesh.copytessellation!Method
src = createmesh(...)
dst = createmesh(...)       # possibly typeof(src) != typeof(dst)

copytessellation!(dst, src) # === dst

Copy tessellation ("connectivity", i.e., vertices and faces without attributes), of source mesh src to destination mesh dst and return dst. (Any prior content of dst is removed.)

Source src and destination dst are both Mesh` but may be of different type (different type parameters, i.e., different attributes).

This method copies the state of src including the "used" state of elements:" src and dst share the same connectivity and respective elements share identical handles.

See also copy!, copyattrs!

source