Description This subroutine applies a ray selection criteria to the raytrace paths database, which has the effect of updating the Filtered Power and Filtered Ray Count quantities for each path. The effect of the applied filter operation(s) are visible to all subsequent path operations in the scripting language and in the GUI dialogs. Raytrace paths, and the rays associated with those paths, must exist prior to calling this subroutine.
Syntax ApplyFilterToRayPaths( tRayFilterOp() )
Parameters tRayFilterOp() As T_RAYFILTEROP Array of T_RAYFILTEROP data structures being applied to the raytrace paths buffer.
Example The following example performs an Advanced Raytrace with raytrace paths enabled, constructs a ray selection filter that isolates rays (a) ending on a detector surface and (b) on a path interacting with a specific surface of interest, applies the ray filter to the paths database, reports information to the output window about the applied filter and the filtered raytrace paths, and then restores the raytrace paths database to its unfiltered state.
Sub Main
DeleteRays() PathDeleteAll() PrefsSetRandomReseed(True)
'Perform the advanced raytrace with raytrace paths enabled Dim tAdv As T_ADVANCEDRAYTRACE InitAdvancedRaytrace( tAdv ) tAdv.draw = False tAdv.rayHistory = True tAdv.rayPaths = True AdvancedRaytrace( tAdv )
'Construct the ray selection filter to be applied to the path database Dim tFilter() As T_RAYFILTEROP ReDim tFilter(1) tFilter(0).opCode = 3 'ray on the specified surface tFilter(0).stringDatum = "Geometry.Detector.Surface" tFilter(1).opCode = 42 'ray on path including surface tFilter(1).stringDatum = "Geometry.Housing.Aperture.Notch.Surface" tFilter(1).combineCode = 0 'AND ApplyFilterToRayPaths( tFilter() )
'Retrieve filtered paths that survived the ray filter operation Dim npaths As Long, pathIDs() As Long npaths = PathFilteredPaths( pathIDs(), True )
'Report information to the output window Print "===================================" Print "Ray selection filter applied to ray paths:" PrintRayFilter( tFilter(), "", False ) Print "" Print "Number of filtered paths = " & npaths Print "Paths returned by PathFilteredPaths() function" Print "Path ID" & Chr(9) & "Filtered Power" & Chr(9) & "Filtered Rays" Dim curpath As Long, ppower As Double, praycount As Long For Each curpath In pathIDs() ppower = PathFilteredPower( curpath ) praycount = PathFilteredRayCount( curpath )
Print curpath; Print ppower; Print praycount
Next
'Restore the raytrace paths database to its unfiltered state Erase tFilter() ReDim tFilter(0) tFilter(0).opCode = 0 ApplyFilterToRayPaths( tFilter() )
End Sub
See Also
|