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  * $Header: /src/master/dx/src/exec/dxmods/_getfield.c,v 1.7 2002/03/21 02:57:26 rhh Exp $
10  */
11 
12 #include <dxconfig.h>
13 
14 
15 
16 
17 #if !defined _GETFIELD_COMPILATION_PASS
18 #define      _GETFIELD_COMPILATION_PASS  1    /*------------------------------*/
19 #endif
20 
21 
22 #if ( _GETFIELD_COMPILATION_PASS == 1 )
23 
24 #include <string.h>
25 #include <dx/dx.h>
26 #include "_getfield.h"
27 
28 
29 #define ERROR_SECTION if ( DXGetError() == ERROR_NONE ) \
30                   DXDebug ( "D", "No error set at %s:%d", __FILE__,__LINE__)
31 
32 
33 /*
34  * Purpose:
35  *   To access a Field's data in one step, performing necessary checks for
36  *   consistency.
37  *
38  * Philosophical question:
39  *    If something is the (product,mesh) of all irregular, what do you call it?
40  *    Takes 3N space rather than N**3 so it is compact.
41  */
42 
43 /*
44  * XXX -
45  * Enhance:
46  *  SetIterator
47  * Assumptions:
48  *  Irregular arrays are always ArrayClass = CLASS_ARRAY.
49  *  Components       are always arrays.
50  *  Attributes       are always strings.
51  *    (But field rendering attributes may be floats, etc.)
52  *  GridConnections are always MeshArray's.
53  *  GridPositions   are always ProductArray's.
54  *  Therefore, stand alone PathArray or RegularArray cannot be Grid*'s.
55  *  No ProductArrays or MeshArray's will have less than 1 term.
56  *
57  *    Connections may be:       Positions may be:
58  *      Array                     Array
59  *      RegularArray              PathArray
60  *      GridPositions             GridConnections
61  *         ProductArray              MeshArray
62  *            RegularArray              PathArray
63  *      ProductArray              MeshArray
64  *         RegularArray              PathArray
65  *         Array                     Array
66  *
67  *  Constant array support.
68  *  Require that:
69  *    positions shape at least matches connection element type
70  *    positions be rank 1
71  *    positions be float
72  *    connections be int
73  *    connections be rank 1
74  *    element type matches shape[0]
75  *    data dep positions or connections
76  *    connections be a classified element type
77  *    connections ref positions
78  *    invalid connections are scalar byte dep connections
79  */
80 
81 
82 #define  ALLOCATE    DXAllocate
83 #define  REALLOCATE  DXReAllocate
84 
85   /*
86    * ALLO: DXAllocate structs.  INCR: Increase allocation.
87    *
88    * NAME - name of the function instantiated
89    * PTR  - pointer type of output and init
90    * REC  - record type having superclass size
91    * INIT - initial value of result
92    */
93 #define NEW_ALLO( NAME, PTR, REC, INIT ) \
94     static PTR NAME ( int count ) \
95     { /*int i;*/  PTR p = (PTR)ALLOCATE((count)*sizeof(struct REC)); \
96       if ( p == ERROR ) return ERROR; \
97       /*for ( i=0; i<count; i++ ) p[i] = INIT;*/  return p; }
98 
99 
100 #define NEW_INCR( NAME, PTR, REC, INIT ) \
101     static PTR NAME ( PTR p, int count, int start ) \
102     { int i;  p = (PTR)REALLOCATE((Pointer)p,((count)*sizeof(struct REC))); \
103       if ( p == ERROR ) return ERROR; \
104       /*for ( i=start; i<count; i++ ) p[i] = INIT;*/  return p; }
105 
106 
107 /* ------------------------------------------------------------------------- */
108 
NEW_ALLO(ALLO_attribute_info,attribute_info,_attribute_info,NULL)109 NEW_ALLO ( ALLO_attribute_info, attribute_info, _attribute_info,  NULL )
110 NEW_ALLO ( ALLO_array_info,     array_info,     _array_allocator, NULL )
111 NEW_ALLO ( ALLO_component_info, component_info, _component_info,  NULL )
112 NEW_ALLO ( ALLO_field_info,     field_info,     _field_info,      NULL )
113 
114 /* ----------------------------- "New" section ----------------------------- */
115 
116 
117 static
118 array_info in_memory_array ( Array input, array_info output )
119 {
120     Array  *arrays = NULL;
121     int    i, grid_dim;
122 
123     DXASSERTGOTO ( ERROR != input );
124     DXASSERTGOTO ( ERROR != output );
125     DXASSERTGOTO ( DXGetObjectClass ( (Object)input ) == CLASS_ARRAY );
126 
127     output->array    = input;
128     output->get_item = NULL;
129 
130     if ( !DXGetArrayInfo
131               ( output->array, NULL, NULL, NULL, &output->rank, NULL ) )
132         goto error;
133 
134     if ( output->rank == 0 ) output->shape = NULL;
135     else
136         if ( ERROR == ( output->shape
137                  = (int *) ALLOCATE ( output->rank * sizeof(int) ) ) )
138             goto error;
139 
140     if ( !DXGetArrayInfo ( output->array,
141                            &output->items,
142                            &output->type,
143                            &output->category,
144                            &output->rank,
145                            &output->shape[0] ) )
146         goto error;
147 
148     output->original_items = output->items;
149     output->itemsize       = DXGetItemSize ( output->array );
150     output->data           = NULL;
151     output->handle         = NULL;
152 
153     switch ( output->class = DXGetArrayClass ( input ) )
154     {
155         case CLASS_ARRAY:
156             if ( ERROR == ( output->data = DXGetArrayData ( output->array ) ) )
157                 goto error;
158             break;
159 
160         case CLASS_CONSTANTARRAY:
161         case CLASS_REGULARARRAY:
162             {
163             int count;
164 
165             if ( DXQueryConstantArray ( output->array, NULL, NULL ) )
166                 output->class = CLASS_CONSTANTARRAY;
167             else
168                 if ( output->class == CLASS_CONSTANTARRAY )
169                     goto error;
170 
171             if ( ( ERROR == ( ((regular_array_info)output)->origin
172                                   = ALLOCATE ( output->itemsize ) ) )
173                  ||
174                  ( ERROR == ( ((regular_array_info)output)->delta
175                                   = ALLOCATE ( output->itemsize ) ) ) )
176                 goto error;
177 
178             if ( !memset ( (char *)(((regular_array_info)output)->delta),
179                            0,
180                            output->itemsize ) )
181                 DXErrorGoto2
182                     ( ERROR_UNEXPECTED,
183                       "#11800", /* C standard library call, %s, returns error */
184                       "memset()" );
185 
186             if ( ( output->class == CLASS_CONSTANTARRAY )
187                  &&
188                  !DXQueryConstantArray
189                       ( output->array,
190                         &count,
191                         ((regular_array_info)output)->origin ) )
192                 goto error;
193 
194             if ( ( output->class == CLASS_REGULARARRAY )
195                  &&
196                  !DXGetRegularArrayInfo
197                       ( (RegularArray)output->array,
198                          &count,
199                          ((regular_array_info)output)->origin,
200                          ((regular_array_info)output)->delta ) )
201                 goto error;
202 
203             if ( output->items != count )
204             {
205                 DXDebug
206                     ( "D",
207                       "Internal error is (%s) assertion failed. (at \"%s\":%d)",
208                       "( output->items == count )",
209                       __FILE__, __LINE__ );
210 
211                 DXErrorGoto
212                     ( ERROR_INTERNAL, "DXGetRegularArrayInfo item count" );
213             }
214             }
215             break;
216 
217         case CLASS_PATHARRAY:
218             {
219             int count;
220 
221             if ( !DXGetPathArrayInfo ( (PathArray)output->array, &count )
222                  ||
223                  !DXGetPathOffset ( (PathArray)output->array,
224                                   &(((path_array_info)output)->offset) ) )
225                 goto error;
226 
227             if ( output->items != ( count - 1 ) )
228             {
229                 DXDebug
230                     ( "D",
231                       "Internal error is (%s) assertion failed. (at \"%s\":%d)",
232                       "( output->items == ( count - 1 ) )",
233                       __FILE__, __LINE__ );
234 
235                 DXErrorGoto
236                     ( ERROR_INTERNAL, "DXGetPathArrayInfo item count" );
237             }
238             }
239             break;
240 
241         case CLASS_PRODUCTARRAY:
242             if ( !DXGetProductArrayInfo
243                       ( (ProductArray)output->array,
244                         &(((product_array_info)output)->n),
245                         NULL )
246                  ||
247                  ( ERROR == ( arrays = (Array *) ALLOCATE
248                        ( ((product_array_info)output)->n * sizeof(Array) ) ) )
249                  ||
250                  !DXGetProductArrayInfo
251                       ( (ProductArray)output->array,
252                         &(((product_array_info)output)->n),
253                         &arrays[0] )
254                  ||
255                  ( ERROR == ( ((product_array_info)output)->terms
256                                   = ALLO_array_info
257                                         ( ((product_array_info)output)->n ))) )
258                 goto error;
259 
260             for ( i=0; i<((product_array_info)output)->n; i++ )
261                 if ( !in_memory_array
262                           ( arrays[i],
263                             /*
264                              * This messy expression should be required
265                              *    in only four places.
266                              */
267                             (array_info)
268                                 &(((struct _array_allocator *)
269                                     ((product_array_info)output)->terms)[i]) ) )
270                     goto error;
271 
272             DXFree ( (Pointer) arrays );  arrays = NULL;
273 
274             if ( !DXQueryGridPositions
275                       ( output->array, &grid_dim, NULL, NULL, NULL ) )
276 
277                 ((product_array_info) output)->grid = FFALSE;
278             else
279             {
280                 ((product_array_info) output)->grid = TTRUE;
281 
282                 /* 3D positions may be assembled in a 2D shape.
283                    But this is not the way Bruce implemented it */
284                 if ( ( output->shape == ERROR )
285                      ||
286                      ( output->rank != 1 )
287                      ||
288                      ( output->shape[0] != grid_dim )
289                      ||
290                      ( output->itemsize != ( grid_dim * sizeof(float) ) ) )
291                 {
292                     DXDebug
293                         ( "D",
294                          "Internal error assertion failed. (at \"%s\":%d)",
295                           __FILE__, __LINE__ );
296 
297                     DXErrorGoto
298                         ( ERROR_INTERNAL, "call to DXQueryGridPositions" );
299                 }
300 
301                 /* XXX move higher */
302                 if ( output->type != TYPE_FLOAT )
303                     DXErrorGoto
304                         ( ERROR_BAD_TYPE,
305                           "positions component must be floating point type" );
306 
307                 if ( ( ERROR == ( ((grid_positions_info)output)->counts
308                                         = (int*) ALLOCATE
309                                                    ( grid_dim * sizeof(int)) ) )
310                      ||
311                      ( ERROR == ( ((grid_positions_info)output)->origin
312                                         = ALLOCATE ( output->itemsize ) ) )
313                      ||
314                      ( ERROR == ( ((grid_positions_info)output)->deltas
315                                         = ALLOCATE
316                                               ( grid_dim * output->itemsize )) )
317                      ||
318                      !DXQueryGridPositions
319                           ( output->array,
320                             NULL,
321                             ((grid_positions_info)output)->counts,
322                             (float *)(((grid_positions_info)output)->origin),
323                             (float *)(((grid_positions_info)output)->deltas)) )
324                     goto error;
325             }
326             break;
327 
328         case CLASS_MESHARRAY:
329             ((mesh_array_info)output)->grow_offsets = NULL;
330 
331             if ( !DXGetMeshArrayInfo
332                       ( (MeshArray)output->array,
333                         &(((mesh_array_info)output)->n),
334                         NULL )
335                  ||
336                  ( ERROR == ( arrays = (Array*) ALLOCATE
337                        ( ((mesh_array_info)output)->n * sizeof(Array) ) ) )
338                  ||
339                  !DXGetMeshArrayInfo
340                       ( (MeshArray)output->array,
341                         &((mesh_array_info)output)->n,
342                         &arrays[0] )
343                  ||
344                  ( ERROR == ( ((mesh_array_info)output)->terms
345                                   = ALLO_array_info
346                                         ( ((mesh_array_info)output)->n ) ) ) )
347                 goto error;
348 
349             for ( i=0; i<((mesh_array_info)output)->n; i++ )
350                 if ( !in_memory_array
351                           ( arrays[i],
352                             /*
353                              * This messy expression should be required
354                              *    in only four places.
355                              */
356                             (array_info)
357                                 &(((struct _array_allocator *)
358                                     ((product_array_info)output)->terms)[i]) ) )
359                     goto error;
360 
361             DXFree ( (Pointer) arrays );  arrays = NULL;
362 
363             if ( !DXQueryGridConnections ( output->array, &grid_dim, NULL ) )
364 
365                 ((mesh_array_info) output)->grid = FFALSE;
366             else
367             {
368                 ((mesh_array_info) output)->grid = TTRUE;
369 
370                 if ( ( output->shape == ERROR )
371                      ||
372                      ( output->rank != 1 )
373                      ||
374                      ( output->shape[0] != (1<<grid_dim) )
375                      ||
376                      ( output->itemsize != ( output->shape[0] * sizeof(int) )) )
377                 {
378                     DXDebug
379                         ( "D",
380                           "Internal error is assertion failed. (at \"%s\":%d)",
381                           __FILE__, __LINE__ );
382 
383                     DXErrorGoto
384                         ( ERROR_INTERNAL, "call to DXQueryGridConnections" );
385                 }
386 
387                 /* XXX move higher */
388                 if ( output->type != TYPE_INT )
389                     DXErrorGoto
390                         ( ERROR_BAD_TYPE,
391                           "connections component must be integer type" );
392 
393                 if ( ( ERROR == ( ((grid_connections_info)output)->counts
394                                      = (int *) ALLOCATE
395                                          ( output->shape[0] * sizeof(int) ) ) )
396                      ||
397                      ( ERROR == ( ((mesh_array_info)output)->offsets
398                                       = (int *)ALLOCATE
399                                ( ((mesh_array_info)output)->n * sizeof(int) )))
400                      ||
401                      !DXQueryGridConnections
402                          ( output->array,
403                            NULL,
404                            ((grid_connections_info)output)->counts )
405                      ||
406                      /* XXX - will this be Meshes and not Grid's */
407                      !DXGetMeshOffsets
408                           ( (MeshArray)output->array,
409                             ((mesh_array_info)output)->offsets ) )
410                     goto error;
411             }
412             break;
413 
414         default:;
415     }
416 
417     return output;
418 
419     error:
420         ERROR_SECTION;
421         return ERROR;
422 }
423 
424 
425 static
in_memory_attribute(Object input,attribute_info output,int n)426 attribute_info in_memory_attribute (Object input, attribute_info output, int n )
427 {
428     Object o = NULL;
429 
430     DXASSERTGOTO ( ERROR != input );
431     DXASSERTGOTO ( ERROR != output );
432 
433     if ( ERROR == ( o = DXGetEnumeratedAttribute ( input, n, &output->name ) ) )
434         goto error;
435 
436     if ( ( output->name == NULL ) || ( strlen ( output->name ) == 0 ) )
437         DXErrorGoto3
438             ( ERROR_DATA_INVALID,
439               "#10210", /* `%s' is not a valid string for %s */
440               "NULL", "the attribute name" );
441 
442 
443     if ( DXGetObjectClass ( o ) == CLASS_STRING )
444     {
445         if ( ERROR == ( output->value = DXGetString ( (String) o ) ) )
446             goto error;
447     }
448     else
449         output->value = NULL; /* XXX */
450 
451     return output;
452 
453     error:
454         ERROR_SECTION;
455         return ERROR;
456 }
457 
458 
459 
460 static
in_memory_component(Field input,component_info output,int n)461 component_info in_memory_component ( Field input, component_info output, int n )
462 {
463     Object o = NULL;
464     int i;
465 
466     DXASSERTGOTO ( ERROR != input );
467     DXASSERTGOTO ( ERROR != output );
468 
469     if ( ERROR == ( o = DXGetEnumeratedComponentValue
470                             ( input, n, &output->name ) ) )
471         goto error;
472 
473     if ( output->name == NULL )
474         DXErrorGoto3
475             ( ERROR_DATA_INVALID,
476               "#10210", /* `%s' is not a valid string for %s */
477               "NULL",
478               "the component name" );
479 
480     if ( DXGetObjectClass ( o ) != CLASS_ARRAY )
481         DXErrorGoto2
482             ( ERROR_DATA_INVALID,
483               "#4414", /* `%s' component is not an array */
484                        /* XXX - #4414 is a Warning class message */
485               output->name );
486 
487     if ( !in_memory_array ( (Array) o, (array_info)&output->array ) )
488         goto error;
489 
490     for ( output->attrib_count = 0;
491           ( NULL != DXGetEnumeratedAttribute
492                         ( o, output->attrib_count, NULL ) );
493           output->attrib_count++ );
494 
495     if ( DXGetError() != ERROR_NONE )
496         goto error;
497 
498     if ( ERROR == ( output->attrib_list
499                         = ALLO_attribute_info ( output->attrib_count ) ) )
500         goto error;
501 
502     for ( i=0; i<STD_COMPONENT_ATTRIBUTE_LIM; i++ )
503         output->std_attribs [ i ] = NULL;
504 
505     output->element_type = NONE;
506 
507     for ( i=0; i<output->attrib_count; i++ )
508     {
509         if ( !in_memory_attribute ( o, &output->attrib_list[i], i ) )
510             goto error;
511 
512 #define MATCH_SUB(A,S)  ( strcmp ( output->attrib_list[i].A, S ) == 0 )
513 
514         if ( MATCH_SUB ( name, "dep" ) )
515             output->std_attribs [ (int)DEP ] = &output->attrib_list[i];
516 
517         else if ( MATCH_SUB ( name, "ref" ) )
518             output->std_attribs [ (int)REF ] = &output->attrib_list[i];
519 
520         else if ( MATCH_SUB ( name, "der" ) )
521             output->std_attribs [ (int)DER ] = &output->attrib_list[i];
522 
523         else if ( MATCH_SUB ( name, "element type" ) )
524         {
525             DXASSERTGOTO ( output->element_type == NONE );
526             DXASSERTGOTO ( output->attrib_list[i].value != NULL );
527 
528             output->std_attribs [ (int)DX_ELEMENT_TYPE ] = &output->attrib_list[i];
529 
530             if ( MATCH_SUB ( value, "lines" ) )
531                 output->element_type = LINES;
532 
533             else if ( MATCH_SUB ( value, "triangles" ) )
534                 output->element_type = TRIANGLES;
535 
536             else if ( MATCH_SUB ( value, "quads" ) )
537                 output->element_type = QUADRILATERALS;
538 
539             else if ( MATCH_SUB ( value, "tetrahedra" ) )
540                 output->element_type = TETRAHEDRA;
541 
542             else if ( MATCH_SUB ( value, "cubes" ) )
543                 output->element_type = CUBES;
544 
545             else if ( MATCH_SUB ( value, "prisms" ) )
546                 output->element_type = PRISMS;
547 
548             else if ( MATCH_SUB ( value, "cubes4D" ) )
549                 output->element_type = CUBES4D;
550 
551             else
552             {
553                 output->element_type = ET_UNKNOWN;
554 
555                 DXErrorGoto3
556                     ( ERROR_DATA_INVALID,
557                       "#10210", /* `%s' is not a valid string for %s */
558                       output->attrib_list[i].value,
559                       "the \"element type\" attribute" );
560             }
561 #undef  MATCH_SUB
562 
563         }
564         else
565             DXDebug
566                 ( "D", "component attribute \"%s\" is not supported",
567                   output->attrib_list[i].name );
568     }
569 
570     return output;
571 
572     error:
573         ERROR_SECTION;
574         return ERROR;
575 }
576 
577 
578 static
in_memory_field(Field input,field_info output)579 field_info in_memory_field ( Field input, field_info output )
580 {
581     int i;
582 
583     DXASSERTGOTO ( input  != ERROR );
584     DXASSERTGOTO ( output != ERROR );
585     DXASSERTGOTO ( DXGetObjectClass ( (Object) input ) == CLASS_FIELD );
586 
587     output->field = input;
588 
589     for ( output->comp_count = 0;
590           (NULL != DXGetEnumeratedComponentValue
591                        ( input, output->comp_count, NULL ));
592           output->comp_count++ );
593 
594     if ( DXGetError() != ERROR_NONE )
595         goto error;
596 
597     if ( ERROR == ( output->comp_list
598                         = ALLO_component_info ( output->comp_count ) ) )
599         goto error;
600 
601     for ( i=0; i<STD_COMPONENT_LIM; i++ )
602         output->std_comps [i] = NULL;
603 
604     for ( i=0; i<output->comp_count; i++ )
605     {
606         if ( !in_memory_component ( input, &output->comp_list[i], i ) )
607             goto error;
608 
609 #define MATCH_SUB(A,S)  ( strcmp ( output->comp_list[i].A, S ) == 0 )
610 
611         if ( MATCH_SUB ( name, "positions" ) )
612         {
613             output->std_comps [ (int)POSITIONS ] = &output->comp_list[i];
614             output->comp_list[i].std_name        = POSITIONS;
615         }
616         else if ( MATCH_SUB ( name, "connections" ) )
617         {
618             output->std_comps [ (int)CONNECTIONS ] = &output->comp_list[i];
619             output->comp_list[i].std_name          = CONNECTIONS;
620         }
621         else if ( MATCH_SUB ( name, "data" ) )
622         {
623             output->std_comps [ (int)DATA ] = &output->comp_list[i];
624             output->comp_list[i].std_name   = DATA;
625         }
626         else if ( MATCH_SUB ( name, "neighbors" ) )
627         {
628             output->std_comps [ (int)NEIGHBORS ] = &output->comp_list[i];
629             output->comp_list[i].std_name        = NEIGHBORS;
630         }
631         else if ( MATCH_SUB ( name, "normals" ) )
632         {
633             output->std_comps [ (int)NORMALS ] = &output->comp_list[i];
634             output->comp_list[i].std_name      = NORMALS;
635         }
636         else if ( MATCH_SUB ( name, "colors" ) )
637         {
638             output->std_comps [ (int)COLORS ] = &output->comp_list[i];
639             output->comp_list[i].std_name     = COLORS;
640         }
641         else if ( MATCH_SUB ( name, "opacity" ) )
642         {
643             output->std_comps [ (int)OPACITY ] = &output->comp_list[i];
644             output->comp_list[i].std_name      = OPACITY;
645         }
646         else if ( MATCH_SUB ( name, "invalid positions" ) )
647         {
648             output->std_comps [ (int)INVALID_POSITIONS ]
649                 = &output->comp_list[i];
650             output->comp_list[i].std_name = INVALID_POSITIONS;
651         }
652         else if ( MATCH_SUB ( name, "invalid connections" ) )
653         {
654             output->std_comps [ (int)INVALID_CONNECTIONS ]
655                 = &output->comp_list[i];
656             output->comp_list[i].std_name = INVALID_CONNECTIONS;
657         }
658         else if ( MATCH_SUB ( name, "original positions" ) )
659         {
660             output->std_comps [ (int)ORIGINAL_POSITIONS ]
661                 = &output->comp_list[i];
662             output->comp_list[i].std_name = ORIGINAL_POSITIONS;
663         }
664         else if ( MATCH_SUB ( name, "color map" ) )
665         {
666             output->std_comps [ (int)COLOR_MAP ] = &output->comp_list[i];
667             output->comp_list[i].std_name        = COLOR_MAP;
668         }
669         else if ( MATCH_SUB ( name, "front colors" ) )
670         {
671             output->std_comps [ (int)FRONT_COLORS ] = &output->comp_list[i];
672             output->comp_list[i].std_name           = FRONT_COLORS;
673         }
674         else if ( MATCH_SUB ( name, "original positions" ) )
675         {
676             output->std_comps [ (int)BACK_COLORS ] = &output->comp_list[i];
677             output->comp_list[i].std_name          = BACK_COLORS;
678         }
679         else
680             output->comp_list[i].std_name = NOT_A_STANDARD;
681 
682 #undef  MATCH_SUB
683     }
684 
685     if ( NULL != DXQueryOriginalSizes ( input, NULL, NULL ) )
686     {
687         /* XXX - setting the values in components dep {posit,connect}ions */
688 
689         if ( !DXQueryOriginalSizes
690                   ( input,
691                     &((array_info)
692                          &(output->std_comps[(int)POSITIONS]->array))
693                                ->original_items,
694                     &((array_info)
695                          &(output->std_comps[(int)CONNECTIONS]->array))
696                                ->original_items ) )
697             goto error;
698 
699         if ( ((array_info)&(output->std_comps[(int)CONNECTIONS]->array))->class
700               == CLASS_MESHARRAY )
701         {
702             int *original_sizes = NULL;
703             int i;
704 
705             mesh_array_info
706                 c_info = (mesh_array_info)
707                               &(output->std_comps[(int)CONNECTIONS]->array);
708 
709             if ( ( ERROR == ( c_info->grow_offsets
710                                   = (int*)ALLOCATE ( c_info->n * sizeof(int) )))
711                  ||
712                  ( ERROR == ( original_sizes
713                                   = (int*)ALLOCATE ( c_info->n * sizeof(int) )))
714                  ||
715                  !DXQueryOriginalMeshExtents
716                       ( input,
717                         c_info->grow_offsets,
718                         original_sizes ) )
719                 goto error;
720 
721 #if 0
722             /* XXX - mind the dimensionality, not necessarily 3 */
723             if ( ( original_sizes[0] * original_sizes[1] * original_sizes[2] )
724                  !=
725                  ((array_info)&(output->std_comps[(int)POSITIONS]->array))
726                      ->original_items )
727             {
728                 DXSetError
729                     ( ERROR_DATA_INVALID, "#11450" );
730               /* Object internal consistency failure.  Use the Verify module. */
731                 DXDebug
732                     ( "D",
733                       "original mesh extents for positions"
734                       " must equal original sizes" );
735             }
736 
737             if ( ( ( original_sizes[0] - 1 ) *
738                    ( original_sizes[1] - 1 ) *
739                    ( original_sizes[2] - 1 ) )
740                  !=
741                  ((array_info)&(output->std_comps[(int)CONNECTIONS]->array))
742                      ->original_items )
743             {
744                 DXSetError
745                     ( ERROR_DATA_INVALID, "#11450" );
746               /* Object internal consistency failure.  Use the Verify module. */
747                 DXDebug
748                     ( "D",
749                       "( original mesh extents connections"
750                       " == original sizes )" );
751             }
752 #endif
753             for ( i=0; i<c_info->n; i++ )
754             {
755                 /* remember, numbers are counts of positions */
756                 ((array_info)
757                     &(((struct _array_allocator *)c_info->terms)[i]))
758                          ->original_items = ( original_sizes[i] - 1 );
759 
760                 if ( ((array_info)
761                         &(((struct _array_allocator *)c_info->terms)[i]))
762                          ->items < ( original_sizes[i] - 1 ) )
763                 {
764                     DXSetError
765                         ( ERROR_DATA_INVALID, "#11450" );
766               /* Object internal consistency failure.  Use the Verify module. */
767                     DXDebug
768                         ( "D",
769                           "( connections count (%d) >="
770                           " original mesh extents (%d) - 1 ), term [%d]",
771                           ((array_info)
772                              &(((struct _array_allocator *)c_info->terms)[i]))
773                                  ->items,
774                           original_sizes[i], i );
775 
776                     goto error;
777                 }
778             }
779 
780             DXFree ( (Pointer)original_sizes );
781         }
782     }
783 
784     return output;
785 
786     error:
787         ERROR_SECTION;
788         return ERROR;
789 }
790 
791 
792 
793 /* ----------------------------- "Free" section ----------------------------- */
794 
795 
796 
797 #define  SUPERFREE(x)  if ( x != NULL ) { DXFree ( (Pointer) x );  x = NULL; }
798 
799 
800 static
free_attribute_info_contents(attribute_info input)801 Error free_attribute_info_contents ( attribute_info input ) { return OK; }
802 
803 
804 static
free_array_info_contents(array_info input)805 Error free_array_info_contents ( array_info input )
806 {
807     int i;
808 
809     DXASSERTGOTO ( input != ERROR );
810 
811     SUPERFREE ( input->shape )
812 
813     if ( ( NULL != input->handle ) && !DXFreeArrayHandle ( input->handle ) )
814         goto error;
815 
816     input->handle = NULL;
817 
818     switch ( input->class )
819     {
820         case CLASS_ARRAY:
821             break;
822 
823         case CLASS_CONSTANTARRAY:
824         case CLASS_REGULARARRAY:
825             SUPERFREE ( ((regular_array_info)input)->origin )
826             SUPERFREE ( ((regular_array_info)input)->delta  )
827             break;
828 
829         case CLASS_PATHARRAY:
830             break;
831 
832         case CLASS_PRODUCTARRAY:
833             if ( ((product_array_info)input)->terms == NULL )
834                 ((product_array_info)input)->n = 0;
835 
836             for ( i=0; i<((product_array_info)input)->n; i++ )
837                 if ( !free_array_info_contents
838                         /*
839                          * This messy expression should be required
840                          *    in only four places.
841                          */
842                           ( (array_info)
843                                 &(((struct _array_allocator *)
844                                     ((product_array_info)input)->terms)[i]) ) )
845                     goto error;
846 
847             if ( ((product_array_info) input)->grid == TTRUE )
848             {
849                 SUPERFREE ( ((grid_positions_info)input)->counts )
850                 SUPERFREE ( ((grid_positions_info)input)->origin )
851                 SUPERFREE ( ((grid_positions_info)input)->deltas )
852             }
853 
854             SUPERFREE ( ((product_array_info)input)->terms )
855             break;
856 
857         case CLASS_MESHARRAY:
858             SUPERFREE ( ((mesh_array_info)input)->offsets )
859             SUPERFREE ( ((mesh_array_info)input)->grow_offsets )
860 
861             if ( ((mesh_array_info)input)->terms == NULL )
862                 ((mesh_array_info)input)->n = 0;
863 
864             for ( i=0; i<((mesh_array_info)input)->n; i++ )
865                 if ( !free_array_info_contents
866                         /*
867                          * This messy expression should be required
868                          *    in only four places.
869                          */
870                           ( (array_info)
871                                 &(((struct _array_allocator *)
872                                     ((mesh_array_info)input)->terms)[i]) ) )
873                     goto error;
874 
875             if ( ((mesh_array_info) input)->grid == TTRUE )
876                 SUPERFREE ( ((grid_connections_info)input)->counts )
877 
878             SUPERFREE ( ((mesh_array_info)input)->terms )
879             break;
880         default:
881 	    break;
882     }
883 
884     return OK;
885 
886     error:
887         ERROR_SECTION;
888         return ERROR;
889 }
890 
891 
892 
893 static
free_component_info_contents(component_info input)894 Error free_component_info_contents ( component_info input )
895 {
896     int i;
897 
898     DXASSERTGOTO ( input != ERROR );
899 
900     if ( input->attrib_list == NULL )
901         input->attrib_count = 0;
902 
903     for ( i=0; i<input->attrib_count; i++ )
904         if ( !free_attribute_info_contents ( &input->attrib_list[i] ) )
905             goto error;
906 
907     SUPERFREE ( input->attrib_list )
908 
909     if ( !free_array_info_contents ( (array_info)&(input->array) ) )
910         goto error;
911 
912     return OK;
913 
914     error:
915         ERROR_SECTION;
916         return ERROR;
917 }
918 
919 
920 
921 static
free_field_info_contents(field_info input)922 Error free_field_info_contents ( field_info input )
923 {
924     int i;
925 
926     DXASSERTGOTO ( input != ERROR );
927 
928     if ( input->comp_list == NULL )
929         input->comp_count = 0;
930 
931     for ( i=0; i<input->comp_count; i++ )
932         if ( !free_component_info_contents ( &input->comp_list[i] ) )
933             goto error;
934 
935     SUPERFREE ( input->comp_list )
936 
937     return OK;
938 
939     error:
940         ERROR_SECTION;
941         return ERROR;
942 }
943 
944 
945 
946 /* ----------------------------- extern section ----------------------------- */
947 
948 
_dxf_InMemory(Field input)949 field_info _dxf_InMemory ( Field input )
950 {
951     field_info output = NULL;
952 
953     DXASSERTGOTO ( input != ERROR );
954     DXASSERTGOTO ( DXGetObjectClass ( (Object) input ) == CLASS_FIELD );
955 
956     if ( ( ERROR == ( output = ALLO_field_info ( 1 ) ) )
957        ||
958        !in_memory_field ( input, output ) )
959         goto error;
960 
961     return output;
962 
963     error:
964         ERROR_SECTION;
965         _dxf_FreeInMemory ( output );
966 
967         return ERROR;
968 }
969 
970 
_dxf_FreeInMemory(field_info input)971 Error _dxf_FreeInMemory ( field_info input )
972 {
973     if ( input != NULL )
974         free_field_info_contents ( input );
975 
976     SUPERFREE ( input );
977 
978     return OK;
979 }
980 
981 
982 
_dxf_SetIterator(component_info input)983 component_info _dxf_SetIterator ( component_info input )
984 {
985     Error (*get_item) () = NULL;
986 
987     DXASSERTGOTO ( ERROR != input );
988     DXASSERTGOTO ( ERROR != ((array_info)&input->array)->array );
989 
990     if ( NULL != ((array_info)&input->array)->get_item )
991         return input;
992 
993     switch ( input->std_name )
994     {
995         case DATA:
996             break;
997 
998         case POSITIONS:
999             switch ( ((array_info)&input->array)->class )
1000             {
1001                 case CLASS_PRODUCTARRAY:
1002                     switch ( ((product_array_info)&input->array)->grid )
1003                     {
1004                         case TTRUE:
1005                             switch ( ((array_info)&input->array)->shape[0] )
1006                             {
1007                                 case 1:
1008                                     get_item = _dxf_get_point_grid_1D;  break;
1009                                 case 2:
1010                                     get_item = _dxf_get_point_grid_2D;  break;
1011                                 case 3:
1012                                     get_item = _dxf_get_point_grid_3D;  break;
1013                                 default:
1014                                     DXErrorGoto3
1015                                         ( ERROR_NOT_IMPLEMENTED,
1016                                           "#11390",
1017                                       /* %s exceeds maximum dimensionality %d */
1018                                           "\"positions\" component", 3 );
1019                             }
1020                             break;
1021 
1022                         default:;
1023                     }
1024                     break;
1025 
1026                 case CLASS_ARRAY:
1027                     switch ( ((array_info)&input->array)->shape[0] )
1028                     {
1029                         case 1:  get_item = _dxf_get_point_irr_1D;  break;
1030                         case 2:  get_item = _dxf_get_point_irr_2D;  break;
1031                         case 3:  get_item = _dxf_get_point_irr_3D;  break;
1032                         default:
1033                             DXErrorGoto3
1034                                 ( ERROR_NOT_IMPLEMENTED,
1035                                   "#11390",
1036                                   /* %s exceeds maximum dimensionality %d */
1037                                   "\"positions\" component", 3 );
1038                     }
1039                     break;
1040 
1041                 default:;
1042             }
1043             break;
1044 
1045         case CONNECTIONS:
1046             switch ( input->element_type )
1047             {
1048                 case LINES:
1049                     switch ( ((array_info)&input->array)->class )
1050                     {
1051                         case CLASS_MESHARRAY:
1052                             switch ( ((mesh_array_info)&input->array)->grid )
1053                             {
1054                                 case TTRUE: get_item = _dxf_get_conn_grid_LINES;
1055                                     break;
1056 
1057                                 default:;
1058                             }
1059                             break;
1060 
1061                         case CLASS_ARRAY: get_item = _dxf_get_conn_irr_LINES;
1062                             break;
1063 
1064                         default:;
1065                     }
1066                     break;
1067 
1068                 case QUADRILATERALS:
1069                     switch ( ((array_info)&input->array)->class )
1070                     {
1071                         case CLASS_MESHARRAY:
1072                             switch ( ((mesh_array_info)&input->array)->grid )
1073                             {
1074                                 case TTRUE: get_item = _dxf_get_conn_grid_QUADS;
1075                                     break;
1076 
1077                                 default:;
1078                             }
1079                             break;
1080 
1081                         case CLASS_ARRAY: get_item = _dxf_get_conn_irr_QUADS;
1082                             break;
1083 
1084                         default:;
1085                     }
1086                     break;
1087 
1088                 case TRIANGLES:
1089                     get_item = _dxf_get_conn_irr_TRIS;
1090                     break;
1091 
1092                 case CUBES:
1093                     switch ( ((array_info)&input->array)->class )
1094                     {
1095                         case CLASS_MESHARRAY:
1096                             switch ( ((mesh_array_info)&input->array)->grid )
1097                             {
1098                                 case TTRUE: get_item = _dxf_get_conn_grid_CUBES;
1099                                     break;
1100 
1101                                 default:;
1102                             }
1103                             break;
1104 
1105                         case CLASS_ARRAY:
1106                             get_item = _dxf_get_conn_irr_CUBES;
1107                             break;
1108 
1109                         default:;
1110                     }
1111                     break;
1112 
1113                 case TETRAHEDRA:
1114                     get_item = _dxf_get_conn_irr_TETS;
1115                     break;
1116 
1117                 case PRISMS:
1118                     if ( ( NULL == ((array_info)&input->array)->data )
1119                          &&
1120                          ( ERROR == ( ((array_info)&input->array)->data
1121                                = DXGetArrayData
1122                                      ( ((array_info)&input->array)->array )) ) )
1123                         goto error;
1124 
1125                     get_item = _dxf_get_conn_irr_PRSMS;
1126                     break;
1127 
1128                 case CUBES4D:
1129                     DXErrorGoto2
1130                         ( ERROR_DATA_INVALID,
1131                           "#11380", /* %s is an invalid connections type */
1132                           input->std_attribs[(int)DX_ELEMENT_TYPE]->value )
1133                     break;
1134 
1135                 case NONE:
1136                 case ET_UNKNOWN:
1137 		    if (input->std_attribs[(int)DX_ELEMENT_TYPE]
1138 			&&
1139 		        input->std_attribs[(int)DX_ELEMENT_TYPE]->value)
1140 			{
1141 			    DXErrorGoto3
1142 				( ERROR_DATA_INVALID,
1143 				  "#10210", /* `%s' is not a valid string for %s */
1144 				  input->std_attribs[(int)DX_ELEMENT_TYPE]->value,
1145 				  "connections element type" );
1146 			}
1147 		      else
1148 			{
1149 		            DXErrorGoto(ERROR_BAD_PARAMETER,
1150 				    "missing element type for connections component");
1151 			}
1152             }
1153             break;
1154 
1155         default:;
1156     }
1157 
1158     if ( NULL == get_item ) {
1159         if ( ERROR != ( ((array_info)&input->array)->handle
1160                  = DXCreateArrayHandle ( ((array_info)&input->array)->array )) )
1161             get_item = _dxf_get_item_by_handle;
1162         else
1163             goto error;
1164     }
1165 
1166     ((array_info)&input->array)->get_item = get_item;
1167 
1168     return input;
1169 
1170     error:
1171         ERROR_SECTION;
1172         return ERROR;
1173 }
1174 
1175 
1176 
_dxf_SetIterator_i(component_info input)1177 component_info _dxf_SetIterator_i ( component_info input )
1178 {
1179     Error (*get_item) () = NULL;
1180 
1181     DXASSERTGOTO ( ERROR != input );
1182     DXASSERTGOTO ( ERROR != ((array_info)&input->array)->array );
1183 
1184     if ( NULL != ((array_info)&input->array)->get_item )
1185         return input;
1186 
1187     switch ( input->std_name )
1188     {
1189         case DATA:
1190             if ( ( ( CATEGORY_REAL == ((array_info)&input->array)->category ) &&
1191                  ( 0 == ((array_info)&input->array)->rank ) ) ||
1192                  ( ( ( 1 == ((array_info)&input->array)->rank     ) &&
1193                    ( 1 == ((array_info)&input->array)->shape[0] )   ) ) )
1194 
1195             switch ( ((array_info)&input->array)->class )
1196             {
1197                 case CLASS_CONSTANTARRAY:
1198                 case CLASS_REGULARARRAY:
1199                     switch ( ((array_info)&input->array)->type )
1200                     {
1201                         case TYPE_FLOAT:  get_item = _dxf_get_data_reg_FLOAT;
1202                              break;
1203                         case TYPE_BYTE:   get_item = _dxf_get_data_reg_BYTE;
1204                              break;
1205                         case TYPE_DOUBLE: get_item = _dxf_get_data_reg_DOUBLE;
1206                              break;
1207                         case TYPE_HYPER:  get_item = _dxf_get_data_reg_HYPER;
1208                              break;
1209                         case TYPE_INT:    get_item = _dxf_get_data_reg_INT;
1210                              break;
1211                         case TYPE_SHORT:  get_item = _dxf_get_data_reg_SHORT;
1212                              break;
1213                         case TYPE_UBYTE:  get_item = _dxf_get_data_reg_UBYTE;
1214                              break;
1215                         case TYPE_UINT:   get_item = _dxf_get_data_reg_UINT;
1216                              break;
1217                         case TYPE_USHORT: get_item = _dxf_get_data_reg_USHORT;
1218                              break;
1219 		        default: break;
1220                     }
1221                     break;
1222 
1223                 case CLASS_ARRAY:
1224                     switch ( ((array_info)&input->array)->type )
1225                     {
1226                         case TYPE_FLOAT:  get_item = _dxf_get_data_irr_FLOAT;
1227                              break;
1228                         case TYPE_BYTE:   get_item = _dxf_get_data_irr_BYTE;
1229                              break;
1230                         case TYPE_DOUBLE: get_item = _dxf_get_data_irr_DOUBLE;
1231                              break;
1232                         case TYPE_HYPER:  get_item = _dxf_get_data_irr_HYPER;
1233                              break;
1234                         case TYPE_INT:    get_item = _dxf_get_data_irr_INT;
1235                              break;
1236                         case TYPE_SHORT:  get_item = _dxf_get_data_irr_SHORT;
1237                              break;
1238                         case TYPE_UBYTE:  get_item = _dxf_get_data_irr_UBYTE;
1239                              break;
1240                         case TYPE_UINT:   get_item = _dxf_get_data_irr_UINT;
1241                              break;
1242                         case TYPE_USHORT: get_item = _dxf_get_data_irr_USHORT;
1243                              break;
1244 		        default: break;
1245                     }
1246                     break;
1247 
1248                 default:;
1249             }
1250             break;
1251 
1252         default:;
1253     }
1254 
1255     if ( NULL != get_item )
1256         ((array_info)&input->array)->get_item = get_item;
1257     else
1258         if ( !_dxf_SetIterator ( input ) )
1259             goto error;
1260 
1261     return input;
1262 
1263     error:
1264         ERROR_SECTION;
1265         return ERROR;
1266 }
1267 
1268 
1269 
_dxf_FindCompInfo(field_info input,char * locate)1270 component_info _dxf_FindCompInfo ( field_info input, char *locate )
1271 {
1272     component_info  output = NULL;
1273     int             i;
1274 
1275     DXASSERTGOTO ( ERROR != input );
1276     DXASSERTGOTO ( ERROR != input->comp_list );
1277 
1278     for ( i=0, output=input->comp_list;  i<input->comp_count;  i++, output++ )
1279         if ( 0 == strcmp ( output->name, locate ) )
1280             return output;
1281 
1282     return NULL;
1283 
1284     /* error: */
1285         ERROR_SECTION;
1286         return ERROR;
1287 }
1288 
1289 
1290 
_dxf_get_item_by_handle(int index,array_info d,Pointer out)1291 Error _dxf_get_item_by_handle ( int index, array_info d, Pointer out )
1292 {
1293     Pointer returned = NULL;
1294 
1295     DXASSERTGOTO ( d != ERROR );
1296     DXASSERTGOTO ( index < d->items );
1297     DXASSERTGOTO ( ERROR != d->handle );
1298 
1299     if ( ERROR == ( returned = DXGetArrayEntry ( d->handle, index, out ) ) )
1300         goto error;
1301 
1302     /* if out is returned, it was used and set.  else set it */
1303 
1304     if ( ( returned != out )
1305          &&
1306          !memcpy ( (char*)out, (char*)returned, d->itemsize ) )
1307         DXErrorGoto2
1308             ( ERROR_UNEXPECTED,
1309               "#11800", /* C standard library call, %s, returns error */
1310               "memset()" );
1311 
1312     return OK;
1313 
1314     error:
1315         ERROR_SECTION;
1316         return ERROR;
1317 }
1318 
1319 
1320 
1321 #endif /* ( _GETFIELD_COMPILATION_PASS == 1 ) */
1322 
1323 
1324 /*---------------------------------------------*\
1325  | Begin generic templates.
1326 \*---------------------------------------------*/
1327 
1328 
1329 #if ( defined GEN_get_data_irr ) && \
1330     ( defined GEN_DATA_TYPE    ) && \
1331     ( defined GEN_DX_TYPE      )
GEN_get_data_irr(int index,array_info d,float * out)1332 Error GEN_get_data_irr ( int index, array_info d, float *out )
1333 {
1334     DXASSERTGOTO ( d != ERROR );
1335     DXASSERTGOTO ( d->data != NULL );
1336     DXASSERTGOTO ( d->type == GEN_DX_TYPE );
1337     DXASSERTGOTO ( index < d->items );
1338     DXASSERTGOTO
1339         ( ( d->rank == 0 ) || (( d->rank == 1 )&&( d->shape[0] == 1 )) );
1340 
1341     /* Simple functions like these are the stuff of #defines */
1342     *out = (float) ( (GEN_DATA_TYPE *)(d->data) ) [index];
1343 
1344     return OK;
1345 
1346     /* error: */
1347         ERROR_SECTION;
1348         return ERROR;
1349 }
1350 #endif
1351 
1352 
1353 
1354 #if ( defined GEN_get_data_reg ) && \
1355     ( defined GEN_DATA_TYPE    ) && \
1356     ( defined GEN_DX_TYPE      )
GEN_get_data_reg(int index,array_info d,float * out)1357 Error GEN_get_data_reg ( int index, array_info d, float *out )
1358 {
1359     DXASSERTGOTO ( d != ERROR );
1360     DXASSERTGOTO ( d->data == NULL );
1361     DXASSERTGOTO ( d->type == GEN_DX_TYPE );
1362     DXASSERTGOTO ( index < d->items );
1363     DXASSERTGOTO
1364         ( ( d->rank == 0 ) || (( d->rank == 1 )&&( d->shape[0] == 1 )) );
1365 
1366     /* Simple functions like these are the stuff of #defines */
1367     *out = (float)
1368            ( *((GEN_DATA_TYPE *)((regular_array_info)d)->origin)
1369              +
1370              ( *((GEN_DATA_TYPE *)((regular_array_info)d)->delta) * index ) );
1371 
1372     return OK;
1373 
1374     /* error: */
1375         ERROR_SECTION;
1376         return ERROR;
1377 }
1378 #endif
1379 
1380 
1381 
1382 #if ( defined GEN_get_point_irr ) && \
1383     ( defined GEN_POINT_D       ) && \
1384     ( defined GEN_POINT_TYPE    )
GEN_get_point_irr(int index,array_info a,GEN_POINT_TYPE * out)1385 Error GEN_get_point_irr ( int index, array_info a, GEN_POINT_TYPE *out )
1386 {
1387     DXASSERTGOTO ( a != ERROR );
1388     DXASSERTGOTO ( a->class == CLASS_ARRAY );
1389     DXASSERTGOTO ( ( a->rank == 1 ) && ( a->shape[0] == GEN_POINT_D ) );
1390     DXASSERTGOTO ( a->data != NULL );
1391     DXASSERTGOTO ( index < a->items );
1392 
1393     *((GEN_POINT_TYPE *)out) = ((GEN_POINT_TYPE *)(a->data))[index];
1394 
1395     return OK;
1396 
1397     /* error: */
1398         ERROR_SECTION;
1399         return ERROR;
1400 }
1401 #endif
1402 
1403 
1404 
1405 #if ( defined GEN_get_point_prod ) && \
1406     ( defined GEN_POINT_D        ) && \
1407     ( defined GEN_POINT_TYPE     ) && \
1408     ( defined GEN_DELTA_TYPE     )
GEN_get_point_prod(int index,array_info a,GEN_POINT_TYPE * out)1409 Error GEN_get_point_prod ( int index, array_info a, GEN_POINT_TYPE *out )
1410 {
1411     array_info      t0, t1, t2;
1412     GEN_DELTA_TYPE  pt;
1413     int             iu, iv, iw;
1414     int             count_1_count_2;
1415 
1416     DXASSERTGOTO ( a != ERROR );
1417     DXASSERTGOTO ( a->data == NULL );
1418     DXASSERTGOTO ( a->class == CLASS_PRODUCTARRAY );
1419     DXASSERTGOTO ( ( a->rank == 1 ) && ( a->shape[0] == GEN_POINT_D ) );
1420     DXASSERTGOTO ( ((product_array_info)a)->grid == FFALSE );
1421     DXASSERTGOTO ( index < a->items );
1422 
1423 #if ( GEN_POINT_D == 1 )
1424 
1425     t0 = (array_info)
1426              &(((struct _array_allocator *)((product_array_info)a)->terms)[0]);
1427 
1428     DXASSERTGOTO ( ( t0->rank == 1 ) && ( t0->shape[0] == GEN_POINT_D ) );
1429 
1430     iu     = index;
1431 
1432 #elif ( GEN_POINT_D == 2 )
1433 
1434     t0 = (array_info)
1435              &(((struct _array_allocator *)((product_array_info)a)->terms)[0]);
1436     t1 = (array_info)
1437              &(((struct _array_allocator *)((product_array_info)a)->terms)[1]);
1438 
1439     DXASSERTGOTO ( ( t0->rank == 1 ) && ( t0->shape[0] == GEN_POINT_D ) );
1440     DXASSERTGOTO ( ( t1->rank == 1 ) && ( t1->shape[0] == GEN_POINT_D ) );
1441 
1442     iu     = index / t1->items;
1443     index  = index - ( iu * t1->items );
1444     iv     = index;
1445 
1446 #elif ( GEN_POINT_D == 3 )
1447 
1448     t0 = (array_info)
1449              &(((struct _array_allocator *)((product_array_info)a)->terms)[0]);
1450     t1 = (array_info)
1451              &(((struct _array_allocator *)((product_array_info)a)->terms)[1]);
1452     t2 = (array_info)
1453              &(((struct _array_allocator *)((product_array_info)a)->terms)[2]);
1454 
1455     DXASSERTGOTO ( ( t0->rank == 1 ) && ( t0->shape[0] == GEN_POINT_D ) );
1456     DXASSERTGOTO ( ( t1->rank == 1 ) && ( t1->shape[0] == GEN_POINT_D ) );
1457     DXASSERTGOTO ( ( t2->rank == 1 ) && ( t2->shape[0] == GEN_POINT_D ) );
1458 
1459     count_1_count_2 = t1->items * t2->items;
1460 
1461     iu     = index / count_1_count_2;
1462     index  = index - ( iu * count_1_count_2 );
1463     iv     = index / t2->items;
1464     index  = index - ( iv * t2->items );
1465     iw     = index;
1466 
1467 #endif
1468 
1469 
1470 #if ( GEN_POINT_D == 1 )
1471 
1472     if ( t0->class == CLASS_REGULARARRAY )
1473     {
1474         pt.du   = *((GEN_POINT_TYPE *)((regular_array_info)t0)->origin);
1475         pt.du.x += ((GEN_POINT_TYPE *)((regular_array_info)t0)->delta)->x * iu;
1476     }
1477     else
1478         pt.du = ((GEN_POINT_TYPE *)(t0->data))[iu];
1479 
1480     ((GEN_POINT_TYPE *)out)->x  =  pt.du.x;
1481 
1482 #elif ( GEN_POINT_D == 2 )
1483 
1484     if ( t0->class == CLASS_REGULARARRAY )
1485     {
1486         pt.du = *((GEN_POINT_TYPE *)((regular_array_info)t0)->origin);
1487         pt.du.x += ((GEN_POINT_TYPE *)((regular_array_info)t0)->delta)->x * iu;
1488         pt.du.y += ((GEN_POINT_TYPE *)((regular_array_info)t0)->delta)->y * iu;
1489     }
1490     else
1491         pt.du = ((GEN_POINT_TYPE *)(t0->data))[iu];
1492 
1493     if ( t1->class == CLASS_REGULARARRAY )
1494     {
1495         pt.dv = *((GEN_POINT_TYPE *)((regular_array_info)t1)->origin);
1496         pt.dv.x += ((GEN_POINT_TYPE *)((regular_array_info)t1)->delta)->x * iv;
1497         pt.dv.y += ((GEN_POINT_TYPE *)((regular_array_info)t1)->delta)->y * iv;
1498     }
1499     else
1500         pt.dv = ((GEN_POINT_TYPE *)(t1->data))[iv];
1501 
1502     ((GEN_POINT_TYPE *)out)->x  =  pt.du.x  +  pt.dv.x;
1503     ((GEN_POINT_TYPE *)out)->y  =  pt.du.y  +  pt.dv.y;
1504 
1505 #elif ( GEN_POINT_D == 3 )
1506 
1507     if ( t0->class == CLASS_REGULARARRAY )
1508     {
1509         pt.du = *((GEN_POINT_TYPE *)((regular_array_info)t0)->origin);
1510         pt.du.x += ((GEN_POINT_TYPE *)((regular_array_info)t0)->delta)->x * iu;
1511         pt.du.y += ((GEN_POINT_TYPE *)((regular_array_info)t0)->delta)->y * iu;
1512         pt.du.z += ((GEN_POINT_TYPE *)((regular_array_info)t0)->delta)->z * iu;
1513     }
1514     else
1515         pt.du = ((GEN_POINT_TYPE *)(t0->data))[iu];
1516 
1517     if ( t1->class == CLASS_REGULARARRAY )
1518     {
1519         pt.dv = *((GEN_POINT_TYPE *)((regular_array_info)t1)->origin);
1520         pt.dv.x += ((GEN_POINT_TYPE *)((regular_array_info)t1)->delta)->x * iv;
1521         pt.dv.y += ((GEN_POINT_TYPE *)((regular_array_info)t1)->delta)->y * iv;
1522         pt.dv.z += ((GEN_POINT_TYPE *)((regular_array_info)t1)->delta)->z * iv;
1523     }
1524     else
1525         pt.dv = ((GEN_POINT_TYPE *)(t1->data))[iv];
1526 
1527     if ( t2->class == CLASS_REGULARARRAY )
1528     {
1529         pt.dw = *((GEN_POINT_TYPE *)((regular_array_info)t2)->origin);
1530         pt.dw.x += ((GEN_POINT_TYPE *)((regular_array_info)t2)->delta)->x * iw;
1531         pt.dw.y += ((GEN_POINT_TYPE *)((regular_array_info)t2)->delta)->y * iw;
1532         pt.dw.z += ((GEN_POINT_TYPE *)((regular_array_info)t2)->delta)->z * iw;
1533     }
1534     else
1535         pt.dw = ((GEN_POINT_TYPE *)(t2->data))[iw];
1536 
1537     ((GEN_POINT_TYPE *)out)->x  =  pt.du.x  +  pt.dv.x  +  pt.dw.x;
1538     ((GEN_POINT_TYPE *)out)->y  =  pt.du.y  +  pt.dv.y  +  pt.dw.y;
1539     ((GEN_POINT_TYPE *)out)->z  =  pt.du.z  +  pt.dv.z  +  pt.dw.z;
1540 
1541 #endif
1542 
1543     return OK;
1544 
1545     error:
1546         ERROR_SECTION;
1547         return ERROR;
1548 }
1549 #endif
1550 
1551 
1552 
1553 
1554 #if ( defined GEN_get_point_grid ) && \
1555     ( defined GEN_POINT_D        ) && \
1556     ( defined GEN_POINT_TYPE     ) && \
1557     ( defined GEN_DELTA_TYPE     )
GEN_get_point_grid(int index,array_info a,GEN_POINT_TYPE * out)1558 Error GEN_get_point_grid ( int index, array_info a, GEN_POINT_TYPE *out )
1559 {
1560 #if ( GEN_CONN_D == 1 ) || ( GEN_CONN_D == 2 ) || ( GEN_CONN_D == 3 )
1561     int    iu;
1562 #endif
1563 #if ( GEN_CONN_D == 2 ) || ( GEN_CONN_D == 3 )
1564     int    iv;
1565 #endif
1566 #if ( GEN_CONN_D == 3 )
1567     int    iw, count_1_count_2;
1568 #endif
1569 
1570     DXASSERTGOTO ( a != ERROR );
1571     DXASSERTGOTO ( a->data == NULL );
1572     DXASSERTGOTO ( a->class == CLASS_PRODUCTARRAY );
1573     DXASSERTGOTO ( ( a->rank == 1 ) && ( a->shape[0] == GEN_POINT_D ) );
1574     DXASSERTGOTO ( ((product_array_info)a)->grid == TTRUE );
1575     DXASSERTGOTO ( index < a->items );
1576     DXASSERTGOTO ( ((grid_connections_info)a)->counts != NULL );
1577 
1578 #if ( GEN_POINT_D == 1 )
1579 
1580     iu     = index;
1581 
1582 #elif ( GEN_POINT_D == 2 )
1583 
1584     iu     = index / ((grid_positions_info)a)->counts[1];
1585     index  = index - ( iu * ((grid_positions_info)a)->counts[1] );
1586     iv     = index;
1587 
1588 #elif ( GEN_POINT_D == 3 )
1589 
1590     count_1_count_2 = ((grid_positions_info)a)->counts[1]
1591                       * ((grid_positions_info)a)->counts[2];
1592 
1593     iu     = index / count_1_count_2;
1594     index  = index - ( iu * count_1_count_2 );
1595     iv     = index / ((grid_positions_info)a)->counts[2];
1596     index  = index - ( iv * ((grid_positions_info)a)->counts[2] );
1597     iw     = index;
1598 
1599 #endif
1600 
1601 
1602 #if ( GEN_POINT_D == 1 )
1603 
1604     ((GEN_POINT_TYPE *)out)->x
1605         = ((GEN_POINT_TYPE *)((grid_positions_info)a)->origin)->x
1606           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->du.x * iu );
1607 
1608 #elif ( GEN_POINT_D == 2 )
1609 
1610     ((GEN_POINT_TYPE *)out)->x
1611         = ((GEN_POINT_TYPE *)((grid_positions_info)a)->origin)->x
1612           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->du.x * iu )
1613           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dv.x * iv );
1614 
1615     ((GEN_POINT_TYPE *)out)->y
1616         = ((GEN_POINT_TYPE *)((grid_positions_info)a)->origin)->y
1617           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->du.y * iu )
1618           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dv.y * iv );
1619 
1620 #elif ( GEN_POINT_D == 3 )
1621 
1622     ((GEN_POINT_TYPE *)out)->x
1623         = ((GEN_POINT_TYPE *)((grid_positions_info)a)->origin)->x
1624           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->du.x * iu )
1625           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dv.x * iv )
1626           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dw.x * iw );
1627 
1628     ((GEN_POINT_TYPE *)out)->y
1629         = ((GEN_POINT_TYPE *)((grid_positions_info)a)->origin)->y
1630           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->du.y * iu )
1631           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dv.y * iv )
1632           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dw.y * iw );
1633 
1634     ((GEN_POINT_TYPE *)out)->z
1635         = ((GEN_POINT_TYPE *)((grid_positions_info)a)->origin)->z
1636           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->du.z * iu )
1637           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dv.z * iv )
1638           + ( ((GEN_DELTA_TYPE *)((grid_positions_info)a)->deltas)->dw.z * iw );
1639 
1640 #endif
1641 
1642     return OK;
1643 
1644     /* error: */
1645         ERROR_SECTION;
1646         return ERROR;
1647 }
1648 #endif
1649 
1650 
1651 
1652 
1653 #if ( defined GEN_get_conn_irr ) && \
1654     ( defined GEN_CONN_TYPE    ) && \
1655     ( defined GEN_CONN_SHAPE   )
GEN_get_conn_irr(int index,array_info c,GEN_CONN_TYPE * out)1656 Error GEN_get_conn_irr ( int index, array_info c, GEN_CONN_TYPE *out )
1657 {
1658     DXASSERTGOTO ( c != ERROR );
1659     DXASSERTGOTO ( c->class == CLASS_ARRAY );
1660     DXASSERTGOTO ( ( c->rank == 1 ) && ( c->shape[0] == GEN_CONN_SHAPE ) );
1661     DXASSERTGOTO ( c->data != NULL );
1662     DXASSERTGOTO ( index < c->items );
1663 
1664     *((GEN_CONN_TYPE *)out) = ( (GEN_CONN_TYPE *) (c->data) ) [index];
1665 
1666     return OK;
1667 
1668     /* error: */
1669         ERROR_SECTION;
1670         return ERROR;
1671 }
1672 #endif
1673 
1674 
1675 
1676 #if ( defined GEN_get_conn_grid ) && \
1677     ( defined GEN_CONN_D        ) && \
1678     ( defined GEN_CONN_TYPE     ) && \
1679     ( defined GEN_CONN_SHAPE    )
GEN_get_conn_grid(int index,array_info c,GEN_CONN_TYPE * out)1680 Error GEN_get_conn_grid ( int index, array_info c, GEN_CONN_TYPE *out )
1681 {
1682 #if ( GEN_CONN_D == 1 ) || ( GEN_CONN_D == 2 ) || ( GEN_CONN_D == 3 )
1683     int    iu;
1684 #endif
1685 #if ( GEN_CONN_D == 2 ) || ( GEN_CONN_D == 3 )
1686     int    i, iv, count_1;
1687 #endif
1688 #if ( GEN_CONN_D == 3 )
1689     int    iw, count_2, count_1_count_2;
1690 #endif
1691 
1692     /*
1693      * XXX - An irregular iterator using this will still
1694      *     have problems with grow.
1695      */
1696 
1697     DXASSERTGOTO ( c != ERROR );
1698     DXASSERTGOTO ( c->class == CLASS_MESHARRAY );
1699     DXASSERTGOTO ( ((mesh_array_info)c)->grid == TTRUE );
1700     DXASSERTGOTO ( ( c->rank == 1 ) && ( c->shape[0] == GEN_CONN_SHAPE ) );
1701     DXASSERTGOTO ( c->data == NULL );
1702     DXASSERTGOTO ( index < c->items );
1703     DXASSERTGOTO ( ((grid_connections_info)c)->counts != NULL );
1704 
1705     /* XXX - Don't forget grid connections counts is in terms of positions. */
1706 
1707 
1708 #if ( GEN_CONN_D == 1 )
1709 
1710     iu = index;
1711 
1712 #elif ( GEN_CONN_D == 2 )
1713 
1714     count_1 = ( ((grid_connections_info)c)->counts[1] - 1 );
1715 
1716     i  = index;
1717     iu = i / count_1;
1718     i  = i - ( iu * count_1 );
1719     iv = i;
1720 
1721     count_1 = count_1 + 1;
1722 
1723 #elif ( GEN_CONN_D == 3 )
1724 
1725     count_1         = ( ((grid_connections_info)c)->counts[1] - 1 );
1726     count_2         = ( ((grid_connections_info)c)->counts[2] - 1 );
1727     count_1_count_2 = count_1 * count_2;
1728 
1729     i  = index;
1730     iu = i / count_1_count_2;
1731     i  = i - ( iu * count_1_count_2 );
1732     iv = i / count_2;
1733     i  = i - ( iv * count_2 );
1734     iw = i;
1735 
1736     count_1 = count_1 + 1;
1737     count_2 = count_2 + 1;
1738     count_1_count_2
1739             = count_1 * count_2;
1740 
1741 #endif
1742 
1743 
1744 #if ( GEN_CONN_D == 1 )
1745 
1746     ((GEN_CONN_TYPE *)out)->p = iu;
1747     ((GEN_CONN_TYPE *)out)->q = iu + 1;
1748 
1749 #elif ( GEN_CONN_D == 2 )
1750 
1751     ((GEN_CONN_TYPE *)out)->p = ( iu * count_1 ) + iv;
1752     ((GEN_CONN_TYPE *)out)->q = ((GEN_CONN_TYPE *)out)->p + 1;
1753     ((GEN_CONN_TYPE *)out)->r = ((GEN_CONN_TYPE *)out)->p + count_1;
1754     ((GEN_CONN_TYPE *)out)->s = ((GEN_CONN_TYPE *)out)->r + 1;
1755 
1756 #elif ( GEN_CONN_D == 3 )
1757 
1758     ((GEN_CONN_TYPE *)out)->p = ( iu * count_1_count_2 ) + ( iv * count_2 ) +iw;
1759     ((GEN_CONN_TYPE *)out)->q = ((GEN_CONN_TYPE *)out)->p + 1;
1760     ((GEN_CONN_TYPE *)out)->r = ((GEN_CONN_TYPE *)out)->p + count_2;
1761     ((GEN_CONN_TYPE *)out)->s = ((GEN_CONN_TYPE *)out)->r + 1;
1762 
1763     ((GEN_CONN_TYPE *)out)->t = ((GEN_CONN_TYPE *)out)->p + count_1_count_2;
1764     ((GEN_CONN_TYPE *)out)->u = ((GEN_CONN_TYPE *)out)->q + count_1_count_2;
1765     ((GEN_CONN_TYPE *)out)->v = ((GEN_CONN_TYPE *)out)->r + count_1_count_2;
1766     ((GEN_CONN_TYPE *)out)->w = ((GEN_CONN_TYPE *)out)->s + count_1_count_2;
1767 
1768 #endif
1769 
1770     return OK;
1771 
1772     /* error: */
1773         ERROR_SECTION;
1774         return ERROR;
1775 }
1776 #endif
1777 
1778 
1779 
1780 #if ( defined GEN_get_neighb_irr ) && \
1781     ( defined GEN_NEIGHB_TYPE    ) && \
1782     ( defined GEN_NEIGHB_SHAPE   )
GEN_get_neighb_irr(int index,array_info n,GEN_NEIGHB_TYPE * out)1783 Error GEN_get_neighb_irr ( int index, array_info n, GEN_NEIGHB_TYPE *out )
1784 {
1785     DXASSERTGOTO ( n != ERROR );
1786     DXASSERTGOTO ( n->class == CLASS_ARRAY );
1787     DXASSERTGOTO ( ( n->rank == 1 ) && ( n->shape[0] == GEN_NEIGHB_SHAPE ) );
1788     DXASSERTGOTO ( n->data != NULL );
1789     DXASSERTGOTO ( index < n->items );
1790 
1791     *((GEN_NEIGHB_TYPE *)out) = ( (GEN_NEIGHB_TYPE *) (n->data) ) [index];
1792 
1793     return OK;
1794 
1795     /* error: */
1796         ERROR_SECTION;
1797         return ERROR;
1798 }
1799 #endif
1800 
1801 
1802 
1803 #if ( defined GEN_get_neighb_grid ) && \
1804     ( defined GEN_NEIGHB_TYPE     ) && \
1805     ( defined GEN_CONN_D          ) && \
1806     ( defined GEN_CONN_SHAPE      )
GEN_get_neighb_grid(int index,array_info c,mesh_bounds b,GEN_NEIGHB_TYPE * out)1807 Error GEN_get_neighb_grid
1808           ( int index, array_info c, mesh_bounds b, GEN_NEIGHB_TYPE *out )
1809 {
1810 #if ( GEN_CONN_D == 1 ) || ( GEN_CONN_D == 2 ) || ( GEN_CONN_D == 3 )
1811     int    iu, count_0;
1812 #endif
1813 #if ( GEN_CONN_D == 2 ) || ( GEN_CONN_D == 3 )
1814     int    i, iv, count_1;
1815 #endif
1816 #if ( GEN_CONN_D == 3 )
1817     int    iw, count_2, count_1_count_2;
1818 #endif
1819 
1820     DXASSERTGOTO ( c != ERROR );
1821     DXASSERTGOTO ( c->class == CLASS_MESHARRAY );
1822     DXASSERTGOTO ( ( c->rank == 1 ) && ( c->shape[0] == GEN_CONN_SHAPE ) );
1823     DXASSERTGOTO ( c->data == NULL );
1824     DXASSERTGOTO ( index < c->items );
1825     DXASSERTGOTO ( ((mesh_array_info)c)->grid == TTRUE );
1826     DXASSERTGOTO ( ((grid_connections_info)c)->counts != NULL );
1827 
1828     /* XXX - Don't forget grid connections counts is in terms of positions. */
1829 
1830 #if ( GEN_CONN_D == 1 )
1831 
1832     count_0 = ( ((grid_connections_info)c)->counts[0] - 1 );
1833 
1834     iu = index;
1835 
1836 #elif ( GEN_CONN_D == 2 )
1837 
1838     count_0 = ( ((grid_connections_info)c)->counts[0] - 1 );
1839     count_1 = ( ((grid_connections_info)c)->counts[1] - 1 );
1840 
1841     i  = index;
1842     iu = i / count_1;
1843     i  = i - ( iu * count_1 );
1844     iv = i;
1845 
1846 #elif ( GEN_CONN_D == 3 )
1847 
1848     count_0         = ( ((grid_connections_info)c)->counts[0] - 1 );
1849     count_1         = ( ((grid_connections_info)c)->counts[1] - 1 );
1850     count_2         = ( ((grid_connections_info)c)->counts[2] - 1 );
1851     count_1_count_2 = count_1 * count_2;
1852 
1853     i  = index;
1854     iu = i / count_1_count_2;
1855     i  = i - ( iu * count_1_count_2 );
1856     iv = i / count_2;
1857     i  = i - ( iv * count_2 );
1858     iw = i;
1859 
1860 #endif
1861 
1862 
1863 #if ( GEN_CONN_D == 1 )
1864 
1865     ((GEN_NEIGHB_TYPE *)out)->i[0]
1866         = ( iu == 0 ) ?
1867           ( ((b==NULL)||(b->i_min==((mesh_array_info)c)->offsets[0]))? -1 : -2 )
1868           : ( index - 1 );
1869 
1870     ((GEN_NEIGHB_TYPE *)out)->i[1]
1871         = ( iu >= ( count_0 - 1 ) ) ?
1872           ( ((b==NULL)||(b->i_max==(((mesh_array_info)c)->offsets[0])+count_0))?
1873               -1 : -2 )
1874           : ( index + 1 );
1875 
1876 #elif ( GEN_CONN_D == 2 )
1877 
1878     ((GEN_NEIGHB_TYPE *)out)->i[0]
1879         = ( iu == 0 ) ?
1880           ( ((b==NULL)||(b->i_min==((mesh_array_info)c)->offsets[0]))? -1 : -2 )
1881           : ( index - count_1 );
1882 
1883     ((GEN_NEIGHB_TYPE *)out)->i[2]
1884         = ( iv == 0 ) ?
1885           ( ((b==NULL)||(b->j_min==((mesh_array_info)c)->offsets[1]))? -1 : -2 )
1886           : ( index - 1 );
1887 
1888     ((GEN_NEIGHB_TYPE *)out)->i[1]
1889         = ( iu >= ( count_0 - 1 ) ) ?
1890           ( ((b==NULL)||(b->i_max==(((mesh_array_info)c)->offsets[0])+count_0))?
1891               -1 : -2 )
1892           : ( index + count_1 );
1893 
1894     ((GEN_NEIGHB_TYPE *)out)->i[3]
1895         = ( iv >= ( count_1 - 1 ) ) ?
1896           ( ((b==NULL)||(b->j_max==(((mesh_array_info)c)->offsets[1])+count_1))?
1897               -1 : -2 )
1898           : ( index + 1 );
1899 
1900 #elif ( GEN_CONN_D == 3 )
1901 
1902     ((GEN_NEIGHB_TYPE *)out)->i[0]
1903         = ( iu == 0 ) ?
1904           ( ((b==NULL)||(b->i_min==((mesh_array_info)c)->offsets[0]))? -1 : -2 )
1905           : ( index - count_1_count_2 );
1906 
1907     ((GEN_NEIGHB_TYPE *)out)->i[2]
1908         = ( iv == 0 ) ?
1909           ( ((b==NULL)||(b->j_min==((mesh_array_info)c)->offsets[1]))? -1 : -2 )
1910           : ( index - count_2 );
1911 
1912     ((GEN_NEIGHB_TYPE *)out)->i[4]
1913         = ( iw == 0 ) ?
1914           ( ((b==NULL)||(b->k_min==((mesh_array_info)c)->offsets[2]))? -1 : -2 )
1915           : ( index - 1 );
1916 
1917     ((GEN_NEIGHB_TYPE *)out)->i[1]
1918         = ( iu >= ( count_0 - 1 ) ) ?
1919           ( ((b==NULL)||(b->i_max==(((mesh_array_info)c)->offsets[0])+count_0))?
1920               -1 : -2 )
1921           : ( index + count_1_count_2 );
1922 
1923     ((GEN_NEIGHB_TYPE *)out)->i[3]
1924         = ( iv >= ( count_1 - 1 ) ) ?
1925           ( ((b==NULL)||(b->j_max==(((mesh_array_info)c)->offsets[1])+count_1))?
1926               -1 : -2 )
1927           : ( index + count_2 );
1928 
1929     ((GEN_NEIGHB_TYPE *)out)->i[5]
1930         = ( iw >= ( count_2 - 1 ) ) ?
1931           ( ((b==NULL)||(b->k_max==(((mesh_array_info)c)->offsets[2])+count_2))?
1932               -1 : -2 )
1933           : ( index + 1 );
1934 
1935 #if 0
1936 DXMessage ( "neighbor[%d] = (%d,%d,%d,%d,%d,%d), limits = (%d,%d,%d,%d,%d,%d), offs = (%d,%d,%d), coun = (%d,%d,%d)",
1937     i,
1938     ((GEN_NEIGHB_TYPE *)out)->i[0],
1939     ((GEN_NEIGHB_TYPE *)out)->i[1],
1940     ((GEN_NEIGHB_TYPE *)out)->i[2],
1941     ((GEN_NEIGHB_TYPE *)out)->i[3],
1942     ((GEN_NEIGHB_TYPE *)out)->i[4],
1943     ((GEN_NEIGHB_TYPE *)out)->i[5],
1944     b->i_max, b->j_max, b->k_max,
1945     b->i_max, b->j_max, b->k_max,
1946     ((mesh_array_info)c)->offsets[0],
1947     ((mesh_array_info)c)->offsets[1],
1948     ((mesh_array_info)c)->offsets[2],
1949     count_0, count_1, count_2 );
1950 #endif
1951 
1952 #endif
1953 
1954     return OK;
1955 
1956     /* error: */
1957         ERROR_SECTION;
1958         return ERROR;
1959 }
1960 #endif
1961 
1962 
1963 /*---------------------------------------------*\
1964  | End generic templates.
1965 \*---------------------------------------------*/
1966 
1967 
1968 #if ( _GETFIELD_COMPILATION_PASS == 1 )
1969 
1970 /*---------------------------------------------*\
1971  | Begin generic instantiation system:
1972  |    for each of the base types: float, char
1973  |       create a copy of those routines that
1974  |          handle those specific types
1975 \*---------------------------------------------*/
1976 
1977 #undef   _GETFIELD_COMPILATION_PASS
1978 #define  _GETFIELD_COMPILATION_PASS  2
1979 
1980 #define  GEN_get_data_irr    _dxf_get_data_irr_FLOAT
1981 #define  GEN_get_data_reg    _dxf_get_data_reg_FLOAT
1982 #define  GEN_DX_TYPE         TYPE_FLOAT
1983 #define  GEN_DATA_TYPE       float
1984 
1985 #include __FILE__
1986 
1987 #undef   GEN_get_data_irr
1988 #undef   GEN_get_data_reg
1989 #undef   GEN_DX_TYPE
1990 #undef   GEN_DATA_TYPE
1991 
1992 #define  GEN_get_data_irr    _dxf_get_data_irr_SHORT
1993 #define  GEN_get_data_reg    _dxf_get_data_reg_SHORT
1994 #define  GEN_DX_TYPE         TYPE_SHORT
1995 #define  GEN_DATA_TYPE       signed short
1996 
1997 #include __FILE__
1998 
1999 #undef   GEN_get_data_irr
2000 #undef   GEN_get_data_reg
2001 #undef   GEN_DX_TYPE
2002 #undef   GEN_DATA_TYPE
2003 
2004 
2005 #define  GEN_get_data_irr    _dxf_get_data_irr_INT
2006 #define  GEN_get_data_reg    _dxf_get_data_reg_INT
2007 #define  GEN_DX_TYPE         TYPE_INT
2008 #define  GEN_DATA_TYPE       signed int
2009 
2010 #include __FILE__
2011 
2012 #undef   GEN_get_data_irr
2013 #undef   GEN_get_data_reg
2014 #undef   GEN_DX_TYPE
2015 #undef   GEN_DATA_TYPE
2016 
2017 
2018 #define  GEN_get_data_irr    _dxf_get_data_irr_DOUBLE
2019 #define  GEN_get_data_reg    _dxf_get_data_reg_DOUBLE
2020 #define  GEN_DX_TYPE         TYPE_DOUBLE
2021 #define  GEN_DATA_TYPE       double
2022 
2023 #include __FILE__
2024 
2025 #undef   GEN_get_data_irr
2026 #undef   GEN_get_data_reg
2027 #undef   GEN_DX_TYPE
2028 #undef   GEN_DATA_TYPE
2029 
2030 
2031 #define  GEN_get_data_irr    _dxf_get_data_irr_BYTE
2032 #define  GEN_get_data_reg    _dxf_get_data_reg_BYTE
2033 #define  GEN_DX_TYPE         TYPE_BYTE
2034 #define  GEN_DATA_TYPE       signed char
2035 
2036 #include __FILE__
2037 
2038 #undef   GEN_get_data_irr
2039 #undef   GEN_get_data_reg
2040 #undef   GEN_DX_TYPE
2041 #undef   GEN_DATA_TYPE
2042 
2043 
2044 #define  GEN_get_data_irr    _dxf_get_data_irr_UBYTE
2045 #define  GEN_get_data_reg    _dxf_get_data_reg_UBYTE
2046 #define  GEN_DX_TYPE         TYPE_UBYTE
2047 #define  GEN_DATA_TYPE       unsigned char
2048 
2049 #include __FILE__
2050 
2051 #undef   GEN_get_data_irr
2052 #undef   GEN_get_data_reg
2053 #undef   GEN_DX_TYPE
2054 #undef   GEN_DATA_TYPE
2055 
2056 
2057 #define  GEN_get_data_irr    _dxf_get_data_irr_USHORT
2058 #define  GEN_get_data_reg    _dxf_get_data_reg_USHORT
2059 #define  GEN_DX_TYPE         TYPE_USHORT
2060 #define  GEN_DATA_TYPE       unsigned short
2061 
2062 #include __FILE__
2063 
2064 #undef   GEN_get_data_irr
2065 #undef   GEN_get_data_reg
2066 #undef   GEN_DX_TYPE
2067 #undef   GEN_DATA_TYPE
2068 
2069 
2070 #define  GEN_get_data_irr    _dxf_get_data_irr_UINT
2071 #define  GEN_get_data_reg    _dxf_get_data_reg_UINT
2072 #define  GEN_DX_TYPE         TYPE_UINT
2073 #define  GEN_DATA_TYPE       unsigned int
2074 
2075 #include __FILE__
2076 
2077 #undef   GEN_get_data_irr
2078 #undef   GEN_get_data_reg
2079 #undef   GEN_DX_TYPE
2080 #undef   GEN_DATA_TYPE
2081 
2082 
2083 #define  GEN_get_data_irr    _dxf_get_data_irr_HYPER
2084 #define  GEN_get_data_reg    _dxf_get_data_reg_HYPER
2085 #define  GEN_DX_TYPE         TYPE_HYPER
2086 #define  GEN_DATA_TYPE       signed long
2087 
2088 #include __FILE__
2089 
2090 #undef   GEN_get_data_irr
2091 #undef   GEN_get_data_reg
2092 #undef   GEN_DX_TYPE
2093 #undef   GEN_DATA_TYPE
2094 
2095 
2096 #define  GEN_get_conn_irr    _dxf_get_conn_irr_LINES
2097 #define  GEN_get_conn_grid   _dxf_get_conn_grid_LINES
2098 #define  GEN_get_neighb_irr  _dxf_get_neighb_irr_LINES
2099 #define  GEN_get_neighb_grid _dxf_get_neighb_grid_LINES
2100 #define  GEN_get_point_irr   _dxf_get_point_irr_1D
2101 #define  GEN_get_point_grid  _dxf_get_point_grid_1D
2102 #define  GEN_POINT_D         1
2103 #define  GEN_CONN_D          1
2104 #define  GEN_CONN_SHAPE      2
2105 #define  GEN_NEIGHB_SHAPE    2
2106 #define  GEN_POINT_TYPE      Point1D
2107 #define  GEN_CONN_TYPE       Line
2108 #define  GEN_NEIGHB_TYPE     neighbor2
2109 #define  GEN_DELTA_TYPE      Deltas1D
2110 
2111 #include __FILE__
2112 
2113 #undef   GEN_get_conn_irr
2114 #undef   GEN_get_conn_grid
2115 #undef   GEN_get_neighb_irr
2116 #undef   GEN_get_neighb_grid
2117 #undef   GEN_get_point_irr
2118 #undef   GEN_get_point_grid
2119 #undef   GEN_POINT_D
2120 #undef   GEN_CONN_D
2121 #undef   GEN_CONN_SHAPE
2122 #undef   GEN_NEIGHB_SHAPE
2123 #undef   GEN_POINT_TYPE
2124 #undef   GEN_CONN_TYPE
2125 #undef   GEN_NEIGHB_TYPE
2126 #undef   GEN_DELTA_TYPE
2127 
2128 
2129 #define  GEN_get_conn_irr    _dxf_get_conn_irr_QUADS
2130 #define  GEN_get_conn_grid   _dxf_get_conn_grid_QUADS
2131 #define  GEN_get_neighb_irr  _dxf_get_neighb_irr_QUADS
2132 #define  GEN_get_neighb_grid _dxf_get_neighb_grid_QUADS
2133 #define  GEN_get_point_irr   _dxf_get_point_irr_2D
2134 #define  GEN_get_point_grid  _dxf_get_point_grid_2D
2135 #define  GEN_POINT_D         2
2136 #define  GEN_CONN_D          2
2137 #define  GEN_CONN_SHAPE      4
2138 #define  GEN_NEIGHB_SHAPE    4
2139 #define  GEN_POINT_TYPE      Point2D
2140 #define  GEN_CONN_TYPE       Quadrilateral
2141 #define  GEN_NEIGHB_TYPE     neighbor4
2142 #define  GEN_DELTA_TYPE      Deltas2D
2143 
2144 #include __FILE__
2145 
2146 #undef   GEN_get_conn_irr
2147 #undef   GEN_get_conn_grid
2148 #undef   GEN_get_neighb_irr
2149 #undef   GEN_get_neighb_grid
2150 #undef   GEN_get_point_irr
2151 #undef   GEN_get_point_grid
2152 #undef   GEN_POINT_D
2153 #undef   GEN_CONN_D
2154 #undef   GEN_CONN_SHAPE
2155 #undef   GEN_NEIGHB_SHAPE
2156 #undef   GEN_POINT_TYPE
2157 #undef   GEN_CONN_TYPE
2158 #undef   GEN_NEIGHB_TYPE
2159 #undef   GEN_DELTA_TYPE
2160 
2161 
2162 #define  GEN_get_conn_irr    _dxf_get_conn_irr_CUBES
2163 #define  GEN_get_conn_grid   _dxf_get_conn_grid_CUBES
2164 #define  GEN_get_neighb_irr  _dxf_get_neighb_irr_CUBES
2165 #define  GEN_get_neighb_grid _dxf_get_neighb_grid_CUBES
2166 #define  GEN_get_point_irr   _dxf_get_point_irr_3D
2167 #define  GEN_get_point_grid  _dxf_get_point_grid_3D
2168 #define  GEN_POINT_D         3
2169 #define  GEN_CONN_D          3
2170 #define  GEN_CONN_SHAPE      8
2171 #define  GEN_NEIGHB_SHAPE    6
2172 #define  GEN_POINT_TYPE      Point
2173 #define  GEN_CONN_TYPE       Cube
2174 #define  GEN_NEIGHB_TYPE     neighbor6
2175 #define  GEN_DELTA_TYPE      Deltas3D
2176 
2177 #include __FILE__
2178 
2179 #undef   GEN_get_conn_irr
2180 #undef   GEN_get_conn_grid
2181 #undef   GEN_get_neighb_irr
2182 #undef   GEN_get_neighb_grid
2183 #undef   GEN_get_point_irr
2184 #undef   GEN_get_point_grid
2185 #undef   GEN_POINT_D
2186 #undef   GEN_CONN_D
2187 #undef   GEN_CONN_SHAPE
2188 #undef   GEN_NEIGHB_SHAPE
2189 #undef   GEN_POINT_TYPE
2190 #undef   GEN_CONN_TYPE
2191 #undef   GEN_NEIGHB_TYPE
2192 #undef   GEN_DELTA_TYPE
2193 
2194 
2195 #define  GEN_get_conn_irr    _dxf_get_conn_irr_TRIS
2196 #define  GEN_get_neighb_irr  _dxf_get_neighb_irr_TRIS
2197 #define  GEN_CONN_SHAPE      3
2198 #define  GEN_NEIGHB_SHAPE    3
2199 #define  GEN_CONN_TYPE       Triangle
2200 #define  GEN_NEIGHB_TYPE     neighbor3
2201 
2202 #include __FILE__
2203 
2204 #undef   GEN_get_conn_irr
2205 #undef   GEN_get_neighb_irr
2206 #undef   GEN_CONN_SHAPE
2207 #undef   GEN_NEIGHB_SHAPE
2208 #undef   GEN_CONN_TYPE
2209 #undef   GEN_NEIGHB_TYPE
2210 
2211 
2212 #define  GEN_get_conn_irr    _dxf_get_conn_irr_TETS
2213 #define  GEN_get_neighb_irr  _dxf_get_neighb_irr_TETS
2214 #define  GEN_CONN_SHAPE      4
2215 #define  GEN_NEIGHB_SHAPE    4
2216 #define  GEN_CONN_TYPE       Tetrahedron
2217 #define  GEN_NEIGHB_TYPE     neighbor4
2218 
2219 #include __FILE__
2220 
2221 #undef   GEN_get_conn_irr
2222 #undef   GEN_get_neighb_irr
2223 #undef   GEN_CONN_SHAPE
2224 #undef   GEN_NEIGHB_SHAPE
2225 #undef   GEN_CONN_TYPE
2226 #undef   GEN_NEIGHB_TYPE
2227 
2228 
2229 #define  GEN_get_conn_irr    _dxf_get_conn_irr_PRSMS
2230 #define  GEN_get_neighb_irr  _dxf_get_neighb_irr_PRSMS
2231 #define  GEN_CONN_SHAPE      6
2232 #define  GEN_NEIGHB_SHAPE    5
2233 #define  GEN_CONN_TYPE       Prism
2234 #define  GEN_NEIGHB_TYPE     neighbor5
2235 
2236 #include __FILE__
2237 
2238 #undef   GEN_get_conn_irr
2239 #undef   GEN_get_neighb_irr
2240 #undef   GEN_CONN_SHAPE
2241 #undef   GEN_NEIGHB_SHAPE
2242 #undef   GEN_CONN_TYPE
2243 #undef   GEN_NEIGHB_TYPE
2244 
2245 #endif /* ( _GETFIELD_COMPILATION_PASS == 1 ) */
2246