Navigation: Scripting Reference Manual > Functions & Subroutines > AddNURBSurf

 

AddNURBSurf

 

Contact Us: fredsupport@photonengr.com

 

Description

This function adds a NURB surface to the associated FRED document.  If there is a problem, the function sets an error and returns -1 without adding the surface.

 

The total number of elements in the points array must be a multiple of three, where each group of three values is the X,Y,Z position of a control point.  The points array can be defined as either a 1-D or 2-D array, without preference being given to either form.  If using the 2-D form, the size of the points array is 2xN, where N is the number of control points minus 1.  If using the 1-D form, the size of the points array is 3*N-1.  Note that the NURB order is given by order =  degree + 1. For example, an order 3 NURB is quadratic and an order 4 NURB is cubic.

 

This is an advanced feature not recommended for anyone who is unfamiliar with NURB technology.

 

 

Syntax

n = AddNURBSurf ( entity, maxIdxU, maxIdxV, orderU, orderV, knotU, knotV, points, weights )

 

Parameters

n (Long)

Node number of the newly added surface, or -1 if there is a problem.

 

entity As T_ENTITY

Holds the generic entity data for the new NURB surface.

 

maxIdxU As Long

One less than the number of terms in the U parameter direction.

 

maxIdxV As Long

One less than the number of terms in the V parameter direction.

 

orderU As Long

The order of the U basis functions.

 

orderV As Long

The order of the V basis functions.

 

knotU() As Double

The U parameter knot array.

 

knotV() As Double

The V parameter knot array.

 

points() As Double

The array of control points having the following sizes (where N is the number of control points):

1-D Form: Array size should have 3*N-1 elements

2-D Form: Array size should be (2, N-1)

 

weights() As Double

The array of control points weights.

 

 

Examples

The following script adds a NURB surface using the 1-D array form:

 

Sub Main

 

    Dim ent As T_ENTITY

    Dim nurbNode As Long, maxIdxU As Long, maxIdxV As Long, orderU As Long, orderV As Long, ceNode As Long

    Dim knotU( ) As Double, knotV( ) As Double, points( ) As Double, weights( ) As Double

 

    'Add a custom element node to store the surface in.

    InitEntity ent

    ent.name = "CustomNURB"

    ent.parent = 2 'geometry node

    ceNode = AddCustomElement( ent )

 

    'Set NURB surface parameters to make a square.

    orderU = 2

    orderV = 2

    maxIdxU = 1

    maxIdxV = 1

 

    'Knot Vectors:

    ReDim knotU( 3 )

    knotU ( 0 ) = 0 : knotU( 1 ) = 0 : knotU( 2 ) = 1 : knotU( 3 ) = 1

    ReDim knotV( 3 )

    knotV ( 0 ) = 0 : knotV( 1 ) = 0 : knotV( 2 ) = 1 : knotV( 3 ) = 1

 

    'Control points:

    ReDim points( 3*4-1 )

    'load X

    points( 0 ) = -0.5 : points( 3 ) = 0.5 : points( 6 ) = -0.5 : points( 9 ) = 0.5

    'load Y

    points( 1 ) = -0.5 : points( 4 ) = -0.5 : points( 7 ) = 0.5 : points( 10 ) = 0.5

    'load Z

    points( 2 ) = 0 : points( 5 ) = 0 : points( 8 ) = 0 : points( 11 ) = 0

 

    'Weights:

    ReDim weights( 3 )

    weights( 0 ) = 1 : weights( 1 ) = 1 : weights( 2 ) = 1 : weights( 3 ) = 1

 

    'Add a NURB surface

    InitEntity ent

    ent.name = "NURB Surface"

    ent.parent = ceNode

    nurbNode = AddNURBSurf( ent, maxIdxU, maxIdxV, orderU, orderV, knotU(), knotV(), points(), weights() )

 

    Update

 

End Sub

 

The following script adds a NURB surface using the 2-D array form:

 

Sub Main

 

    Dim ent As T_ENTITY

    Dim nurbNode As Long, maxIdxU As Long, maxIdxV As Long, orderU As Long, orderV As Long, ceNode As Long

    Dim knotU( ) As Double, knotV( ) As Double, points( ) As Double, weights( ) As Double

 

    'Add a custom element node to store the surface in.

    InitEntity ent

    ent.name = "CustomNURB"

    ent.parent = 2 'geometry node

    ceNode = AddCustomElement( ent )

 

    'Set NURB surface parameters to make a square.

    orderU = 2

    orderV = 2

    maxIdxU = 1

    maxIdxV = 1

 

    'Knot Vectors:

    ReDim knotU( 3 )

    knotU ( 0 ) = 0 : knotU( 1 ) = 0 : knotU( 2 ) = 1 : knotU( 3 ) = 1

    ReDim knotV( 3 )

    knotV ( 0 ) = 0 : knotV( 1 ) = 0 : knotV( 2 ) = 1 : knotV( 3 ) = 1

 

    'Control points:

    ReDim points( 2, 3 )

    'load X

    points( 0, 0 ) = -0.5 : points( 0, 1 ) = 0.5 : points( 0, 2 ) = -0.5 : points( 0, 3 ) = 0.5

    'load Y

    points( 1, 0 ) = -0.5 : points( 1, 1 ) = -0.5 : points( 1, 2 ) = 0.5 : points( 1, 3 ) = 0.5

    'load Z

    points( 2, 0 ) = 0 : points( 2, 1 ) = 0 : points( 2, 2 ) = 0 : points( 2, 3 ) = 0

 

    'Weights:

    ReDim weights( 3 )

    weights( 0 ) = 1 : weights( 1 ) = 1 : weights( 2 ) = 1 : weights( 3 ) = 1

 

    'Add a NURB surface

    InitEntity ent

    ent.name = "NURB Surface"

    ent.parent = ceNode

    nurbNode = AddNURBSurf( ent, maxIdxU, maxIdxV, orderU, orderV, knotU(), knotV(), points(), weights() )

 

    Update

 

End Sub

 

 

See Also

T_ENTITY

GetNURBSurf

SetNURBSurf

Surfaces

 

 

 

 

 

Copyright © Photon Engineering, LLC