Navigation: Scripting Reference Manual > Functions & Subroutines > ApplyFilterToRays

 

ApplyFilterToRays

 

Contact Us: fredsupport@photonengr.com

 

Description

This command applies an array of T_RAYFILTEROP data structures to the active ray buffer and deactivates any rays not meeting the ray filter requirements.  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.

 

 

Syntax

rayCount = ApplyFilterToRays( tRayFilterOp() )

 

 

Parameters

rayCount (Long or Huge_)

Returned number of rays which were deactivated due to failing the ray filter requirements.

 

tRayFilterOp() As T_RAYFILTEROP

Array of T_RAYFILTEROP data structures being applied to the ray buffer.  This array can be retrieved from an existing analysis surface by using the GetRayFilter function.

 

 

Example

The following example retrieves the ray filter set from an analysis surface, prints out the number of filters retrieved and their specifications and then applies the filters to rays in the active buffer.

 

Sub Main

 

    ClearOutputWindow

 

    'Analysis surface whose ray filter set is being retrieved

    Dim anaNode As Long

    anaNode = FindFullName( "Analysis Surface(s).DetectorAnalysis" )

 

    'Retrieve the set of ray filters

    Dim tRayFilterOp() As T_RAYFILTEROP

    Dim filterCount As Long

    filterCount = GetRayFilter( anaNode, tRayFilterOp() )

    Print filterCount & " ray filters retrieved. "

 

    'Print out ray filter information

    Dim curFilterOp As Long

    For curFilterOp = 0 To filterCount-1

        Print "Filter " & curFilterOp & ":"

        Print Chr(9) & "Operation code: " & Chr(9) & tRayFilterOp( curFilterOp ).opCode

        Print Chr(9) & "Datum: " & Chr(9) &  tRayFilterOp( curFilterOp ).datum

        Print Chr(9) & "Combine code: " & Chr(9) &  tRayFilterOp( curFilterOp ).combineCode

    Next curFilterOp

   

    'Apply filters to existing rays in buffer

    Dim rayCnt As Long

    rayCnt = ApplyFilterToRays( tRayFilterOp() )

    Print rayCnt & " rays deactivated."

 

End Sub 

 

The following example shows how to create a set of three filters from the script and apply them to the ray buffer.

 

Sub Main

 

    'Dimension an array of T_RAYFILTEROP's.  This example

    'contains 3 filters.

    Dim tRayFilterOp(2) As T_RAYFILTEROP

 

    'Create first filter: rays on a specific entity

    tRayFilterOp(0).opCode                = 3

    tRayFilterOp(0).combineCode           = 0 'And

    tRayFilterOp(0).stringDatum           = "Geometry.Plane.Surface"

    tRayFilterOp(0).wantOppositeOperation = False

 

    'Create the second filter: wavelengths above 0.5 microns

    tRayFilterOp(1).opCode                = 9

    tRayFilterOp(1).combineCode           = 0 'And

    tRayFilterOp(1).datum                 = 0.5

    tRayFilterOp(1).wantOppositeOperation = True

 

    'Create the third filter: wavelengths below 0.7 microns

    tRayFilterOp(2).opCode                = 9

    tRayFilterOp(2).combineCode           = 0 'And

    tRayFilterOp(2).datum                 = 0.6999999999

    tRayFilterOp(2).wantOppositeOperation = False

 

    'Apply the filter stack to the ray buffer

    ApplyFilterToRays( tRayFilterOp )

 

 

End Sub

 

See Also

GetRayFilter

Basic Ray Data Commands

T_RAYFILTEROP

 

 

 

 

 

Copyright © Photon Engineering, LLC