The basic structure for the voxel viewer macro we want is as follows:

1) Obtain the detected intensity values for each voxel in the detector volume, and determine the maximum overall intensity value.

2) Create one rectangular volume object for each voxel whose recorded intensity is greater than some threshold value

3) Export all these rectangular volume objects as a single CAD object

The “Voxel Maker.ZPL” macro at the end of this article does all this, and a bit more. It will create several different CAD objects, each one with a different threshold cutoff value. Then it imports these CAD objects into the current lens file, so that the user may color the objects to match the different threshold values (red for the highest threshold value, followed by yellow, green, and blue).

The attached macro also minimizes the memory used (for files that have very large numbers of detector volume voxels) by saving multiple sub-systems of pixels, and then re-loading these sub-systems and finally exporting one, large CAD object for each threshold color.

Save the attached macro in the appropriate folder on your computer, and then run it on the lens file we’ve just created.

You’ll need to supply the macro with some information, so just answer the requests that pop up on the ZPL Macro Input window. Note that default answers are given in brackets, and if you simply hit [enter] the default answer is taken. For the lens file we’ve just created, you can use the default answers for all except “use polarization?” which must be answered with ‘1’ so that the rays can be properly absorbed by the glass cylinder.

When the macro is finished running, you’ll just need to change the Draw colors of the four newly-created CAD objects (change the Draw color of the “voxel_red_object” to a red color, the Draw color of the “voxel_yellow_object” to a yellow color, and so on). Below is the resulting NSC Shaded Model layout:



You can clearly see where the ‘hot’ voxels are inside the glass cylinder. Keep in mind that this simple example had just 10 pixels in each of the x-, y-, and z-directions; there are 1000 voxels in the detector volume. A detector volume with finer pixels will have far more voxels.

The attached macro is designed to handle such large voxel numbers with ease. Of course, the resulting CAD object files will be quite large, and the production of these files will take some time. But the results can be truly illuminating. Below are some samples of voxel objects created using the attached macro for some more complex setups.

The image below was made using the file supplied with ZEMAX (in the directory ZEMAX/Samples/Non-sequential/Miscellaneous) called “voxel detector for flash lamp pumping.ZMX,” with the number of z-planes increased from 25 to 100. In the example below, the detector volume has 101 x 101 x 100 pixels, or over 1 million voxels.



The next example shows how the “Voxel Maker.ZPL” macro is also useful for visualizing light patterns on the surfaces of complex objects. The image below was made by choosing a highly-absorbing material for the complex object, so that light rays would not penetrate beyond a single voxel into the object. With this method, it is now possible to use the entire surface of any complex object as a detector plane, as if the detector plane were draped over the object.

For this setup, an LED was positioned above and aimed at a mechanical mirror mount. The detector voxels clearly show the exact locations of the very brightest portions of illumination on the mirror mount, and they also show the exact size and shape of shadows (regions where no voxels are lit) in the illumination pattern.



With the “Voxel Maker.ZPL” macro, it is now possible to visualize 3D stray light patterns over complex objects.

The final example shows how to use the “Voxel Maker.ZPL” macro to envision a detection volume, where an imaging detector is set up to view a volume of space that is being illuminated, as one might find in a detector for smoke or particulates. The image below shows the basic setup.




A large lens (yellow) is placed in front of a high-power LED (blue-green). Light from this LED/lens system (rays shown in purple) illuminates a volume of space, where a sample of gas or particles will be introduced.

A very small detector (red) is placed inside a tube (purple) with a small lens (blue) at the front end. This detector is meant to view the same volume of space that is being illuminated by the LED/lens system. To see where the detector/lens system is looking, we replace the detector with a Source Rectangle:




Now there are rays (gray) showing exactly where the detector is looking. Looking at the layout above, it would be easy to assume that this system is set up very well, with the detector looking exactly at the brightest part of the LED illumination. We’re now going to go several steps further, in order to really evaluate how well this LED/detector system works.

We’ll add a detector volume to the system, as shown below.



Next, we will run the “Voxel Maker.ZPL” macro, using only the LED rays at this time, in order to view the 3D pattern of the LED/lens system.



We can see that the LED illumination pattern is well-aligned with the detector’s general imaging path. Note that the voxels in the above diagram are lit only when the irradiant flux on any given voxel exceeds a certain value. Some tuning of these threshold limit values (in the macro) is necessary in order to achieve the best quality picture.

Note also that the light pattern, especially the pattern of the blue voxels, appears to be shaped like a plume, as though light were bending around. However, there is still light in the regions of space where no voxels are lit: the light there just did not exceed the threshold chosen for the blue voxels.

Next, a material was applied to each of the newly-created voxel CAD objects. The absorption of each material was set to match the intensity level of light in each of the four (red, yellow, green, and blue) objects. For example, the red object had a threshold irradiance level twice as high as that of the yellow object. Therefore a material was created for the red object that had twice the absorption as that of the yellow object.

After all the voxel CAD objects were prepared in this way, light was projected out of the detector into the volume, and the “Voxel Maker.ZPL” macro was run once more. The image below shows the overlap between LED light and detector imaging (red/yellow). For reference, the main body of LED illumination is also shown in gray.



The animation below shows how the entire system can easily be rotated and manipulated to help visualize the spatial characteristics of the illumination/detection overlap area.