Navigation: Scripting Reference Manual > Functions & Subroutines > PrintRayFilter

 

PrintRayFilter

 

Contact Us: fredsupport@photonengr.com

 

Description

This subroutine prints a text output summary of a T_RAYFILTEROP array to either the output window or a specified output file.  The purpose of this command is to facilitate documentation of ray selection filters that may have been applied during a scripted analysis.

 

 

Syntax

PrintRayFilter( tRayFilter(), outputLocation, fileAppend )

 

 

Parameters

tRayFilterOp() As T_RAYFILTEROP

Array of T_RAYFILTEROP data structures being reported.

 

outputLocation As String

When this argument is an empty string, "", the ray filter summary text will be printed to FRED's output window.  Otherwise, this argument should specify the full path to an output text file where the summary should be written (ex. "C:\tmp\support\rayFilter.txt").

 

fileAppend As Boolean

This argument applies only when the outputLocation argument directs the summary text to an output file.  In that case, the summary text will be appended to the end of specified file when fileAppend=True.  If fileAppend=False, the text file contents will be overwritten by the ray filter summary text.

 

 

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

Basic Ray Data Commands

T_RAYFILTEROP

ApplyFilterToRayPaths

ApplyFilterToRays

 

 

 

 

 

Copyright © Photon Engineering, LLC