Shape Database Tutorial (Part A): Creating 3D shapes from images
The Shape database in OghmaNano is a repository of geometric objects that can be reused across simulations. It is particularly useful for shapes that cannot easily be described by simple analytic functions – for example AFM-derived surface roughness, photonic crystals generated from 2D images, or imported CAD geometries. Once a shape has been built and stored here, it can be attached to objects in the Optical Workbench and used in ray-tracing, FDTD, or other optical simulations.
In this first part you will create a simple demo structure from a built-in 2D pattern, turn it into a 3D triangular mesh, and explore how mesh resolution affects both the visual quality and the computational cost of your simulations.
Step 1: Open the Shape database
Start from any simulation (for example the Reflection from film ray-tracing demo). Click the Databases tab in the ribbon and then click Shape database, as highlighted in ??. This opens the Shape database window (??).
afm_image, photonic_xtal, saw_wave,
teapot). You can reuse these in multiple simulations.
Step 2: Create a new shape entry
To create a new shape, right-click in the white area of the Shape database window and choose New → New shape from the context menu, as shown in ??.
A dialog appears asking for a New shape name. Enter
demo and click OK. The Shape editor
window then opens for your new shape
(??).
Step 3: Inspect the default Shape editor view
The Shape editor displays a 3D view on the left and a 2D image on the right (??). The default 2D pattern is a simple array of white circles on a black background, representing a photonic crystal or pillar array. Initially, the 3D view contains only a flat grid.
demo.
The right panel shows a default 2D pattern; the left panel will display the 3D mesh
once it has been built.
The toolbar at the top of the Shape editor contains three key buttons for this tutorial:
- Show Mesh – toggles the display of the existing 3D mesh.
- Edit Mesh – opens the mesh configuration window.
- Build Mesh – converts the 2D image into a 3D triangular mesh.
Step 4: Build your first mesh
Click Build Mesh (blue triangle icon). The right-hand pattern is converted into a 3D array of pillars in the left-hand view, and a triangular surface mesh is generated to approximate the 2D shape (??).
Use the mouse to rotate and zoom the 3D view. You will probably notice that the pillars are quite angular – more triangular than circular. This is because the initial mesh resolution is intentionally low, using only a modest number of triangles to keep the mesh lightweight.
Step 5: Refine the mesh resolution
To improve the fidelity of the shape, click Edit Mesh in the Shape editor toolbar. This opens the Configure mesh window (??).
The important fields are:
- x-triangles / y-triangles: the number of triangles used to seed the mesh in each direction (for example 20 Ă— 20 or 40 Ă— 40).
- Method: the meshing strategy. The default
Node reducemethod starts from a regular grid and then removes triangles that are not needed to represent the shape. - Min allowable angle: a quality constraint that prevents extremely skinny triangles.
Try increasing the resolution from 20 to 40 in both x-triangles and y-triangles, then click OK to close the dialog and click Build Mesh again. Repeat this process a few times, experimenting with values such as 40 Ă— 40 or 50 Ă— 50, and inspect how the 3D pillars change shape.
Remember that with the Node reduce method, the algorithm starts with a full
grid of triangles and then eliminates those that are unimportant for representing the
shape. The final mesh therefore contains fewer triangles than the raw
x-triangles Ă— y-triangles product might suggest.
Step 6: Compare with a refined mesh
After increasing the resolution and rebuilding, you should obtain a mesh similar to ??. The pillars now appear much more circular and the triangular facets are smaller and more evenly distributed.
Step 7: Choosing a meshing method
For many patterns the Node reduce algorithm works well, because it removes
redundant triangles and keeps the shape compact. However, for some surfaces – in particular
AFM height maps or other rough surfaces – discarding triangles may lead to a loss of detail.
In such cases you may prefer to use a method that does not reduce the node
count (for example a no-reduction or uniform grid option in the
Method drop-down, if available). This preserves a regular triangular grid over the
entire image.
Whichever method you choose, it is important to balance accuracy and speed. Every additional triangle contributes to the cost of subsequent optical simulations. In practice the runtime often grows faster than linearly with the total triangle count, so:
- Use the smallest mesh that still captures the essential features of the shape.
- Avoid the temptation to use extremely fine meshes “just in case” – they can slow down ray tracing or FDTD calculations dramatically.
- Keep a copy of both a “high-resolution” and a “lightweight” version of complex shapes in the database so you can choose the appropriate one for each study.
👉 Next step: Continue to Part B (placeholder) to learn how to import external CAD files into the Shape database and convert them into meshes suitable for OghmaNano simulations.