Navigation: Scripting Reference Manual > Script Examples > Examples - Curves

 

Examples - Curves

 

Contact Us: fredsupport@photonengr.com

 

These examples cover the basic FRED scripting commands involving curves:

"Add" - add a curve or curve properties,

"Get" - retrieve curve data,

"Init" - initialize a curve structure,

"Set" - set curve data.

 

The following structures are required for curve definitions and specific curve types:

T_ENTITY

T_APERTURECURVEOP

T_CURVEBASICINFO

T_LINE

T_CIRCULARARC

T_CONICARC

 

Each curve type requires at least one structure be part of its definition.


 

"Add" a curve or curve data

Adding a line curve requires two structures, T_ENTITY and T_LINE. Set the curve's basic properties with T_ENTITY. At a minimum, give the curve a name. If the curve will be used to generate a swept surface, then set traceable to False. Set other basic properties as needed. The starting and ending xyz points of the T_LINE structure should be initialized to avoid ambiguity. Set these to their desired coordinate values before adding the line. Issue and Update command to refresh the FRED document:

 

Dim cent As T_ENTITY

Dim linedef As T_LINE

InitLine linedef  'sets starting point to x=y=z=0 and ending point to x=1 y=z=0

 

cent.name="My First Line"

cent.traceable=False

 

'new starting and ending xyz values

linedef.startX=2:  linedef.startY=3:  linedef.startZ=0

linedef.endX=1:    linedef.endY=1:    linedef.endZ=1

 

line1id = AddLine ( cent, linedef )

Update

 

A segmented curve requires only one structure. An array must be declared and populated with the desired number of points and xyz values. In this example, a rectangular closed curve is created in the z=0 plane. This requires 5 xyz values to close the curve:

 

Dim segent As T_ENTITY
Dim segpoints(2,4) As Double

segent.name="My Seg Curve"
segent.traceable=False

'5 sets of xyz for segmented curve

segpoints(0,0)=0: segpoints(1,0)=0:   segpoints(2,0)=0
segpoints(0,1)=1: segpoints(1,1)=0:   segpoints(2,1)=0
segpoints(0,2)=1: segpoints(1,2)=2.5: segpoints(2,2)=0
segpoints(0,3)=0: segpoints(1,3)=2.5: segpoints(2,3)=0
segpoints(0,4)=0: segpoints(1,4)=0:   segpoints(2,4)=0

id = AddSegmentedCurve ( segent, segpoints )
Update

 

In this example, a composite curve is made from three existing curves. The new composite curve is named then an array is declared and populated with the curve's identifiers before issuing AddCompositeCurve:

 

Dim compent As T_ENTITY
Dim compids(2) As Long

compent.name="My Composite Curve"
compids(0)=7:compids(1)=12;compids(2)=31       'identifiers for the three curves

id = AddCompositeCurve ( compent, compids )

Update

 

Aperture curves are used to trim surfaces. In this example, an aperture curve is created that uses three existing curves; one as a "Hole", one as a "ClearAperture" and one as an "Obscuration". The T_APERTURECURVOP structure contains the curve identifiers, their group number and the type of aperture for which each curve is to be used.

 

Dim apent As T_ENTITY
Dim cops(2) As T_APERTURECURVEOP

apent.name="My Aperture Curve"
 

'curve identifier, group number and function

cops(0).curv=5 :cops(0).group=1: cops(0).action="Hole"
cops(1).curv=6 :cops(1).group=1: cops(1).action="ClearAperture"
cops(2).curv=9 :cops(2).group=1: cops(2).action="Obscuration"

id = AddApertureCurve( apent, cops )
Update


 

"Get" curve data

The "Get" commands retrieve data from curve entities. In this example, the parameters of a conic arc are loaded into declared structures (See the specific structures for information on what parameters they contain):

 

Dim conent As T_ENTITY

Dim arc As T_CONICARC

GetConicArc conid, conent, arc

 

 

The number of segments in a Segmented curve or the number of curves used in an aperture collection curve can also be retrieved:

 

nseg = GetSegmentedCurveSegCount ( segid )

 

or

 

numcurves = GetApertureCurveOpCount ( apcollid )


 

"Init" a curve structure

Lines, circular arc and conic arcs require that their structures be initialized. This operation insures that values are assigned to all parameters in a structure.

 

Dim arc As T_CONICARC

InitConicArc arc


 

"Set" curve data

Define or alter existing curves with the "Set" commands. When editing a curve, a "Set" command should be used in concert with a "Get" command to insure only the desired changes are made. In this example, only the starting x & y-values and the D coefficient of the curve are changed:

 

Dim conent As T_ENTITY

Dim arc As T_CONICARC

GetConicArc conid3, conent, arc

 

'alter only these conic curve parameters

 arc.startX=arc.startX+0.1

 arc.startY=arc.startY-0.1

 arc.D=arc.D*1.1

SetConicArc conid3, conent, arc

 

In this example, the aperture collection defining a mask has one of it curves exchanged for another. Here, the curve will serve the same purpose as the one it replaces:

 

Dim apent As T_ENTITY
Dim apcrv(2) As T_APERTURECURVEOP

 

apsid=FindName("mask")

GetApertureCurve apsid, apent, apcrv

apcrv(1).curv=13                       'identifier for curve to be substituted

SetApertureCurve apsid, apent, apcrv


See Also….

Advanced Raytrace

Basic Raytrace

Coatings

Elements

Entity Info

General Ray Data

Gratings

Importance Sampling

Linear Transforms

Materials

Ray Buffer Handling

Ray Data Get/Set

Ray Path

Raytrace Control

Scatter

Sources

Surfaces

 

 

 

 

 

Copyright © Photon Engineering, LLC