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