Home Examples Screenshots User manual Bluesky logo
OghmaNano Simulate organic/Perovskite Solar Cells, OFETs, and OLEDs DOWNLOAD

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 (??).

OghmaNano Databases ribbon with the Shape database button highlighted.
The Shape database button in the Databases ribbon tab. Clicking this opens the central repository of reusable shapes.
Main Shape database window showing a list of existing shapes such as afm_image, box, saw_wave and teapot.
The main Shape database window. Each icon corresponds to a stored 3D shape (for example 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 ??.

Shape database context menu with New → New shape selected.
Creating a new shape entry from the Shape database. Right-click and select New → New shape.

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.

Initial Shape editor window showing the default 2D photonic crystal pattern and an empty 3D grid.
The initial Shape editor view for the new shape demo. The right panel shows a default 2D pattern; the left panel will display the 3D mesh once it has been built.
Shape editor with an initial 3D pillar array built from the photonic crystal image.
First build of the mesh using the default settings. The 2D pattern on the right has been extruded into a 3D array of pillars on the left. At this stage the pillars may look quite faceted and not very circular.

The toolbar at the top of the Shape editor contains three key buttons for this tutorial:

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 (??).

Configure mesh window showing x-triangles, y-triangles, method and minimum allowable angle.
The Configure mesh window. Here you set the initial number of triangles across the x and y directions and choose the meshing method.
Shape editor after increasing mesh resolution, showing a smoother pillar array.
A refined mesh after increasing the resolution. The higher triangle density produces a much smoother and more faithful representation of the original 2D pattern.

The important fields are:

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:

👉 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.