Description This subroutine sets the configuration parameters for a grating of the type "Two source user-recorded holographic optical element". The grating OPL polynomials for Source 1 or Source 2 (or both) should be re-recorded using the DiffractHOEExRecord() function after changes are made to the grating.
Syntax SetDiffractHOEEx( grat, src1, src2, is1real, is2real, ncoefs1, ncoefs2 )
Parameters grat As Long Node number of the grating surface whose "Two source user-recorded holographic optical element" specification is being modified.
src1 As Long Node number of the source being used as recording source 1 in the grating specification. Use -1 for the "None" option, in which case active rays in the buffer will be traced during the recording step.
src2 As Long Node number of the source being used as recording source 2 in the grating specification. Use -1 for the "None" option, in which case active rays in the buffer will be traced during the recording step.
is1real As Boolean Set to True if the source 1 OPL is "real" and set to False for the "virtual" option.
is2real As Boolean Set to True if the source 2 OPL is "real" and set to False for the "virtual" option.
ncoefs1 As Long Specifies the number of polynomial coefficients to be used for OPL fitting during the recording of grating source 1.
ncoefs2 As Long Specifies the number of polynomial coefficients to be used for OPL fitting during the recording of grating source 2.
Example The example below demonstrates how to retrieve and report the current configuration for a grating of the type, "Two source user-recorded holographic optical element", modify the grating configuration, and re-record the hologram.
Sub Main
'User-recorded grating surface Dim grat As Long grat = FindFullName( "Geometry.HoeX Grating.HoeX Grating.HoeX Surf" )
'Retrieve current grating specification Dim src1 As Long, src2 As Long Dim is1real As Boolean, is2real As Boolean Dim ncoefs1 As Long, ncoefs2 As Long GetDiffractHOEEx( grat, src1, src2, is1real, is2real, ncoefs1, ncoefs2 )
'Print summary of grating specification Print "" Print "Grating surface: " & GetFullName( grat ) Print Chr(9) & "Source 1" & Chr(9) & "Source 2" Print "Node:" & Chr(9) & GetName(src1) & Chr(9) & GetName(src2) Print "Real:" & Chr(9) & is1real & Chr(9) & is2real Print "Terms:" & Chr(9) & ncoefs1 & Chr(9) & ncoefs2
'Modify the grating specification by doubling coefficients and re-record both sources Dim nRays As Long SetDiffractHOEEx( grat, -1, src2, is1real, is2real, 2*ncoefs1, 2*ncoefs2 ) nRays = DiffractHOEExRecord( grat, True, True )
'Report recording If nRays = 0 Then Print "Recording failed." Else Print "Rays used in hologram recording: " & nRays End If
End Sub
See Also Diffraction Grating Script Commands
|