Assembly

class pyvsim.Primitives.Assembly[source]

The assembly class is a non-terminal node in the Components tree. It carries almost no properties of its own, but makes sure that all geometrical transformations are propagated to its subcomponents.

The subcomponents are stored in a numpy array. This is definetely not always needed (except when fancy slicing is desired), but this keeps the consistency all along the code, making all lists instances of numpy.ndarray.

Methods

acceptVisitor(visitor)[source]

This method is a provision for the Visitor Pattern <http://http://en.wikipedia.org/wiki/Visitor_pattern> and is be used for traversing the tree.

As an assembly has sub-elements, we must iterate through them

append(component, n=None)[source]

Adds element at the component list.

Parameters :

component : Component

The Component to be added

n : int = None

[Optional] The position of the component to be added. If no parameter is given, the element is added at the end of the list, otherwise it is added at the n-th position.

Returns :

n :

The list length.

bounds[source]

Returns the boundaries of the assembly by finding the minimum bounding box aligned to the axis that contains it.

The algorithm works by finding the maximum and minimum values of x, y and z by traversing the subcomponents.

Returns :

bounds : numpy.ndarray \((2,3)\)

An array containing the following elements: [[xmin, ymin, zmin],

[xmax, ymax, zmax]]

clearData()[source]

This method iterates the clearData to all the items found in the list, making the clearData method be executed through the whole components tree.

intersections(p0, p1, tol=1e-08)[source]

This method searches for intersections between a given set of line segments and the Parts included in this Assembly. Please check the documentation at Part class for a better description of its internals.

Parameters :

p0, p1 - numpy.ndarray :math:`(N,3)` :

Coordinates defining N segments by 2 points (each p0, p1 pair), which will be tested for intersection with the polygons defined in the structure.

tol - double :

Tolerance used in the criteria for intersection (see documentation of each implementation)

Returns :

None :

If no intersections are found. Otherwise returns a list with:

lineParameter :

This is used to indicate how far the intersection point is from the segment starting point, if 0, the intersection is at p0 and if 1, the intersection is at p1

Iff the parameter is > 1 (999), no intersection was found

intersectionCoordinates :

This is where the intersections are found

triangleIndexes :

This is the index of the triangle where the intersection was found. If no intersection found, will return 0, but attention, the only way to guarantee that no intersection was found is when the lineParameter is zero.

normals :

The normal vector at the intersection point (if the surface is defined with normals at vertices, interpolation is performed).

part :

A list with references to this object. This is, in this case, redundant, but that makes the function signature uniform with the Assembly class

material = None

The assembly material is important in the case it is an environment (the root element of the simulation). As a default, assemblies are initialized as IdealMaterial (no chromatic dispersion) and refractiveIndex = 1

refractiveIndex(wavelength=5.32e-07)[source]

Returns the index of refraction of the material given the wavelength (or a list of them)

Parameters :

wavelength : scalar or numpy.ndarray \((N)\)

The wavelength of the incoming light given in meters

Returns :

refractiveIndex : same dimension as wavelength

The index of refraction

remove(element)[source]

Remove the element at the n-th position of the component list. This also de-registers this assembly as its parent.

Parameters :

element : string, int or object

The name, the position in the list or the object to be removed

Returns :

element :

A reference to the element, if one is to re-use that.

rotateImplementation(angle, axis, pivotPoint)[source]

This method iterates the rotation to all the items found in the list, making the rotate method be executed through the whole components tree.

surfaceProperty = None

Surface property of the assembly is not important, but it is set as default to Component.TRANSPARENT

translateImplementation(vector)[source]

This method iterates the translation to all the items found in the list, making the translate method be executed through the whole components tree.

This Page