Skip to content

Instantly share code, notes, and snippets.

@olegknyazev
Created October 28, 2018 14:52
Show Gist options
  • Save olegknyazev/0eb8c4599f1440a78d8dfbd6a822c1bc to your computer and use it in GitHub Desktop.
Save olegknyazev/0eb8c4599f1440a78d8dfbd6a822c1bc to your computer and use it in GitHub Desktop.
About Formatting: The empty line dilemma
def copyFrom
(source: ReadOnlySpace[ShapeT],
sourceRegion: CellBox = null,
destination: Int3 = this.lower): Unit = {
val sourceBounds =
if (sourceRegion != null) {
Check.argument(source.bounds contains sourceRegion)
sourceRegion
} else
source.bounds
val translation = destination - sourceBounds.lower
Check.argument(bounds contains (sourceBounds move translation),
s"Destination region (${sourceBounds move translation}) doesn't fit within destination space")
Check.argument(source zoneIsolated sourceBounds,
"Some shapes in source space intersects boundaries of source region")
for (cell <- sourceBounds.iterateCells) {
val shape = source.at(cell)
if (shape != null)
insertOrReplace(source.centerOfShapeAt(cell) + translation, shape)
else
remove(cell + translation)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment