Navigation: Scripting Reference Manual > Functions & Subroutines > SurfRoughSetDescription

 

SurfRoughSetDescription

 

Contact Us: fredsupport@photonengr.com

 

Description

This command sets the description string for a given surface roughness node.

 

 

Syntax

SurfRoughSetDescription roughNode, roughDesc

 

 

Parameters

roughNode As Long

Node number of the surface roughness model being modified.

 

roughDesc As String

String descriptor being set for roughNode.

 

 

Example

The following example creates a surface roughness model with a Gaussian distribution according to a specified HWHM. 

 

Sub Main

 

          Dim numSamps As Long

          Dim hwhm As Double, maxAng As Double, overallProb As Double

          '----------------

          'USER INPUT

          '----------------

          'number of samples to use in the SRSN roughness model

          numSamps = 90

          'maximum angular deviation for sample points in degrees

          maxAng = 1

          'half-width half-max of the gaussian distribution in degrees

          hwhm = 0.175 'degrees

          'probability of surface normal deviation occurring on intersection

          overallProb = 0.98

          '----------------

          'Derived parameters

          Dim c As Double

          c = hwhm/Sqr(2*Log(2))

 

          'Delete all existing sampled normal roughness models

          Dim roughCount As Long, curRough As Long

          For curRough = SurfRoughGetMaxNodeNum To 0 Step -1

                    If SurfRoughIsValidNode( curRough ) Then

                              If SurfRoughGetType( curRough ) = "SampRanNorm" Then

                                        Print "Sampled random normal roughness model at node " & curRough & " deleted."

                                        SurfRoughDelete( curRough )

                              End If

                    End If

          Next curRough

 

          'Create a new sampled random surface normal (SRSN) roughness model

          Dim roughNode As Long

          roughNode = SurfRoughSRSNCreate( "Gaussian Roughness", "HWHM=" & CStr(hwhm) )

 

          'Dynamically size the arrays for the SRSN sample entries

          Dim angles() As Double

                    ReDim angles( numSamps )

          Dim relProbs() As Double

                    ReDim relProbs( numSamps )

          Dim curSamp As Long

 

          'Set entries for the gaussian SRSN model

          For curSamp = 0 To numSamps-1

                    'Assign angle and gaussian probability with sin(theta) correction factor

                    'Populate angle sample value

                    If curSamp = 0 Then

                              angles(curSamp) = 1e-6

                    Else

                              angles(curSamp) = curSamp*(maxAng/(numSamps-1))

                    End If

                    'Populate probability value

                    relProbs(curSamp) = Exp(-(angles(curSamp)/c)^2)

                    relProbs(curSamp) = relProbs(curSamp)*Sin(DegToRad(angles(curSamp)))

          Next curSamp

 

          'Set the entries to the surface roughness node

          SurfRoughSRSNSetEntries( roughNode, angles(), relProbs() )

 

          'Set the overall probability for the roughness

          SurfRoughSRSNSetOverallRoughnessProbability( roughNode, overallProb )

 

              'Set the descriptor string

              SurfRoughSetDescription( roughNode, "Gaussian with HWHM=" & Format$(hwhm,"#0.00") )

 

          'Update the document

          Update

 

End Sub

 

 

See Also

SurfRoughCopy

SurfRoughDelete

SurfRoughDeleteAllNodes

SurfRoughFindName

SurfRoughGetDescription

SurfRoughGetMaxNodeNum

SurfRoughGetName

SurfRoughGetNodeCount

SurfRoughGetType

SurfRoughIsActive

SurfRoughIsValidNode

SurfRoughSetActive

SurfRoughSetName

SurfRoughSRSNCreate

SurfRoughSRSNGetEntries

SurfRoughSRSNGetEntryCount

SurfRoughSRSNGetIthAngle

SurfRoughSRSNGetIthProbability

SurfRoughSRSNGetOverallRoughnessProbability

SurfRoughSRSNSetEntries

SurfRoughSRSNSetOverallRoughnessProbability

 

 

 

 

 

Copyright © Photon Engineering, LLC