/* See {pz_plot_dyn.h}. */ /* Last edited on 2015-01-20 16:47:04 by stolfilocal */ /* !!! Move to libmsmatch !!! */ #include #include #include #include #include #include #include #include #include #include #include #include #include void pz_plot_seg_seg_grid( PSPlot.File *f, pz_segment_pair *s, pz_segment_pair *sRef, double cellSize, bool_t drawDiags ) { { /* with */ ??? n0 = s[0].ns; ??? lo0 = (((double)s[0].ini - sRef[0].ini) + 0.5e0) * cellSize; ??? hi0 = lo0 + ((double)n0 - 1) * cellSize; ??? n1 = s[1].ns; ??? lo1 = (((double)s[1].ini - sRef[1].ini) + 0.5e0) * cellSize; ??? hi1 = lo1 + ((double)n1 - 1) * cellSize; /* do */ for (i0 = 0; i0 <= n0-1 ; i0++){ { /* with */ ??? xt0 = lo0 + ((double)i0) * cellSize; /* do */ f.segment(xt0, lo1, xt0, hi1); }; }; for (i1 = 0; i1 <= n1 - 1 ; i1++){ { /* with */ ??? xt1 = lo1 + ((double)i1) * cellSize; /* do */ f.segment(lo0, xt1, hi0, xt1); }; }; if (( drawDiags )){ for (k = 2; k <= n0 + n1 - 2 ; k++){ { /* with */ ??? da0 = FLOAT(n0 - MIN(k, n0), double) * cellSize; ??? da1 = FLOAT(MAX(k, n0) - n0, double) * cellSize; ??? db0 = FLOAT(n0 + n1 - MAX(k, n1) - 1, double) * cellSize; ??? db1 = FLOAT(MIN(k, n1) - 1, double) * cellSize; /* do */ if (( s[0].rev == s[1].rev )){ f.segment(lo0 + da0, lo1 + da1, lo0 + db0, lo1 + db1) }else{ f.segment(hi0 - da0, lo1 + da1, hi0 - db0, lo1 + db1); }; }; }; }; } } /* pz_plot_seg_seg_grid */ TYPE IntPair == i2_t; CONST BadPair == IntPair{(int.ne - 1), (int.ne - 1)}; IntPair ReducePair( pz_match_pair p, pz_segment_pair *s, pz_segment_pair *sRef, int dLo, int dHi ) /* Given an index pair relative to segments "s[0]" and "s[1]", returns the corresponding index pair relative to segments "sRef[0]" and "sRef[1]". Does NOT consider that the curves are periodic. Returns "BadPair" if either component "j" of the result does not lie in the range "[dLo .. sRef[j].ns + dHi]". */ VAR r: IntPair; { for (j = 0; j <= 1 ; j++){ affirm(s[j].cvx == sRef[j].cvx ); affirm(s[j].tot == sRef[j].tot ); { /* with */ ??? i = pz_segment_rel_index(pz_segment_abs_index(p[j], s[j]), sRef[j]); /* do */ if (( i >= dLo ) ANDAND ( i <= sRef[j].ns + dHi )){ r[j] = i }else{ return BadPair; }; }; }; return r } /* ReducePair */ double Coord( int iRel, pz_segment_t *sRef, double step ) /* Given a sample index "iRel" relative to a segment "sRef", returns the corresponding plot coordinate, assuming that the minimum coordinate in "sRef" is "0.5e0 * step". */ { if (( sRef.rev )){ return (((double)sRef.ns - 1 - iRel) + 0.5e0) * step }else{ return (((double)iRel) + 0.5e0) * step; } } /* Coord */ void pz_plot_match_boxes( PSPlot.File *f, pz_match_t *m, pz_segment_pair *s, pz_segment_pair *sRef, double cellSize, double boxSize ) { { /* with */ ??? r = (((double)boxSize)) / 2.0e0; ??? extra = CEILING(r/cellSize + 0.1e0 * cellSize); /* do */ for (k = 0; k < (m.ne ) ; k++){ { /* with */ ??? p = ReducePair(m[k], s, sRef, -extra, +extra); /* do */ if (( p != BadPair )){ { /* with */ ??? xp = Coord(p[0], sRef[0], cellSize); ??? yp = Coord(p[1], sRef[1], cellSize); /* do */ f.rectangle(xp - r, xp + r, yp - r, yp + r); }; }; }; };; } } /* pz_plot_match_boxes */ void pz_plot_match_path( PSPlot.File *f, pz_match_t *m, pz_segment_pair *s, pz_segment_pair *sRef, double cellSize ) { for (k = 1; k < (m.ne ) ; k++){ { /* with */ ??? p = ReducePair(m[k-1], s, sRef, -1, +1); ??? q = ReducePair(m[k], s, sRef, -1, +1); /* do */ if (( p != BadPair ) ANDAND ( q != BadPair )){ { /* with */ ??? xp = Coord(p[0], sRef[0], cellSize); ??? yp = Coord(p[1], sRef[1], cellSize); ??? xq = Coord(q[0], sRef[0], cellSize); ??? yq = Coord(q[1], sRef[1], cellSize); /* do */ f.segment(xp, yp, xq, yq); }; }; }; }; } /* pz_plot_match_path */ void pz_plot_match_dots( PSPlot.File *f, pz_match_t *m, pz_segment_pair *s, pz_segment_pair *sRef, double cellSize, double dotSize ) { if (( dotSize <= 0.0 )){ return ;}; f.setLineWidth(1.0); { /* with */ ??? r = (((double)dotSize)) / 2.0e0; ??? extra = CEILING(((double)r)/cellSize + 0.1e0 * cellSize); /* do */ for (k = 0; k < (m.ne ) ; k++){ { /* with */ ??? p = ReducePair(m[k], s, sRef, -extra, +extra); /* do */ if (( p != BadPair )){ { /* with */ ??? xp = Coord(p[0], sRef[0], cellSize); ??? yp = Coord(p[1], sRef[1], cellSize); /* do */ f.dot(xp, yp, dotSize); }; }; }; };; } } /* pz_plot_match_dots */