// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: April 3, 1997 // // Description: // The selectVisibleIsoparms() procedure takes a surface list, // and adds all the visible isoparms as selection items to the curveList. // // Input Arguments: // surfaceList - the surfaces to do this to // curveList - append to the list // curveCount - start at this index into curveList // UorVorBoth - 0 for U only, 1 for V only, 2 for both. // // Return Value: // Number of trimmed surfaces where trim info was ignored. // global proc int selectVisibleIsoparms( string $surfaceList[], string $curveList[], int $curveCount, int $UorVorBoth, int $includeFirstAndLast ) // // Description: // Append the isoparm selection items to the curve list. { string $dupl[]; float $knots[]; float $val, $quot; int $i, $n, $div; int $s, $ns, $d; string $surface; if( ($UorVorBoth < 0) || ($UorVorBoth > 2) ) { $UorVorBoth = 2; } // To extract a single isoparm: string $isonode = `createNode curveFromSurfaceIso`; setAttr ($isonode + ".iv") 0.0; setAttr ($isonode + ".rv") true; string $isonodesurf = $isonode + ".is"; // To get the knots from the extracted isoparm: string $infonode = `createNode curveInfo`; string $infonodeknots = ($infonode + ".kn"); // Connect extract and info nodes: connectAttr ($isonode + ".oc") ($infonode + ".ic"); int $ignoredTrimsCount = 0; // We know these are surfaces. Get the display values from them: $surface = $surfaceList[0]; $ns = size($surfaceList); for( $s=0; $s<$ns; $s+=1 ) { $surface = $surfaceList[$s]; if( `getAttr -size ($surface + ".tf")` > 0 ) { $ignoredTrimsCount += 1; } // DO THE U ISOPARMS FIRST: if( (0 == $UorVorBoth) || (2 == $UorVorBoth) ) { // For the division values, 0 means "do it in a single step". int $div = `getAttr ($surface + ".dvu")`; int $deg = `getAttr ($surface + ".du")`; setAttr ($isonode + ".idr") 0; connectAttr ($surface + ".l") $isonodesurf; $knots = `getAttr $infonodeknots`; $n = size($knots); for( $i=($deg-1); $i<($n-$deg); $i+=1 ) { if( $knots[$i+1] == $knots[$i] ) continue; $val = $knots[$i]; if( $includeFirstAndLast || ($i != ($deg-1)) ) { $curveList[$curveCount] = ($surface + ".u[" + $val + "]"); $curveCount += 1; } if( $div > 0 ) { $quot = ($knots[$i+1] - $val) / ($div+1); for( $d=0; $d<$div; $d+=1 ) { $val += $quot; $curveList[$curveCount] = ($surface + ".u[" + $val + "]"); $curveCount += 1; } } } $val = $knots[$n-$deg]; // Only if the surface is open in this direction do we // add this last isoparm. Closed and periodic surfaces // do not need this last isoparm because it is the // same as the first isoparm. Also, skip if we don't // want first and last. // if( $includeFirstAndLast && `getAttr ($surface + ".formU")` == 0 ) { $curveList[$curveCount] = ($surface + ".u[" + $val + "]"); $curveCount += 1; } } // DO THE V ISOPARMS SECOND: if( (1 == $UorVorBoth) || (2 == $UorVorBoth) ) { // For the division values, 0 means "do it in a single step". int $div = `getAttr ($surface + ".dvv")`; int $deg = `getAttr ($surface + ".dv")`; setAttr ($isonode + ".idr") 1; if( 2 != $UorVorBoth ) { connectAttr ($surface + ".l") $isonodesurf; } $knots = `getAttr $infonodeknots`; $n = size($knots); for( $i=($deg-1); $i<($n-$deg); $i+=1 ) { if( $knots[$i+1] == $knots[$i] ) continue; $val = $knots[$i]; if( $includeFirstAndLast || ($i != $deg-1) ) { $curveList[$curveCount] = ($surface + ".v[" + $val + "]"); $curveCount += 1; } if( $div > 0 ) { $quot = ($knots[$i+1] - $val) / ($div+1); for( $d=0; $d<$div; $d+=1 ) { $val += $quot; $curveList[$curveCount] = ($surface + ".v[" + $val + "]"); $curveCount += 1; } } } $val = $knots[$n-$deg]; // Only if the surface is open in this direction do we // add this last isoparm. Closed and periodic surfaces // do not need this last isoparm because it is the // same as the first isoparm. // if( $includeFirstAndLast && `getAttr ($surface + ".formV")` == 0 ) { $curveList[$curveCount] = ($surface + ".v[" + $val + "]"); $curveCount += 1; } } disconnectAttr ($surface + ".l") $isonodesurf; } // Don't need these anymore: delete $isonode $infonode; return $ignoredTrimsCount; }