From 958c8e92b343e82ca1b4d1824887a6e8160183c6 Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 23 Oct 2004 14:35:41 +0000 Subject: [PATCH] new arrangements for points - bits shown as absent --- TODO | 4 +- cprogs.make | 2 + layout/.cvsignore | 8 ++- layout/Makefile | 39 ++++++++---- layout/compose-segenco.c | 114 ++++++++++++++++++++++++++++++++++ layout/layout | 21 ++++--- layout/make-dgram-make | 12 ++++ layout/ours.dgram-list | 1 + layout/segcmapassign | 72 ++++++++++----------- layout/segencolayers.gen-make | 20 ++++++ layout/x.gdb | 7 ++- 11 files changed, 239 insertions(+), 61 deletions(-) create mode 100644 layout/compose-segenco.c create mode 100755 layout/make-dgram-make create mode 100644 layout/ours.dgram-list create mode 100755 layout/segencolayers.gen-make diff --git a/TODO b/TODO index 01bd316..dafba0f 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ layout polarity diagram colourful segment encoding: - have to fix it so that points' fixed bits are always drawn implement segmap so that we can do midx decide what to do about crossings (difficult to show both tracks) + wire layout diagram thing into Tcl and see speed etc. + make moveable feature selection in subseg2display bitwise rather than + setwise 1. Write lots and lots and lots of PIC programs diff --git a/cprogs.make b/cprogs.make index 5ef8b50..06f15fc 100644 --- a/cprogs.make +++ b/cprogs.make @@ -1,4 +1,6 @@ OPTIMISE= -O2 +WERROR= -Werror CFLAGS= -Wall -Wwrite-strings -Wpointer-arith \ -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes \ + $(WERROR) \ -g $(OPTIMISE) diff --git a/layout/.cvsignore b/layout/.cvsignore index 14dadea..733ed45 100644 --- a/layout/.cvsignore +++ b/layout/.cvsignore @@ -1,8 +1,12 @@ *.d4 ours-*.ps -ours-g[0-9]*.ppm +*.dgram-*.p*.segenco.ps +*.dgram-*.p*.segenco.ppm *.new *.segcmapreq *.segcmap -subseg2display +*.m +*.run-layout t.* +subseg2display +compose-segenco diff --git a/layout/Makefile b/layout/Makefile index ecdaefd..86e4535 100644 --- a/layout/Makefile +++ b/layout/Makefile @@ -8,7 +8,7 @@ LAYOUTOPTS= -E=*$(E_TRACK) $(LAYOUTOPTS_ALL) LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A' XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' -LAYOUTOPTS_SEGS= '-e*=*rm' '-e=5G' +LAYOUTOPTS_SEGS= '-e*=*rm' LAYERS_LS= 0 10 20 LAYERS_PS= $(addsuffix .ps, $(LAYERS_LS)) @@ -18,7 +18,7 @@ LAYERS= $(LAYERS_L) $(LAYERS_E) LPAGES= $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps)) -CPROGS= subseg2display +CPROGS= subseg2display compose-segenco default: $(CPROGS) all: default lpages layers @@ -26,10 +26,18 @@ all: default lpages layers layers: $(LAYERS) lpages: $(LPAGES) +include ours.dgram.m +include segencolayers.m + o=>$@.new && mv -f $@.new $@ +LINK= $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) + subseg2display: subseg2display.o - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) -lnetpbm -lpub -lm + $(LINK) -lnetpbm -lpub -lm + +compose-segenco: compose-segenco.o + $(LINK) -lnetpbm %.d4: %.m4 $(M4INCS) Makefile m4 -s <$< $o @@ -43,16 +51,19 @@ subseg2display: subseg2display.o %-ap.ps: %.d4 layout ./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o -ours-g%.ps: ours.d4 ours-g%.segcmap layout - ./layout <$< -l$* $(LAYOUTOPTS_SEGS) -GLours-g$*.segcmap $o +%.segcmapreq: %.run-layout + ./$< $(LAYOUTOPTS_SEGS) -GR $o -ours-g%.segcmap: ours-g%.segcmapreq segcmapassign +%.segcmap: %.segcmapreq segcmapassign ./segcmapassign <$< $o -ours-g%.segcmapreq: ours.d4 layout - ./layout <$< -l$* $(LAYOUTOPTS_SEGS) -GR $o +%.dgram.m: %.dgram-list make-dgram-make + ./make-dgram-make <$< $* $o + +%.m: %.gen-make + ./$< $o -ours-g%.ppm: ours-g%.ps +%.segenco.ppm: %.segenco.ps Makefile gs -dNOPAUSE -dBATCH -dSAFER -q \ -sDEVICE=ppmraw -r72 -g595x842 \ -sOutputFile=$@.new $< && mv -f $@.new $@ @@ -72,14 +83,16 @@ parts.ps: showlib.d4 layout ./layout <$< $(LAYOUTOPTS_ALL) $o # test case -t.ppm: ours-g0.ppm x.gdb subseg2display +t.ppm: ours.dgram-bot.pa.segenco.ppm x.gdb subseg2display gdb -x x.gdb clean: - -rm -f -- *.d4 *~ *.new t.ppm + -rm -f -- *.d4 *~ t.* *.m *.new core -rm -f ours-*.ps parts.ps - -rm -f *.oprint-*.ps + -rm -f *.oprint-*.ps *.run-layout + -rm -f *.segcmap *.segcmapreq + -rm -f *.dgram-*.p*.segenco.ps *.dgram-*.p*.segenco.ppm -rm -f $(CPROGS) *.o .PRECIOUS: $(OPRINTS) -.PRECIOUS: ours-g0.ps ours-g%.segcmap ours-g%.segcmapreq +.PRECIOUS: %.segcmap %.segcmapreq %.segenco.ppm %.d4 diff --git a/layout/compose-segenco.c b/layout/compose-segenco.c new file mode 100644 index 0000000..fcc6c6a --- /dev/null +++ b/layout/compose-segenco.c @@ -0,0 +1,114 @@ +/* + * usage: + * compose-segenco \ + * thing.pf.segenco.ppm \ + * thing.p0.segenco.ppm \ + * thing.p1.segenco.ppm \ + * thing.p2.segenco.ppm \ + * ... + * thing.p5.segenco.ppm + * + * writes resulting composite encoding + */ + +#include +#include +#include + +#include + +#define FILES 7 + +struct file { + const char *fn; + FILE *f; +}; + +typedef unsigned char val; + +static struct file f[FILES]; +static int nf, fi, rows=-1, cols; +static int row, col; + +static void badformat(const char *m) { + fprintf(stderr,"bad format: %s: row=%d,col=%d:\n %s\n", + f[fi].fn, row,col, m); + exit(12); +} + +int main(int argc, char **argv) { + const char *arg; + int trows, tcols, informat; + pixval maxval; + + ppm_init(&argc,argv); + if (!*argv || !*++argv || (*argv)[0]=='-') { + fprintf(stderr,"bad usage\n"); exit(12); + } + + for (fi=0, nf=0; + (arg= *argv++); + fi++, nf++) { + if (nf >= FILES) { fprintf(stderr,"too many files\n"); exit(12); } + + f[fi].fn= arg; + f[fi].f= fopen(arg, "rb"); + if (!f[fi].f) { perror(arg); exit(8); } + + ppm_readppminit(f[fi].f, &tcols, &trows, &maxval, &informat); + if (maxval != 255) badformat("wrong maxval"); + if (informat != RPPM_FORMAT) badformat("wrong format"); + + if (rows==-1) { + rows= trows; + cols= tcols; + } else { + if (rows != trows || cols != tcols) badformat("wrong size"); + } + } + + ppm_writeppminit(stdout, cols, rows, 255, 0); + + for (row=0; row> fi; /* bits are reversed; first fi pos 1 not 0 */ + } + } + + if (fwrite(ov,1,3,stdout)!=3) { perror("writing"); exit(16); } + + } + + return 0; +} diff --git a/layout/layout b/layout/layout index 342aaaa..4b3ecc6 100755 --- a/layout/layout +++ b/layout/layout @@ -14,6 +14,7 @@ our $quiet=0; our $debug=0; our $output_layer= '*'; our $subsegcmapreq=0; +our $subsegmovfeatpos='f'; our $ps_page_shift= 615; our $ps_page_xmul= 765.354; @@ -51,6 +52,7 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { elsif (s/^S([0-9.]+)$//) { $scale= $1 * 1.0; } elsif (s/^P(\d+)x(\d+)$//) { $page_x= $1; $page_y= $2; } elsif (s/^GR//) { $subsegcmapreq=1; } + elsif (s/^GP(\d+|f)$//) { $subsegmovfeatpos=$1; } elsif (s/^GL(.*)$//) { my ($sscmfn) = $1; my ($sscmf); @@ -61,7 +63,7 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { $!=0; $_= <$sscmf>; die $! unless defined $_; last if m/^E/; next unless m/^C/; - m,^C\s+(\w*/(?:[A-Za-z_]+\d+)?)\s+(\S.*\S)\s*$, + m,^C\s+(\w*/(?:[A-Za-z_]+)?)\s+(\S.*\S)\s*$, or die "$sscmfn:$.: syntax error in subseg cmap\n"; $subsegcmap{$1}= $2; } @@ -645,13 +647,14 @@ sub parametric_segment ($$$$$) { print DEBUG "ps $p0 $p1 $lenperp ($ppu)\n"; $draw= current_draw(); if ($draw =~ m/G/) { - my ($pt,$going,$red,$csegbare); + my ($pt,$going,$red,$csegbare,$movfeat,$movstroke); $going=0; o("% segments @segments\n"); o(" $psu_subseglw setlinewidth\n"); $param=$p0; $pt= &$calcfn; for (;;) { + $movstroke= " stroke\n"; $csegbare= $segments[0]; $csegbare =~ s/^\-//; if ($subsegcmapreq) { @@ -659,7 +662,13 @@ print DEBUG "ps $p0 $p1 $lenperp ($ppu)\n"; print "$csegbare\n" or die $!; $subsegcmap{$csegbare}++; } - } elsif (exists $subsegcmap{$csegbare}) { + } else { + $movfeat= $csegbare =~ s,(/\D+)(\d+)$,$1, ? $2 : 'f'; + if ($subsegmovfeatpos ne $movfeat) { + $movstroke= "% no-stroke\n"; + } + die "unknown subsegment colour for $csegbare\n" + unless exists $subsegcmap{$csegbare}; $red= $pt->{A} / (2*$pi); $red *= 64; $red += 128; @@ -669,8 +678,6 @@ print DEBUG "ps $p0 $p1 $lenperp ($ppu)\n"; $red /= 255.0; $red= sprintf("%f", $red); o(" $red $subsegcmap{$csegbare} setrgbcolor\n"); - } else { - die "unknown subsegment colour for $csegbare\n"; } o_path_begin(); parametric__o_pt($pt); @@ -680,12 +687,12 @@ print DEBUG "ps $p0 $p1 $lenperp ($ppu)\n"; segment_used_len($psu_ulen); $pt= &$calcfn; parametric__o_pt($pt); - o_path_strokeonly(); + o($movstroke); } segment_used_len(($p1-($param-$ppu)) * $lenperp); $param=$p1; parametric__o_pt(&$calcfn); - o_path_strokeonly(); + o($movstroke); } if ($draw =~ m/C/) { my ($pt); diff --git a/layout/make-dgram-make b/layout/make-dgram-make new file mode 100755 index 0000000..039a983 --- /dev/null +++ b/layout/make-dgram-make @@ -0,0 +1,12 @@ +#!/bin/sh +set -e +stem=$1 +echo '# autogenerated' +while read dgram args; do + cat <\$@.new + chmod +x \$@.new && mv -f \$@.new \$@ + +END +done diff --git a/layout/ours.dgram-list b/layout/ours.dgram-list new file mode 100644 index 0000000..fb4d333 --- /dev/null +++ b/layout/ours.dgram-list @@ -0,0 +1 @@ +bot -l0 -e=5G diff --git a/layout/segcmapassign b/layout/segcmapassign index 48622ac..e2b23b8 100755 --- a/layout/segcmapassign +++ b/layout/segcmapassign @@ -6,23 +6,23 @@ # lines: # # C -# where is N/[MP] (see informat.txt) and and +# where is N/[M] (see informat.txt) and and # contain no whitespace and are suitable for inserting like this # into the PostScript output: # ...code to compute and stack red in range [0,1>... # setrgbcolor # # S 0x -# F 0x 0x +# F 0x 0x # where (1<> 8) & 0x03)<<6; + $green |= $posinfo; + $blue= $segnum & 0xff; + $greenr= reverse_bits_in_byte($green); + $bluer= reverse_bits_in_byte($blue); + printf("C %s/%s %.6f %.6f\n". + "# %s/%s 0x%x 0x%x 0x%x 0x%x\n", + $seg,$movfeat, $greenr/255.0, $bluer/255.0, + $seg,$movfeat, $green, $blue, $greenr, $bluer) + or die $!; +} + +our $movfeatposbits= 6; + while (<>) { m,^(\w*)/([A-Za-z_]*)(\d*)$, or die; ($seg,$movfeat,$movconf)=($1,$2,$3); if (!length $seg) { - printf("C /%s%s 0 0\n", - $movfeat, $movconf) - or die $!; + die "too many $seg $movfeat" if + length $movfeat && $movconf >= $movfeatposbits-1; + cssnmap($seg,$movfeat,0, + length $movfeat ? 1<<($movfeatposbits-1) : 0); next; } die if length $movconf && !length $movfeat; @@ -80,23 +100,6 @@ sub reverse_bits_in_byte ($) { return $d; } -sub cssnmap ($$$$) { - my ($seg,$movfeatconf,$segnum,$posinfo) = @_; - my ($green,$blue,$greenr,$bluer); - $green= (($segnum >> 8) & 0x03)<<6; - $green |= $posinfo; - $blue= $segnum & 0xff; - $greenr= reverse_bits_in_byte($green); - $bluer= reverse_bits_in_byte($blue); - printf("C %s/%s %.10f %.10f\n". - "# %s/%s 0x%x 0x%x 0x%x 0x%x\n", - $seg,$movfeatconf, - $greenr/255, $bluer/255, - $seg,$movfeatconf, - $green, $blue, $greenr, $bluer) - or die $!; -} - our ($segnum) = 1; our ($conf,$posbit,$posbiti,$abovenext); @@ -105,7 +108,7 @@ foreach $seg (sort keys %seg) { $si= $seg{$seg}; $si->{Num}= $segnum++; die if $si->{Num} >= 1024; - $abovenext= 0x40; + $abovenext= 1<<$movfeatposbits; printf("S %s 0x%x\n", $seg, $si->{Num}) or die $!; @@ -114,20 +117,17 @@ foreach $seg (sort keys %seg) { $si->{Feat}{$b}{Max} <=> $si->{Feat}{$a}{Max}; } keys %{ $si->{Feat} }) { $fi= $si->{Feat}{$movfeat}; - for ($posbit=1,$posbiti=0; - $posbit<=$fi->{Max}; - $posbit<<=1,$posbiti++) { } + $posbiti= $fi->{Max}+1; + $posbit= 1<<$posbiti; $abovenext -= $posbit; die "too many $seg" if $abovenext <= 0; $fi->{Prefix}= $abovenext; $fi->{ConfigMask}= $posbit-1; $fi->{ConfigBits}= $posbiti; - printf("F %s 0x%x %s 0x%x %d 0x%x\n", + printf("F %s 0x%x %s 0x%x %d\n", $seg, $si->{Num}, - $movfeat, $fi->{Prefix}, $fi->{ConfigBits}, $fi->{Max}); - foreach ($conf=0; $conf<=$fi->{Max}; $conf++) { - cssnmap($seg, $movfeat.$conf, $si->{Num}, $fi->{Prefix}+$conf); - } + $movfeat, $fi->{Prefix}, $fi->{ConfigBits}); + cssnmap($seg, $movfeat, $si->{Num}, $fi->{Prefix}); } } diff --git a/layout/segencolayers.gen-make b/layout/segencolayers.gen-make new file mode 100755 index 0000000..60e864b --- /dev/null +++ b/layout/segencolayers.gen-make @@ -0,0 +1,20 @@ +#!/bin/sh +set -e +echo '# autogenerated' +x="%.pf.segenco.ppm" +for p in f 0 1 2 3 4 5; do + cat <t.ppm \ +set args ours.dgram-bot.pa.segenco.ppm >t.ppm \ b 0 200 200 200 \ 0. 0 200 200 200 \ .. 0 000 000 000 \ @@ -8,7 +8,10 @@ set args ours-g0.ppm >t.ppm \ r -660 0 0 0 \ F 500 1000 1000 1000 \ R -500 1000 1000 1000 \ - u0 \ + u0 u0.0x20 u0.0x21 u0.0x22 u0.0x23 \ + u0.0x24 u0.0x25 u0.0x26 u0.0x27 \ + u0.0x28 u0.0x29 u0.0x2a u0.0x2b \ + u0.0x2c u0.0x2d u0.0x2e u0.0x2f \ f0x1 f0x1.0x3e f0x1.0x3f \ F0x2 F0x2.0x3e F0x2.0x3f \ f0x3 f0x3.0x3e f0x3.0x3f \ -- 2.30.2