8.1.1 The Formex class

This class represents a structured set of 3D coordinates. Basically, a Formex is a three dimensional array8.1 of float values. The array has a shape (nelems,nplex,3). Each slice [i,j] of the array contains the three coordinates of a point in space. Each slice [i] of the array contains a connected set of nplex points: we will refer to it as an element. The number of points in an element is also called the plexitude of the element or the plexitude of the Formex (since all elements in a Formex have the same number of points).

The Formex class does not attribute any geometrical interpretation to the grouping of points in an element. This is left to the user, or to subclasses.

Thus, an element consisting of two points could (and usually will) represent a straight line segment between this two points. But the points could just as well be the two opposite corners of a rectangle. An element with plexitude 3 (in short: plex-3 element) could be interpreted as a triangle or as two straight line segments or as a curved line or even as a circle through these points. If it is a triangle, it could be either the circumference of the triangle or the part of the plane inside that circumference. As far as the Formex class concerns, each element is just a set of points.

All elements in a Formex must have the same number of points, but you can construct Formex instances with any (positive) number of nodes per element. A plex-1 Formex is just a collection of unconnected nodes (each element is a single point).

One way of attaching other data (than the coordinates of its points) to the elements of a Formex, is by using the 'property' attribute. The property is an array holding one integer value for each of the elements of the Formex. The interpretation of this property value is again completely left to the user. It could be a code for the type of element, or for the color to draw this element with. Often it will be used as an index into some other (possibly complex) data structure holding all the characteristics of that element. By including this property index into the Formex class, we make sure that when new elements are constructed from existing ones, the element properties are automatically propagated.

class Formex( data=[[[]]],prop=None)
Create a new Formex from the specified data and optional property values. The data can either be: another Formex instance, a string that can be interpreted by the pattern() method to create coordinates, or a 2D or 3D array of coordinates or a structure (e.g. compound list) that can be transformed to such an array.

If 2D coordinates are given, a 3-rd coordinate 0.0 will be added. Internally, a Forme always has 3D coordinates.

Example: F = Formex([[[1,0],[0,1]],[[0,1],[1,2]]]) creates a Formex with two elements, each having 2 points in the global z-plane.

If a prop argument is specified, the setProp() method will be called with this argument to assign the properties to the Formex.

If no data are specified, an empty Formex is created. The use of empty Formices is not very well tested yet, and therefore not not encouraged.



Footnotes

... array8.1
Currently, this is implemented as a NumPy ndarray object. If you want to do complex things in pyFormex, some basic knowledge of NumPy may be required .