AlignContainer2D Class¶
 class plask.geometry.AlignContainer2D¶
Align2D()
Container with its items located according to specified alignment.
Container in which every item is located according to its alignment specification. Items in this container can overlap with each other so, although their order matches, you can create any arrangement you wish.
Example
To create a trapezoid of the height 2µm and lower and upper bases of 4µm and 3µm, respectively, you can issue the following commands:
>>> trapezoid = plask.geometry.Align2D() >>> trapezoid.append(plask.geometry.Rectangle(4, 2, 'GaAs'), 0, 0) >>> trapezoid.append(plask.geometry.Triangle((0, 2), (1, 2), 'air'), bottom=0, right=4)
The triangle now overlaps a part of the rectangle.
alias of
Align2D
Methods¶

Add new object to the container with provided alignment. 

Test if the geometry object contains a point. 

Get list of the geometry tree leafs. 

Calculate bounding boxes of all the geometry tree leafs. 

Calculate positions of all the geometry tree leafs. 

Get list of 

Get list of the geometry tree objects matching condition. 

Get material at the given point. 

Calculate bounding boxes of all instances of specified object. 

Calculate positions of all instances of the specified object. 

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

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

Get roles of objects at specified point. 

Test if the specified point has a given role. 

Return index of the given item.Args: object: Object which lower edge should lie at height 0. 

Insert new object to the container at specified position with provided alignment. 

Modify all objects in the geometry tree. 

Move item existing in the container, setting its position according to the new aligners. 

Test if the specified geometry object contains a point. 

Check if the object is complete and ready for calculations. 
Attributes¶
Minimal rectangle which contains all points of the geometry object (in local coordinates). 

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

Role of the object. 

List of all the roles of the object. 

Step info for mesh generation for nonuniform objects. 
Descriptions¶
Method Details¶
 AlignContainer2D.append(item, c0, c1)¶
 AlignContainer2D.append(item, **alignments)
 AlignContainer2D.append(item, translation=plask.vec(0, 0))
Add new object to the container with provided alignment.
 Parameters:
item (geometry object) – Item to add.
translation (
plask.vec
) – Twodimensional vector specifying the position of the item origin.c0 (float) – Horizontal component of the vector specifying the position of the item origin.
c1 (float) – Vertical component of the vector specifying the position of the item origin.
alignments (dict) – Alignment specifications. The keys in this dictionary can be
left
,right
,top
,bottom
,#center
, and #` where # is an axis name. The corresponding values are positions of a given edge/center/origin of the item. Exactly one alignment for each axis must be given.
 AlignContainer2D.contains(c0, c1)¶
 AlignContainer2D.contains(point)
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
 AlignContainer2D.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()
.
 AlignContainer2D.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()
.
 AlignContainer2D.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()
.
 AlignContainer2D.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()
.
 AlignContainer2D.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
 AlignContainer2D.get_material(c0, c1)¶
 AlignContainer2D.get_material(point)
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.
 AlignContainer2D.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()
 AlignContainer2D.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()
 AlignContainer2D.get_paths(point, all=False)¶
 AlignContainer2D.get_paths(c0, c1, 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.
See also
 AlignContainer2D.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
 AlignContainer2D.get_roles(c0, c1)¶
 AlignContainer2D.get_roles(point)
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
 AlignContainer2D.has_role(role, c0, c1)¶
 AlignContainer2D.has_role(role, point)
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
 AlignContainer2D.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.
 AlignContainer2D.insert(index, item, **alignments)¶
 AlignContainer2D.insert(index, item, translation=plask.vec(0, 0))
 AlignContainer2D.insert(index, item, c0, c1)
Insert new object to the container at specified position with provided alignment.
 Parameters:
index (int) – Item index after insertion.
item (geometry object) – Item to insert.
translation (
plask.vec
) – Twodimensional vector specifying the position of the item origin.c0 (float) – Horizontal component of the vector specifying the position of the item origin.
c1 (float) – Vertical component of the vector specifying the position of the item origin.
alignments (dict) – Alignment specifications. The keys in this dictionary can be
left
,right
,top
,bottom
,#center
, and #` where # is an axis name. The corresponding values are positions of a given edge/center/origin of the item. Exactly one alignment for each axis must be given.
 AlignContainer2D.modify_objects(callable)¶
Modify all objects in the geometry tree.
This method calls
callable
on every object in the geometry tree. Thecallable
takes a single geometry object as an argument and should returnNone
(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:
 AlignContainer2D.move_item(path, **alignments)¶
Move item existing in the container, setting its position according to the new aligners.
 Parameters:
path (Path) – Path returned by
append()
specifying the object to move.alignments (dict) – Alignment specifications. The keys in this dictionary are can be
left
,right
,top
,bottom
,#center
, and #` where # is an axis name. The corresponding values are positions of a given edge/center/origin of the item. Exactly one alignment for each axis must be given.
 AlignContainer2D.object_contains(object, mesh)¶
 AlignContainer2D.object_contains(object, point)
 AlignContainer2D.object_contains(object, path, c0, c1)
 AlignContainer2D.object_contains(object, path, point)
 AlignContainer2D.object_contains(object, c0, c1)
 AlignContainer2D.object_contains(object, path, 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
 AlignContainer2D.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¶
 AlignContainer2D.bbox = <property object>¶
Minimal rectangle which contains all points of the geometry object (in local coordinates).
See also
 AlignContainer2D.dims = <property object>¶
Number of object’s dimensions (int, 2 or 3).
 AlignContainer2D.role = <property object>¶
Role of the object. Valid only if the object has only one role.
 AlignContainer2D.roles = <property object>¶
List of all the roles of the object.
 AlignContainer2D.steps = <property object>¶
Step info for mesh generation for nonuniform objects.
This parameter is considered only for the nonuniform 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 nonuniform object be subdivided.
It is possible to assign simply an integer number to this parameter, in which case it changes its
num
attribute.