#ifndef CubeArray_H #define CubeArray_H /* Last edited on 2007-02-04 22:01:55 by stolfi */ /* Procedures to build 3D maps that are a 3D array of cubes topology. */ #define CubeArray_H_copyright \ "Copyright © 2000 Universidade Estadual de Campinas (UNICAMP)" #include #include #include #include Place_vec_t CubeArrayMake ( uint n0, uint n1, uint n2, bool_t nodes, bool_t edges, bool_t walls, bool_t cells ); /* Builds a 3D map on the 3-sphere that consists of an array with {n0 × n1 × n2} cuboidal cells, plus one exterior cell. The map has {NV = (n0+1)*(n1+1)*(n2+1)} nodes {NE = n0*(n1+1)*(n2+1) + (n0+1)*n1*(n2+1) + (n0+1)*(n1+1)*n2} edges {NF = n0*n1*(n2+1) + n0*(n1+1)*n2 + (n0+1)*n1*n2} walls {NP = n0*n1*n2 + 1} cells {4*NF} wedges {16*NF} places Returns a vector {pv[0..48*n0*n1*n2-1]} with the 48 places {p} on the array that have {p.cell} equal to the interior of the cubelets. Those places are indexed according to {CubeArrayPlaceIndex} below. If {nodes} is TRUE, the procedure sets the node data slots of those places to pointers to 8 new node data records, numbered according to {CubeArrayNodeIndex} below. If {nodes} is FALSE, the node records are not created, and the node data slots are set to NULL. The meaning of {edges}, {walls} and {cells} is analogous. */ Place_t CubeArrayTransPlace(Place_t p, int d0, int d1, int d2); /* Given a place {p} on the interior of a cell with cubical topology, returns the place {q} obtained by translating {p} by {d0,d1,d2} cells along axes {0,1,2} relative to {p}. The result {q} has the same relative axes than {q}. The result is undefined if the displacements cause {p} to cross the border of the array. However, depending on {d2}, the new place {q} may have {q.hith==o} or {q.yond==o} where {o} is the exterior cell. . */ void CubeArrayGetCellNodes(Place_t p, Node_t v[]); /* Given a place {p} on the interior of a cell with cubical topology, returns the eight node record pointers. The corner with coordinates {(x0,x1,x2)} relative to {p} is returned in {v[x2*4+x1*2+x0]}. */ void CubeArrayFixCoords(Place_t p, Coords_t *c, double lo[], double hi[]); /* Given a place {p} on the interior of a cell with cubical topology, assigns coordinates to the nodes of that cell. The coordinates will span the range {[lo[i]_hi[i]]} along axis {i}. The node {p.node} will be located at the point corner {(lo[0],lo[1],lo[2],0)}. The edge {p.edge} will be parallel to axis {0}, and the wall {p.wall} will be parallel to axes{0} and {1}. If either of {lo} or {hi} is NULL, the procedure assumes {lo[i]==0} and {hi[i]==1}, respectively The coordinates of a node {v} of the facet-edge structure are stored in {c.e[vn]} where {vn} is the {num} field of the node data record of {v}. Threfore, the procedure assumes that the element data records have been created and properly appended to the facet-edge structure. */ Place_t CubeArrayMakeSng(void); /* INDEXING FUNCTIONS The following procedures return a numeric index for a place, node, edge, or wall of the cube map, given its coordinates on the canonical geometric realization in {R^3} -- namely, the unit cube {U^3 == [0_1]^3}. If not said otherwise, axis indices {i,j,k} must be distinct integers in {0..2}, and corodinates {xi,xj,xk} must be 0 or 1. */ uint CubeArrayPlaceIndex(uint i, uint j, uint k, uint xi, uint xj, uint xk); /* The index of a place {p} in the result of {CubeArrayMake} such that {p.edge} is parallel to axis {i}; {p.wall} is parallel to axes {i} and {j} and orthogonal to axis {k}; and the coordinates of {p.node} along axes {i,j,k} are {xi,xj,xk}. */ uint CubeArrayNodeIndex(uint i, uint j, uint k, uint xi, uint xj, uint xk); /* The index of the node {v} whose coordinates along axes {i,j,k} are {xi,xj,xk}. */ uint CubeArrayEdgeIndex(uint j, uint k, uint xj, uint xk); /* The index of an edge {e} that is orthogonal to axes {j,k}, and whose coordinates along those axes are {xj,xk}. */ uint CubeArrayWallIndex(uint k, uint xk); /* The index of the wall {f} that is orthogonal to axis {k}, and has coordinate {xk} along that axis. */ #define CubeArray_H_author \ "C interface created by J. Stolfi, feb/2007." #endif