#ifndef Map_H #define Map_H /* Last edited on 2024-11-14 05:13:44 by stolfi */ /* Explicit representation of the topology of a 3D map. */ #define Map_H_copyright \ "Copyright © 2001 Universidade Estadual de Campinas (UNICAMP)" #define _GNU_SOURCE #include #include #include #include #include #include /* ENUMERATION */ typedef struct ElemTableRec_t { Place_vec_t node; Place_vec_t edge; Place_vec_t wall; Place_vec_t cell; Wedge_vec_t wedge; /* The wedges. */ /* These fields are used by {JStri.h}: [???] */ /* uint der; */ /* Edge Ring Degree */ /* uint bdr; */ /* Where (0) indicates without boundary */ /* (1) indicates with boundary */ /* and (2) indicates that cells are octahedra */ } ElemTableRec_t; /* Explicit tables of elements of a 3D map. A {ElemTableRec_t} structure {top} describes a 3D map {N}, consisting zero or more connected components of the maps represented by the facet-edge structure. The structure is basically four tables {top.elem[d]}, for {d} in {0..3} that provide direct access to all {d}-dimensional elements of {N}. For data structure {top} to be valid, each data field {p.data[d]} of every place {p} on {N} must contain a pointer to the appropriate {d}-dimensional element record --- a {NodeRec_t}, {EdgeRec_t}, {WallRec_t}, or {CellRec_t}, respectively, for {d == 0,1,2,3}. There must be a distinct and unique element record for each map element. Moreover, the {num} fields of all {d}-element records of {N} must contain sequential integers from 0 to {n-1}, in any order; where {n} is the number of such elements in the map {N}. Finally, for each {d} in {0..3} and each {i} in {0..n-1}, the entry {p = top.elem[d].e[i]} must be a place on the {d}-element with number {i}; that is, one must have {p.data[d]->num == i}. Each component of {N} may come from {M} or {M*} indifferently. However, if a component {K} of {M} is included in {N}, its dual {K*} must not be. */ typedef ElemTableRec_t *ElemTable_t; ElemTableRec_t MakeElemTable(Place_vec_t root); /* This procedure builds an element record table for the submap {N} that is reachable from the places {root.e[0..root.ne-1]}. Let {PL(e)} denote the set of all places on a given element {e}. Upon entry, for any {dim}-dimensional element {e}, the slots {{ Elem(p,dim) : p in PL(e) }} must be either al NULL, or all equal to the same element data record {r}. If they are NULL, the procedure creates a new element record {r} and sets all those slots to point to {r}. If those slots are not NULL, they are left undisturbed. All existing element data records of a given dimension {dim} must be numbered consecutively, starting from 0. Any new element records will be numbered so as to preserve this property. [!!! Modify to allow cumulative collection !!!] */ void FreeMapData(ElemTableRec_t *top); /* This procedure reclaims all the storage associated with the map element table {top}, including the element data records and the tables {top->elem[0..3].e}. */ typedef struct TopoDict_t { uint32_vec_t OldNodeNum; uint32_vec_t OldEdgeNum; uint32_vec_t OldWallNum; uint32_vec_t OldCellNum; } TopoDict_t; /* CELL TOPOLOGY */ typedef struct CellElementTable_t { Place_vec_t vRef; /* One Place_t out of each node. */ Place_vec_t eRef; /* One Place_t on each edge. */ Place_vec_t fRef; /* One Place_t on the boundary of each wall. */ } CellElementTable_t; /* A data structure that lists all elements on the boundary of a cell {c} of the map. [!!! This should be just a {ElemTableRec_t} for the submap that comprises the cell's star !!!]. */ CellElementTable_t *MakeCellTopology(Place_t p); /* Returns the elements of the boundary of the cell PnegP(Dual(a))==OrgV(a). Note that `PWedge(a)->@{edge->?}' is an @{edge->?} of the dual map. */ bool_t TriviallyIsomorphic(ElemTableRec_t *ta, ElemTableRec_t *tb); /* True iff {ta} and {tb} are topologically isomorphic, with the trivial isomorphism (that is, if elements with same index have the same topological relationship in both). */ /* INPUT/OUTPUT */ void FWriteTopology(FILE *wr, ElemTableRec_t *top, char *cmt /* DF " " */); /* Writes {top} and {cmt} to {wr}, in format that can be read back. */ typedef struct TopReadData_t { ElemTableRec_t top; char *cmt; } TopReadData_t; /* Data read from a topology file, namely the reconstructed element table {top} and the comment text {cmt} read from the top of the file. */ TopReadData_t FReadTopology(FILE *rd); /* Reads from {rd} a topology file created by {FWriteTopology}. */ void WriteTopology(char *name, char *tag, ElemTableRec_t *top, char *cmt /* DF " " */); /* Same as {FWriteTopology}, but writes a new disk file called "{name}{tag}.tp". */ TopReadData_t ReadTopology(char *name, char *tag); /* Same as {FReadTopology}, but reads from an existing disk file called "{name}{tag}.tp". */ void WriteDualTopology(char *name, ElemTableRec_t *top, char *cmt /* DF " " */); /* Writes the dual of {top}, and {cmt} to file disk in a format that can be read back. The file will have the given {name} with ".tp" appended. [!!! Should be unnecessary !!!] */ bool_t WallOnBoundary(Place_t p); /* TRUE iff either of the cells adjacent to {p} has {exists==FALSE}. */ void SetExWallsOfEdge(Place_t p, bool_t exists); /* Set the {exists} bit of every wall around the edge or {p}. */ void SetExNode(Place_t p, bool_t exists); /* Set the {exists} bit of the node of {p}. */ void SetExEdge(Place_t p, bool_t exists); /* Set the {exists} bit of the edge of {p}. */ void SetExWall(Place_t p, bool_t exists); /* Set the {exists} bit of the wall of {p}. */ void SetExCell(Place_t p, bool_t exists); /* Set the {exists} bit of the cell of {p}. */ #define Map_H_author \ "C Interface created by J. Stolfi in jan/2007.\n" \ "Partly based on Modula-3 interfaces by L.A.P.Lozada (1999)\n"\ "and R.M.Rosi (1994).\n"\ "Revisions:\n" \ " 24-01-2007 : Converted to C by J. Stolfi\n" \ " 25-01-2007 : Exported {SetExEdge}, {SetExNode}, etc." #endif