Meshes
Creating meshes
createmesh
also "creates" a type. Use similar
for creating empty meshes of identical type and clone(::Mesh)
for (deep-)copying.
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.glimpse
— Functionglimpse([io,] mesh)
Show a more detailed summary of the mesh than Base.show
.
Copying attributes
Base.copy!
— Methodsrc = 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.
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
.
See also copytessellation!
, copyattrs!
Base.copy!
— Methodcopy!(dst, src, handles)
Copy all attributes defined by handles
from source src
to destination dst
.
Require attributes for same mesh elemets, i.e., dst
and src
are both vertex, face, half-edge or edge attributes.
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.
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!
Base.map!
— Methodmap!(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
PMesh.copyattrs!
— Methodcopyattrs(dst, src)
Copy user-defined vertex, face, half-edge and edge attributes from mesh src
to dst
and return dst
.
Requires identical tessellation of src
and dst
: call copyattrs!
after [copytessellation!
]!
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
.
See also copytessellation!
, copyattrs!
, copyvattrs!
, copyfattrs!
, copyhattrs!
, copyeattrs!
PMesh.copyeattrs!
— MethodCopy edge attributes, see copyattrs!
PMesh.copyfattrs!
— MethodCopy face attributes, see copyattrs!
PMesh.copyhattrs!
— MethodCopy half-edge attributes, see copyattrs!
PMesh.copytessellation!
— Methodsrc = 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!
PMesh.copyvattrs!
— MethodCopy vertex attributes, see copyattrs!