Skip to main content

ZOS-API- How to use Non sequential ray tracing tools

  • September 30, 2019
  • 1 reply
  • 524 views

Julia
Fully Spectral
Forum|alt.badge.img+2
  • Fully Spectral
  • 53 replies
NSCRayTrace = TheSystem.Tools.OpenNSCRayTrace();
NSCRayTrace.ClearDetectors(0);
NSCRayTrace.SplitNSCRays = true;
NSCRayTrace.ScatterNSCRays = false;
NSCRayTrace.UsePolarization = true;
NSCRayTrace.IgnoreErrors = true;
NSCRayTrace.SaveRays = true;
NSCRayTrace.SaveRaysFile = 'Digital_projector_flys_eye_homogenizer.ZRD';
NSCRayTrace.RunAndWaitForCompletion();
NSCRayTrace.Close();
  • Run NSC ray trace
Logic = {'False', 'True'};
ZRDReader = TheSystem.Tools.OpenRayDatabaseReader();
prefix=TheSystem.SystemFile.TrimEnd('.ZMX');
ZRDReader.ZRDFile = System.String.Concat(prefix,'.ZRD') ;
ZRDReader.RunAndWaitForCompletion();
if ZRDReader.Succeeded == 0
        disp('Raytracing failed!\n\n')
        disp(ZRDReader.ErrorMessage)
else
        disp('Raytracing completed!\n\n')
end
ZRDResult = ZRDReader.GetResults();
[success_NextResult, rayNumber, waveIndex, wlUM, numSegments] = ZRDResult.ReadNextResult();
while success_NextResult == 1
    fprintf('\n\nsuccess_NextResult: %s, rayNumber: %d, waveIndex: %d, wlUM: %d, numSegments: %d\n\n',...
        Logic{success_NextResult+1}, rayNumber, waveIndex, wlUM, numSegments)
 fprintf('%20s %13s %13s %8s %8s %8s %10s %6s %7s %8s %8s %8s %8s%10s %5s\n','success_NextSegmentFull','segmentLevel', 'segmentParent','hitObj','hitFace',...
     'insideOf','status','x','y','z','l','m','n','xybin','lmbin');
[success_NextSegmentFull, segmentLevel, segmentParent, hitObj, hitFace, insideOf, status,...
        x, y, z, l, m, n, exr, exi, eyr, eyi, ezr, ezi, intensity, pathLength,...
        xybin, lmbin, xNorm, yNorm, zNorm, index, startingPhase, phaseOf, phaseAt] =...
        ZRDResult.ReadNextSegmentFull();
 while success_NextSegmentFull == 1
     fprintf('%15s %15d %15d %10d %8d %7d %13s %8.3f %8.3f %8.3f %8.3f %7.3f %7.3f %6d %6d \n',Logic{success_NextSegmentFull+1}, segmentLevel, segmentParent, hitObj,hitFace, insideOf, char(status),x, y, z, l, m, n,xybin,lmbin);
        [success_NextSegmentFull, segmentLevel, segmentParent, hitObj, hitFace, insideOf, status,...
            x, y, z, l, m, n, exr, exi, eyr, eyi, ezr, ezi, intensity, pathLength,...
            xybin, lmbin, xNorm, yNorm, zNorm, index, startingPhase, phaseOf, phaseAt] =...
            ZRDResult.ReadNextSegmentFull();
    end
    [success_NextResult, rayNumber, waveIndex, wlUM, numSegments] = ZRDResult.ReadNextResult();
end
ZRDReader.Close();


 

In the above code:

  • Open the ray database reader tool
  • Set the ZRD file to be read
  • Run tool Ray Database Reader
  • Use GetResult() method to get result ray by ray ( ReadNextResult() ) and segment by segment (ReadNextSegment())
  • Print data of each ray and each segment

Did this topic help you find an answer to your question?

1 reply

Amy Entin
  • Infrared
  • 7 replies
  • August 9, 2022

Hi!

When I try to use the code given in this example, specifically:

NSCRayTrace = TheSystem.Tools.OpenNSCRayTrace();
NSCRayTrace.ClearDetectors(0);

 

I get the error “Dot indexing is not supported for variables of this type.” for the second line.

Has the syntax been updated?

 

If it matters, I’m using MATLAB R2018a.

 

 

Edit: I figured it out so updated for people searching in the future: only one tool can be open at a time, so if you are working on a piece of code and running a section more than once, if that section includes the open tool function, the line that opens it doesn’t throw an error, but creates a null variable, so any function you try to use with it will return “Dot indexing is not supported for variables of this type.” Close the tool in the command window and rerun.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings