#ifndef Cube_H #define Cube_H /* Last edited on 2007-02-04 21:52:27 by stolfi */ /* Procedures to build 3D maps with cubical topology. */ #define Cube_H_copyright \ "Copyright © 2000 Universidade Estadual de Campinas (UNICAMP)" #include #include #include #include Place_vec_t CubeMake(bool_t nodes, bool_t edges, bool_t walls, bool_t cells); /* Builds a 3D map on the 3-sphere whose 2-skeleton is the surface of the cubical polyhedron {U^3==[0_1]^3}. The map has 8 nodes 12 edges 6 walls 2 cells 24 wedges 96 places Returns a vector {pv[0..47]} with the 48 places {p} on the cube that have {p.cell} equal to the interior of the. Those places are indexed according to {CubePlaceIndex} 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 {CubeNodeIndex} 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-RELATIVE AXES Each place {p} on a cube defines three /logical axes/ that can be used to specify the position of map elements or other places relative to {p} and coordinates in a standard geometric realization of the cube. Specifically, / axis 0 relative to {p}/ is parallel to {p.edge}, and points from {p.orig} to {p.dest}. Axis 1 is parallel to {p.wall} and perpendicular to {p.edge}, and points away from {p.edge} into {p.wall}. Axis 2 is perpendicular to {p.wall}, and points away from {p.wall} into {p.cell}. */ Place_t CubeMirrorPlace(Place_t p, uint i); /* Given a place {p} on the interior of a cell with cubical topology, returns the place {q} that is the mirror image of {p} across a plane that bisects the cell and is perpendicular to coordinate axis {i} relative to {p}. The result {q} has {q.cell==p.cell}. */ void CubeGetCellNodes(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 CubeFixCoords(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 CubeMakeSng(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 CubePlaceIndex(uint i, uint j, uint k, uint xi, uint xj, uint xk); /* The index of a place {p} in the result of {CubeMake} 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 CubeNodeIndex(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 CubeEdgeIndex(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 CubeWallIndex(uint k, uint xk); /* The index of the wall {f} that is orthogonal to axis {k}, and has coordinate {xk} along that axis. */ #define Cube_H_author \ "C interface created by J. Stolfi, feb/2007." #endif