net.imglib2.FinalRealInterval Java Examples

The following examples show how to use net.imglib2.FinalRealInterval. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FitToInterval.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onChanged(final Change<? extends Source<?>> change)
{
	while (change.next())
		if (change.wasAdded() && change.getList().size() == 1)
		{
			final Source<?>         addedSource = change.getAddedSubList().get(0);
			final double[]          min         = Arrays.stream(Intervals.minAsLongArray(addedSource.getSource(
					0,
					0
			                                                                                                  ))).asDoubleStream().toArray();
			final double[]          max         = Arrays.stream(Intervals.maxAsLongArray(addedSource.getSource(
					0,
					0
			                                                                                                  ))).asDoubleStream().toArray();
			final AffineTransform3D tf          = new AffineTransform3D();
			addedSource.getSourceTransform(0, 0, tf);
			tf.apply(min, min);
			tf.apply(max, max);
			fitToInterval.fit(Intervals.smallestContainingInterval(new FinalRealInterval(min, max)));
		}

}
 
Example #2
Source File: TransformTools.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public static FinalRealInterval applyTranslation(RealInterval img, TranslationGet translation, boolean[] ignoreDims){

		// get number of dimensions we actually use
		int n = 0;
		for (int d = 0; d < ignoreDims.length; ++d)
			if (!ignoreDims[d])
				n++;
		
		final double [] min = new double [n];
		final double [] max = new double [n];
		
		int i2 = 0;
		for (int i = 0; i< img.numDimensions();++i)
		{
			if (!ignoreDims[i])
			{
				min[i2] = img.realMin(i) + translation.getTranslation(i);
				max[i2] = img.realMax(i) + translation.getTranslation(i);
				i2++;
			}
		}
		return new FinalRealInterval(min, max);
	}
 
Example #3
Source File: TransformTools.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public static FinalRealInterval getOverlap(final RealInterval img1, final RealInterval img2){
	final int n = img1.numDimensions();
	final double [] min = new double [n];
	final double [] max = new double [n];
	
	for (int i = 0; i< n; i++)
	{
		min[i] = Math.max(img1.realMin(i), img2.realMin(i));
		max[i] = Math.min(img1.realMax(i), img2.realMax(i));
		
		// intervals do not overlap
		if ( max[i] < min [i])
			return null;
	}
	
	return new FinalRealInterval(min, max);
}
 
Example #4
Source File: ViewFrustum.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public RealInterval viewPlaneAtGivenDistance(final double z)
{
	final double[] min = new double[2], max = new double[2];
	for (int d = 0; d < 2; ++d)
	{
		final double halfLen = tanHalfFov[d] * z;
		min[d] = -halfLen;
		max[d] = +halfLen;
	}
	return new FinalRealInterval(min, max);
}
 
Example #5
Source File: MaskedSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private Interval scaleIntervalToLevel(final Interval interval, final int intervalLevel, final int targetLevel)
{
	if (intervalLevel == targetLevel) { return interval; }

	final double[] min = LongStream.of(Intervals.minAsLongArray(interval)).asDoubleStream().toArray();
	final double[] max = LongStream.of(Intervals.maxAsLongArray(interval)).asDoubleStream().map(d -> d + 1).toArray();
	final double[] relativeScale = DataSource.getRelativeScales(this, 0, targetLevel, intervalLevel);
	LOG.debug("Scaling interval {} {} {}", min, max, relativeScale);
	org.janelia.saalfeldlab.util.grids.Grids.scaleBoundingBox(min, max, min, max, relativeScale);
	return Intervals.smallestContainingInterval(new FinalRealInterval(min, max));

}
 
Example #6
Source File: MaskedSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RealRandomAccessible<T> getInterpolatedSource(final int t, final int level, final Interpolation method)
{
	final RealRandomAccessible<T> sourceToExtend;

	// ignore interpolation method because we cannot use linear interpolation on LabelMultisetType
	final RealRandomAccessible<T> interpolatedSource = this.source.getInterpolatedSource(t, level, Interpolation.NEARESTNEIGHBOR);
	if (!this.showCanvasOverBackground.get() || this.affectedBlocks.size() == 0 && this.currentMask == null)
	{
		LOG.debug("Hide canvas or no mask/canvas data present -- delegate to underlying source");
		sourceToExtend = interpolatedSource;
	}
	else
	{
		final RealRandomAccessible<VolatileUnsignedLongType> canvas = interpolateNearestNeighbor(Views.extendValue(this.canvases[level].getRai(), new VolatileUnsignedLongType(Label.INVALID)));
		final RealRandomAccessible<VolatileUnsignedLongType> mask = this.tMasks[level];
		final RealRandomAccessibleTriple<T, VolatileUnsignedLongType, VolatileUnsignedLongType> composed = new
				RealRandomAccessibleTriple<>(
				interpolatedSource,
				canvas,
				mask
		);
		sourceToExtend = new PickOne<>(composed, pacT.copyWithDifferentNumOccurences(numContainedVoxels(level)));
	}

	// extend the interpolated source with the specified out of bounds value
	final RealInterval bounds = new FinalRealInterval(source.getSource(t, level));
	final RealRandomAccessibleRealInterval<T> boundedSource = new FinalRealRandomAccessibleRealInterval<>(sourceToExtend, bounds);
	return new ExtendedRealRandomAccessibleRealInterval<>(boundedSource, new RealOutOfBoundsConstantValueFactory<>(extensionT.copy()));
}
 
Example #7
Source File: MaskedSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RealRandomAccessible<D> getInterpolatedDataSource(final int t, final int level, final Interpolation method)
{
	final RealRandomAccessible<D> dataSourceToExtend;

	// ignore interpolation method because we cannot use linear interpolation on LabelMultisetType
	final RealRandomAccessible<D> interpolatedDataSource = this.source.getInterpolatedDataSource(t, level, Interpolation.NEARESTNEIGHBOR);
	if (!this.showCanvasOverBackground.get() || this.affectedBlocks.size() == 0 && this.currentMask == null)
	{
		LOG.debug("Hide canvas or no mask/canvas data present -- delegate to underlying source");
		dataSourceToExtend = interpolatedDataSource;
	}
	else
	{
		final RealRandomAccessible<UnsignedLongType> dataCanvas = interpolateNearestNeighbor(Views.extendValue(this.dataCanvases[level], new UnsignedLongType(Label.INVALID)));
		final RealRandomAccessible<UnsignedLongType> dataMask = this.dMasks[level];
		final RealRandomAccessibleTriple<D, UnsignedLongType, UnsignedLongType> composed = new RealRandomAccessibleTriple<>(
				interpolatedDataSource,
				dataCanvas,
				dataMask);
		dataSourceToExtend = new PickOne<>(composed, pacD.copyWithDifferentNumOccurences(numContainedVoxels(level)));
	}

	// extend the interpolated source with the specified out of bounds value
	final RealInterval bounds = new FinalRealInterval(source.getDataSource(t, level));
	final RealRandomAccessibleRealInterval<D> boundedDataSource = new FinalRealRandomAccessibleRealInterval<>(dataSourceToExtend, bounds);
	return new ExtendedRealRandomAccessibleRealInterval<>(boundedDataSource, new RealOutOfBoundsConstantValueFactory<>(extensionD.copy()));
}
 
Example #8
Source File: MeshGeneratorJobManager.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private Node createBlockShape(final ShapeKey<T> key)
	{
		final Interval keyInterval = key.interval();
		final double[] worldMin = new double[3], worldMax = new double[3];
		Arrays.setAll(worldMin, d -> keyInterval.min(d));
		Arrays.setAll(worldMax, d -> keyInterval.min(d) + keyInterval.dimension(d));
		unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMin, worldMin);
		unshiftedWorldTransforms.apply(key.scaleIndex()).apply(worldMax, worldMax);

		final RealInterval blockWorldInterval = new FinalRealInterval(worldMin, worldMax);
		final double[] blockWorldSize = new double[blockWorldInterval.numDimensions()];
		Arrays.setAll(blockWorldSize, d -> blockWorldInterval.realMax(d) - blockWorldInterval.realMin(d));

		// the standard Box primitive is made up of triangles, so the unwanted diagonals are visible when using DrawMode.Line
//		final Box box = new Box(
//				blockWorldSize[0],
//				blockWorldSize[1],
//				blockWorldSize[2]
//			);
		final PolygonMeshView box = new PolygonMeshView(Meshes.createQuadrilateralMesh(
				(float) blockWorldSize[0],
				(float) blockWorldSize[1],
				(float) blockWorldSize[2]
		));

		final double[] blockWorldTranslation = new double[blockWorldInterval.numDimensions()];
		Arrays.setAll(blockWorldTranslation, d -> blockWorldInterval.realMin(d) + blockWorldSize[d] * 0.5);

		box.setTranslateX(blockWorldTranslation[0]);
		box.setTranslateY(blockWorldTranslation[1]);
		box.setTranslateZ(blockWorldTranslation[2]);

		final PhongMaterial material = Meshes.painteraPhongMaterial();
		box.setCullFace(CullFace.NONE);
		box.setMaterial(material);
		box.setDrawMode(DrawMode.LINE);

		return box;
	}
 
Example #9
Source File: TransformTools.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
/**
 * get overlap in local image coordinates (assuming min = (0,0,..))
 * @param img image interval (global coordinates)
 * @param overlap overlap interval (global coordinates)
 * @return overlap interval  in local coordinates
 */
public static FinalRealInterval getLocalOverlap(RealInterval img, RealInterval overlap){
	final int n = img.numDimensions();
	final double [] min = new double [n];
	final double [] max = new double [n];
	
	for (int i = 0; i< n; i++)
	{
		min[i] = Math.max(0, overlap.realMin(i) - img.realMin(i)) ;
		max[i] = Math.max(0, overlap.realMax(i) - img.realMin(i));
	}
	return new FinalRealInterval(min, max);
}
 
Example #10
Source File: SceneBlockTree.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
public static BlockTree<BlockTreeFlatKey, BlockTreeNode<BlockTreeFlatKey>> createSceneBlockTree(
		final DataSource<?, ?> source,
		final ViewFrustum viewFrustum,
		final AffineTransform3D eyeToWorldTransform,
		final int levelOfDetail,
		final int coarsestScaleLevel,
		final int finestScaleLevel,
		final CellGrid[] rendererGrids,
		final BooleanSupplier wasInterrupted)
{
	final int numScaleLevels = source.getNumMipmapLevels();

	final double maxPixelsInProjectedVoxel = levelOfDetailMaxPixels[
			Math.max(0, Math.min(levelOfDetail - MeshSettings.Defaults.Values.getMinLevelOfDetail(), levelOfDetailMaxPixels.length - 1))
		];
	LOG.debug("levelOfDetail={}, maxPixelsInProjectedVoxel={}", levelOfDetail, maxPixelsInProjectedVoxel);

	final ViewFrustumCulling[] viewFrustumCullingInSourceSpace = new ViewFrustumCulling[numScaleLevels];
	final double[] minMipmapPixelSize = new double[numScaleLevels];
	for (int i = 0; i < viewFrustumCullingInSourceSpace.length; ++i)
	{
		final AffineTransform3D sourceToWorldTransform = new AffineTransform3D();
		source.getSourceTransform(0, i, sourceToWorldTransform);

		final AffineTransform3D cameraToSourceTransform = new AffineTransform3D();
		cameraToSourceTransform.preConcatenate(eyeToWorldTransform).preConcatenate(sourceToWorldTransform.inverse());

		viewFrustumCullingInSourceSpace[i] = new ViewFrustumCulling(viewFrustum, cameraToSourceTransform);

		final double[] extractedScale = new double[3];
		Arrays.setAll(extractedScale, d -> Affine3DHelpers.extractScale(cameraToSourceTransform.inverse(), d));
		minMipmapPixelSize[i] = Arrays.stream(extractedScale).min().getAsDouble();
	}

	final double[][] sourceScales = new double[numScaleLevels][];
	Arrays.setAll(sourceScales, i -> DataSource.getScale(source, 0, i));

	final BlockTree<BlockTreeFlatKey, BlockTreeNode<BlockTreeFlatKey>> blockTree = new BlockTree<>();
	final LinkedHashMap<BlockTreeFlatKey, BlockTreeFlatKey> blockAndParentQueue = new LinkedHashMap<>();

	// start with all blocks at the lowest resolution
	final int lowestResolutionScaleLevel = numScaleLevels - 1;
	final CellGrid rendererGridAtLowestResolution = rendererGrids[lowestResolutionScaleLevel];
	final long numBlocksAtLowestResolution = Intervals.numElements(rendererGridAtLowestResolution.getGridDimensions());
	LongStream.range(0, numBlocksAtLowestResolution).forEach(blockIndex -> blockAndParentQueue.put(new BlockTreeFlatKey(lowestResolutionScaleLevel, blockIndex), null));

	while (!blockAndParentQueue.isEmpty() && !wasInterrupted.getAsBoolean())
	{
		final Iterator<Map.Entry<BlockTreeFlatKey, BlockTreeFlatKey>> it = blockAndParentQueue.entrySet().iterator();
		final Map.Entry<BlockTreeFlatKey, BlockTreeFlatKey> entry = it.next();
		it.remove();

		final BlockTreeFlatKey key = entry.getKey();
		final BlockTreeFlatKey parentKey = entry.getValue();

		final int scaleLevel = key.scaleLevel;
		final Interval blockInterval = Grids.getCellInterval(rendererGrids[scaleLevel], key.blockIndex);

		if (viewFrustumCullingInSourceSpace[scaleLevel].intersects(blockInterval))
		{
			final double distanceFromCamera = viewFrustumCullingInSourceSpace[scaleLevel].distanceFromCamera(blockInterval);
			final double screenSizeToViewPlaneRatio = viewFrustum.screenSizeToViewPlaneRatio(distanceFromCamera);
			final double screenPixelSize = screenSizeToViewPlaneRatio * minMipmapPixelSize[scaleLevel];
			LOG.debug("scaleIndex={}, screenSizeToViewPlaneRatio={}, screenPixelSize={}", scaleLevel, screenSizeToViewPlaneRatio, screenPixelSize);

			final BlockTreeNode<BlockTreeFlatKey> treeNode = new BlockTreeNode<>(parentKey, new HashSet<>(), distanceFromCamera);
			blockTree.nodes.put(key, treeNode);
			if (parentKey != null)
				blockTree.nodes.get(parentKey).children.add(key);

			// check if needed to subdivide the block
			if (scaleLevel > coarsestScaleLevel || (scaleLevel > finestScaleLevel && screenPixelSize > maxPixelsInProjectedVoxel))
			{
				final int nextScaleLevel = scaleLevel - 1;
				final CellGrid rendererNextLevelGrid = rendererGrids[nextScaleLevel];

				final double[] relativeScales = new double[3];
				Arrays.setAll(relativeScales, d -> sourceScales[scaleLevel][d] / sourceScales[nextScaleLevel][d]);

				final double[] nextScaleLevelBlockMin = new double[3], nextScaleLevelBlockMax = new double[3];
				for (int d = 0; d < 3; ++d)
				{
					nextScaleLevelBlockMin[d] = blockInterval.min(d) * relativeScales[d];
					nextScaleLevelBlockMax[d] = (blockInterval.max(d) + 1) * relativeScales[d] - 1;
				}
				final Interval nextLevelBlockInterval = Intervals.smallestContainingInterval(new FinalRealInterval(nextScaleLevelBlockMin, nextScaleLevelBlockMax));

				// find out what blocks at higher resolution intersect with this block
				final long[] intersectingNextLevelBlockIndices = Grids.getIntersectingBlocks(nextLevelBlockInterval, rendererNextLevelGrid);
				for (final long intersectingNextLevelBlockIndex : intersectingNextLevelBlockIndices)
				{
					final BlockTreeFlatKey childKey = new BlockTreeFlatKey(nextScaleLevel, intersectingNextLevelBlockIndex);
					blockAndParentQueue.put(childKey, key);
				}
			}
		}
	}

	return !wasInterrupted.getAsBoolean() ? blockTree : null;
}
 
Example #11
Source File: CatmaidJsonLoader.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
		PlatformImpl.startup(() -> {});
		final Path path = Paths.get(System.getProperty("user.home"), "Downloads", "catmaid-meshes", "Block3.json");
		final TriangleMesh mesh = new CatmaidJsonLoader().loadMesh(path);
		final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY};
		final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY};
		for (int i = 0; i < mesh.getPoints().size(); i += 3) {
			for (int d = 0; d < 3; ++d) {
				min[d] = Math.min(min[d], mesh.getPoints().get(i + d));
				max[d] = Math.max(max[d], mesh.getPoints().get(i + d));
			}
		}
		System.out.print(Arrays.toString(min) +" " + Arrays.toString(max));
		final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max));
		final MeshView mv = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE));
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		final Viewer3DFX viewer = new Viewer3DFX(800, 600);
		viewer.meshesEnabledProperty().set(true);
		mv.setOpacity(1.0);
		viewer.setInitialTransformToInterval(interval);
		final MeshView mv2 = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial());
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		mv2.setTranslateX(100);
		viewer.meshesGroup().getChildren().addAll(mv, mv2);
		Platform.setImplicitExit(true);
		Platform.runLater(() -> {
			final Scene scene = new Scene(viewer);
			final Stage stage = new Stage();
			stage.setScene(scene);
			stage.setWidth(800);
			stage.setHeight(600);
			stage.show();
		});
//		final String mesh = "<IndexedTriangleSet  index='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35'><Coordinate point='440474 99212 136120 440474 119212 136120 460474 99212 136120 460474 99212 136120 440474 119212 136120 460474 119212 136120 440474 99212 136120 460474 99212 136120 460474 99212 156120 440474 99212 136120 460474 99212 156120 440474 99212 156120 440474 119212 136120 440474 119212 156120 460474 119212 156120 440474 119212 136120 460474 119212 156120 460474 119212 136120 440474 99212 156120 460474 119212 156120 440474 119212 156120 440474 99212 156120 460474 99212 156120 460474 119212 156120 440474 99212 136120 440474 119212 156120 440474 119212 136120 440474 99212 136120 440474 99212 156120 440474 119212 156120 460474 99212 136120 460474 119212 136120 460474 99212 156120 460474 119212 136120 460474 119212 156120 460474 99212 156120'/></IndexedTriangleSet>";
//		final Document doc = Jsoup.parse(mesh);
//		System.out.println(doc);
//		System.out.println(doc.select("IndexedTriangleSet").attr("index"));
	}
 
Example #12
Source File: ObjLoader.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
		PlatformImpl.startup(() -> {});
		// https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html
//		final String objFile = "al.obj";
//		final String objFile = "diamond.obj";
		final String objFile = "alfa147.obj";
		final Path path = Paths.get(System.getProperty("user.home"), "Downloads", objFile);
		final TriangleMesh mesh = new ObjLoader().loadMesh(path);
		final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY};
		final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY};
		for (int i = 0; i < mesh.getPoints().size(); i += 3) {
			for (int d = 0; d < 3; ++d) {
				min[d] = Math.min(min[d], mesh.getPoints().get(i + d));
				max[d] = Math.max(max[d], mesh.getPoints().get(i + d));
			}
		}
		final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max));
		final MeshView mv = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE));
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		final Viewer3DFX viewer = new Viewer3DFX(800, 600);
		viewer.meshesEnabledProperty().set(true);
		mv.setOpacity(1.0);
		viewer.setInitialTransformToInterval(interval);
		final MeshView mv2 = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial());
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		mv2.setTranslateX(100);
		viewer.meshesGroup().getChildren().addAll(mv, mv2);
//		final double factor = 1;
//		final double w = 1*factor, h = 2*factor, d = 3*factor;
//		final Box box = new Box(w, h, d);
//		box.setCullFace(CullFace.NONE);
//		box.setOpacity(1.0);
//		box.setMaterial(Meshes.painteraPhongMaterial(Color.RED));
//		viewer.meshesGroup().getChildren().add(box);
		Platform.setImplicitExit(true);
		Platform.runLater(() -> {
			final Scene scene = new Scene(viewer);
			final Stage stage = new Stage();
			stage.setScene(scene);
			stage.setWidth(800);
			stage.setHeight(600);
			stage.show();
		});
	}
 
Example #13
Source File: BoundingBoxGUI.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param spimData
 * @param viewIdsToProcess
 * @param minBB
 * @param maxBB
 * @return - true if the SpimData object was modified, otherwise false
 */
public static boolean computeMaxBoundingBoxDimensions( final SpimData2 spimData, final List< ViewId > viewIdsToProcess, final double[] minBB, final double[] maxBB )
{
	for ( int d = 0; d < minBB.length; ++d )
	{
		minBB[ d ] = Double.MAX_VALUE;
		maxBB[ d ] = -Double.MAX_VALUE;
	}

	boolean changed = false;
	IOFunctions.println( new Date( System.currentTimeMillis() ) + ": Estimating Bounding Box for Fusion. If size of images is not known (they were never opened before), some of them need to be opened once to determine their size.");

	for ( final ViewId viewId : viewIdsToProcess )
	{
		final ViewDescription viewDescription = spimData.getSequenceDescription().getViewDescription( 
				viewId.getTimePointId(), viewId.getViewSetupId() );

		if ( !viewDescription.isPresent() )
			continue;

		if ( !viewDescription.getViewSetup().hasSize() )
			changed = true;

		final Dimensions size = ViewSetupUtils.getSizeOrLoad( viewDescription.getViewSetup(), viewDescription.getTimePoint(), spimData.getSequenceDescription().getImgLoader() );
		final double[] min = new double[]{ 0, 0, 0 };
		final double[] max = new double[]{
				size.dimension( 0 ) - 1,
				size.dimension( 1 ) - 1,
				size.dimension( 2 ) - 1 };
		
		final ViewRegistration r = spimData.getViewRegistrations().getViewRegistration( viewId );
		r.updateModel();
		final FinalRealInterval interval = r.getModel().estimateBounds( new FinalRealInterval( min, max ) );
		
		for ( int d = 0; d < minBB.length; ++d )
		{
			minBB[ d ] = Math.min( minBB[ d ], interval.realMin( d ) );
			maxBB[ d ] = Math.max( maxBB[ d ], interval.realMax( d ) );
		}
	}

	return changed;
}
 
Example #14
Source File: Grids.java    From paintera with GNU General Public License v2.0 3 votes vote down vote up
/**
 *
 * Snap {@code min}, {@code max} to {@code cellGrid}, i.e. increase/decrease min/max such that
 * min/max are integer multiples of block size/cell size. The snapped interval is restricted
 * to the interval defined by {@code cellGrid}.
 *
 * @param min top-left corner of interval
 * @param max bottom-right corner of interval
 * @param cellGrid defines the block size/cell size to which to snap
 * @return new interval that is aligned with block size/cell size of {@code cellGrid}
 */
public static Interval snapToGrid(
		final double[] min,
		final double[] max,
		final CellGrid cellGrid
)
{
	return snapToGrid(new FinalRealInterval(min, max), cellGrid);
}