chiark / gitweb /
redactgraph prints and documents forforsafety
authorian <ian>
Sun, 20 Mar 2005 18:51:09 +0000 (18:51 +0000)
committerian <ian>
Sun, 20 Mar 2005 18:51:09 +0000 (18:51 +0000)
layout/redactgraph.c

index 70953b41215053bdc5ea3ffd7d7cf2e2e0374c9e..dcd5bd783014345f7a4994f8a067f98ec92c9b1d 100644 (file)
@@ -1,4 +1,26 @@
 /*
+ * output format from printforforsafety is lines like this:
+ *   segment <node>.<side> <node>.<side> <segment>[/<movinfo>]
+ *   #...         (comment)
+ *                (blank)
+ *   end          (at end of file, mandatory)
+ * syntactic restrictions:
+ *   <node> is alphanumeric and starts with a letter
+ *   <side> is precisely the digit 0 or the digit 1
+ *   <segment> is alphanumeric (and comes from the layout)
+ *   <movinfo> is  <movfeat><movpos>[<movfeat><movpos>...]*<combpos>
+ *            where <movfeat> is alphabetic and <movpos> is and
+ *            <combpos> are in decimal and have no unnecessary leading 0's
+ * semantic restrictions (not enforced by redactgraph but ought to
+ * be impossible for layout designer to violate):
+ *   Each <segment>[/<movinfo>] appears exactly once.
+ *   <segment> appears either once without /<movinfo> or always with.
+ *   Each side of each node appears either
+ *    - once as the 0th or 1th end of a <segment>
+ *    - one or more times as the same end of <segment>/<movinfo>'s with
+ *      the same <segment>
+ *    - not at all (indicates a terminus)
+ * Refer to safety.h for info regarding <combpos>.
  */
 /* for debugging, runes like
  *  ./ours.redactgraph consistency movfeatsplitedges consistency movfeatrmstubs consistency movfeatsplitnodes consistency trivpairnodes consistency trivnullnodes consistency printforneato | neato -Tps >u.ps
@@ -244,7 +266,7 @@ static void node_surely_orphaned(Node *node) {
   LIST_UNLINK(all_nodes, node);
 }
 
-/*---------- operations ----------*/
+/*---------- operations - heavyweight graph redaction ----------*/
 
   /* We combine the individual moveable features in each segment into
    * a single `feature' with the cross-product of all of the
@@ -504,6 +526,8 @@ static void movfeatsplitnodes(void) {
   }
 }
 
+/*---------- operations - trivial graph redaction etc. ----------*/
+
 static void trivpairnodes(void) {
   /* Eliminate near-trivial nodes - in this case, ones which have only
    * two edges, which come in on opposite sides, have the same
@@ -621,6 +645,8 @@ static void consistency(void) {
   check("command-line request");
 }
 
+/*---------- operations - output ----------*/
+
 static void printforneato(void) {
   Node *node;
   EdgeEnd *edgeend;
@@ -656,6 +682,47 @@ static void printforneato(void) {
   output("}\n");
 }
 
+static void printforforsafety(void) {
+  Node *node;
+  Edge *edge;
+  EdgeEnd *edgeend;
+  int side, end, weight, i;
+  Segment *segment;
+  MovFeat *movfeat;
+  
+  FOR_ALL_NODES(node) {
+    FOR_EDGES(edge, node,side,edgeend) {
+      output("segment ");
+      FOR_BOTH(end) {
+       output("n%s.%d ",
+              edge->ends[end].node->node->pname,
+              edge->ends[end].node->side);
+      }
+      segment= edge->subseg->segment;
+      output(segment->segname);
+      if (segment->n_movfeats>1) {
+       if (!segment->starfeature) {
+         fprintf(stderr,"printforforsafety before movfeatsplitedges!\n");
+         exit(8);
+       }
+       output("/");
+       weight= 1;
+       FOR_SEGMENT_MOVFEATS(i,movfeat, segment) {
+         if (!movfeat->movfeat) continue;
+         output("%s%d", movfeat->movfeat,
+                (edge->movpos / weight) % movfeat->n_positions);
+         weight *= movfeat->n_positions;
+       }
+       output("*%d", edge->movpos);
+      }
+      output("\n");
+    }
+  }
+  output("end\n");
+}
+
+/*---------- main program ----------*/
+
 typedef struct {
   const char *name;
   void (*fn)(void);
@@ -664,6 +731,7 @@ typedef struct {
 static const OpInfo opinfos[]= {
 #define OI(x) { #x, x },
   OI(printforneato)
+  OI(printforforsafety)
   OI(consistency)
   OI(movfeatsplitedges)
   OI(movfeatrmstubs)