3 $tex_points_to_mm = (25.4)/(65536.*72.27)
5 # If the interval (a,b) overlaps the interval (c,d) then return the amount by which they overlap.
6 # Otherwise return false.
8 if a>c then return overlap(c,d,a,b) end
9 # ab should lie strictly underneath cd
10 if b<c then return false end
15 return sprintf((x+0.5).to_i.to_s,"%d")
19 Dir["*.pos"].each { |filename|
22 ch = $1 # interpret as string, not integer, e.g., in NP 001 is not the same as 01
30 File.open(filename,'r') do |f|
32 if line=~/^fig,label=fig:(.*),page=(.*),x=(.*),y=(.*),at=(.*)/ then
33 fig,pg,x,y = $1,$2.to_i,$3.to_i,$4.to_i
34 x = x*$tex_points_to_mm
35 y = y*$tex_points_to_mm
36 if page.has_key?(fig) then
37 if page[fig]!=pg then print "figure #{fig} occurs on both page #{page[fig]} and page #{pg} -- maybe the second one needs a suffix\n" end
38 if x<lo_x[fig] then lo_x[fig]=x end
39 if x>hi_x[fig] then hi_x[fig]=x end
40 if y<lo_y[fig] then lo_y[fig]=y end
41 if y>hi_y[fig] then hi_y[fig]=y end
49 if index_by_page[pg]==nil then
50 index_by_page[pg] = {fig=>'1'}
52 index_by_page[pg][fig] = 1
56 index_by_page.each_index { |pg|
57 figs = index_by_page[pg]
61 if f<g and overlap(lo_y[f],hi_y[f],lo_y[g],hi_y[g]) and overlap(lo_x[f],hi_x[f],lo_x[g],hi_x[g]) then
62 print "***** colliding figs, ch. #{ch}, p. #{pg}, #{f} and #{g}, overlapping by #{mm(overlap(lo_x[f],hi_x[f],lo_x[g],hi_x[g]))} mm horiz, #{mm(overlap(lo_y[f],hi_y[f],lo_y[g],hi_y[g]))} mm vert\n"
63 #print " #{f} extends from #{mm(lo_y[f])} to #{mm(hi_y[f])} mm, #{g} from #{mm(lo_y[g])} to #{mm(hi_y[g])} mm \n"
73 print "no .pos files found\n"