2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2008--2011 Han-Wen Nienhuys <hanwen@lilypond.org>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
23 #include "skyline-pair.hh"
25 LY_DEFINE (ly_paper_system_p
, "ly:paper-system?",
27 "Is @var{obj} a C++ @code{Prob} object of type"
28 " @code{paper-system}?")
30 return ly_prob_type_p (obj
, ly_symbol2scm ("paper-system"));
33 LY_DEFINE (ly_paper_system_minimum_distance
, "ly:paper-system-minimum-distance",
34 2, 0, 0, (SCM sys1
, SCM sys2
),
35 "Measure the minimum distance between these two paper-systems,"
36 " using their stored skylines if possible and falling back to"
37 " their extents otherwise.")
40 Prob
*p1
= unsmob_prob (sys1
);
41 Prob
*p2
= unsmob_prob (sys2
);
42 Skyline_pair
*sky1
= Skyline_pair::unsmob (p1
->get_property ("vertical-skylines"));
43 Skyline_pair
*sky2
= Skyline_pair::unsmob (p2
->get_property ("vertical-skylines"));
46 ret
= (*sky1
)[DOWN
].distance ((*sky2
)[UP
]);
49 Stencil
*s1
= unsmob_stencil (p1
->get_property ("stencil"));
50 Stencil
*s2
= unsmob_stencil (p2
->get_property ("stencil"));
51 Interval iv1
= s1
->extent (Y_AXIS
);
52 Interval iv2
= s2
->extent (Y_AXIS
);
53 ret
= iv2
[UP
] - iv1
[DOWN
];
55 return scm_from_double (ret
);