1 /*
2 * Automatically generated - DO NOT EDIT!
3 */
4
5 #ifndef __objectClass
6 #define __objectClass
7 /***********************************************************************/
8 /* Open Visualization Data Explorer */
9 /* (C) Copyright IBM Corp. 1989,1999 */
10 /* ALL RIGHTS RESERVED */
11 /* This code licensed under the */
12 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
13 /***********************************************************************/
14
15 /*
16 \section{Object class}
17
18 Every object begins with an object preamble, which contains the class
19 number and a reference count.
20 */
21
22 #include <dx/dx.h>
23
24 /* the following make ANSI compilers happier */
25 struct shade;
26 struct buffer;
27 struct tile;
28 struct gather;
29 struct survey;
30 struct count;
31
32 struct _root {
33 int size;
34 Class class;
35 char *name;
36 };
37 #define CLASS_SIZE(x) (((struct _root *)(x))->size)
38 #define CLASS_CLASS(x) (((struct _root *)(x))->class)
39 #define CLASS_NAME(x) (((struct _root *)(x))->name)
40
41
42 extern struct object_class _dxdobject_class;
43 Error _dxfDelete(Object);
44 Error _dxfno_Delete(Object);
45 Error _dxfShade(Object, struct shade *);
46 Error _dxfno_Shade(Object, struct shade *);
47 Object _dxfBoundingBox(Object, Point*, Matrix*, int);
48 Object _dxfno_BoundingBox(Object, Point*, Matrix*, int);
49 Object _dxfPaint(Object, struct buffer *, int, struct tile *);
50 Object _dxfno_Paint(Object, struct buffer *, int, struct tile *);
51 Object _dxfGather(Object, struct gather *, struct tile *);
52 Object _dxfno_Gather(Object, struct gather *, struct tile *);
53 Error _dxfPartition(Object, int*, int, Object*, int);
54 Error _dxfno_Partition(Object, int*, int, Object*, int);
55 Object _dxfGetType(Object, Type*, Category*, int*, int*);
56 Object _dxfno_GetType(Object, Type*, Category*, int*, int*);
57 Object _dxfCopy(Object, enum _dxd_copy);
58 Object _dxfno_Copy(Object, enum _dxd_copy);
59 Error _dxfObject_Delete(Object);
60 Object _dxfObject_BoundingBox(Object, Point*, Matrix*, int);
61 Error _dxfObject_Shade(Object, struct shade *);
62
63 #define NATTRIBUTES 2 /* number of attributes in object */
64
65 struct object { /* object preamble */
66 struct object_class *class; /* class vector */
67 Class class_id; /* class id (for debugging only!) */
68 lock_type lock; /* for Reference and Delete */
69 int count; /* reference count */
70 int tag; /* object tag */
71 struct attribute { /* object attributes */
72 char *name; /* attribute name */
73 Object value; /* attribue value */
74 } local[NATTRIBUTES], *attributes; /* the attributes */
75 int nattributes; /* number of attributes */
76 int attr_alloc; /* allocated space for attributes */
77 };
78
79 #if 0 /* was if OPTIMIZED */
80 #define CHECK(obj, cls) { \
81 if (!obj) \
82 return ERROR; \
83 }
84 #else
85 #define CHECK(obj, cls) { \
86 if (!obj) \
87 return ERROR; \
88 if (DXGetObjectClass((Object)(obj)) != cls) \
89 DXErrorReturn(ERROR_BAD_CLASS, "called with object of wrong class"); \
90 }
91 #endif
92 /**
93 This macro eases the task of checking argument class. Note: This is not needed
94 when a method implementation is called, because {\tt o} and its class will
95 both have been checked by the method.
96 **/
97
98 Object _dxf_NewObject(struct object_class *class);
99 /**
100 This internal routine is called only by other {\tt New...} routines to
101 create and initialize the object preamble.
102 **/
103
104 Object _dxf_CopyObject(Object new, Object old, enum _dxd_copy copy);
105 /**
106 Copies the portion of the data of {\tt old} managed by the {\tt
107 Object} class to {\tt new}. This is provided for subclasses of {\tt Object}
108 to use in their copy routines. Copying works something like creating
109 an object. Every class {\tt X} that implements copying should provide
110 an {\tt \_CopyX} routine that copies relevant data from an old object
111 to a new object, so that subclass copy routines may call this routine
112 to copy the superclass's data. The {\tt CopyX} routine just creates a
113 new object of the appropriate type and then calls {\tt \_CopyX} to copy
114 the data.
115 **/
116 #endif
117 #ifndef __arrayClass
118 #define __arrayClass
119 /***********************************************************************/
120 /* Open Visualization Data Explorer */
121 /* (C) Copyright IBM Corp. 1989,1999 */
122 /* ALL RIGHTS RESERVED */
123 /* This code licensed under the */
124 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
125 /***********************************************************************/
126
127 /*
128 \section{Array class}
129
130 Dynamic arrays are implemented by re-allocating the storage block
131 pointed to by {\tt data} as necessary, thus increasing the size of the block in
132 proportion to the current size. If only one dynamic array is being
133 created at a time, the overhead is minimal. If two or more are being
134 created simultaneously, the overhead is a small fixed number of copy
135 operations of the entire data. To demonstrate this: Let $\alpha>1$ be the factor by which
136 the block is enlarged. Suppose $N$ is the final size of the block,
137 where $\alpha^n<N<\alpha^{n+1}$. The number of bytes copied in
138 filling the block is $1+\alpha+\alpha^2+\cdots+\alpha^n =
139 (\alpha^{n+1}-1)/(\alpha-1)$. The average number of copy operations is
140 the limit as $n$ goes to infinity of the average over the interval between
141 $\alpha^n$ and $\alpha^{n+1}$ of the ratio between the number of bytes
142 copied and $N$; this can be calculated to be $(\alpha\ln\alpha)/(\alpha-1)^2$.
143 For $\alpha={3\over2}$ we copy the data 2.4 times; for $\alpha={4\over3}$,
144 3.4 times; for $\alpha={5\over4}$, 4.5 times. In any case, if the size of the
145 array is known in advance, it can be pre-allocated. DX also keeps track of
146 a local copy of the data on each processor.
147 */
148
149
150
151 extern struct array_class _dxdarray_class;
152 Pointer _dxfGetArrayData(Array);
153 Pointer _dxfno_GetArrayData(Array);
154 Error _dxfArray_Delete(Array);
155 Object _dxfArray_GetType(Array, Type*, Category*, int*, int*);
156 Pointer _dxfArray_GetArrayData(Array);
157 Object _dxfArray_Copy(Array, enum _dxd_copy);
158
159
160 extern struct sharedarray_class _dxdsharedarray_class;
161 Error _dxfSharedArray_Delete(SharedArray);
162 Pointer _dxfSharedArray_GetArrayData(SharedArray);
163
164
165 extern struct regulararray_class _dxdregulararray_class;
166 Error _dxfRegularArray_Delete(RegularArray);
167 Pointer _dxfRegularArray_GetArrayData(RegularArray);
168
169
170 extern struct patharray_class _dxdpatharray_class;
171 Pointer _dxfPathArray_GetArrayData(PathArray);
172
173
174 extern struct productarray_class _dxdproductarray_class;
175 Error _dxfProductArray_Delete(ProductArray);
176 Pointer _dxfProductArray_GetArrayData(ProductArray);
177
178
179 extern struct mesharray_class _dxdmesharray_class;
180 Error _dxfMeshArray_Delete(MeshArray);
181 Pointer _dxfMeshArray_GetArrayData(MeshArray);
182
183
184 extern struct constantarray_class _dxdconstantarray_class;
185 Pointer _dxfConstantArray_GetArrayData(ConstantArray);
186
187 #define MAX_PROCESSORS 32 /* maximum number of processors */
188 #define NLSHAPE 5 /* small shape array size */
189 #define NLDATA 12 /* small data size (in doubles) */
190
191 struct array {
192
193 struct object object; /* object preamble */
194
195 Type type; /* char, short, int, float, double */
196 Category category; /* real, complex, quaternion */
197 int rank; /* dimensionality */
198 int *shape; /* extent in each dimension */
199 int lshape[NLSHAPE]; /* extents for small dims */
200
201 unsigned int items; /* number of items defined */
202 int size; /* size of ea item (from type, etc.) */
203 Pointer data; /* the data itself */
204 double ldata[NLDATA]; /* room for data (double aligned) */
205 lock_type inprogress; /* compact data expansion in prog? */
206 unsigned int allocated; /* number of items allocated */
207
208 #if 0
209 struct { /* local copies of data: */
210 int reference; /* number of references */
211 Pointer data; /* the local data itself */
212 } local[MAX_PROCESSORS]; /* one for each processor */
213 #endif
214 };
215
216 struct sharedarray { /* shared array structure */
217 struct array array; /* array class preamble */
218 int id; /* shared memory id */
219 Pointer base; /* base of shared segment on this proc */
220 long offset; /* offset of data in segment */
221 };
222
223 struct regulararray { /* regular array structure */
224 struct array array; /* array class preamble */
225 Pointer origin; /* position of first */
226 Pointer delta; /* spacing of points */
227 };
228
229 struct patharray { /* regular connections structure */
230 struct array array; /* array class preamble */
231 int offset; /* information offset relative to */
232 }; /* field that this is part of */
233
234 struct productarray { /* product array structure */
235 struct array array; /* array class preamble */
236 int nterms; /* number of terms */
237 Array *terms; /* the terms */
238 };
239
240 struct mesharray { /* product array structure */
241 struct array array; /* array class preamble */
242 int nterms; /* number of terms */
243 Array *terms; /* the terms */
244 };
245
246 struct constantarray { /* constant array structure */
247 struct array array; /* array class preamble */
248 Pointer data; /* constant value */
249 };
250
251 Array _dxf_NewArrayV(Type type, Category category, int rank, int *shape,
252 struct array_class *class);
253
254
255 #if 0 /* was if OPTIMIZED */
256 #define CHECKARRAY(obj, cls) { \
257 if (!obj) \
258 return ERROR; \
259 }
260 #else
261 #define CHECKARRAY(obj, cls) { \
262 if (!obj) \
263 return ERROR; \
264 if (DXGetArrayClass((Array)(obj)) != cls) \
265 DXErrorReturn(ERROR_BAD_CLASS, "called with array of wrong class"); \
266 }
267 #endif
268 /**
269 This macro eases the task of checking argument class. Note: This is not needed
270 when a method implementation is called, because {\tt o} and its class will
271 both have been checked by the method.
272 **/
273
274 /*
275 * These macros are used by GetArrayData for the compact arrays
276 * (RegularArray, ProductArray, PathArray, MeshArray) to lock the
277 * arrays during expansion so that only one processor at a time
278 * does it, avoiding memory leaks.
279 */
280
281 #define EXPAND_LOCK(a) { \
282 if (a->array.data) { \
283 DXsyncmem(); \
284 return a->array.data; \
285 } \
286 DXlock(&a->array.inprogress, DXProcessorId()); \
287 if (a->array.data) { \
288 DXunlock(&a->array.inprogress, DXProcessorId());\
289 DXsyncmem(); \
290 return a->array.data; \
291 } \
292 }
293
294 #define EXPAND_RETURN(a, result) { \
295 a->array.data = (Pointer)(result); \
296 DXunlock(&a->array.inprogress, DXProcessorId()); \
297 return (Pointer)(result); \
298 }
299
300 #define EXPAND_ERROR(a) { \
301 DXunlock(&a->array.inprogress, DXProcessorId()); \
302 return NULL; \
303 }
304 #endif
305
306 struct object_class {
307 struct _root root;
308 Class class;
309 char *name;
310 Error (*Delete)();
311 Error (*Shade)();
312 Object (*BoundingBox)();
313 Object (*Paint)();
314 Object (*Gather)();
315 Error (*Partition)();
316 Object (*GetType)();
317 Object (*Copy)();
318 };
319
320 struct array_class {
321 struct object_class super;
322 Class class;
323 char *name;
324 Pointer (*GetArrayData)();
325 };
326
_dxfno_GetArrayData(Array a)327 Pointer _dxfno_GetArrayData(Array a) {
328 char *name;
329 name = (*(struct array_class **)a)->name;
330 DXSetError(ERROR_BAD_PARAMETER, "#12130", "DXGetArrayData", name);
331 return NULL;
332 }
333
334 struct array_class _dxdarray_class = {
335 sizeof(struct array),
336 CLASS_ARRAY,
337 "array",
338 CLASS_ARRAY,
339 "array",
340 _dxfArray_Delete,
341 _dxfObject_Shade,
342 _dxfObject_BoundingBox,
343 _dxfno_Paint,
344 _dxfno_Gather,
345 _dxfno_Partition,
346 _dxfArray_GetType,
347 _dxfArray_Copy,
348 CLASS_ARRAY,
349 "array",
350 _dxfArray_GetArrayData,
351 };
352
_dxfGetArrayData(Array a)353 Pointer _dxfGetArrayData(Array a) {
354 if (!a)
355 return NULL;
356 return (*(struct array_class **)a)->GetArrayData((Array)a);
357 }
358
DXGetArrayClass(Array o)359 Class DXGetArrayClass(Array o) {
360 return o? (*(struct array_class **)o)->class: CLASS_MIN;
361 }
362
363 struct sharedarray_class {
364 struct array_class super;
365 Class class;
366 char *name;
367 };
368
369 struct sharedarray_class _dxdsharedarray_class = {
370 sizeof(struct sharedarray),
371 CLASS_SHAREDARRAY,
372 "sharedarray",
373 CLASS_ARRAY,
374 "array",
375 _dxfSharedArray_Delete,
376 _dxfObject_Shade,
377 _dxfObject_BoundingBox,
378 _dxfno_Paint,
379 _dxfno_Gather,
380 _dxfno_Partition,
381 _dxfArray_GetType,
382 _dxfArray_Copy,
383 CLASS_SHAREDARRAY,
384 "sharedarray",
385 _dxfSharedArray_GetArrayData,
386 CLASS_SHAREDARRAY,
387 "sharedarray",
388 };
389
DXGetSharedArrayClass(SharedArray o)390 Class DXGetSharedArrayClass(SharedArray o) {
391 return o? (*(struct sharedarray_class **)o)->class: CLASS_MIN;
392 }
393
394 struct regulararray_class {
395 struct array_class super;
396 Class class;
397 char *name;
398 };
399
400 struct regulararray_class _dxdregulararray_class = {
401 sizeof(struct regulararray),
402 CLASS_REGULARARRAY,
403 "regulararray",
404 CLASS_ARRAY,
405 "array",
406 _dxfRegularArray_Delete,
407 _dxfObject_Shade,
408 _dxfObject_BoundingBox,
409 _dxfno_Paint,
410 _dxfno_Gather,
411 _dxfno_Partition,
412 _dxfArray_GetType,
413 _dxfArray_Copy,
414 CLASS_REGULARARRAY,
415 "regulararray",
416 _dxfRegularArray_GetArrayData,
417 CLASS_REGULARARRAY,
418 "regulararray",
419 };
420
DXGetRegularArrayClass(RegularArray o)421 Class DXGetRegularArrayClass(RegularArray o) {
422 return o? (*(struct regulararray_class **)o)->class: CLASS_MIN;
423 }
424
425 struct patharray_class {
426 struct array_class super;
427 Class class;
428 char *name;
429 };
430
431 struct patharray_class _dxdpatharray_class = {
432 sizeof(struct patharray),
433 CLASS_PATHARRAY,
434 "patharray",
435 CLASS_ARRAY,
436 "array",
437 _dxfArray_Delete,
438 _dxfObject_Shade,
439 _dxfObject_BoundingBox,
440 _dxfno_Paint,
441 _dxfno_Gather,
442 _dxfno_Partition,
443 _dxfArray_GetType,
444 _dxfArray_Copy,
445 CLASS_PATHARRAY,
446 "patharray",
447 _dxfPathArray_GetArrayData,
448 CLASS_PATHARRAY,
449 "patharray",
450 };
451
DXGetPathArrayClass(PathArray o)452 Class DXGetPathArrayClass(PathArray o) {
453 return o? (*(struct patharray_class **)o)->class: CLASS_MIN;
454 }
455
456 struct productarray_class {
457 struct array_class super;
458 Class class;
459 char *name;
460 };
461
462 struct productarray_class _dxdproductarray_class = {
463 sizeof(struct productarray),
464 CLASS_PRODUCTARRAY,
465 "productarray",
466 CLASS_ARRAY,
467 "array",
468 _dxfProductArray_Delete,
469 _dxfObject_Shade,
470 _dxfObject_BoundingBox,
471 _dxfno_Paint,
472 _dxfno_Gather,
473 _dxfno_Partition,
474 _dxfArray_GetType,
475 _dxfArray_Copy,
476 CLASS_PRODUCTARRAY,
477 "productarray",
478 _dxfProductArray_GetArrayData,
479 CLASS_PRODUCTARRAY,
480 "productarray",
481 };
482
DXGetProductArrayClass(ProductArray o)483 Class DXGetProductArrayClass(ProductArray o) {
484 return o? (*(struct productarray_class **)o)->class: CLASS_MIN;
485 }
486
487 struct mesharray_class {
488 struct array_class super;
489 Class class;
490 char *name;
491 };
492
493 struct mesharray_class _dxdmesharray_class = {
494 sizeof(struct mesharray),
495 CLASS_MESHARRAY,
496 "mesharray",
497 CLASS_ARRAY,
498 "array",
499 _dxfMeshArray_Delete,
500 _dxfObject_Shade,
501 _dxfObject_BoundingBox,
502 _dxfno_Paint,
503 _dxfno_Gather,
504 _dxfno_Partition,
505 _dxfArray_GetType,
506 _dxfArray_Copy,
507 CLASS_MESHARRAY,
508 "mesharray",
509 _dxfMeshArray_GetArrayData,
510 CLASS_MESHARRAY,
511 "mesharray",
512 };
513
DXGetMeshArrayClass(MeshArray o)514 Class DXGetMeshArrayClass(MeshArray o) {
515 return o? (*(struct mesharray_class **)o)->class: CLASS_MIN;
516 }
517
518 struct constantarray_class {
519 struct array_class super;
520 Class class;
521 char *name;
522 };
523
524 struct constantarray_class _dxdconstantarray_class = {
525 sizeof(struct constantarray),
526 CLASS_CONSTANTARRAY,
527 "constantarray",
528 CLASS_ARRAY,
529 "array",
530 _dxfArray_Delete,
531 _dxfObject_Shade,
532 _dxfObject_BoundingBox,
533 _dxfno_Paint,
534 _dxfno_Gather,
535 _dxfno_Partition,
536 _dxfArray_GetType,
537 _dxfArray_Copy,
538 CLASS_CONSTANTARRAY,
539 "constantarray",
540 _dxfConstantArray_GetArrayData,
541 CLASS_CONSTANTARRAY,
542 "constantarray",
543 };
544
DXGetConstantArrayClass(ConstantArray o)545 Class DXGetConstantArrayClass(ConstantArray o) {
546 return o? (*(struct constantarray_class **)o)->class: CLASS_MIN;
547 }
548
549