//AUTOMATICALLY GENERATED BY genfields.pl.
//DO NOT EDIT!!!!

package vrml.field;
import vrml.*;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

public class ConstMFRotation extends ConstMField {
    public ConstMFRotation() {
    }

    public ConstMFRotation(float[] rotations) {
        this(rotations.length, rotations);
    }

    public ConstMFRotation(int size, float[] rotations) {
        for (int i = 0; i < size; i += 4)
            __vect.addElement(new ConstSFRotation(rotations[i], rotations[i+1], rotations[i+2], rotations[i+3]));
    }

    public ConstMFRotation(float[][] rotations) {
        for (int i = 0; i < rotations.length; i++)
            __vect.addElement(new ConstSFRotation(rotations[i][0], rotations[i][1], rotations[i][2], rotations[i][3]));
    }

    public void getValue(float[] rotations) {
        __updateRead();
        int size = __vect.size();
        for (int i = 0; i < size; i++) {
            ConstSFRotation sfRotation = (ConstSFRotation) __vect.elementAt(i);
            rotations[4*i+0] = sfRotation.axisX;
            rotations[4*i+1] = sfRotation.axisY;
            rotations[4*i+2] = sfRotation.axisZ;
            rotations[4*i+3] = sfRotation.angle;
        }
    }

    public void getValue(float[][] rotations) {
        __updateRead();
        int size = __vect.size();
        for (int i = 0; i < size; i++)
            ((ConstSFRotation) __vect.elementAt(i)).getValue(rotations[i]);
    }

    public void get1Value(int index, float[] rotations) {
        __update1Read(index);
        ((ConstSFRotation) __vect.elementAt(index)).getValue(rotations);
    }

    public void get1Value(int index, SFRotation sfRotation) {
        __update1Read(index);
        sfRotation.setValue((ConstSFRotation) __vect.elementAt(index));
    }

    public String toString() {
        __updateRead();
        StringBuffer sb = new StringBuffer("[");
        int size = __vect.size();
        for (int i = 0; i < size; i++) {
            if (i > 0) sb.append(", ");
            sb.append(__vect.elementAt(i));
        }
        return sb.append("]").toString();
    }

    public void __fromPerl(BufferedReader in)  throws IOException {
        __vect.clear();
	String lenline = in.readLine();
	//System.out.println ("__fromPerl, read in length as " + lenline);
        //int len = Integer.parseInt(in.readLine());
	int len = Integer.parseInt(lenline);
        for (int i = 0; i < len; i++) {
            ConstSFRotation sf = new ConstSFRotation();
            sf.__fromPerl(in);
            __vect.addElement(sf);
        }
    }

    public void __toPerl(PrintWriter out)  throws IOException {
        StringBuffer sb = new StringBuffer("");
        int size = __vect.size();
	//out.print(size);
        for (int i = 0; i < size; i++) {
            ((ConstSFRotation) __vect.elementAt(i)).__toPerl(out);
	    if (i != (size-1)) out.print (", ");
	}
	//out.println();
    }
    //public void setOffset(String offs) { this.offset = offs; } //JAS2
    //public String getOffset() { return this.offset; } //JAS2
}