JScript の例: メソッド「2」の回避策の使用

 
 
 

上記の VBScript 例は、NurbsCurve.Get2 メソッドを使って JScript で再作成できます。このメソッドは、出力値の配列を使用して、NURBS カーブの完全なデータの説明を返します。

var oSpiral = ActiveSceneRoot.AddGeometry( "Arc", "NurbsCurve" );
var vbOutput = new VBArray( oSpiral.ActivePrimitive.Geometry.Curves(0).Get2( siSINurbs ) );
var aOutput = vbOutput.toArray();

var vbCtrlPts = new VBArray( aOutput[0] );
var vbKnots = new VBArray( aOutput[1] );
var bClosed = aOutput[2];
var lDegree = aOutput[3];
var eParFactor = aOutput[4];

LogMessage( "INFORMATION FOR " + oSpiral + ":" );
LogMessage( "===================================================================" );
LogMessage( "Control Points:" );
for ( i = 0; i < vbCtrlPts.ubound(2); i++ )
{
	LogMessage( "x = " + vbCtrlPts.getItem(0,i) +
			"; y = " + vbCtrlPts.getItem(1,i) +
			"; z = " + vbCtrlPts.getItem(2,i)
			);
}

LogMessage( "---------------------------------------------------------------" );
LogMessage( "Knots:" );
var sKnotArray = "";
for ( j = 0; j < vbKnots.ubound(1); j++ )
{
	if ( j == 0 )
	{
		sKnotArray = vbKnots.getItem(j).toString(10);
	}
	else
	{
		sKnotArray = sKnotArray + ", " + vbKnots.getItem(j).toString(10);
	}
}
LogMessage( sKnotArray );

LogMessage( "---------------------------------------------------------------" );
if ( bClosed )
{
	LogMessage( oSpiral + " is closed." );
}
else
{
	LogMessage( oSpiral + " is not closed." );
}

LogMessage( "---------------------------------------------------------------" );
LogMessage( "Degree of " + oSpiral + " is " + lDegree + "." );

LogMessage( "---------------------------------------------------------------" );
switch( eParFactor )
{
	case siUniformParameterization :
		LogMessage( oSpiral + "'s knot parameterization is uniform." );
		break;
	case siNonUniformParameterization :
		LogMessage( oSpiral + "'s knot parameterization is non-uniform." );
		break;
	case siChordLengthParameterization :
		LogMessage( oSpiral + "'s knot parameterization is chord-length." );
		break;
	default :
		LogMessage( oSpiral + "'s knot parameterization is centripetal." );
}

// Output:
//INFO : "INFORMATION FOR arc:"
//INFO : "================================================================="
//INFO : "Control Points:"
//INFO : "x = 0; y = 4; z = 0"
//INFO : "x = 0.13092598458093568; y = 4; z = 0"
//INFO : "x = 0.39268664586056534; y = 3.9871386274509976; z = 0"
//INFO : "x = 0.7816191305260763; y = 3.9294482440542317; z = 0"
//INFO : "x = 1.1630045604222143; y = 3.833915126009607; z = 0"
//INFO : "x = 1.5331948818921716; y = 3.701459309480353; z = 0"
//INFO : "x = 1.888618288771264; y = 3.5333564163398594; z = 0"
//INFO : "x = 2.22585364684673; y = 3.3312253695207223; z = 0"
//INFO : "x = 2.541652716312285; y = 3.0970128008383315; z = 0"
//INFO : "x = 2.832974307831633; y = 2.83297430783163; z = 0"
//INFO : "x = 3.097012800838334; y = 2.541652716312281; z = 0"
//INFO : "x = 3.331225369520725; y = 2.225853646846725; z = 0"
//INFO : "x = 3.5333564163398616; y = 1.8886182887712594; z = 0"
//INFO : "x = 3.701459309480355; y = 1.5331948818921681; z = 0"
//INFO : "x = 3.8339151260096073; y = 1.1630045604222107; z = 0"
//INFO : "x = 3.9294482440542317; y = 0.7816191305260733; z = 0"
//INFO : "x = 3.987138627450999; y = 0.39268664586056134; z = 0"
//INFO : "x = 4; y = 0.13092598458093568; z = 0"
//INFO : "-----------------------------------------------------------------"
//INFO : "Knots:"
//INFO : "0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16"
//INFO : "-----------------------------------------------------------------"
//INFO : "arc is not closed."
//INFO : "-----------------------------------------------------------------"
//INFO : "Degree of arc is 3."
//INFO : "-----------------------------------------------------------------"
//INFO : "arc's knot parameterization is non-uniform."
重要:

関数に明示的に定義された戻り値がある場合は、その戻り値から出力引数を抽出することはできません。 これは、その関数が出力引数の配列ではなく特定の値を戻すためです。 「C# およびスクリプト リファレンス」の「戻り値」セクションでは、コマンドが明示的な戻り値を使用するかどうか、またその値が何であるかを調べることができます。