Description This subroutine performs the Best Geometric Focus analysis in any output coordinate system for all rays on a specified entity and stores the calculation data in a data structure variable. This calculation is based on geometric ray properties and does not include diffraction effects.
If needed, the ApplyFilterToRays() command can be used to apply a ray selection criteria filter to the ray buffer prior to calling the BestFocus command. The resulting calculation will operate only on those rays satisfying the ray selection filter criteria.
Syntax BestFocus n, coordSys, focusInfo
Parameters n As Long Node number of the entity on which the rays of interest exist. Only rays on the entity identified by n are included in the calculation. Use a value of -1 to include all rays.
coordSys As Long Node number specifying the coordinate system in which the focusInfo data is calculated. Use a value of -1 to specify the global coordinate system.
focusInfo As T_BESTFOCUS Passed in as an argument, this data structure contains the results of the best focus calculation after the subroutine executes.
Example This example demonstrates how to use the BestFocus command to automatically reposition an entity. The PrintBestFocus command relays information to the output window. The accompanying sample file "<install dir>\Resources\Samples\Tutorials & Examples\exampleBestFocus.frd" implements this example as an embedded script.
Sub Main
Dim op As T_OPERATION Dim bf As T_BESTFOCUS Dim sNode As Long, detNode As Long
ClearOutputWindow
'Find rear lens surface and detector node ID's sNode = FindFullName( "Geometry.OS 011-1110.Surface 2" ) detNode = FindFullName( "Geometry.DetectorPlane" )
'Trace the rays Print "Tracing initial configuration..." EnableTextPrinting False DeleteRays() TraceCreateDraw() EnableTextPrinting True
'Compute the best focus for rays on the surface "DetectorPlane" Element Primitive 'and give the results In the coordinate system of the rear lens surface Print "Computing best focus..." BestFocus GetChild(detNode), sNode, bf
'Print best focus information to the output window. Use rays on the child surface 'of the DetectorPlane Element Primitive node and print the results in the 'coordinate system of the rear lens surface. PrintBestFocus GetChild(detNode), sNode
'Use the results of the best focus calculation to move the detector plane. 'Operation 1 of the detector node is a Z-Shift. Print "" Print "Moving the detector plane..." GetOperation detNode, 1, op op.val1 = bf.z SetOperation detNode, 1, op
'Update the document Update
'Trace again for visual affect Print "Performing new trace..." EnableTextPrinting False TraceCreateDraw() EnableTextPrinting True
Print "All Done!"
End Sub
See Also
|