@Test public void testGetIncompleteTierStacks() throws Exception { final int maxPixelsPerDimension = 1024; final double maxCompleteAlignmentQuality = 1.0; final StackId roughTilesStackId = new StackId("flyTEM", "trautmane_fafb_fold", "rough_tiles_e"); final Bounds tier2WarpTilesBounds = new Bounds(36645.0, 37689.0, 2210.0, 48752.0, 50262.0, 2220.0); int tier = 3; final TierDimensions tier3Dimensions = TierDimensions.buildPrimeSplitTier(tier2WarpTilesBounds, maxPixelsPerDimension, tier); final List<HierarchicalStack> tier3Stacks = tier3Dimensions.getSplitStacks(roughTilesStackId, tier); for (final HierarchicalStack splitStack : tier3Stacks) { splitStack.setAlignmentQuality(maxCompleteAlignmentQuality - 0.1); } final Bounds tier3WarpTilesBounds = new Bounds(36645.0, 37689.0, 2210.0, 48753.0, 50262.0, 2220.0); HierarchicalTierRegions tierRegions = new HierarchicalTierRegions(tier3WarpTilesBounds, tier3Stacks, tier3Dimensions, maxCompleteAlignmentQuality); tier = 4; final TierDimensions tier4Dimensions = TierDimensions.buildPrimeSplitTier(tier3WarpTilesBounds, maxPixelsPerDimension, tier); final List<HierarchicalStack> tier4Stacks = tier4Dimensions.getSplitStacks(roughTilesStackId, tier); List<HierarchicalStack> incompleteTier4Stacks = tierRegions.getIncompleteTierStacks(tier4Stacks); Assert.assertEquals("invalid number of incomplete stacks when all prior tier stacks have good quality", 0, incompleteTier4Stacks.size()); for (final HierarchicalStack splitStack : tier3Stacks) { if (splitStack.getTierRow() == 0) { splitStack.setAlignmentQuality(maxCompleteAlignmentQuality + 0.1); } } tierRegions = new HierarchicalTierRegions(tier3WarpTilesBounds, tier3Stacks, tier3Dimensions, maxCompleteAlignmentQuality); incompleteTier4Stacks = tierRegions.getIncompleteTierStacks(tier4Stacks); final int tier3Columns = tier3Stacks.get(0).getTotalTierColumnCount(); final int tier4Columns = tier4Stacks.get(0).getTotalTierColumnCount(); final int expectedIncompleteTier4Rows = (tier4Columns / tier3Columns) + 1; final int expectedIncompleteStacksSize = expectedIncompleteTier4Rows * tier4Columns; Assert.assertEquals("invalid number of incomplete stacks when first row prior tier stacks have bad quality", expectedIncompleteStacksSize, incompleteTier4Stacks.size()); final List<HierarchicalStack> partialTier3Stacks = new ArrayList<>(tier3Stacks.size()); for (final HierarchicalStack splitStack : tier3Stacks) { if (splitStack.getTierRow() < 2) { partialTier3Stacks.add(splitStack); } } tierRegions = new HierarchicalTierRegions(tier3WarpTilesBounds, partialTier3Stacks, tier3Dimensions, maxCompleteAlignmentQuality); incompleteTier4Stacks = tierRegions.getIncompleteTierStacks(tier4Stacks); Assert.assertEquals("same number of incomplete stacks should be found for partial list", expectedIncompleteStacksSize, incompleteTier4Stacks.size()); }
@SuppressWarnings("Convert2streamapi") public List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks) { final List<HierarchicalStack> incompleteTierStacks = new ArrayList<>(currentTierStacks.size()); Integer currentTier = null; for (final HierarchicalStack splitStack : currentTierStacks) { if (currentTier == null) { currentTier = splitStack.getTier(); } addTierRegion(splitStack, false); } final Set<String> completedSplitStackNames = new HashSet<>(currentTierStacks.size()); for (final TileBounds completedSplitStack : tierRegions.findCompletelyObscuredTiles()) { completedSplitStackNames.add(completedSplitStack.getSectionId()); } for (final HierarchicalStack currentTierStack : currentTierStacks) { if (! completedSplitStackNames.contains(currentTierStack.getSplitStackId().getStack())) { incompleteTierStacks.add(currentTierStack); } } LOG.info("getIncompleteTierStacks: exit, {} out of {} tier {} stacks are incomplete", incompleteTierStacks.size(), currentTierStacks.size(), currentTier); return incompleteTierStacks; }
HierarchicalTierRegions { @SuppressWarnings("Convert2streamapi") public List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks) { final List<HierarchicalStack> incompleteTierStacks = new ArrayList<>(currentTierStacks.size()); Integer currentTier = null; for (final HierarchicalStack splitStack : currentTierStacks) { if (currentTier == null) { currentTier = splitStack.getTier(); } addTierRegion(splitStack, false); } final Set<String> completedSplitStackNames = new HashSet<>(currentTierStacks.size()); for (final TileBounds completedSplitStack : tierRegions.findCompletelyObscuredTiles()) { completedSplitStackNames.add(completedSplitStack.getSectionId()); } for (final HierarchicalStack currentTierStack : currentTierStacks) { if (! completedSplitStackNames.contains(currentTierStack.getSplitStackId().getStack())) { incompleteTierStacks.add(currentTierStack); } } LOG.info("getIncompleteTierStacks: exit, {} out of {} tier {} stacks are incomplete", incompleteTierStacks.size(), currentTierStacks.size(), currentTier); return incompleteTierStacks; } }
HierarchicalTierRegions { @SuppressWarnings("Convert2streamapi") public List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks) { final List<HierarchicalStack> incompleteTierStacks = new ArrayList<>(currentTierStacks.size()); Integer currentTier = null; for (final HierarchicalStack splitStack : currentTierStacks) { if (currentTier == null) { currentTier = splitStack.getTier(); } addTierRegion(splitStack, false); } final Set<String> completedSplitStackNames = new HashSet<>(currentTierStacks.size()); for (final TileBounds completedSplitStack : tierRegions.findCompletelyObscuredTiles()) { completedSplitStackNames.add(completedSplitStack.getSectionId()); } for (final HierarchicalStack currentTierStack : currentTierStacks) { if (! completedSplitStackNames.contains(currentTierStack.getSplitStackId().getStack())) { incompleteTierStacks.add(currentTierStack); } } LOG.info("getIncompleteTierStacks: exit, {} out of {} tier {} stacks are incomplete", incompleteTierStacks.size(), currentTierStacks.size(), currentTier); return incompleteTierStacks; } HierarchicalTierRegions(final Bounds priorTierWarpStackBounds,
                                   final List<HierarchicalStack> priorTierStacks,
                                   final TierDimensions priorTierDimensions,
                                   final double maxCompleteAlignmentQuality); }
HierarchicalTierRegions { @SuppressWarnings("Convert2streamapi") public List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks) { final List<HierarchicalStack> incompleteTierStacks = new ArrayList<>(currentTierStacks.size()); Integer currentTier = null; for (final HierarchicalStack splitStack : currentTierStacks) { if (currentTier == null) { currentTier = splitStack.getTier(); } addTierRegion(splitStack, false); } final Set<String> completedSplitStackNames = new HashSet<>(currentTierStacks.size()); for (final TileBounds completedSplitStack : tierRegions.findCompletelyObscuredTiles()) { completedSplitStackNames.add(completedSplitStack.getSectionId()); } for (final HierarchicalStack currentTierStack : currentTierStacks) { if (! completedSplitStackNames.contains(currentTierStack.getSplitStackId().getStack())) { incompleteTierStacks.add(currentTierStack); } } LOG.info("getIncompleteTierStacks: exit, {} out of {} tier {} stacks are incomplete", incompleteTierStacks.size(), currentTierStacks.size(), currentTier); return incompleteTierStacks; } HierarchicalTierRegions(final Bounds priorTierWarpStackBounds,
                                   final List<HierarchicalStack> priorTierStacks,
                                   final TierDimensions priorTierDimensions,
                                   final double maxCompleteAlignmentQuality); @SuppressWarnings("Convert2streamapi") List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks); }
HierarchicalTierRegions { @SuppressWarnings("Convert2streamapi") public List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks) { final List<HierarchicalStack> incompleteTierStacks = new ArrayList<>(currentTierStacks.size()); Integer currentTier = null; for (final HierarchicalStack splitStack : currentTierStacks) { if (currentTier == null) { currentTier = splitStack.getTier(); } addTierRegion(splitStack, false); } final Set<String> completedSplitStackNames = new HashSet<>(currentTierStacks.size()); for (final TileBounds completedSplitStack : tierRegions.findCompletelyObscuredTiles()) { completedSplitStackNames.add(completedSplitStack.getSectionId()); } for (final HierarchicalStack currentTierStack : currentTierStacks) { if (! completedSplitStackNames.contains(currentTierStack.getSplitStackId().getStack())) { incompleteTierStacks.add(currentTierStack); } } LOG.info("getIncompleteTierStacks: exit, {} out of {} tier {} stacks are incomplete", incompleteTierStacks.size(), currentTierStacks.size(), currentTier); return incompleteTierStacks; } HierarchicalTierRegions(final Bounds priorTierWarpStackBounds,
                                   final List<HierarchicalStack> priorTierStacks,
                                   final TierDimensions priorTierDimensions,
                                   final double maxCompleteAlignmentQuality); @SuppressWarnings("Convert2streamapi") List<HierarchicalStack> getIncompleteTierStacks(final List<HierarchicalStack> currentTierStacks);  }