Skip to content

Commit b980020

Browse files
committed
Better check for link between rest and augmentation dot
1 parent 2d18d8b commit b980020

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

app/src/main/java/org/audiveris/omr/sig/inter/AugmentationDotInter.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,10 @@ private Link lookupLink (List<Inter> systemRests,
496496
// lookupRestLinks //
497497
//-----------------//
498498
/**
499-
* Look up for all possible links with rests
499+
* Look up for all possible links with rests.
500+
* <p>
501+
* As opposed to a head or a dot, a rest can be rather high.
502+
* Therefore, we have to adjust the ordinate tests.
500503
*
501504
* @param systemRests system rests, sorted by abscissa
502505
* @param system containing system
@@ -524,14 +527,18 @@ public List<Link> lookupRestLinks (List<Inter> systemRests,
524527
final List<Inter> rests = dotStack.filter(
525528
Inters.intersectedInters(systemRests, GeoOrder.BY_ABSCISSA, luBox));
526529
final int minDx = scale.toPixels(AugmentationRelation.getXOutGapMinimum(profile));
530+
final double heightRatio = AugmentationRelation.getRestHeightRatio().getValue();
527531

528532
for (Inter inter : rests) {
529-
RestInter rest = (RestInter) inter;
530-
Point refPt = rest.getCenterRight();
531-
double xGap = dotCenter.x - refPt.x;
533+
final RestInter rest = (RestInter) inter;
534+
final int restHeight = rest.getBounds().height;
535+
final double yMargin = restHeight * heightRatio;
536+
final Point refPt = rest.getCenterRight();
537+
final double xGap = dotCenter.x - refPt.x;
532538

533539
if (xGap >= minDx) {
534540
double yGap = Math.abs(refPt.y - dotCenter.y);
541+
yGap = Math.max(0, yGap - yMargin);
535542
AugmentationRelation rel = new AugmentationRelation();
536543
rel.setOutGaps(scale.pixelsToFrac(xGap), scale.pixelsToFrac(yGap), profile);
537544

app/src/main/java/org/audiveris/omr/sig/relation/AugmentationRelation.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class AugmentationRelation
5959

6060
private static final Logger logger = LoggerFactory.getLogger(AugmentationRelation.class);
6161

62-
private static final double[] OUT_WEIGHTS = new double[]
62+
private static final double[] OUT_WEIGHTS = new double[] //
6363
{ constants.xOutWeight.getValue(), constants.yWeight.getValue() };
6464

6565
//~ Methods ------------------------------------------------------------------------------------
@@ -200,6 +200,14 @@ public static Scale.Fraction getYGapMaximum (int profile)
200200
return (Scale.Fraction) constants.getConstant(constants.yGapMax, profile);
201201
}
202202

203+
//--------------------//
204+
// getRestHeightRatio //
205+
//--------------------//
206+
public static Constant.Ratio getRestHeightRatio ()
207+
{
208+
return constants.restHeightRatio;
209+
}
210+
203211
//~ Inner Classes ------------------------------------------------------------------------------
204212

205213
//-----------//
@@ -240,5 +248,9 @@ private static class Constants
240248
private final Constant.Ratio yWeight = new Constant.Ratio(
241249
1,
242250
"Relative impact weight for yGap");
251+
252+
private final Constant.Ratio restHeightRatio = new Constant.Ratio(
253+
0.45,
254+
"Height margin ratio given to a rest");
243255
}
244256
}

0 commit comments

Comments
 (0)