private void compressStream(CompressionStream stream) {
	if (benchmark) startTime = System.currentTimeMillis() ;

	// Create the Huffman table.
	huffmanTable = new HuffmanTable() ;

	// Quantize the stream, compute deltas between consecutive elements if
	// possible, and histogram the data length distribution.
	stream.quantize(huffmanTable) ;

	// Compute tags for stream tokens.
	huffmanTable.computeTags() ;

	// Create the output buffer and assemble the compressed output.
	outputBuffer = new CommandStream(stream.getByteCount() / 3) ;
	stream.outputCommands(huffmanTable, outputBuffer) ;

	// Print any desired info.
	if (benchmark) printBench(stream) ;
	if (printStream) stream.print() ;
	if (printHuffman) huffmanTable.print() ;

	// Set up the compressed geometry header object.
	cgHeader.bufferType = stream.streamType ;
	cgHeader.bufferDataPresent = 0 ;
	cgHeader.lowerBound = new Point3d(stream.ncBounds[0]) ;
	cgHeader.upperBound = new Point3d(stream.ncBounds[1]) ;

	if (stream.vertexNormals)
	    cgHeader.bufferDataPresent |=
		CompressedGeometryData.Header.NORMAL_IN_BUFFER ;

	if (stream.vertexColor3 || stream.vertexColor4)
	    cgHeader.bufferDataPresent |=
		CompressedGeometryData.Header.COLOR_IN_BUFFER ;

	if (stream.vertexColor4)
	    cgHeader.bufferDataPresent |=
		CompressedGeometryData.Header.ALPHA_IN_BUFFER ;

	cgHeader.start = 0 ;
	cgHeader.size = outputBuffer.getByteCount() ;

	// Clear the huffman table for next use.
	huffmanTable.clear() ;
    }