FreeWRL / FreeX3D 4.3.0
FWMFVec3d.java
1package sai;
2import org.web3d.x3d.sai.*;
3import java.util.*;
4
5public class FWMFVec3d extends FreeWRLMField implements MFVec3d {
6 FreeWRLBrowser browser;
7 private static final int ROWS = 3;
8
10 super(def, b);
11 browser = b;
12 }
13
14 public void getValue(double[][] value) throws ArrayIndexOutOfBoundsException {
15 int lines;
16 int count1;
17 int count2;
18 StringTokenizer tokens;
19 String rep;
20
21 if (RLreturn == null) {
22 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
23 } else {
24 rep = RLreturn;
25 }
26
27 tokens = new StringTokenizer(rep);
28
29 lines = Integer.valueOf(tokens.nextToken()).intValue();
30
31 if (value.length < lines) {
32 throw new ArrayIndexOutOfBoundsException("MFVec3d getValue passed array of insufficient size");
33 }
34
35 for (count1=0; count1<lines; count1++) {
36 if ((value[count1]).length < ROWS) {
37 throw new ArrayIndexOutOfBoundsException("MFVec3d getValue passed array with sub array of insufficient size");
38 }
39 for(count2=0; count2<ROWS; count2++) {
40 value[count1][count2] = Double.valueOf(tokens.nextToken()).doubleValue();
41 }
42 }
43 }
44 public void getValue(double[] value) throws ArrayIndexOutOfBoundsException {
45 int lines;
46 int count1;
47 StringTokenizer tokens;
48 String rep;
49
50 if (RLreturn == null) {
51 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
52 } else {
53 rep = RLreturn;
54 }
55
56 tokens = new StringTokenizer(rep);
57
58 lines = Integer.valueOf(tokens.nextToken()).intValue();
59
60 if (value.length < (lines*ROWS)) {
61 throw new ArrayIndexOutOfBoundsException("MFVec3d getValue passed array of insufficient size");
62 }
63
64 for (count1=0; count1<(lines*ROWS); count1++) {
65 value[count1] = Double.valueOf(tokens.nextToken()).doubleValue();
66 }
67 }
68 public void get1Value(int index, double[] value) throws ArrayIndexOutOfBoundsException {
69 int lines;
70 int count1;
71 int count2;
72 StringTokenizer tokens;
73 String rep;
74 double[][] tval;
75
76 if (RLreturn == null) {
77 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
78 } else {
79 rep = RLreturn;
80 }
81
82 tokens = new StringTokenizer(rep);
83
84 lines = Integer.valueOf(tokens.nextToken()).intValue();
85
86 if (value.length < ROWS) {
87 throw new ArrayIndexOutOfBoundsException("MFVec3d get1Value passed array of insufficient size");
88 }
89
90 if (lines < index) {
91 throw new ArrayIndexOutOfBoundsException("MFVec2f get1Value passed index out of bounds");
92 }
93
94 tval = new double[lines][ROWS];
95
96 for (count1=0; count1<lines; count1++) {
97 for(count2=0; count2<ROWS; count2++) {
98 tval[count1][count2] = Double.valueOf(tokens.nextToken()).doubleValue();
99 }
100 }
101
102 for (count1=0; count1<ROWS; count1++) {
103 value[count1] = tval[index][count1];
104 }
105 }
106 public void setValue(int size, double[] value) throws ArrayIndexOutOfBoundsException {
107 int count;
108 String val;
109
110 if ((size*ROWS) > value.length) {
111 throw new ArrayIndexOutOfBoundsException("MFVec3d setValue not passed enough values to complete request");
112 }
113
114 val = " " + size;
115
116 for (count = 0; count < (size*ROWS); count++) {
117 val = val + " " + value[count];
118 }
119 browser.newSendEvent(this, val);
120 }
121 public void setValue(int size, double[][] value) throws ArrayIndexOutOfBoundsException {
122 int count;
123 String val;
124
125 if (size > value.length) {
126 size = value.length;
127 }
128
129 val = " " + size;
130
131 for (count = 0; count < size; count++) {
132 if ((value[count]).length < ROWS) {
133 throw new ArrayIndexOutOfBoundsException("MFVec3d setValue passed degenerate vector value");
134 }
135 val = val + " " + value[count][0] + " " + value[count][1] + " " + value[count][2];
136 }
137 browser.newSendEvent(this, val);
138 }
139 public void set1Value(int index, double[] value) throws ArrayIndexOutOfBoundsException {
140 if (value.length < ROWS) {
141 throw new ArrayIndexOutOfBoundsException("MFVec3d set1Value passed degenerate vector value");
142 }
143 browser.newSendEvent(this, " ONEVAL " + index + " " + value[0] + " " + value[1] + " " + value[2]);
144 }
145 public void append(double[] value) {
146 int lines;
147 int count1;
148 int count2;
149 int count;
150 StringTokenizer tokens;
151 String rep;
152 String val;
153 int size;
154
155 if (RLreturn == null) {
156 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
157 } else {
158 rep = RLreturn;
159 }
160
161 tokens = new StringTokenizer(rep);
162
163 lines = Integer.valueOf(tokens.nextToken()).intValue();
164 size = value.length/ROWS;
165
166 val = " " + (lines+size);
167
168 for (count = 0; count < lines; count++) {
169 val = val + " " + Double.valueOf(tokens.nextToken()).doubleValue() + " " + Double.valueOf(tokens.nextToken()).doubleValue() + " " + Double.valueOf(tokens.nextToken()).doubleValue();
170 }
171
172 for (count = 0; count < value.length; count++) {
173 if (value.length < ROWS) {
174 throw new ArrayIndexOutOfBoundsException("MFVec2f append degenerate vector value received");
175 }
176
177 val = val + " " + value[count] + " " + value[count+1] + " " + value[count+2];
178 count++;
179 count++;
180 }
181
182 browser.newSendEvent(this, val);
183 }
184 public void insertValue(int index, double[] value) {
185 int lines;
186 int count1;
187 int count2;
188 int count;
189 StringTokenizer tokens;
190 String rep;
191 String val;
192 int size;
193
194 if (RLreturn == null) {
195 rep = browser.SendEventOut(nodePtr, offset, datasize, dataType, command);
196 } else {
197 rep = RLreturn;
198 }
199
200 tokens = new StringTokenizer(rep);
201
202 lines = Integer.valueOf(tokens.nextToken()).intValue();
203 size = value.length/ROWS;
204
205 val = " " + (lines+size);
206
207 for (count = 0; count < index; count++) {
208 val = val + " " + Double.valueOf(tokens.nextToken()).doubleValue() + " " + Double.valueOf(tokens.nextToken()).doubleValue() + " " + Double.valueOf(tokens.nextToken()).doubleValue();
209 }
210
211 for (count = 0; count < value.length; count++) {
212 if (value.length < ROWS) {
213 throw new ArrayIndexOutOfBoundsException("MFVec2f insert degenerate vector value received");
214 }
215
216 val = val + " " + value[count] + " " + value[count+1] + " " + value[count+2];
217 count++;
218 count++;
219 }
220
221 for (count = (index+size); count < (lines+size); count++) {
222 val = val + " " + Double.valueOf(tokens.nextToken()).doubleValue() + " " + Double.valueOf(tokens.nextToken()).doubleValue() + " " + Double.valueOf(tokens.nextToken()).doubleValue();
223 }
224
225 browser.newSendEvent(this, val);
226 }
227}