#ifndef OctfData_H #define OctfData_H /* Last edited on 2007-02-03 23:32:59 by stolfi */ #include #include #include #include #define _GNU_SOURCE #include /* [!!! Rename this module {MapRep} or merge it with {Map}. !!!] */ /* DATA RECORDS FOR MAP ELEMENTS */ typedef struct NodeRec_t { uint num; /* Node number. */ /* Fields of {TriangulationNodeRec_t}: */ bool_t exists; /* FALSE for ghost nodes. [!!! Should be called {visible}? !!!] */ bool_t fixed; /* TRUE if position is fixed. */ bool_t xmark; /* Used by MakeCellTopology. */ frgb_t color; /* Color for painting. */ frgb_t transp; /* Transp. coefficient for painting. */ float radius; /* Node radius for drawing. */ char *label; /* Node label, useful in bar.sub. */ } NodeRec_t; /* A {NodeRec_t} record represents a vertex of the primal map. [!!! Unify with {CellRec_t} via duality !!!] */ /* #default NodeRec_t.exists TRUE */ /* #default NodeRec_t.fixed FALSE */ /* #default NodeRec_t.xmark FALSE */ /* #default NodeRec_t.color (frgb_t{0.0,0.0,0.0}) */ /* #default NodeRec_t.transp (frgb_t{0.0,..}) */ /* #default NodeRec_t.radius 0.020 */ /* #default NodeRec_t.label "VV" */ typedef struct EdgeRec_t { uint num; /* Serial number of edge. */ Place_t pa; /* A place on the edge. */ uint dg; /* For computing degree of node */ bool_t exists; /* FALSE for immaterial edges */ bool_t degenerate; /* to mark as an element degenerate */ bool_t xmark; /* Mark used by MakeCellTopology */ frgb_t color; /* Color for drawing */ frgb_t transp; /* Transp. coeffs for painting */ float radius; /* radius for drawing */ NodeRec_t *node[2]; /* endpoints nodes */ int root; /* The root edge. */ bool_t marks2[2]; /* Used by Numberedges, ex: marks2[SpinBit(a)] associated to edge */ } EdgeRec_t; /* #default EdgeRec_t.exists TRUE */ /* #default EdgeRec_t.degenerate FALSE */ /* #default EdgeRec_t.color (frgb_t{0.0,0.0,0.0}) */ /* #default EdgeRec_t.transp (frgb_t{0.0,..}) */ /* #default EdgeRec_t.radius 0.004 */ /* #default EdgeRec_t.root (-1) */ typedef struct WallRec_t { uint num; /* Wall serial number. */ Place_t pa; /* A place on this wall. */ bool_t exists; /* FALSE for ghost walls */ bool_t xmark; /* Mark used by MakeCellTopology */ frgb_t color; /* Color for painting */ frgb_t transp; /* Transp. coeffs for painting */ Node_vec_t node; /* endpoints nodes */ bool_t degenerate; /* to mark an element as degenerate*/ int root; /* The root wall */ } WallRec_t; /* #default WallRec_t.exists TRUE */ /* #default WallRec_t.degenerate FALSE */ /* #default WallRec_t.color (frgb_t{1.0,1.0,0.20}) */ /* #default WallRec_t.transp (frgb_t{0.7,0.7,0.7}) */ /* #default WallRec_t.root (-1) */ typedef struct CellRec_t { uint num; /* Node number. */ /* Fields of {TriangulationCellRec_t}: */ bool_t exists; /* FALSE for ghost cells. */ bool_t ymark; /* Used by ?????. */ Node_vec_t *node; /* Nodes defining the cell. */ frgb_t color; /* Color for painting. */ frgb_t transp; /* Transp. coefficient for painting. */ int root; /* The "root" cell. */ /* Used by {JSTri.h}: [???] */ bool_t degenerate; /* Element is degenerate */ } CellRec_t; /* #default CellRec_t.exists TRUE */ /* #default CellRec_t.ymark FALSE */ /* #default CellRec_t.color (frgb_t{1.0,..}) */ /* #default CellRec_t.transp (frgb_t{1.0,..}) */ /* #default CellRec_t.root (-1) */ /* #default CellRec_t.degenerate FALSE */ typedef void* Elem_t; /* A generic element record; either {Node_t}, {Edge_t}, {Wall_t}, {Cell_t}, or NULL. */ Node_t MakeNode(uint num); Edge_t MakeEdge(uint num); Wall_t MakeWall(uint num); Cell_t MakeCell(uint num); /* These procedures create new unattached element records. They should be attached to the structure with {SetOrg}, {SetEdge}, etc.. The argument {num} goes into the record's {num} field. [!!! Remove {num} assignment after calls. !!!] */ Elem_t MakeElem(uint dim, uint num); /* A generic element record constructor: either {MakeNode}, {MakeEdge}, {MakeWall}, or {MakeCell}, depending on {dim}. */ /* ELEMENT SLOTS OF PLACES */ Elem_t PElem(Place_t p, uint dim); /* Returns the current contents of the element data slot of dimension {dim} associated with {p}. */ Edge_t PEdge(Place_t p); /* Returns the {Edge_t} currently stored in the edge slot of {p} (or of {p*}, if {p} is on the dual map). [!!! should be dual-sensitive !!!] Note that {PEdge(p)}, {PEdge(Flip0(p))}, {PEdge(Flip3(p))}, {PEdge(Flip03(p))} are the same slot, so assigning to any of them also sets the other three. */ Wall_t PWall(Place_t p); /* Returns the {Wall_t} currently stored in the wall slot of {p} (or of {p*}, if {p} is on the dual map). [!!! should be dual-sensitive !!!] Note that {PWall(p)}, {PWall(Flip0(p))}, {PWall(Flip3(p))}, {PWall(Flip03(p))} are the same slot, so assigning to any of them also sets the other three. */ Node_t OrgV(Place_t p); /* The current contents of the origin node slot of {p}; same as {PElem(p, 0)}. The place {p} must be on the primal map. [!!!] [!!! Rename to {PNode(p)} and {POrig(p)} !!!] Note that {OrgV(p)} and {OrgV(Flip3(p))} are the same slot, so assigning to either of them also sets the other. */ Cell_t PnegP(Place_t p); /* The current contents of the cell negative of {p}. The place {p} must be on the primal map. [!!!] [!!! Rename to {PCell(p)} and {PHith(p)} !!!] Note that {PnegP(p)} and {PnegP(Flip0(p))} are the same slot, so assigning to either of them also sets the other. */ Node_t DesV(Place_t p); /* The destination of {p}; same as {OrgV(Clock(p))}. The place {p} must be on the primal map. [!!!] [!!! Rename to {PDest(p)} !!!] */ Cell_t PposP(Place_t p); /* The positive cell of {p}, narrowed to type {Cell_t}. The place {p} must be on the primal map. [!!!] [!!! Rename to {PYond(p)} !!!] */ /* ATTACHING MAP ELEMENTS TO THE FACET-EDGE STRUCTURE */ void SetElem(Place_t p, uint dim, Elem_t e); /* Stores {e} into the element data slot of dimension {dim} associated with {p}. */ void SetOrg(Place_t p, Node_t n); /* Stores element record {n} in the `origin node' slot of {p}. [!!! Rename to {SetNode} !!!] */ void SetPneg(Place_t p, Cell_t n); /* Stores element record {n} in the `negative cell' slot of {p}. Same as {SetOrg(Dual(p),n)}. [!!! Rename to {SetCell} !!!] */ void SetEdge(Place_t p, Edge_t e); /* Assign {e} to the `edge' slot of {p}. */ void SetWall(Place_t p, Wall_t f); /* Assign {f} to the `wall' slot of {p}. */ void SetOrgAll(Place_t p, Node_t n); /* Does {SetOrg(t,n)} for all places {t} with the same origin node as {p}. Those are the places that can be reached from {p} by chains of {NextF}, {NextE}, and {Clock} steps. */ void SetOrgAllN(Place_t p, Node_t n); /* Does {SetOrg(t,n)} for SOME places {t} with the same origin node as {p}. Works only for certain maps. Taken from {MakeObjectTriang.c}. */ void SetOrgAllSame(Place_t p); /* Does {SetOrg(t,Orgv(p))} for SOME places {t} with the same origin node as {p}. Works only for certain maps. Taken from {MakeObjectTriang.c}. */ void SetPnegOfWall(Place_t p, Cell_t n); /* Does {SetPneg(t,n)} for all places {t} with the same wall and cell as {p} (i.e. on the {NextE} ring of {p}). */ void SetPnegOfNearbyWalls(Place_t p, Cell_t n); /* Sets to {n} the {PnegP} pointer of all places whose wall is the wall {f} of {p}, or one of the walls adjacent to {f} on the same negative cell as {p}. */ void SetPpos(Place_t p, Cell_t n); /* Stores element record {n} in the `positive cell' slot of {p}. Same as {SetOrg(Clock(Dual(a),n) == SetOrg(Tors(a),n)}. */ void SetPposOfWall(Place_t p, Cell_t n); /* Does {SetPpos(t,n)} for all places {t} with same wall and cell as {p} (i.e. on the {NextE} ring of {p}). */ void SetPposQUX(Place_t p, Cell_t n); /* Set the places (12) belong to same positive cell {PposP} equal to {n}. */ /* GLOBAL ELEMENT RECORD CREATION */ void ProvideElemRecords(Place_vec_t root, uint dim, Place_vec_t *vP); /* Enumerates all palces that are reachable from the {root} places. For each such place {p}, makes sure that its {dim}-dimensional element data slot {PElem(p,dim)} is non-NULL and consistent. Let {PL(e)} denote the set of all places on a given {dim}-dimensional element {e}. Upon entry, for any {dim}-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. If {vP} is not NULL, the procedure appends after {vP->e[0..vp->ne-1]} one place on each {dim}-dimensional element record that it created. At the end, {vp->ne} will have been incremented by the number of new element records that were clreated. The area {*vP->e} reallocated as needed. The represnetative places that get appended to {vP} may not be evenly connected to each other or to the root places, even if the map is orientable. The newly created element records are numbered sequentially starting from {vp->ne}, or from 0 if {vP == NULL}. */ /* ELEMENT RENUMBERING The following procedures enumerate all places that are reachable from the places {pv.e[0..pv.ne-1]} by steps that preserve primality and orientation (namely {NextE}, {NextF}, and {Clock}.). Each procedure returns a vector with one pointer to each distinct element record found during the enumeration. */ Node_vec_t RenumberNodes(Place_vec_t *pv); /* Collects and renumbers all (primal) nodes reachable from {pv.e[0..pv.ne-1]}. */ Cell_vec_t RenumberCells(Place_vec_t *pv); /* Collects and renumbers all (primal) cells reachable from {pv.e[0..pv.ne-1]} by chains of {ONext}, {OPrev} and {Clock}, and assigns them distinct serial numbers from 0 up. Returns the number of nodes found. Uses the procedure {EnumNodes} of library {libm3triang}. */ #endif