#ifndef OctfData_H #define OctfData_H /* Last edited on 2007-01-25 03:10:12 by stolfi */ #include #include #include #include #define _GNU_SOURCE #include /* 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 { Place_t pa; /* A place on the edge. */ uint num; /* Serial number of 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 { Place_t pa; /* A place on this wall. */ uint num; /* Wall serial number. */ 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 */ bool_t marks2[2]; /* Used by RenumberWalls, ex: marks2[DualBit(a)] associated to 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 Node_t MakeNode(void); Edge_t MakeEdge(void); Wall_t MakeWall(void); Cell_t MakeCell(void); /* These procedures create new unattached element records. They should be attached to the structure with {SetOrg}, {SetEdge}, etc.. */ /* ATTACHING MAP ELEMENTS TO THE FACET-EDGE STRUCTURE */ Edge_t PEdge(Place_t p); /* Returns the {Edge_t} assigned to the edge slot of {p} (or of {p*}, if {p} is on the dual map). [!!! should be dual-sensitive !!!] */ Wall_t PWall(Place_t p); /* Returns the {Wall_t} assigned to the wall slot of {p} (or of {p*}, if {p} is on the dual map). [!!! should be dual-sensitive !!!] */ NodeOrCell_t Org(Place_t p); /* Returns the element record that is currently stored in the `origin node' slot of of {p}. */ void SetOrg(Place_t p, Node_t n); /* Stores element record {n} in the `origin node' 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. */ NodeOrCell_t Pneg(Place_t p); /* Returns the element record that is currently stored in the `negative cell' slot of {p}. */ 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)}. */ 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 {Pneg} 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}. */ NodeOrCell_t Ppos(Place_t p); /* Returns the element record that is currently stored in the `positive cell' slot of {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 {Ppos} equal to {n}. */ Node_t OrgV(Place_t p); /* The origin of {p}, narrowed to type {Node_t}. The place {p} must be on the primal map. [!!!] */ Node_t DesV(Place_t p); /* The destination of {p}, narrowed to type {Node_t}. The place {p} must be on the primal map. [!!!] */ Cell_t PnegP(Place_t p); /* The cell negative of {p}, narrowed to type {Cell_t}. The place {p} must be on the primal map. [!!!] */ 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. [!!!] */ /* ELEMENT RENUMBERING The following procedures enumerate all places that are reachable from the places {pv.el[0..pv.nel-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. */ Edge_vec_t RenumberEdges(Place_vec_t *pv); /* Collects and renumbers all (primal) edges reachable from {pv[0..pv.nel-1]}. */ Wall_vec_t RenumberWalls(Place_vec_t *pv); /* Collects and renumbers all (primal) walls reachable from {pv[0..pv.nel-1]}. */ Node_vec_t RenumberNodes(Place_vec_t *pv); /* Collects and renumbers all (primal) nodes reachable from {pv.el[0..pv.nel-1]}. */ Cell_vec_t RenumberCells(Place_vec_t *pv); /* Collects and renumbers all (primal) cells reachable from {pv.el[0..pv.nel-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}. */ Place_vec_t RenumberEdgesOutOfNodes(Place_vec_t *pv); /* Collects and renumbers all (primal) edges with the same origin nodes as the places {pv[0..pv.nel-1]}. */ #endif