Navigation: Scripting Reference Manual > Functions & Subroutines > CompressRayBufferWithFilter

 

CompressRayBufferWithFilter

 

Contact Us: fredsupport@photonengr.com

 

Description

This function performs a ray buffer compression operation with a user-defined ray selection filter.  The original ray buffer will be compressed such that only rays satisfying the ray selection filter criteria will remain after the compression operation is performed.  The advantage of compressing the ray buffer, as opposed to just deleting rays in a ray buffer loop, is that ray buffer compression reduces the memory consumption of the ray buffer.  Ray deletion removes the ray data but does not restructure or release the ray buffer memory footprint.  Buffer compression is not always needed or required, except in cases where post-processing ray data consumes a significant portion of analysis time and the rays of interest are a small fraction of the total ray buffer size.

 

Syntax

nRays = CompressRayBufferWithFilter( tFilterOp() )

 

Parameters

nRays (Long)

Returned value indicating the number of rays that satisfied the ray selection filter criteria in tFilterOp().  After compression, the ray buffer will contain this many rays.

 

tFilterOp()

An array of T_RAYFILTEROP data structures that define the ray selection filter applied during ray buffer compression.  Only rays satisfying the ray selection criteria will survive the ray buffer compression operation.

 

Example

The example below demonstrates how to use an array of T_RAYFILTEROP data structures to compress the ray buffer such that only the rays of interest remain.  The ray selection filter constructed in this examples requires that (a) the rays are currently on the "Analysis Surface(s).Det ana" object, (b) the rays wavelengths are less than 0.7 microns, and (c) the rays wavelengths are larger than 0.5 microns.  Only rays satisfying each of these three requirements will survive the buffer compression and be included in the final Irradiance distribution.

 

Sub Main

          

    'Analysis surface for Irradiance

    Dim ana As Long

    ana = FindFullName( "Analysis Surface(s).Det ana" )

 

    'Wavelength limits for rays of interest after compression (in microns)

    Dim minWL As Double, maxWL As Double

    minWL = 0.5 : maxWL = 0.7

 

    'Detector surface of interest.

    Dim det As Long

    det = FindFullName( "Analysis Surface(s).Detector" )

 

    'Define the ray filters we want to apply

    'Only rays passing these filter specifications will survive buffer compression

    Dim tFilterOp(2) As T_RAYFILTEROP

    tFilterOp(0).opCode = 3 'Rays on the specified surface

    tFilterOp(0).stringDatum = GetFullName( det )

    tFilterOp(1).opCode = 9 'Wavelengths <= value

    tFilterOp(1).datum = maxWL

    tFilterOp(1).combineCode = 0 'AND

    tFilterOp(2).opCode = 9

    tFilterOp(2).wantOppositeOperation = True 'Operand becomes Wavelengths > value

    tFilterOp(2).datum = minWL

    tFilterOp(2).combineCode = 0 'AND

 

    'Perform a raytrace

    TraceCreate()

 

    'Report ray count before compression

    Print "Ray count = " & GetLiveRayCount()

 

    'Compress the buffer

    Dim nRays As Long

    nRays = CompressRayBufferWithFilter( tFilterOp() )

 

    'Report final ray count

    Print "Compressed ray count = " & GetLiveRayCount()

 

    'Compute and display the irradiance

    Dim arn As Long

    IrradianceToARN( ana, "Irradiance Result", arn )

    ARNDisplayInChart( arn, "" )

 

End Sub

 

See Also

Ray Script Commands

CompressRayBuffer

 

 

 

 

 

Copyright © Photon Engineering, LLC