1 /***********************************************************************/
2 /* Open Visualization Data Explorer */
3 /* (C) Copyright IBM Corp. 1989,1999 */
4 /* ALL RIGHTS RESERVED */
5 /* This code licensed under the */
6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
7 /***********************************************************************/
8
9 #include <dxconfig.h>
10
11 #if defined(HAVE_STRING_H)
12 #include <string.h>
13 #endif
14
15 #include <dx/dx.h>
16 static Error GetObjectAndCameraFromCache(char *, Object *, Camera *);
17
18 #define CACHE_TAG in[0]
19
20 #define OBJECT out[0]
21 #define CAMERA out[1]
22
23 Error
m_GetScene(Object * in,Object * out)24 m_GetScene(Object *in, Object *out)
25 {
26 char *tag;
27
28 if (! CACHE_TAG)
29 {
30 DXSetError(ERROR_MISSING_DATA, "no cache tag");
31 goto error;
32 }
33
34 if (! DXExtractString(CACHE_TAG, &tag))
35 {
36 DXSetError(ERROR_MISSING_DATA, "cache tag must be a string");
37 goto error;
38 }
39
40 if (! GetObjectAndCameraFromCache(tag, &OBJECT, (Camera *)&CAMERA))
41 {
42 DXSetError(ERROR_INTERNAL, "unable to access scene data");
43 goto error;
44 }
45
46 return OK;
47
48 error:
49
50 OBJECT = NULL;
51 CAMERA = NULL;
52 return ERROR;
53 }
54
55
56 static Error
GetObjectAndCameraFromCache(char * tag,Object * object,Camera * camera)57 GetObjectAndCameraFromCache(char *tag, Object *object, Camera *camera)
58 {
59 char *buf;
60
61 if (object)
62 {
63 buf = (char *)DXAllocate(strlen(tag) + strlen(".object") + 1);
64 if (! buf)
65 goto error;
66
67 sprintf(buf, "%s.object", tag);
68
69 *object = DXGetCacheEntry(buf, 0, 0);
70 DXFree((Pointer)buf);
71 }
72
73 if (camera)
74 {
75 buf = (char *)DXAllocate(strlen(tag) + strlen(".camera") + 1);
76 if (! buf)
77 goto error;
78
79 sprintf(buf, "%s.camera", tag);
80
81 *camera = (Camera)DXGetCacheEntry(buf, 0, 0);
82 DXFree((Pointer)buf);
83 }
84
85 return OK;
86
87 error:
88 return ERROR;
89 }
90