Description Data structure for an advanced ray trace. Depending on the number of rays traced, it may be necessary to dimension ray index and ray counter variables as data type Huge_ instead of Long. Please see Multi-threaded Raytracing for more information.
Definition Type T_ADVANCEDRAYTRACE applyRayFilter As Boolean compressRayBuffer As Boolean filter() As T_RAYFILTEROP filterDisposition As String hitCount As Long stepRay As Long (or Huge_) drawEveryNthTracedRay As Long (or Huge_) method As String rayPathsMergeExisting As Boolean rayHistory As Boolean End Type
Members applyRayFilter If True, the filter() is applied to the rays after the raytrace and all rays which do NOT meet the specified filter() are either deleted or set inactive, depending on filterDisposition. For very large raytraces where only a small subset of the total rays will be of interest for post-raytrace analyses, applying a ray filter to delete, or deactivate, rays that are not of interest and using the compressRayBuffer option can result in faster analyses.
compressRayBuffer When True, deleted rays (or any empty ray slots in the buffer) are removed at the end of the raytrace and the ray buffer is compressed to its most compact size. As a consequence, memory usage is decreased and the time spent to process the ray buffer during analyses calculations (or scripting loops) is also reduced. The effect of ray buffer compression will be most noticeable when the rays of interest represent a small fraction of the total rays traced during the raytrace.
This option can be used in combination with either mode of filterDisposition.
filter() An array of T_RAYFILTEROP structures that define the ray selection criteria to be applied post-trace when applyRayFilter=True.
filterDisposition Can be one of "delete" or "set inactive". When filterDisposition="delete" and applyRayFilter=True, rays that do not meet the filter() requirement will be deleted from the ray buffer at the conclusion of the raytrace. When filterDisposition="set inactive" and applyRayFilter=True, rays that do not meet the filter() requirement will be marked as inactive from the ray buffer at the conclusion of the raytrace.
hitCount Holds the maximum number of surface intersections allowed during the raytrace. A value of -1 means there is no limit.
startSurfID Holds the identifier specifying the starting surface. Only rays on the start surface will be raytraced. A value of -1 means use any surface.
stopSurfID Holds the identifier specifying the stopping surface. Any ray intersecting this surface will stop regardless of its coating and raytrace control specifications. A value of -1 means that there is no explicit stopping surface.
startRay Holds the identifier of the first ray in the ray buffer to trace. A value of 0 means the first ray in the ray buffer.
stopRay Holds the identifier of the last ray in the ray buffer to trace. InitAdvancedRaytrace sets this value to 2,147,483,647.
stepRay Holds the number of rays to skip between ray tracings. For example, if this is set to 2 and startRay is set to 0, the ray trace will trace rays 0, 2, 4, 6, etc. A value of 1 will cause every ray between 'startRay' and 'stopRay' to be traced.
drawEveryNthTracedRay Specifies how many rays will be rendered in the visualization window (if rays are being drawn during the raytrace). For example, if this is set to 2 and startRay is set to 0, the ray trace will draw rays 0, 2, 4, 6, etc. A value of 1 will cause every ray between 'startRay' and 'stopRay' to be drawn.
pathID Holds the identifier of the sequential path to trace. This variable is ignored unless the value of "method" is "User Path" or "Raytrace Path".
method Specifies the intersection search method. It can be one of "Hierarchy", "Linear", "User Path", or "Raytrace Path". InitAdvancedRaytrace sets this value to "Hierarchy".
transmitReflectOnStop When set to True, specifies that the ray transmit/reflect operation is carried out when the ray hits the stop surface.
traceActiveSources When set to True, specifies that all rays in the existing ray buffer are deleted and new rays from all traceable sources are created for raytracing. False specifies that the rays in the existing ray buffer will be raytraced.
draw When set to True, specifies that the rays are to be rendered as they are traced.
rayPaths When set to True, specifies that the ray paths are to be determined during the ray trace. InitAdvancedRaytrace sets this value to False.
rayPathsMergeExisting When True, raytrace paths generated during the current raytrace will be merged with any existing raytrace paths.
suppressScatter When set to True, specifies that no rays will be generated due to surface scattering during the ray trace. Bulk volume scatter within a material is unaffected by this setting. InitAdvancedRaytrace sets this value to False.
suppressSummary When set to True, specifies that the raytrace summary is not to be printed at the end of the ray trace. InitAdvancedRaytrace sets this value to False.
rayHistory When set to True, specifies that a ray history file file is to be created during the raytrace. InitAdvancedRaytrace sets this value to False.
Examples The example below demonstrates how to configure the T_ADVANCEDRAYTRACE structure to trace existing rays with paths and history enabled and also apply a post-raytrace filter that deletes all rays not on paths that interacted with surface "Geometry.Housing.Aperture.Notch.Surface". The number of rays traced, the number of rays that exist after the filter is applied, and the number of paths with non-zero active ray counts are reported to the output window.
Sub Main
DeleteRays()
'Source whose rays we want to trace Dim src As Long src = FindFullName( "Optical Sources.Lambertian Plane 1" ) CreateSource( src )
'Construct the ray filter for rays we want to keep Dim tFilter(0) As T_RAYFILTEROP tFilter(0).opCode = 42 tFilter(0).stringDatum = "Geometry.Housing.Aperture.Notch.Surface"
'Initialize and call the advanced raytrace Dim nTraced As Long Dim tAdv As T_ADVANCEDRAYTRACE InitAdvancedRaytrace( tAdv ) tAdv.traceActiveSources = False tAdv.draw = False tAdv.rayPaths = True tAdv.rayHistory = True tAdv.filter = tFilter() tAdv.filterDisposition = "delete" tAdv.applyRayFilter = True nTraced = AdvancedRaytrace( tAdv )
Print "Rays traced = " & nTraced Print "Rays in buffer = " & GetRayCount()
'Retrieve path ID's with non-zero filtered ray counts 'Note: because of the post-trace filter and deletion of rays in the 'advanced raytrace, some paths will no longer have any active rays associated 'with them. These paths will have 0 "filtered ray counts". Dim pids() As Long PathFilteredPaths( pids(), True ) Print "Paths with rays = " & UBound(pids())+1
End Sub
Used as Parameter in
|