D. Mesh, Topology and Pattern
Form finding a cable-net or generating a compression-only vault usually starts with a 2D Mesh
, which represents the horizontal projection of the eventual structure. The line segments of this Mesh
is called Pattern. For example, a pattern could be created from an existing structure.
1. Interactive Mesh Constructor in Rhino
Pattern generation usually starts with a base Mesh
, and then optimize or modify the mesh topologically later. Here are a few ways to create a base mesh with objects in Rhino.
1.a: From Mesh
A Rhino mesh object can be converted to a COMPAS mesh object.
1.b: From Surface
A non-trimmed Rhino NURBS surface or a Rhino polysurface can be used to create a Mesh. Note that the control point numbers in u-, v-directions of the surface won't influence the mesh.
1.c: From Lines
The most simple and manual way is to draw the edges of the Mesh as Rhino lines. Each edge should be an individual line in the XY plane; all lines should be broken at all line intersections. In other words, these lines may not be overlapping.
A mesh data structure is the network of faces. Thus, if the input set of lines must consist of closed loops of lines representing the faces. If the lines are not closed, such as a "leaf" edge, which contains a vertex with degree 1 will be omitted.
1.d: From Points
For strictly two-dimensional points in the XY plane, they can also be used to create a base mesh.
Mesh.from_lines()
and Mesh.from_points()
creates two different types of two-dimensional face shapes that are commonly used. The former one is quadrilateral, quad mesh and the latter one is triangle. Quadrilateral and triangle faces have 4 and 3 vertices on every face. A quadrilateral mesh could be turned into a triangle mesh by splitting each set of four into two sets of three. A quadrilateral face could be non-planar. By moving the vertices along z-axis in the earlier part of this session has led to 4 non-planar quad faces.
Mesh.quads_to_triangles()
could convert a quad mesh to a triangle mesh.
2. Ex. Delaunay triangulation
Triangulation is a method that is fast and robust for create a base mesh. Here a set of random vertices in the boundary is used to compute a Delaunay triangulation Delaunay triangulations maximize the minimum angle of all the angles of the triangles in the triangulation; they tend to avoid sliver triangles. We can use function compas.geometry.delaunay_from_points
.
3. Remote Procedure Call and Proxy
Python has a default implementation in C: CPython. However, Rhino uses another implementation of the language, IronPython, based on .NET. As such, it implements the default core language and most of the standard library. Some Python packages available through PIP are pure Python and rely on elements supported by IronPython. Some other modules are, however, specific to the implementation. In particular, NumPy uses native C code, which is supported by CPython but not by IronPython.
To work around this limitation, COMPAS provides a mechanism to access the functionality of a CPython environment seamlessly from any other Python environment through a Remote Procedure Call(RPC)
.
Continuing the example of Delaunay triangulation in the last session, there are two functions in COMPAS, delaunay_from_points()
and delaunay_from_points_numpy()
, the former could be called in Rhino with pure IronPython, whereas the latter needs a Proxy.
Comparing the computing time, delaunay_from_points()
takes 0.0419921875 s and delaunay_from_points_numpy()
takes 0.01100921630859375s, which is around four times faster. The comparative advantage of using numpy
and Proxy would expand along with the increase in the input scale.
4. Topological Modification
4.a: Delete Vertices
Mesh.delete_vertex(key)
would delete a vertex from the mesh and everything that is attached to it. For example, holes can be created by deleting interior vertices is a base mesh, or a pattern.
4.b: Delete Faces
5. Subdivision
Mesh Class contains different subdivision methods to densify the original mesh.
5.a: subdivision tracking attributes
Here we create a function to track the hierarchy of each subdivision using the mesh attributes.
5.b: visualize vertices hierarchy
Here original nodes are white dots, children are red and grandchildren are black.
5.c: visualize edge hierarchy
5.d: visualize face hierarchy
The following image shows you the change of face keys. The smallest fkeys
are shown in green, and the largest ones are shown in red. In each subdivision iteration, old fkey
would be deleted and new fkey
would be created. Thus, if you try to show the fkeys
after 2 times of subdivisoon, you will not be able to the former fkeys
.
Note that adding and removing elements will not cause identifiers to be renumbered. Therefore, after certain topological operations (e.g. subdivision), vertex and face identifiers no longer necessarily form contiguous sequences. This needs to be taken into account when converting sequences of vertices, faces, and edges to lists, for example for numerical calculation. To transparently convert non-contiguous sequences of identifiers to contiguous list indices, use “key/index maps”.
5.e: mesh subdivision methods
An input mesh can be subdivided under different subdivision algorithms.
mesh_subdivide_quad()
could subdivide a mesh such that all faces are quads. The former example is a quad scheme subdivision.
mesh_subdivide_tri()
could subdivide a mesh using simple insertion of vertices.
mesh_subdivide_catmullclark()
subdivides a mesh using the Catmull-Clark algorithm. Catmull-Clark subdivision is similar to the quad subdivision, but with smoothing after every level of further subdivision.
mesh_subdivide_corner()
subdivides a mesh by cutting corners.
Last updated