The Boolean Native and Boolean CAD objects in OpticStudio can be used to extend the range of parametric object shapes that can be modeled in Non-Sequential Mode. This article describes how to use the nesting rule in Non-Sequential Mode to replace Boolean objects and improve ray tracing efficiency.
This article assumes the user is familiar with the Boolean Native and Boolean CAD objects.
Authored By Akash Arora, updated by Sandrine Auriol
Downloads
Introduction
There may be cases in which the parametric object shapes provided by OpticStudio aren't enough to model your system. When that happens there are three useful options: use a Boolean CAD object, use a Boolean Native object, or utilize OpticStudio's nesting rules.
The Boolean CAD object provides a high amount of flexibility, but low accuracy for high-order aspheres and higher computation times. The Boolean Native provides low computation time and high accuracy, but is not efficient for a large number of objects. Finally, nesting rules provide greater speed in ray tracing, but lower mechanical accuracy.
In this article, we will use three examples to expand upon the strengths and weaknesses of each of these methods for ray tracing with complex objects.
Boolean CAD, Boolean Native, and nested objects
The Boolean CAD object works by converting multiple parent objects to NURBS-based surface representations, and then performing the desired Boolean operations to trim the objects to the desired geometry. While this capability offers significant flexibility, NURBS representations require more memory, more time to raytrace, and can be less accurate for high-order aspheres than the native (or parametric) equivalent.
The Boolean Native object is similar to the Boolean CAD object, but it uses a more efficient ray tracing algorithm because the parent objects are native OpticStudio objects. It doesn’t convert each component object into a NURBS representation, and instead uses the parent objects’ native geometry. (Note that both Boolean objects use a NURBS-based representation for visualization in the system viewers though.) In addition to being faster, ray tracing through the Boolean Native object is also more accurate than the Boolean CAD object because it uses the high-precision surface definitions of the parent objects. However, the rays still need to trace through each parent object and need to consider the defined Boolean geometry operations. Therefore, if many objects need to be combined, ray tracing through Boolean Native objects can be slower than nesting the objects, but Boolean objects aren’t always required to simulate certain combinations of parent objects.
In Non-Sequential Mode, OpticStudio uses a nesting rule to determine how to treat objects and surfaces that overlap with one another. This rule dictates that when two objects overlap, the object listed last in the Non-Sequential Component Editor (NSCE) determines the properties in the region of overlap. This behavior provides the equivalent of adding or subtracting volume objects with each other. While overlapping objects can give the correct raytracing results, visualization and mechanical export are lacking because there is no single object representation.
For more details about the Boolean objects, see the article "How to use the Boolean CAD, Boolean Native, and Compound Lens objects, and the Combine Objects tool".
Raytracing with non-parametric objects
Anytime a specifically shaped object is needed, it is always a good idea to ensure the object isn’t already natively supported in OpticStudio. You can browse the list of provided objects in the OpticStudio Help Files: The Setup Tab>Editors Group (Setup Tab)>Non-sequential Component Editor>Non-sequential Geometry Objects.
If none of the built-in objects suffices, the next step is to consider nesting multiple objects to achieve the desired shape. The nesting rule can provide the equivalent of adding (A+B) and subtracting (A-B) two or more objects. To achieve an addition of objects via nesting, the objects should all have the same material. To achieve a subtraction, the object(s) to subtract should be defined last in the NSC editor and have no material (air).
Example 1: Boolean Native or nesting objects
An example that could be modeled by nesting objects or forming a Boolean is a lens with a hole.
Open the attached file "Boolean vs Nesting Example.ZAR". The file models rays hitting a standard lens with a tilted cylindrical hole.
There are four configurations that show different ways to model this kind of system.
- Configuration 1: draws and traces the parent objects.
- Configuration 2: draws and traces the Boolean CAD object.
- Configuration 3: draws and traces the Boolean Native object.
- Configuration 4: draws the Boolean object and traces the parent objects.
For each configuration, we will compare the result on the detector viewer, the time to complete the raytrace and the appearance of the system on a viewer. The performance is compared on an 8 CPU computer. For each configuration, OpticStudio traces 2E6 rays with Split NSC Rays turned on:
The results are given in the table below:
Configuration 1 | Configuration 2 | Configuration 3 | Configuration 4 | |
Ray Tracing | Nesting rule | Boolean CAD | Boolean Native | Nesting rule |
Draw | Native | Boolean | Boolean | Boolean |
Run Time | 8.5s | 1.6min (96s) | 11.6s | 8.1s |
Ray Tracing accuracy | Accurate | Accurate | Accurate | Accurate |
Viewer | OpticStudio draws overlapping objects: It doesn't draw like a lens with a hole |
Lens with a hole | Lens with a hole | Lens with a hole |
Let’s discuss the results:
- Configuration 1 draws and traces the parent objects, while ignoring the Boolean objects altogether. The shaded model clearly shows the lens and cylinder overlapping. The nesting rule dictates that the object listed second in the NSC editor takes precedence in the region of overlap. Thus, the rays see the glass lens with a cylinder of air through the middle. Clearly the only issue with this setup is that the overlapping objects don’t draw like a lens with a hole.
- When switching to Configuration 2, it traces and draws the Boolean CAD object and completely ignores the parent objects. The object draws perfectly in this configuration, but the raytracing is quite slow. When considering the Boolean CAD object, the same system takes 1.6 minutes to raytrace; 11x slower than the nested parent objects! Furthermore, the System Check report displays a "Trivial warning" (under Setup...Diagnostics...System Check): "Trivial: Boolean CAD object 4 only has native parent objects; consider using Bolean Native instead". In that case, the results shown on the detector viewer are identical to configuration 1 in which the nested objects were used.
Important: The lesson here is that if a volume is formed from Native objects, the nesting object or the Boolean Native object should be utilized instead of the Boolean CAD object.
- Configuration 3 uses the Boolean Native object. The ray tracing time is 11.6s which is nearly as fast as tracing with the nesting objects. The reason is that the Boolean Native object doesn’t convert each component object into a NURBS-based surface representation, and instead uses the parent objects’ native geometry. The object draws perfectly.
- Configuration 4: As we have seen in Configuration 1, nested objects aren’t as intuitive as Boolean objects from a visual standpoint. Configuration 4 simulates a setup where we can achieve the best of both models: fast raytracing and good visualization. Rays consider the parent objects and ignore the Boolean objects. Parent objects aren’t displayed, and the Boolean object is drawn. The object looks as we intend and the raytrace is fast because rays are only considering the parametric parent objects.
Conclusions for Example 1:
- If the parent objects are Native objects, do not use the Boolean CAD object but consider using the nesting rule or the Boolean Native object instead.
- The Boolean Native object is the recommended solution when only a few objects need to be combined. However, if many objects need to be combined, nesting the objects will likely raytrace faster than using the Boolean Native object.
- One restriction to the nesting rule is that you cannot always simulate the desired object shape. The nesting rule can provide the equivalent of adding (A+B) and subtracting (A-B) two objects but will not suffice for more complicated operations (A&B, A^B, A$B). In that case, the Boolean Native object is recommended.
- Furthermore, even if you can use nested objects, exporting to CAD for mechanical specification requires a single object representation (i.e. a Boolean object). In these instances, using a Boolean object is often required.
Example 2: Boolean Native object
Example 2 is an example of a Boolean operation that cannot be directly replicated by nesting the parent objects. Open the file {Zemax}\Samples\Non-sequential\Geometry Creation\Boolean Example 2- a lens with a hexagonal edge.
This hexagonal lens is created by taking the intersection (&) of an extruded hexagon and a standard lens. The NSC nesting rule would not be able to create the same hexagonal lens from these parent objects.
We could, however, create such a lens with nested objects by modifying the extruded object. Open the object properties dialog for the extruded object and click Edit Aperture File.
In the UDA file, add the following line at the end: REC 0 0 200 200 0 1 1. This will create a volume that is essentially a rectangular volume with a hexagonal hole through the middle as seen below.
The hexagonal lens can now be created by subtracting this volume from the standard lens; basically, trimming the lens. For proper nesting, the extruded object needs to be placed after the lens. These modifications are included in the "Nested Hexagonal Lens.ZAR" within the article attachments.
When using the nesting object, the same computational advantages can be gained from modeling the lens in this manner over a Boolean CAD object as was achieved in the previous example. The drawbacks to this method are the same as before, visualization of the part in layouts and exporting to CAD.
In this example, the recommended solution is the Boolean Native object. That object is only a combination of two objects. Ray tracing will be accurate and fast, and the object will be drawn correctly.
Example 3: Nesting objects
Example 3 is an example of a Boolean operation that can be directly replicated by nesting the parent objects. Open the attached file "Boolean vs Nested Example 5- a complex light pipe". This file is a slighlty modifed version of the sample file ({Zemax}\Samples\Non-sequential\Geometry Creation). It models a complex light pipe.
There are two configurations that show different ways to model that kind of system.
- Configuration 1: draws and traces the parent objects.
- Configuration 2: draws and traces the Boolean Native object
For both configurations, we will compare the time to complete the raytrace and the appearance of the system in a viewer. The performance is compared on an 8 CPU computer. For each configuration, OpticStudio traces 1E6 rays with Split NSC Rays turned on:
The results are given in the table below:
Configuration 1 | Configuration 2 | |
Ray Tracing | Nesting rule | Boolean Native |
Draw | Native | Boolean |
Run Time | 0.4s | 3.7min (222s) |
Let’s discuss the results:
- Configuration 1 draws and traces the parent objects, while ignoring the Boolean object. The shaded model clearly shows the lightpipe. The nesting rule works very well in this case. Raytracing is fast and the visualization is correct.
- Configuration 2 traces and draws the Boolean Native object and completely ignores the parent objects. The object draws perfectly in this configuration, but the raytracing is slow. The raytracing takes 3.7 minutes to complete which is more than 500x slower than the nested parent objects!
This is because the rays need to trace through all the parent objects and consider the Boolean geometry operations. Since there are many objects to combine, nesting the objects traces much faster than the Boolean Native object.
Important: The lesson here is that if a volume is formed from many Native objects, nesting the objects should be used instead of the Boolean Native object.
Following from these examples, you can use the series of questions below to decide which way of combining objects is recommended:
Are you adding or subtracting objects?
- If no, use one of the Boolean objects.
- Do you only have Native objects?
- If yes, use the Boolean Native object.
- If no, use the Boolean CAD object,
- Do you only have Native objects?
- If yes, use the nesting rule or one of the Boolean objects.
- How many objects do you want to combine?
- If only a few, use of the Boolean objects.
- If many, nest the objects.
- How many objects do you want to combine?
KA-01439
Comments
Please sign in to leave a comment.