FreeWRL / FreeX3D 4.3.0
EAI_C_Field.c
1
2/****************************************************************************
3 This file is part of the FreeWRL/FreeX3D Distribution.
4
5 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
6
7 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
19****************************************************************************/
20
21#include "EAI_C.h"
22#include "config.h"
23#include "system.h"
24
25
26void X3D_freeEventIn(X3DEventIn* ev) {
27 if (ev != NULL)
28 free(ev);
29}
30
31void X3D_freeEventOut(X3DEventOut* ev) {
32 if (ev != NULL)
33 free(ev);
34}
35
36void X3D_freeNode(X3DNode* node) {
37 int i;
38
39 if (node == NULL) {
40 printf("TRYING TO FREE NULL PTR\n");
41 return;
42 }
43
44 switch (node->type) {
45 case FIELDTYPE_SFVec3f:
46 case FIELDTYPE_SFVec3d:
47 case FIELDTYPE_SFVec2f:
48 case FIELDTYPE_SFColor:
49 case FIELDTYPE_SFFloat:
50 case FIELDTYPE_SFRotation:
51 case FIELDTYPE_SFColorRGBA:
52 case FIELDTYPE_SFBool:
53 case FIELDTYPE_SFInt32:
54 case FIELDTYPE_SFTime:
55 free(node);
56 break;
57
58 case FIELDTYPE_SFString:
59 free(node->X3D_SFString.strptr);
60 free(node);
61
62 break;
63
64 case FIELDTYPE_MFString:
65 for (i = 0; i < node->X3D_MFString.n; i++) {
66 free(node->X3D_MFString.p[i].strptr);
67 }
68 free(node->X3D_MFString.p);
69 free(node);
70 break;
71
72 case FIELDTYPE_MFFloat:
73 case FIELDTYPE_MFVec3f:
74 case FIELDTYPE_MFVec3d:
75 case FIELDTYPE_MFVec2f:
76 case FIELDTYPE_MFRotation:
77 case FIELDTYPE_MFColor:
78 case FIELDTYPE_MFBool:
79 case FIELDTYPE_MFColorRGBA:
80 case FIELDTYPE_MFInt32:
81 free(node->X3D_MFInt32.p);
82 free(node);
83 break;
84
85
86 default:
87 free(node);
88
89 }
90}
91
92X3DNode *X3D_newSFVec3f (float a, float b, float c) {
93 X3DNode *retval;
94 retval = malloc (sizeof(X3DNode));
95 retval->X3D_SFVec3f.type = FIELDTYPE_SFVec3f;
96 retval->X3D_SFVec3f.c[0] = a;
97 retval->X3D_SFVec3f.c[1] = b;
98 retval->X3D_SFVec3f.c[2] = c;
99 return retval;
100}
101
102void X3D_getSFVec3f(X3DNode* node, float* value) {
103 if (node->X3D_SFVec3f.type != FIELDTYPE_SFVec3f)
104 return;
105 value[0] = node->X3D_SFVec3f.c[0];
106 value[1] = node->X3D_SFVec3f.c[1];
107 value[2] = node->X3D_SFVec3f.c[2];
108
109}
110
111X3DNode *X3D_newSFVec3d (double a, double b, double c) {
112 X3DNode *retval;
113 retval = malloc (sizeof(X3DNode));
114 retval->X3D_SFVec3d.type = FIELDTYPE_SFVec3d;
115 retval->X3D_SFVec3d.c[0] = a;
116 retval->X3D_SFVec3d.c[1] = b;
117 retval->X3D_SFVec3d.c[2] = c;
118 return retval;
119}
120
121void X3D_getSFVec3d(X3DNode* node, double* value) {
122 if (node->X3D_SFVec3d.type != FIELDTYPE_SFVec3d)
123 return;
124 value[0] = node->X3D_SFVec3d.c[0];
125 value[1] = node->X3D_SFVec3d.c[1];
126 value[2] = node->X3D_SFVec3d.c[2];
127}
128
129X3DNode *X3D_newSFColor (float a, float b, float c) {
130 X3DNode *retval;
131 retval = malloc (sizeof(X3DNode));
132 retval->X3D_SFColor.type = FIELDTYPE_SFColor;
133 retval->X3D_SFColor.c[0] = a;
134 retval->X3D_SFColor.c[1] = b;
135 retval->X3D_SFColor.c[2] = c;
136 return retval;
137}
138
139void X3D_getSFColor(X3DNode* node, float* value) {
140 if (node->X3D_SFColor.type != FIELDTYPE_SFColor)
141 return;
142 value[0] = node->X3D_SFColor.c[0];
143 value[1] = node->X3D_SFColor.c[1];
144 value[2] = node->X3D_SFColor.c[2];
145}
146
147X3DNode *X3D_newSFVec2f (float a, float b) {
148 X3DNode *retval;
149 retval = malloc (sizeof(X3DNode));
150 retval->X3D_SFVec2f.type = FIELDTYPE_SFVec2f;
151 retval->X3D_SFVec2f.c[0] = a;
152 retval->X3D_SFVec2f.c[1] = b;
153 return retval;
154}
155
156void X3D_getSFVec2f(X3DNode* node, float* value) {
157 if (node->X3D_SFVec2f.type != FIELDTYPE_SFVec2f)
158 return;
159 value[0] = node->X3D_SFVec3f.c[0];
160 value[1] = node->X3D_SFVec3f.c[1];
161}
162
163X3DNode *X3D_newSFRotation (float a, float b,float c, float d) {
164 X3DNode *retval;
165 retval = malloc (sizeof(X3DNode));
166 retval->X3D_SFRotation.type = FIELDTYPE_SFRotation;
167 retval->X3D_SFRotation.r[0] = a;
168 retval->X3D_SFRotation.r[1] = b;
169 retval->X3D_SFRotation.r[2] = c;
170 retval->X3D_SFRotation.r[3] = d;
171 return retval;
172}
173
174void X3D_getSFRotation(X3DNode* node, float* value) {
175 if (node->X3D_SFRotation.type != FIELDTYPE_SFRotation)
176 return;
177 value[0] = node->X3D_SFRotation.r[0];
178 value[1] = node->X3D_SFRotation.r[1];
179 value[2] = node->X3D_SFRotation.r[2];
180 value[3] = node->X3D_SFRotation.r[3];
181}
182
183X3DNode *X3D_newSFColorRGBA (float a, float b,float c, float d) {
184 X3DNode *retval;
185 retval = malloc (sizeof(X3DNode));
186 retval->X3D_SFColorRGBA.type = FIELDTYPE_SFColorRGBA;
187 retval->X3D_SFColorRGBA.r[0] = a;
188 retval->X3D_SFColorRGBA.r[1] = b;
189 retval->X3D_SFColorRGBA.r[2] = c;
190 retval->X3D_SFColorRGBA.r[3] = d;
191 return retval;
192}
193
194void X3D_getSFColorRGBA(X3DNode* node, float* value) {
195 if (node->X3D_SFColorRGBA.type != FIELDTYPE_SFColorRGBA)
196 return;
197 value[0] = node->X3D_SFColorRGBA.r[0];
198 value[1] = node->X3D_SFColorRGBA.r[1];
199 value[2] = node->X3D_SFColorRGBA.r[2];
200 value[3] = node->X3D_SFColorRGBA.r[3];
201}
202
203X3DNode *X3D_newSFBool (int a) {
204 X3DNode *retval;
205 retval = malloc (sizeof(X3DNode));
206 retval->X3D_SFBool.type = FIELDTYPE_SFBool;
207 retval->X3D_SFBool.value = a;
208 return retval;
209}
210
211void X3D_getSFBool(X3DNode* node, int* value) {
212 if (node->X3D_SFBool.type != FIELDTYPE_SFBool)
213 return;
214 *value = node->X3D_SFBool.value;
215}
216
217X3DNode *X3D_newSFFloat (float a) {
218 X3DNode *retval;
219 retval = malloc (sizeof(X3DNode));
220 retval->X3D_SFFloat.type = FIELDTYPE_SFFloat;
221 retval->X3D_SFFloat.value = a;
222 return retval;
223}
224
225void X3D_getSFFloat(X3DNode* node, float* value) {
226 if (node->X3D_SFFloat.type != FIELDTYPE_SFFloat)
227 return;
228 *value = node->X3D_SFFloat.value;
229}
230
231X3DNode *X3D_newSFTime (double a) {
232 X3DNode *retval;
233 retval = malloc (sizeof(X3DNode));
234 retval->X3D_SFTime.type = FIELDTYPE_SFTime;
235 retval->X3D_SFTime.value = a;
236 return retval;
237}
238
239void X3D_getSFTime(X3DNode* node, double* value) {
240 if (node->X3D_SFTime.type != FIELDTYPE_SFTime)
241 return;
242 *value = node->X3D_SFTime.value;
243}
244
245X3DNode *X3D_newSFInt32 (int a) {
246 X3DNode *retval;
247 retval = malloc (sizeof(X3DNode));
248 retval->X3D_SFInt32.type = FIELDTYPE_SFInt32;
249 retval->X3D_SFInt32.value = a;
250 return retval;
251}
252
253void X3D_getSFInt32(X3DNode* node, int* value) {
254 if (node->X3D_SFInt32.type != FIELDTYPE_SFInt32)
255 return;
256 *value = node->X3D_SFBool.value;
257}
258
259X3DNode *X3D_newSFString(char* string) {
260 X3DNode *retval;
261 retval = malloc (sizeof(X3DNode));
262 retval->X3D_SFString.type = FIELDTYPE_SFString;
263 retval->X3D_SFString.len = strlen(string);
264 retval->X3D_SFString.strptr = malloc((strlen(string) + 1)*sizeof(char));
265 memcpy(retval->X3D_SFString.strptr, string, strlen(string));
266 retval->X3D_SFString.strptr[strlen(string)] = '\0';
267 return retval;
268}
269
270char* X3D_getSFString(X3DNode* node) {
271 char* string;
272 if (node->type != FIELDTYPE_SFString)
273 return 0;
274 string = malloc((node->X3D_SFString.len + 1)*sizeof(char));
275 memcpy(string, node->X3D_SFString.strptr, node->X3D_SFString.len);
276 string[node->X3D_SFString.len] = '\0';
277 return string;
278}
279
280X3DNode *X3D_newMFInt32(int num, int* array){
281 int i;
282 X3DNode* retval;
283
284 retval = malloc(sizeof(X3DNode));
285 retval->type = FIELDTYPE_MFInt32;
286 retval->X3D_MFInt32.n = num;
287 retval->X3D_MFInt32.p = malloc (sizeof(X3DNode) * num);
288
289 for (i = 0; i < num; i++) {
290 retval->X3D_MFInt32.p[i].value = array[i];
291 retval->X3D_MFInt32.p[i].type= FIELDTYPE_SFInt32;
292 }
293
294 return retval;
295}
296
297void X3D_getMFInt32(X3DNode* node, int** array, int* num) {
298 int i;
299
300 if (node->type != FIELDTYPE_MFInt32)
301 return;
302 *num = node->X3D_MFInt32.n;
303
304 *array = malloc (node->X3D_MFInt32.n * sizeof(int));
305
306 for (i = 0; i < node->X3D_MFInt32.n; i++) {
307 (*array)[i] = node->X3D_MFInt32.p[i].value;
308 }
309}
310
311X3DNode *X3D_newMFFloat(int num, float* array){
312 int i;
313 X3DNode* retval;
314
315 retval = malloc(sizeof(X3DNode));
316 retval->type = FIELDTYPE_MFFloat;
317 retval->X3D_MFFloat.n = num;
318 retval->X3D_MFFloat.p = malloc (sizeof(X3DNode) * num);
319
320 for (i = 0; i < num; i++) {
321 retval->X3D_MFFloat.p[i].value = array[i];
322 retval->X3D_MFFloat.p[i].type= FIELDTYPE_SFFloat;
323 }
324
325 return retval;
326}
327
328void X3D_getMFFloat(X3DNode* node, float** array, int* num) {
329 int i;
330
331 if (node->type != FIELDTYPE_MFFloat)
332 return;
333 *num = node->X3D_MFFloat.n;
334
335 *array = malloc (node->X3D_MFFloat.n * sizeof(float));
336
337 for (i = 0; i < node->X3D_MFFloat.n; i++) {
338 (*array)[i] = node->X3D_MFFloat.p[i].value;
339 }
340}
341
342X3DNode *X3D_newMFVec3f(int num, float(* array)[3]){
343 int i;
344 X3DNode* retval;
345
346 retval = malloc(sizeof(X3DNode));
347 retval->type = FIELDTYPE_MFVec3f;
348 retval->X3D_MFVec3f.n = num;
349 retval->X3D_MFVec3f.p = malloc (sizeof(X3DNode) * num);
350
351 for (i = 0; i < num; i++) {
352 retval->X3D_MFVec3f.p[i].type= FIELDTYPE_SFVec3f;
353 retval->X3D_MFVec3f.p[i].c[0]= array[i][0];
354 retval->X3D_MFVec3f.p[i].c[1]= array[i][1];
355 retval->X3D_MFVec3f.p[i].c[2]= array[i][2];
356 }
357
358 return retval;
359}
360
361void X3D_getMFVec3f(X3DNode* node, float*** array, int* num) {
362 int i;
363
364 if (node->type != FIELDTYPE_MFVec3f)
365 return;
366 *num = node->X3D_MFVec3f.n;
367
368 (*array) = (float**) malloc(node->X3D_MFVec3f.n*sizeof(float*));
369 (*array)[0] = (float*) malloc (node->X3D_MFVec3f.n * sizeof(float) * 3);
370 for (i = 0; i < node->X3D_MFVec2f.n; i++)
371 (*array)[i] = (*array)[0] + i * 3;
372
373 for (i = 0; i < node->X3D_MFFloat.n; i++) {
374 (*array)[i][0] = node->X3D_MFVec3f.p[i].c[0];
375 (*array)[i][1] = node->X3D_MFVec3f.p[i].c[1];
376 (*array)[i][2] = node->X3D_MFVec3f.p[i].c[2];
377 }
378}
379
380void X3D_getMFColor(X3DNode* node, float*** array, int* num) {
381 int i;
382
383 if (node->type != FIELDTYPE_MFColor)
384 return;
385 *num = node->X3D_MFColor.n;
386
387 (*array) = (float**) malloc(node->X3D_MFColor.n*sizeof(float*));
388 (*array)[0] = (float*) malloc (node->X3D_MFColor.n * sizeof(float) * 3);
389 for (i = 0; i < node->X3D_MFFloat.n; i++)
390 (*array)[i] = (*array)[0] + i * 3;
391
392 for (i = 0; i < node->X3D_MFFloat.n; i++) {
393 (*array)[i][0] = node->X3D_MFColor.p[i].c[0];
394 (*array)[i][1] = node->X3D_MFColor.p[i].c[1];
395 (*array)[i][2] = node->X3D_MFColor.p[i].c[2];
396 }
397}
398
399X3DNode *X3D_newMFColor(int num, float(* array)[3]){
400 int i;
401 X3DNode* retval;
402
403 retval = malloc(sizeof(X3DNode));
404 retval->type = FIELDTYPE_MFColor;
405 retval->X3D_MFColor.n = num;
406 retval->X3D_MFColor.p = malloc (sizeof(X3DNode) * num);
407
408 for (i = 0; i < num; i++) {
409 retval->X3D_MFColor.p[i].type= FIELDTYPE_SFColor;
410 retval->X3D_MFColor.p[i].c[0]= array[i][0];
411 retval->X3D_MFColor.p[i].c[1]= array[i][1];
412 retval->X3D_MFColor.p[i].c[2]= array[i][2];
413 }
414
415 return retval;
416}
417
418X3DNode *X3D_newMFVec2f(int num, float(* array)[2]){
419 int i;
420 X3DNode* retval;
421
422 retval = malloc(sizeof(X3DNode));
423 retval->type = FIELDTYPE_MFVec2f;
424 retval->X3D_MFVec2f.n = num;
425 retval->X3D_MFVec2f.p = malloc (sizeof(X3DNode) * num);
426
427 for (i = 0; i < num; i++) {
428 retval->X3D_MFVec2f.p[i].type= FIELDTYPE_SFVec2f;
429 retval->X3D_MFVec2f.p[i].c[0]= array[i][0];
430 retval->X3D_MFVec2f.p[i].c[1]= array[i][1];
431 }
432
433 return retval;
434}
435
436void X3D_getMFVec2f(X3DNode* node, float*** array, int* num) {
437 int i;
438
439 if (node->type != FIELDTYPE_MFVec2f)
440 return;
441 *num = node->X3D_MFVec2f.n;
442
443 (*array) = (float**) malloc(node->X3D_MFVec2f.n*sizeof(float*));
444 (*array)[0] = (float*) malloc (node->X3D_MFVec2f.n * sizeof(float) * 2);
445 for (i = 0; i < node->X3D_MFVec2f.n; i++)
446 (*array)[i] = (*array)[0] + i * 2;
447
448 for (i = 0; i < node->X3D_MFVec2f.n; i++) {
449 (*array)[i][0] = node->X3D_MFVec2f.p[i].c[0];
450 (*array)[i][1] = node->X3D_MFVec2f.p[i].c[1];
451 }
452}
453
454X3DNode *X3D_newMFRotation(int num, float(* array)[4]){
455 int i;
456 X3DNode* retval;
457
458 retval = malloc(sizeof(X3DNode));
459 retval->type = FIELDTYPE_MFRotation;
460 retval->X3D_MFRotation.n = num;
461 retval->X3D_MFRotation.p = malloc (sizeof(X3DNode) * num);
462
463 for (i = 0; i < num; i++) {
464 retval->X3D_MFRotation.p[i].type= FIELDTYPE_SFRotation;
465 retval->X3D_MFRotation.p[i].r[0]= array[i][0];
466 retval->X3D_MFRotation.p[i].r[1]= array[i][1];
467 retval->X3D_MFRotation.p[i].r[2]= array[i][2];
468 retval->X3D_MFRotation.p[i].r[3]= array[i][3];
469 }
470
471 return retval;
472}
473
474void X3D_getMFRotation(X3DNode* node, float*** array, int* num) {
475 int i;
476
477 if (node->type != FIELDTYPE_MFRotation)
478 return;
479 *num = node->X3D_MFRotation.n;
480
481 (*array) = (float**) malloc(node->X3D_MFRotation.n*sizeof(float*));
482 (*array)[0] = (float*) malloc (node->X3D_MFRotation.n * sizeof(float) * 4);
483 for (i = 0; i < node->X3D_MFRotation.n; i++)
484 (*array)[i] = (*array)[0] + i * 4;
485
486 for (i = 0; i < node->X3D_MFFloat.n; i++) {
487 (*array)[i][0] = node->X3D_MFRotation.p[i].r[0];
488 (*array)[i][1] = node->X3D_MFRotation.p[i].r[1];
489 (*array)[i][2] = node->X3D_MFRotation.p[i].r[2];
490 (*array)[i][3] = node->X3D_MFRotation.p[i].r[3];
491 }
492}
493
494X3DNode *X3D_newMFColorRGBA(int num, float(* array)[4]){
495 int i;
496 X3DNode* retval;
497
498 retval = malloc(sizeof(X3DNode));
499 retval->type = FIELDTYPE_MFColorRGBA;
500 retval->X3D_MFColorRGBA.n = num;
501 retval->X3D_MFColorRGBA.p = malloc (sizeof(X3DNode) * num);
502
503 for (i = 0; i < num; i++) {
504 retval->X3D_MFColorRGBA.p[i].type= FIELDTYPE_SFColorRGBA;
505 retval->X3D_MFColorRGBA.p[i].r[0]= array[i][0];
506 retval->X3D_MFColorRGBA.p[i].r[1]= array[i][1];
507 retval->X3D_MFColorRGBA.p[i].r[2]= array[i][2];
508 retval->X3D_MFColorRGBA.p[i].r[3]= array[i][3];
509 }
510
511 return retval;
512}
513
514void X3D_getMFColorRGBA(X3DNode* node, float*** array, int* num) {
515 int i;
516
517 if (node->type != FIELDTYPE_MFColorRGBA)
518 return;
519 *num = node->X3D_MFColorRGBA.n;
520
521 (*array) = (float**) malloc(node->X3D_MFColorRGBA.n*sizeof(float*));
522 (*array)[0] = (float*) malloc (node->X3D_MFColorRGBA.n * sizeof(float) * 4);
523 for (i = 0; i < node->X3D_MFColorRGBA.n; i++)
524 (*array)[i] = (*array)[0] + i * 4;
525
526 for (i = 0; i < node->X3D_MFColorRGBA.n; i++) {
527 (*array)[i][0] = node->X3D_MFColorRGBA.p[i].r[0];
528 (*array)[i][1] = node->X3D_MFColorRGBA.p[i].r[1];
529 (*array)[i][2] = node->X3D_MFColorRGBA.p[i].r[2];
530 (*array)[i][3] = node->X3D_MFColorRGBA.p[i].r[3];
531 }
532}
533
534X3DNode *X3D_newMFBool(int num, int* array){
535 int i;
536 X3DNode* retval;
537
538 retval = malloc(sizeof(X3DNode));
539 retval->type = FIELDTYPE_MFBool;
540 retval->X3D_MFBool.n = num;
541 retval->X3D_MFBool.p = malloc (sizeof(X3DNode) * num);
542
543 for (i = 0; i < num; i++) {
544 retval->X3D_MFBool.p[i].value = array[i];
545 retval->X3D_MFBool.p[i].type= FIELDTYPE_SFBool;
546 }
547
548 return retval;
549}
550
551void X3D_getMFBool(X3DNode* node, int** array, int* num) {
552 int i;
553
554 if (node->type != FIELDTYPE_MFBool)
555 return;
556 *num = node->X3D_MFBool.n;
557
558 *array = malloc (node->X3D_MFBool.n * sizeof(int));
559
560 for (i = 0; i < node->X3D_MFBool.n; i++) {
561 (*array)[i] = node->X3D_MFBool.p[i].value;
562 }
563}
564
565X3DNode *X3D_newMFVec3d(int num, double(* array)[3]){
566 int i;
567 X3DNode* retval;
568
569 retval = malloc(sizeof(X3DNode));
570 retval->type = FIELDTYPE_MFVec3d;
571 retval->X3D_MFVec3d.n = num;
572 retval->X3D_MFVec3d.p = malloc (sizeof(X3DNode) * num);
573
574 for (i = 0; i < num; i++) {
575 retval->X3D_MFVec3d.p[i].type= FIELDTYPE_SFVec3d;
576 retval->X3D_MFVec3d.p[i].c[0]= array[i][0];
577 retval->X3D_MFVec3d.p[i].c[1]= array[i][1];
578 retval->X3D_MFVec3d.p[i].c[2]= array[i][2];
579 }
580
581 return retval;
582}
583
584void X3D_getMFVec3d(X3DNode* node, double*** array, int* num) {
585 int i;
586
587 if (node->type != FIELDTYPE_MFVec3d)
588 return;
589 *num = node->X3D_MFVec3d.n;
590
591 (*array) = (double**) malloc(node->X3D_MFVec3d.n*sizeof(double*));
592 (*array)[0] = (double*) malloc (node->X3D_MFVec3d.n * sizeof(double) * 3);
593 for (i = 0; i < node->X3D_MFVec3d.n; i++) {
594 (*array)[i] = (*array)[0] + i * 3;
595 (*array)[i][1] = node->X3D_MFVec3d.p[i].c[1];
596 (*array)[i][2] = node->X3D_MFVec3d.p[i].c[2];
597 }
598}
599
600X3DNode *X3D_newMFString(int num, char array[][STRLEN]){
601 int i;
602 X3DNode* retval;
603 retval = malloc (sizeof (X3DNode));
604 retval->type = FIELDTYPE_MFString;
605 retval->X3D_MFString.n = num;
606 retval->X3D_MFString.p = malloc (sizeof (X3DNode) * num);
607
608 for (i = 0; i < num; i++) {
609 /* Doug Sanden changes */
610 retval->X3D_MFString.p[i].type = FIELDTYPE_SFString; /*based on pattern above ie vec3f this should be SF */
611 retval->X3D_MFString.p[i].len = strlen(array[i]);
612 retval->X3D_MFString.p[i].strptr = malloc(sizeof(char)*STRLEN);
613 memcpy(retval->X3D_MFString.p[i].strptr, array[i], STRLEN);
614 }
615
616 return retval;
617}
618
619void X3D_getMFString(X3DNode* node, char*** array, int* num) {
620 int i;
621
622 if (node->type != FIELDTYPE_MFString)
623 return;
624
625
626 *num = node->X3D_MFString.n;
627
628 (*array) = (char**) malloc(node->X3D_MFString.n*sizeof(char*));
629 (*array)[0] = (char*) malloc(node->X3D_MFString.n * sizeof(char) * STRLEN);
630
631 for (i = 0; i < node->X3D_MFString.n; i++) {
632 (*array)[i] = (*array)[0] + (i*256);
633 memcpy((*array)[i], node->X3D_MFString.p[i].strptr, STRLEN);
634 }
635}
636
637X3DNode *X3D_newSFNode(){printf ("New node not implemented yet for this type\n");return NULL;}
638X3DNode *X3D_newSFImage(){printf ("New node not implemented yet for this type\n");return NULL;}
639X3DNode *X3D_newMFNode(){printf ("New node not implemented yet for this type\n");return NULL;}
640/* Nodes not used in FreeWRL */
641X3DNode *X3D_newMFVec2d(int num){printf ("New node not implemented yet for this type\n");return NULL;}
642X3DNode *X3D_newMFTime(int num){printf ("New node not implemented yet for this type\n");return NULL;}
643X3DNode *X3D_newSFVec2d (double a, double b){printf ("New node not implemented yet for this type\n");return NULL;}
644char *fieldTypeName(char type){printf ("New node not implemented yet for this type\n");return NULL;}
645
646