eradiate.scenes.biosphere.InstancedCanopyElement
eradiate.scenes.biosphere.InstancedCanopyElement#
- class eradiate.scenes.biosphere.InstancedCanopyElement(id=None, canopy_element=None, instance_positions=_Nothing.NOTHING)[source]#
Bases:
eradiate.scenes.core.SceneElement
Instanced canopy element [
instanced
].This class wraps a canopy element and defines locations where to position instances (i.e. clones) of it.
Class method constructors
from_file
(filename[, canopy_element])Construct a
InstancedCanopyElement
from a text file specifying instance positions.- Parameters
id (
str
, optional, default:None
) – User-defined object identifier.canopy_element (
CanopyElement
, optional) – Instanced canopy element. Can be specified as a dictionary, which will be converted bybiosphere_factory
.instance_positions (array-like, default:
[]
) – Instance positions as an (n, 3)-array.Unit-enabled field (default: ucc[‘length’])
- Fields
canopy_element (
CanopyElement
, optional) – Instanced canopy element.instance_positions (
quantity
) – Instance positions as an (n, 3)-array.
- classmethod from_file(filename, canopy_element=None)[source]#
Construct a
InstancedCanopyElement
from a text file specifying instance positions.File format
Each line defines an instance position as a whitespace-separated 3-vector of Cartesian coordinates.
Important
Location coordinates are assumed to be given in meters.
- Parameters
filename (path-like) – Path to the text file specifying the leaves in the canopy. Can be absolute or relative.
canopy_element (
CanopyElement
ordict
, optional) –CanopyElement
to be instanced. If a dictionary is passed, if is interpreted bybiosphere_factory
. If set toNone
, an empty leaf cloud will be created.
- Returns
InstancedCanopyElement
– CreatedInstancedCanopyElement
.- Raises
ValueError – If
filename
is set toNone
.FileNotFoundError – If
filename
does not point to an existing file.
- kernel_bsdfs(ctx)[source]#
Return BSDF plugin specifications.
- Parameters
ctx (
KernelDictContext
) – A context data structure containing parameters relevant for kernel dictionary generation.- Returns
dict
– Return a dictionary suitable for merge with aKernelDict
containing all the BSDFs attached to the shapes in the leaf cloud.
- kernel_dict(ctx)[source]#
Return a dictionary suitable for kernel scene configuration.
- Parameters
ctx (
KernelDictContext
) – A context data structure containing parameters relevant for kernel dictionary generation.- Returns
KernelDict
– Kernel dictionary which can be loaded as a Mitsuba object.
- kernel_instances(ctx)[source]#
Return instance plugin specifications.
- Parameters
ctx (
KernelDictContext
) – A context data structure containing parameters relevant for kernel dictionary generation.- Returns
dict
– A dictionary suitable for merge with aKernelDict
containing instances.
- kernel_shapes(ctx)[source]#
Return shape plugin specifications.
- Parameters
ctx (
KernelDictContext
) – A context data structure containing parameters relevant for kernel dictionary generation.- Returns
dict
– A dictionary suitable for merge with aKernelDict
containing all the shapes in the canopy.