Description This function allows an array to be populated with the ray path numbers for all paths whose Filtered Ray Count values are either zero or non-zero and returns the total number of paths in the populated array. This function is useful when applied after ApplyFilterToRayPaths in order to retrieve all path numbers that either survive, or are excluded by, the path filtering operation (i.e. all paths which have non-zero Filtered Ray Count values).
Syntax nPaths = PathFilteredPaths( filteredPaths(), isNonZero )
Parameters nPaths (Long) Returned number of paths that are stored in the filteredPaths() array after the function executes.
filteredPaths() As Long This array variable is passed into the function as an argument and is populated with ray path numbers after the function executes. The ray path numbers stored in the filteredPaths() array have Filtered Ray Count values satisfying the isNonZero argument.
isNonZero As Boolean This argument specifies whether the ray path numbers stored in the filteredPaths() array have Filtered Ray Count values that are either zero or non-zero. When isNonZero=True, the path numbers stored in filteredPaths() have Filtered Ray Count values > 0. When isNonZero=False, the path numbers stored in filteredPaths() have Filtered Ray Count values = 0.
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
|