===================
NURBS Surface Trims
===================

Trimmed NURBS surfaces are followed by a terminated list of surface trims. Much like the top-level opcodes, surface trims have a format that is dictatedby the opcode character. The main differences are that they always apply to NURBS surfaces,and there are few enough of them to be described in just this one document.

Trim objects generally specify a closed region on the parameter space of the NURBS surface. The only exception to this is are trim objects that are given as part of a trim collection,in which case they describe one section of a piecewise closed region.  In addition do describingthe closed region, they dictate the operation that is to be done on that area, either "keep" or"remove".  "Remove" operations cut away the closed region.  "Keep" operations cut away everything exceptthe region.  The operation control bit (0x01) on objects that are part of an ``NS_Trim_Collection`` is ignored, since only collectively do such objects specify a closed region.

NURBS surfaces are parameterized from 0 to 1 always, so control vertices should be specifiedwith that in mind.  Note that this contrasts with some solid modelling kernels, which parameterize their surfaces with respect to their knots.

.. raw:: html

	<strong>Trim opcodes:</strong>
	<table BORDER =1 WIDTH="500">
	<TR>
		<TD height=21 width=50>0</TD>
		<TD height=21 width=390>trim list termination</TD>
	</TR>
	<tr>
		<td WIDTH=50 HEIGHT=21>1</td>
		<td WIDTH=390 HEIGHT=21>trim poly</td>
	</tr>
	<tr>
		<td WIDTH=50 HEIGHT=21>2</td>
		<td WIDTH=390 HEIGHT=21>trim curve</td>
	</tr>
	<tr>
		<td WIDTH=50 HEIGHT=21>3</td>
		<td WIDTH=390 HEIGHT=21>trim collection</td>
	</tr>
	</table>

	<strong>Trim controls:</strong>
	<table BORDER =1 WIDTH="500">
	<tr>
		<td WIDTH=50 HEIGHT=21>0x01</td>
		<td WIDTH=390 HEIGHT=21>trim is a "keep" operation</td>
	</tr>
	<tr>
		<td WIDTH=50 HEIGHT=21>0x02</td>
		<td WIDTH=390 HEIGHT=21>trim curve has weights (relevant to <em>trim curve</em> only)</td>
	</tr>
	<tr>
		<td WIDTH=50 HEIGHT=21>0x04</td>
		<td WIDTH=390 HEIGHT=21>trim curve has knots (relevant to <em>trim curve</em> only)</td>
	</tr>
	</table>

**NS_Trim_Termination (0)**

No operands.

**NS_Trim_Poly (1)**

.. raw:: html
   
    <STRONG>Byte</STRONG>&nbsp;control_bits,
    <STRONG>Long</STRONG>&nbsp;control_count,
    <STRONG>(</STRONG><EM>2 x control_count</EM><STRONG>)</STRONG> x <STRONG>Float</STRONG>&nbsp;control_points,
    
    	  
    <table BORDER =1 WIDTH="530">
    <TR>
        <TD height=21 width=131>control_bits</TD>
        <TD height=21 width=390>miscellaneous control options bits (see above)</TD>
	</TR>
    <TR>
        <TD height=21 width=131>point_count</TD>
        <TD height=21 width=390>number of control points in the poly</TD>
	</TR>
    <tr>
	    <td WIDTH=131 HEIGHT=21>points</td>
	    <td WIDTH=390 HEIGHT=21><EM>control_count</EM> pairs of u,v data</td>
	</tr>
    </table>

	<!-------------------------TRIM CURVE----------------------------------------->

		**NS_Trim_Curve (2)**
		
		<STRONG>Byte</STRONG>&nbsp;options,
		<br><STRONG>Byte</STRONG>&nbsp;degree,
		<br><STRONG>Long</STRONG>&nbsp;control_count,
		<br><STRONG>(</STRONG><EM>2 x control_count</EM><STRONG>)</STRONG> x <STRONG>Float</STRONG>&nbsp;control_points,
		<br><STRONG>[(</STRONG><EM>control_count</EM><STRONG>)</STRONG> x <STRONG>Float</STRONG>&nbsp;weights<STRONG>]</STRONG>,
		<br><STRONG>[(</STRONG><EM>control_count+degree+1</EM><STRONG>)</STRONG> x <STRONG>Float</STRONG>&nbsp;knots<STRONG>]</STRONG>,
		<br><STRONG>[Float</STRONG>&nbsp;start<STRONG>]</STRONG>,
		<br><STRONG>[Float</STRONG>&nbsp;end<STRONG>]</STRONG>
		
		
		<table BORDER =1 WIDTH="530">
		<TR>
			<TD height=21 width=131>control_bits</TD>
			<TD height=21 width=390>miscellaneous control options bits (see above)</TD>
		</TR>
		<TR>
			<TD height=21 width=131>degree</TD>
			<TD height=21 width=390>degree of the curve</TD>
		</TR>
		<TR>
			<TD height=21 width=131>control_count</TD>
			<TD height=21 width=390>number of control points in the curve</TD>
		</TR>
		<tr>
			<td WIDTH=131 HEIGHT=21>control_points</td>
			<td WIDTH=390 HEIGHT=21><EM>control_count</EM> triplets of x, y, z data</td>
		</tr>
		<tr>
			<td WIDTH=131 HEIGHT=21>weights</td>
			<td WIDTH=390 HEIGHT=21><EM>control_count</EM> weight factors</td>
		</tr>
		<tr>
			<td WIDTH=131 HEIGHT=21>knots</td>
			<td WIDTH=390 HEIGHT=21><EM>control_count + degree + 1</EM> knot values</td>
		</tr>
		<tr>
			<td WIDTH=131 HEIGHT=21>start</td>
			<td WIDTH=390 HEIGHT=21>parametric start point (0-1, default 0)</td>
		</tr>
		<tr>
			<td WIDTH=131 HEIGHT=21>end</td>
			<td WIDTH=390 HEIGHT=21>parametric end point (0-1, default 1)</td>
		</tr>
		</table>

	<!-------------------------TRIM COLLECTION------------------------------------>
		**NS_Trim_Collection (3)**
		
		<STRONG>Byte</STRONG>&nbsp;control_bits,
		<STRONG>Variable</STRONG>&nbsp;trim list
		
		<table BORDER =1 WIDTH="530">
		<TR>
			<TD height=21 width=131>control_bits</TD>
			<TD height=21 width=390>miscellaneous control options bits (see above)</TD>
		</TR>
		<tr>
			<td WIDTH=131 HEIGHT=21>trim list</td>
			<td WIDTH=390 HEIGHT=21>a terminated list of trim objects that together form a single closed region.</td>
		</tr>
		</table>

