PLaSK User Manual

SingleStack2D Class

class plask.geometry.SingleStack2D(shift=0, **alignment)

Container that organizes its items in a vertical stack (2D version).

The bottom side of the first object is located at the shift position in container local coordinates. Each consecutive object is placed on the top of the previous one.

Parameters:
  • shift (float) – Position in the local coordinates of the bottom of the stack.
  • alignment (dict) – Horizontal alignment specifications. This dictionary can contain only one item. Its key can be left, right, #center, and # where # is the horizontal axis name. The corresponding value is the position of the given edge/center/origin of the item. This alignment can be overriden while adding the objects to the stack. By default the alignment is {'left': 0}.

See also

Function plask.geometry.Stack2D().

Methods

align_zero_on(…) Align zero with the vertical position pos of the specified item.
append(item, **alignment) Append a new object to the stack.
contains(…) Test if the geometry object contains a point.
get_leafs([path]) Get list of the geometry tree leafs.
get_leafs_bboxes([path]) Calculate bounding boxes of all the geometry tree leafs.
get_leafs_positions([path]) Calculate positions of all the geometry tree leafs.
get_leafs_translations([path]) Get list of Translation objects holding all the geometry tree leafs.
get_matching_objects(cond) Get list of the geometry tree objects matching condition.
get_material(…) Get material at the given point.
get_object_bboxes(object[, path]) Calculate bounding boxes of all instances of specified object.
get_object_positions(object[, path]) Calculate positions of all instances of the specified object.
get_paths(…) Get subtree containing paths to all leafs covering the specified point.
get_role_objects(role) Get list of the geometry tree objects that have the specified role.
get_roles(…) Get roles of objects at specified point.
has_role(…) Test if the specified point has a given role.
index(item[, path]) Return index of the given item.Args: object: Object which lower edge should lie at height 0.
insert(index, item, **alignment) Insert a new object to the stack.
modify_objects(callable) Modify all objects in the geometry tree.
move_item(path, **alignment) Move horizontally item existing in the stack, setting its position according to the new aligner.
object_contains(…) Test if the specified geometry object contains a point.
prepend(item, **alignment) Prepend a new object to the stack.
set_zero_below(item[, path]) Set zero below the specified item.
validate() Check if the object is complete and ready for calculations.

Attributes

bbox Minimal rectangle which contains all points of the geometry object (in local coordinates).
default_aligner Default alignment for new stack items.
dims Number of object’s dimensions (int, 2 or 3).
role Role of the object.
roles List of all the roles of the object.
steps Step info for mesh generation for non-uniform objects.

Descriptions

Method Details

SingleStack2D.align_zero_on(item, path, pos)
SingleStack2D.align_zero_on(item)
SingleStack2D.align_zero_on(item, pos)
SingleStack2D.align_zero_on(item, path)

Align zero with the vertical position pos of the specified item.

This method shifts the local coordinates of the stack vertically. The vertical coordinate of the stack origin is placed at the local position pos of the specified item (0 by default).

Parameters:
  • item – Stack item which lower edge should lie at height 0.
  • path – Path specifying a particular item instance.
  • pos – Local position of the specified object to place at stack zero.
SingleStack2D.append(item, **alignment)

Append a new object to the stack.

This method adds a new item to the stack and places it at its top.

Parameters:
  • item (GeometryObject2D) – Object to append to the stack.
  • alignment (dict) – Horizontal alignment specifications. This dictionary can contain only one item. Its key can be left, right, #center, and # where # is the horizontal axis name. By default the object is aligned according to the specification in the stack constructor.
SingleStack2D.contains(point)
SingleStack2D.contains(c0, c1)

Test if the geometry object contains a point.

Parameters:
  • point (plask.vector) – Vector with local coordinates of the tested point.
  • c0 (float) – Horizontal local coordinate of the tested point.
  • c1 (float) – Vertical local coordinate of the tested point.
Returns:

True if the geometry object contains the given point.

Return type:

bool

SingleStack2D.get_leafs(path=None)

Get list of the geometry tree leafs.

This method returns all the geometry tree leafs located under this geometry object. By leaf we understand a proper geometry object, in contrast to any container or transformation.

Parameters:path – Path that can be used to select only some leafs.
Returns:List of translations of the leafs.
Return type:sequence

All these methods are guaranteed to return their sequences in the same order: get_leafs(), get_leafs_bboxes(), get_leafs_positions(), get_leafs_translations().

SingleStack2D.get_leafs_bboxes(path=None)

Calculate bounding boxes of all the geometry tree leafs.

This method computes the bounding boxes of all the geometry tree leafs located under this geometry object. By leaf we understand a proper geometry object, in contrast to any container or transformation.

The bounding boxes are computed in the local coordinates of this object.

Parameters:path – Path that can be used to select only some leafs.
Returns:List of vectors containing the position of the leafs.
Return type:sequence

All these methods are guaranteed to return their sequences in the same order: get_leafs(), get_leafs_bboxes(), get_leafs_positions(), get_leafs_translations().

SingleStack2D.get_leafs_positions(path=None)

Calculate positions of all the geometry tree leafs.

This method computes position of all the geometry tree leafs located under this geometry object. By leaf we understand a proper geometry object, in contrast to any container or transformation.

The position are computed in the local coordinates of this object.

Parameters:path – Path that can be used to select only some leafs.
Returns:List of vectors containing the position of the leafs.
Return type:sequence

All these methods are guaranteed to return their sequences in the same order: get_leafs(), get_leafs_bboxes(), get_leafs_positions(), get_leafs_translations().

SingleStack2D.get_leafs_translations(path=None)

Get list of Translation objects holding all the geometry tree leafs.

This method computes the Translation objects of all the geometry tree leafs located under this geometry object. By leaf we understand a proper geometry object, in contrast to any container or transformation.

The translations are computed in the local coordinates of this object.

Parameters:path – Path that can be used to select only some leafs.
Returns:List of translations of the leafs.
Return type:sequence

All these methods are guaranteed to return their sequences in the same order: get_leafs(), get_leafs_bboxes(), get_leafs_positions(), get_leafs_translations().

SingleStack2D.get_matching_objects(cond)

Get list of the geometry tree objects matching condition.

This method returns all the objects in the geometry tree that match the specified condition.

Parameters:cond – Python callable that accepts a geometry object and returns Boolean indicating whether the object should be returned by this method or not.
Returns:List of objects matching your condition.
Return type:sequence
SingleStack2D.get_material(point)
SingleStack2D.get_material(c0, c1)

Get material at the given point.

This method returns a material object with the material at the given point if this point is located within the geometry object self. Otherwise the method returns None.

Parameters:
  • point (plask.vector) – Vector with local coordinates of the tested point.
  • c0 (float) – Horizontal local coordinate of the tested point.
  • c1 (float) – Vertical local coordinate of the tested point.
Returns:

Material at the specified point or None.

SingleStack2D.get_object_bboxes(object, path=None)

Calculate bounding boxes of all instances of specified object.

The bounding boxes are computed in the local coordinates of self.

Parameters:
  • object – Object to test.
  • path – Path specifying a particular object instance.
Returns:

List of bounding boxes of the instances of the object.

Return type:

sequence

All these methods are guaranteed to return their sequences in the same order, provided they are called with the same arguments: get_object_bboxes(), get_object_positions()

SingleStack2D.get_object_positions(object, path=None)

Calculate positions of all instances of the specified object.

The position are computed in the local coordinates of self.

Parameters:
  • object – Object to test.
  • path – Path specifying a particular object instance.
Returns:

List of vectors containing the position of the instances of the object.

Return type:

sequence

All these methods are guaranteed to return their sequences in the same order, provided they are called with the same arguments: get_object_bboxes(), get_object_positions()

SingleStack2D.get_paths(c0, c1, all=False)
SingleStack2D.get_paths(point, all=False)

Get subtree containing paths to all leafs covering the specified point.

Parameters:
  • point (plask.vector) – Vector with local coordinates of the tested point.
  • c0 (float) – Horizontal local coordinate of the tested point.
  • c1 (float) – Vertical local coordinate of the tested point.
  • all (bool) – If True then all the leafs intersecting the point are considered. Otherwise, only the path to the topmost (i.e. visible) object is returned.
Returns:

Subtree with the path to the specified point.

SingleStack2D.get_role_objects(role)

Get list of the geometry tree objects that have the specified role.

This method returns all the objects in the geometry tree that have the specified role.

Warning

This method will return the very object with the role specified and not its items, which is against the normal behavior of the roles.

Parameters:role (str) – Role to search objects with.
Returns:List of objects matching your condition.
Return type:sequence
SingleStack2D.get_roles(point)
SingleStack2D.get_roles(c0, c1)

Get roles of objects at specified point.

This method returns a set of all the roles given to the every object intersecting the specified point.

Parameters:
  • point (plask.vector) – Vector with local coordinates of the tested point.
  • c0 (float) – Horizontal local coordinate of the tested point.
  • c1 (float) – Vertical local coordinate of the tested point.
Returns:

Set of the roles at given point.

Return type:

set

SingleStack2D.has_role(role, point)
SingleStack2D.has_role(role, c0, c1)

Test if the specified point has a given role.

This method checks if any object intersecting the specified point has the role role.

Parameters:
  • point (plask.vector) – Vector with local coordinates of the tested point.
  • c0 (float) – Horizontal local coordinate of the tested point.
  • c1 (float) – Vertical local coordinate of the tested point.
Returns:

True if the point has the role role.

Return type:

bool

SingleStack2D.index(item, path=None)
Return index of the given item.Args:
object: Object which lower edge should lie at height 0. path: Path specifying a particular item instance.
SingleStack2D.insert(index, item, **alignment)

Insert a new object to the stack.

This method adds a new item to the stack and places it at the position specified by index.

Parameters:
  • index (int) – Index of the inserted item in the stack.
  • item (GeometryObject2D) – Object to insert to the stack.
  • alignment (dict) – Horizontal alignment specifications. This dictionary can contain only one item. Its key can be left, right, #center, and # where # is the horizontal axis name. By default the object is aligned according to the specification in the stack constructor.
SingleStack2D.modify_objects(callable)

Modify all objects in the geometry tree.

This method calls callable on every object in the geometry tree. The callable takes a single geometry object as an argument and should return None (in which case nothing happens), a new object to replace the original one, or an empty tuple (which will result in the removal of the original object).

Parameters:callable – a callable filtering each object in the tree
Returns:modified geometry
Return type:GeometryObject
SingleStack2D.move_item(path, **alignment)

Move horizontally item existing in the stack, setting its position according to the new aligner.

Parameters:
  • path (Path) – Path returned by append() specifying the object to move.
  • alignment (dict) – Alignment specifications. The only key in this dictionary are can be left, right, #center, and #` where # is an axis name. The corresponding values is the positions of a given edge/center/origin of the item. Exactly one alignment for horizontal axis must be given.
SingleStack2D.object_contains(object, path, mesh)
SingleStack2D.object_contains(object, path, point)
SingleStack2D.object_contains(object, point)
SingleStack2D.object_contains(object, path, c0, c1)
SingleStack2D.object_contains(object, c0, c1)
SingleStack2D.object_contains(object, mesh)

Test if the specified geometry object contains a point.

The given geometry object must be located somewhere within the self geometry tree.

Parameters:
  • object – Object to test.
  • path – Path specifying a particular object instance.
  • point (plask.vector) – Vector with local coordinates of the tested point.
  • c0 (float) – Horizontal local coordinate of the tested point.
  • c1 (float) – Vertical local coordinate of the tested point.
  • mesh (plask.mesh.Mesh) – Mesh, which points are tested.
Returns:

True if the specified geometry object contains the given point.

If a mesh is tested, the return value is an array of bools.

Return type:

bool

SingleStack2D.prepend(item, **alignment)

Prepend a new object to the stack.

This method adds a new item to the stack and places it at its bottom.

Parameters:
  • item (GeometryObject2D) – Object to prepend to the stack.
  • alignment (dict) – Horizontal alignment specifications. This dictionary can contain only one item. Its key can be left, right, #center, and # where # is the horizontal axis name. By default the object is aligned according to the specification in the stack constructor.
SingleStack2D.set_zero_below(item, path=None)

Set zero below the specified item.

This method shifts the local coordinates of the stack vertically. The vertical coordinate of the stack origin is placed at the bootom edge of the specified item.

Parameters:
  • item – Stack item which lower edge should lie at height 0.
  • path – Path specifying a particular item instance.
SingleStack2D.validate()

Check if the object is complete and ready for calculations.

This method is specific for a particular object. It raises an exception if the object definition is somehow incomplete.

Attribute Details

SingleStack2D.bbox

Minimal rectangle which contains all points of the geometry object (in local coordinates).

SingleStack2D.default_aligner

Default alignment for new stack items.

SingleStack2D.dims

Number of object’s dimensions (int, 2 or 3).

SingleStack2D.role

Role of the object. Valid only if the object has only one role.

SingleStack2D.roles

List of all the roles of the object.

SingleStack2D.steps

Step info for mesh generation for non-uniform objects.

This parameter is considered only for the non-uniform leafs in the geometry tree. It has two attributes that can be changed:

num Maximum number of the mesh steps in each direction the object is divided into.
dist Minimum step size.

The exact meaning of these attributes depend on the mesh generator, however in general they indicate how densely should the non-uniform object be subdivided.

It is possible to assign simply an integer number to this parameter, in which case it changes its num attribute.