Back to index

texmacs  1.0.7.15
Classes | Defines | Typedefs | Functions
page_breaker.cpp File Reference
#include "Line/lazy_vstream.hpp"
#include "vpenalty.hpp"
#include "skeleton.hpp"
#include "merge_sort.hpp"

Go to the source code of this file.

Classes

struct  page_breaker_rep

Defines

#define MAIN_FLOW   0
#define FNOTE_FLOW   1
#define FLOAT_FLOW   2
#define NR_FLOWS   3
#define INVALID_BREAK   0
#define BAD_BREAK   1
#define VALID_BREAK   2

Typedefs

typedef array< int > vbreak
typedef array< int > ladder

Functions

void sort (pagelet &pg)
vpenalty as_vpenalty (SI diff)
bool var_path_inf_eq (path p1, path p2)
static int fast_find (array< path > a, path p)
static int find_length (array< space > a, int start, SI ht)
static int find_end_block (array< path > a, int start, int end)
page_item access (array< page_item > l, path p)
array< page_itemsub (array< page_item > l, path p, path q)
static bool starts (path p, path q)
bool inf_eq (vbreak br1, vbreak br2)
static ladder sub (ladder ld, int start, int end)
SI stretch_space (space spc, double stretch)
skeleton break_pages (array< page_item > l, space ph, int qual, space fn_sep, space fnote_sep, space float_sep, font fn)

Define Documentation

#define BAD_BREAK   1

Definition at line 28 of file page_breaker.cpp.

#define FLOAT_FLOW   2

Definition at line 24 of file page_breaker.cpp.

#define FNOTE_FLOW   1

Definition at line 23 of file page_breaker.cpp.

#define INVALID_BREAK   0

Definition at line 27 of file page_breaker.cpp.

#define MAIN_FLOW   0

Definition at line 22 of file page_breaker.cpp.

#define NR_FLOWS   3

Definition at line 25 of file page_breaker.cpp.

#define VALID_BREAK   2

Definition at line 29 of file page_breaker.cpp.


Typedef Documentation

typedef array<int> ladder

Definition at line 21 of file page_breaker.cpp.

typedef array<int> vbreak

Definition at line 20 of file page_breaker.cpp.


Function Documentation

page_item access ( array< page_item l,
path  p 
)

Definition at line 202 of file page_breaker.cpp.

                                    {
  page_item item= l[p->item];
  if (is_nil (p->next)) return item;
  else {
    lazy_vstream ins= (lazy_vstream) item->fl[p->next->item];
    return access (ins->l, p->next->next);
  }
}

Here is the call graph for this function:

vpenalty as_vpenalty ( SI  diff)

Definition at line 20 of file vpenalty.cpp.

                      {
  if (diff < 0) diff= -diff;
  if (diff < 0x1000) return vpenalty (0, (diff*diff) >> 16);
  else if (diff < 0x100000) return vpenalty (0, (diff >> 8) * (diff >> 8));
  else return vpenalty (0, 0x1000000);
}

Here is the caller graph for this function:

skeleton break_pages ( array< page_item l,
space  ph,
int  qual,
space  fn_sep,
space  fnote_sep,
space  float_sep,
font  fn 
)

Definition at line 1501 of file page_breaker.cpp.

{
  page_breaker_rep* H=
    tm_new<page_breaker_rep> (l, ph, qual, fn_sep, fnote_sep, float_sep, fn);
  // cout << HRULE << LF;
  skeleton sk= H->make_skeleton ();
  tm_delete (H);
  return sk;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int fast_find ( array< path a,
path  p 
) [static]

Definition at line 164 of file page_breaker.cpp.

                                  {
  int n= N(a), step= n, i= n>>1;
  while (step>1) {
    step= (step+1)>>1;
    if (var_path_inf_eq (p, a[i])) i= max (0, i-step);
    else i= min (n-1, i+step);
  }
  if (!var_path_inf_eq (p, a[i])) i= i+1;
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_end_block ( array< path a,
int  start,
int  end 
) [static]

Definition at line 188 of file page_breaker.cpp.

                                                   {
  if (a[end-1] == path_add (a[start], end-1-start)) return end;
  int n= end-start, step= n, i= (start+end+1)>>1;
  while (step>1) {
    step= (step+1)>>1;
    if ((i>start) && (a[i-1] != path_add (a[start], i-1-start)))
      i= max (start, i-step);
    else i= min (end-1, i+step);
  }
  if ((i>start) && (a[i-1] != path_add (a[start], i-1-start))) i--;
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_length ( array< space a,
int  start,
SI  ht 
) [static]

Definition at line 176 of file page_breaker.cpp.

                                               {
  int n= N(a)- start, step= n, i= (start + N(a))>>1;
  while (step>1) {
    step= (step+1)>>1;
    if (ht <= a[i]->def) i= max (start, i-step);
    else i= min (N(a)-1, i+step);
  }
  if (ht > a[i]->def) i= min (N(a)-1, i+1);
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool inf_eq ( vbreak  br1,
vbreak  br2 
)

Definition at line 585 of file page_breaker.cpp.

                                {
  int i, n= N(br1);
  for (i=0; i<n; i++)
    if (br1[i] > br2[i]) return false;
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sort ( pagelet pg)

Definition at line 89 of file skeleton.cpp.

                   {
  int i, n= N (pg->ins);
  while (true) {
    bool flag =true;
    for (i=0; i<n-1; i++)
      if (pg->ins[i+1] < pg->ins[i]) {
       insertion tmp= pg->ins[i];
       pg->ins[i]= pg->ins[i+1];
       pg->ins[i+1]= tmp;
       flag= false;
      }
    if (flag) break;
  }
}

Here is the call graph for this function:

static bool starts ( path  p,
path  q 
) [inline, static]

Definition at line 235 of file page_breaker.cpp.

                        {
  return (N(p) >= N(q)) && (head (p, N(q)) == q);
}

Here is the call graph for this function:

SI stretch_space ( space  spc,
double  stretch 
)

Definition at line 906 of file page_breaker.cpp.

                                          {
  if (stretch > 0.0) return (SI) (spc->def + stretch * (spc->max - spc->def));
  if (stretch < 0.0) return (SI) (spc->def + stretch * (spc->def - spc->min));
  return spc->def;
}

Here is the caller graph for this function:

array<page_item> sub ( array< page_item l,
path  p,
path  q 
)

Definition at line 212 of file page_breaker.cpp.

                                         {
  if (is_atom (p) && is_atom (q)) {
    int i= p->item, j= q->item, k;
    array<page_item> r (j-i);
    for (k=i; k<j; k++) r[k-i]= l[k];
    return r;
  }
  else {
    if ((N(p) <= 2) || (N(q) <= 2)) {
      cerr << "\nThe paths were " << p << " and " << q << "\n";
      FAILED ("paths to short");
    }
    if ((p->item != q->item) || (p->next->item != q->next->item)) {
      cerr << "\nThe paths were " << p << " and " << q << "\n";
      FAILED ("paths don't match");
    }
    page_item item= l[p->item];
    lazy_vstream ins= (lazy_vstream) item->fl[p->next->item];
    return sub (ins->l, p->next->next, q->next->next);
  }
}

Here is the call graph for this function:

static ladder sub ( ladder  ld,
int  start,
int  end 
) [static]

Definition at line 636 of file page_breaker.cpp.

                                    {
  // cout << "sub " << ld << ", " << start << ", " << end;
  int i, n= end-start;
  ladder ret (n);
  for (i=0; i<n; i++)
    ret[i]= ld[start+i];
  // cout << " -> " << ret << LF;
  return ret;
}

Here is the call graph for this function:

bool var_path_inf_eq ( path  p1,
path  p2 
)

Definition at line 156 of file page_breaker.cpp.

                                   {
  if (is_nil (p1) || is_nil (p2)) return is_nil (p1);
  if (p1->item<p2->item) return true;
  if (p1->item>p2->item) return false;
  return var_path_inf_eq (p1->next, p2->next);
}

Here is the call graph for this function:

Here is the caller graph for this function: