PolyhedronGeometry
A metatype for representing a constructive geometry using polyhedrons.
Attributes
None.
Note
The geometry is locked once it has been instanciated. However media properties can still be modified, e.g. their density.
Constructor
A PolyhedronGeometry is a hierarchy of convex polyhedrons. The constructor takes a top (mother) polyhedron as first argument and an optional reference frame. If no reference frame is provided then the polyhedrons coordinates are assumed to be defined in the simulation frame.
Note
It is the user's responsibility to ensure that the polyhedrons are indeed convex.
Synopsis
pumas.PolyhedronGeometry(polyhedron, (frame))
Arguments
Name | Type | Description |
---|---|---|
polyhedron | table |
Top (mother) polyhedron as described below. |
(frame) | UnitaryTransformation | Reference frame for polyhedrons. If nil polyhedrons are assumed to be defined in the simulation frame. |
A convex polyhedron is defined by a filling Medium and by
a list of faces delimiting its inner volume. Each face is specified by a point
lying on the face and by a unit normal vector, outward going. In addition the
volume can contain an arbitrary number of daughter polyhedrons. The data of a
polyhedron are provided as a Lua table
with the following synopsis:
polyhedron = {medium, {x, y, z, nx, ny, nz, ...}, {(daughter), ...}}
where the various elements are listed in the table below.
Name | Type | Description |
---|---|---|
medium | Medium or string |
Filling medium of the polyhedron. If a string is provided it must reference a TabulatedMaterial. Then a UniformMedium is implicitly created and filled with the corresponding material. |
x | number |
Cartesian x (first) coordinate of a point on the face, in m. |
y | number |
Cartesian y (second) coordinate of the same point on the face, in m. |
z | number |
Cartesian z (third) coordinate of the same point on the face, in m. |
nx | number |
Cartesian x (first) coordinate of the normal to the face, outward going. |
ny | number |
Cartesian y (second) coordinate of the normal to the face, outward going. |
nz | number |
Cartesian z (third) coordinate of the normal to the face, outward going. |
(daughter) | table |
A daughter polyhedron contained inside and following the same semantic. |
Note
The sequence x, y, z, nx, ny and nz has to be repeated for each face.
Note
The daughter polyhedrons must not overlap and must all be contained in the mother volume. It is the user's responsibility to ensure that there is no overlap.
See also
PolyhedronGeometry.export
Export the polyhedrons to a file. This method requires an output filename to be
provided as first argument. Extra keyword options can be specified for the
export in a second table
argument, e.g. colorization (see below).
Note
If not explicitly specified the file format for the export is inferred from the extension of the output filename.
Synopsis
PolyhedronGeometry:export(path, {(color)=, (format)=})
Arguments
Name | Type | Description |
---|---|---|
path | string |
Output file for the export. |
(color) | table or function |
Color of the exported polyhedrons. |
(format) | string |
Format of the exported data. Currently only 'ply ' is supported. |
If the color option is provided as a table
then it must be formated as
{red, green, blue}
with color values ranging from 0 to 255. The color table
can be indexed by number or by color names ({red=, green=, blue=}
).
Alternatively one can also provide a painter callback function
with the
following synopsis: color(medium)
where medium is a constitutive
Medium of the PolyhedronGeometry. This
function must return three numbers in the range 0 to 255 indicating the the
color code to apply to the corresponding medium.
Returns
nil
See also
PolyhedronGeometry.insert
Insert a daughter geometry into the PolyhedronGeometry.
This method behaves as the table.insert
Lua function. If no index is specified
the daughter geometry is appended as the last element.
Synopsis
PolyhedronGeometry:insert(daughter)
PolyhedronGeometry:insert(index, daughter)
Arguments
Name | Type | Description |
---|---|---|
index | number |
Table index of the inserted geometry. |
daughter | Geometry | Daughter geometry to insert. |
Returns
nil
See also
PolyhedronGeometry.remove
Remove a daughter geometry from the PolyhedronGeometry
given its index. If no index is provided the last daughter geometry is removed.
This method behaves as the table.remove
Lua function.
Synopsis
PolyhedronGeometry:remove((index))
Arguments
Name | Type | Description |
---|---|---|
(index) | number |
Table index of the daughter geometry to remove. |
Returns
Type | Description |
---|---|
Geometry | The removed geometry. |