In our Shapemaker application we have the need to render large amounts of specific geometries to represent any telecom tower and ancillaries mounted on it as close to the reality, as possible. This results in the need to be able to render thousands different partial geometries in our 3D viewer, which is based on the ShapeDiver web viewer technology.
Besides the tower itself and ladder, which may contain 500 – 2000 separate members with round or angular cross-section, a lot of various geometries for ancillaries have to be rendered as well. Some ancillaries are simple box shape (panel antennas or RRUs) and these normally are very simple to be rendered. On the other side, grid microwave dishes, YAGI antennas or Helix shaped antennas are composed of many separate pieces of 3D geometry. Normally we render these antennas as pipes and curved edges are converted to polyline segments. Therefore, a single antenna may be composed out of few hundreds of elements. In order to render the tower and ancillaries as quickly as possible, we will show how we prepare the geometry to reach best performance with reasonable quality.
Comparative study of different approaches
The geometry is defined by a Grasshopper script, using visual programing to define any of the telecom structure that is possible to be designed in Shapemaker. I will demonstrate the performance of a very simple case of the need of rendering N straight pipes (N ranging between 400 – 2000 pieces of geometry).
The simplest approach
The simplest way to render pipes would be to construct pipe as BREP geometry and sending this geometry to ShapeDiver to get the rendering in the 3D viewer. In the Grasshopper script, this approach is very simple to code.
However, BREPs are complex geometries that in order to get rendered need to be transformed into mesh. ShapeDiver conveniently does this conversion for us so the definition of the geometry this way works. However, this way we have no power over the performance or quality of the generated mesh. Additionally, each BREP is handled separately which results in lot of geometries to be sent to the viewer and consequently, this approach will be one of the most time demanding.
Generate custom mesh
In the script, we could transform the BREPs into mesh elements by using “Mesh Brep” component and quality settings for the mesh approximation. Using smaller quality (coarser mesh) should then lead to performance gains.
On the image above, you may see that locally the operation of constructing mesh is very time consuming and in this case, it took 2.7 s to construct mesh for 1600 BREPs. Now in this case we do have the option to sacrifice a portion of the high fidelity rendering to have the rendering done quicker. On the image below you can see meshed cylinder either in performance mode (96 mesh faces) and in high fidelity mesh (232 mesh faces).
Using the coarser mesh is visible only with great zoom level and for the overview of the telecom tower as well as the ancillaries, it is more than appropriate.
Mesh and transformations
The recommended way to create the geometry to render is to create no geometry at all (or close to that). In the script below you can see that I created just a single mesh and the used transformations to give the viewer all the necessary information, but in very condensed way. Transformation is basically a 4x4 matrix, that transforms the original (single) mesh into any shape or alignment in 3D space.
So instead in creating 2000 members, even if each member is different, but they all have the common shape – the pipe, we can send the single original mesh and list of 2000 transformation matrices as attributes.
To compare the previous approach, I have tested also an alternative (intermediate) approach when single mesh is created and then the transformations are applied to the geometries directly resulting in 2000 meshes in the desired positions. This approach skips the most time consuming part of creating BREP geometries and then converting them to mesh as it created a single mesh which is then moved, rotated or resizer based on the inputted values.
This intermediate approach is more similar to the traditional use of Grasshopper scripts, when the geometry may be displayed directly as well.
Results
The speed of rendering depends greatly on whether the end covers of the pipes are rendered as well, if the BREPs are created during the script runtime. We can also observe on the figures below, that using the optimal approach with creating a single mesh and list of transformations leads to the least time needed for the rendering and also there is nearly no difference on if the pipe is rendered with or without lids.
For the pipes without the lids, all the methods show similar performance, and it seems in case of using opened BREPs there is no need to try to optimize the script. For closed geometries the effect is however very substantial. Interesting is, that using list of meshes (“Meshes”) is not too much slower than the optimal set (“1 mesh + list of transformations”) and it feels simpler to introduce into any Grasshopper script.
What is interesting and was also observed, that there is no visible decrease in runtime of the optimal set (“1 mesh + list of transformations”) when coarser mesh is used. All the data sets on the following figure show mostly differences in values due to statistical reasons.
The pipes meshed with 96 faces were rendered in exactly same time as pipes the 232 faces, sometimes even a bit slower. Therefore the “1 mesh + list of transformations” seems very viable for high-fidelity rendering as using more precise mesh including lids have no visible effect on the rendering time.
Conclusions
Lets use the data what were gathered in the previous chapter and estimate the effect on the 3D viewer rendering performance of a lattice telecom tower with moderate size and 30 ancillaries of various types mounted on it.
If we look at closeup of the part of the tower geometry, we can see that the members are for the structural engineering calculation defined just by a straight thin line and the cross-section defines the shape (volume) of the rendered member. The ends of each member are actually not visible at all and in most common cases it is not needed to render the small circular lids at the ends of the members. Very similar situation is the case of the Grid microwave dishes or the YAGI or Helix antennas.
For this case the optimal rendering approach using the mesh and transformations would reduce the time needed for rendering by approximately 20%. On the other hand, the script may become more complex to read and maintain.
It is mostly the mounting rods and microwave dishes, where the ends of the pipes are really visible and, in these cases, substantial speed improvement may be achieved by using the mesh and transformations approach described above resulting in up to 5x faster rendering of these members compared to the simple script approach using just BREPs.