Note that ForeignArray instances are not usually created by users, and ForeignArray is not a class name available in MeshPy. It is just used to explain the interface provided.
Almost all input and output data in MeshPy can be accessed using the ForeignArray interface. It is called “foreign” because it provides access to an area of memory accessible by a pointer managed by an outside piece of software, such as a mesh generator.
Note that ForeignArray has no append method. Instead, use ForeignArray.resize() and then set the consecutive entries of the array.
Return the number of entries in the array. If the array is 2D (i.e. has non-1 unit), ForeignArray.__len__() only returns the length of the leading dimension. For example, for an array of points in n-dimensional space, __len__() returns the number of points.
If this ForeignArray represents a two-dimensional array, such as an array of point coordinates, ForeignArray.unit() gives the size of the subordinate dimension.
For example, for an array of points in 3-dimensional space, ForeignArray.__len__() returns the number of dimensions (3).
Return a bool indicating whether storage has been allocated for this array. This is only meaningful if the size of this array is tied to that of another, see ForeignArray.setup().
Change the length of the array as returned by ForeignArray.__len__().
Set up (i.e. allocate) storage for the array. This only works on arrays whose size is tied to that of other arrays, such as an array of point markers, which necessarily has the same size as the associated array of points, if it is allocated.
Release any storage associated with the array.
Get and set entries in the array. If this foreign array is 2D (see ForeignArray.unit), index may be a 2-tuple of integers, as in:
points[2,1] = 17
MeshInfo objects are picklable.
A 2D ForeignArray of float with dimension (N,2), providing a list of points that are referred to by index from other entries of this structure.
If MeshInfo.number_of_point_attributes is non-zero, this is a ForeignArray of floats of point attributes.
This element’s size is tied to that of MeshInfo.points.
ForeignArray of floats of point attributes.
This element’s size is tied to that of MeshInfo.points.
This element’s size is tied to that of MeshInfo.elements.
This element’s size is tied to that of MeshInfo.elements.
Defautls to 4 for linear tetrahedra. Change to 10 for second-order tetrahedra.
Convenient setters:
Other functionality:
Return a duplicate copy of this object.
Subdivide facets into subdivisions subfacets.
This routine is useful if you have to prohibit the insertion of Steiner points on the boundary of your triangulation to allow the mesh to conform either to itself periodically or another given mesh. In this case, you may use this routine to create the necessary resolution along the boundary in a predefined way.
subdivisions is either an int, indicating a uniform number of subdivisions throughout, or a list of the same length as facets, specifying a subdivision count for each individual facet.
Returns a tuple (new_points, new_facets), or (new_points, new_facets, new_facet_markers) if facet_markers is not None.
Run time switches for TetGen. See the TetGen documentation for the meaning of each switch.
Using the kwargs constructor argument, all the attributes defined below can be set. This setting will occur after Options.parse_switches() is called with the switches parameter.
Convenient setters:
Set a list of simple, single-polygon factes. Unlike MeshInfo.set_facets_ex(), this method does not allow holes and only lets you use a single polygon per facet.
Note
When the above says “list”, any repeatable iterable also accepted instead.
Set a list of complicated facets. Unlike MeshInfo.set_facets(), this method allows holes and multiple polygons per facet.
Note
When the above says “list”, any repeatable iterable also accepted instead.
Other functionality:
TetGen-provided loading and saving:
Parameters: | insert_points – a MeshInfo object specifying additional points to be inserted |
---|
Extrude a given connected base_shape (a list of (x,y) points) along the z axis. For each step in the extrusion, the base shape is multiplied by a radius and shifted in the z direction. Radius and z offset are given by rz_points, which is a list of (r, z) tuples.
Returns (points, facets, facet_holestarts, markers), where points is a list of (3D) points and facets is a list of polygons. Each polygon is, in turn, represented by a tuple of indices into points. If point_idx_offset is not zero, these indices start at that number. markers is a list equal in length to facets, each specifying the facet marker of that facet. facet_holestarts is also equal in length to facets, each element is a list of hole starting points for the corresponding facet.
Use MeshInfo.set_facets_ex() to add the extrusion to a MeshInfo structure.
The extrusion proceeds by generating quadrilaterals connecting each ring. If any given radius in rz_points is 0, triangle fans are produced instead of quads to provide non-degenerate closure.
If closure is EXT_OPEN, no efforts are made to put end caps on the extrusion.
If closure is EXT_CLOSED_IN_RZ, then a torus-like structure is assumed and the last ring is just connected to the first.
If ring_markers is not None, it is an list of markers added to each ring. There should be len(rz_points)-1 entries in this list. If rings are added because of closure options, they receive the corresponding XXX_closure_marker. If facet_markers is given, this function returns (points, facets, markers), where markers is is a list containing a marker for each generated facet. Unspecified markers generally default to 0.
If ring_point_indices is given, it must be a list of the same length as rz_points. Each entry in the list may either be None, or a list of point indices. This list must contain the same number of points as the base_shape; it is taken as the indices of pre-existing points that are to be used for the given ring, instead of generating new points.