/***********************************************************************/ /* Open Visualization Data Explorer */ /* (C) Copyright IBM Corp. 1989,1999 */ /* ALL RIGHTS RESERVED */ /* This code licensed under the */ /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ /***********************************************************************/ #include #include #include #include #include "internals.h" /* * DXNeighbors routines */ Array _dxf_TetraNeighbors(Field f); Array _dxf_CubeNeighbors(Field f); static Array TriNeighbors(Field f); static Array QuadNeighbors(Field f); struct hash { /* entry per face */ int element; /* element containing face */ short face; /* face number in element */ short count; /* number of occurences */ }; #define SORT(a,b) {int t; if (anhash) DXErrorGoto(ERROR_NO_MEMORY, "neighbors hash table is full"); nsurface += 1; /* assume surface */ hash[h].element = tetra; /* put entry in table */ hash[h].face = tri; } else if (hash[h].count&1) { /* count now odd, was even: */ nsurface += 1; /* now surface */ ninner -= 1; /* was inner */ } else { /* count now even, was odd: */ nsurface -= 1; /* was surface */ ninner += 1; /* now inner */ if (hash[h].count==2) { neighbors[tetra][tri] = hash[h].element; neighbors[hash[h].element][hash[h].face] = tetra; } } } } /* check number of faces */ if (DXQueryDebug("N")) { for (ns=0, ni=0, tetra=0; tetranhash) DXErrorGoto(ERROR_NO_MEMORY, "neighbors hash table is full"); nsurface += 1; /* assume surface */ hash[h].element = cubenum; /* put entry in table */ hash[h].face = face; } else if (hash[h].count&1) { /* count now odd, was even: */ nsurface += 1; /* now surface */ ninner -= 1; /* was inner */ } else { /* count now even, was odd: */ nsurface -= 1; /* was surface */ ninner += 1; /* now inner */ if (hash[h].count==2) { neighbors[cubenum][face] = hash[h].element; neighbors[hash[h].element][hash[h].face] = cubenum; } } } } DXDebug("N", "%d faces (%d surface, %d inner), %d entries", nsurface+ninner, nsurface, ninner, n); DXFree((Pointer)hash); return a; error: DXFree((Pointer)hash); return NULL; }