forked from abey79/vpype
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for begin/end blocks, with repeat and matrix block proc…
…essors
- Loading branch information
Showing
6 changed files
with
192 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
.DS_Store | ||
/.idea | ||
__pycache__ | ||
*.egg-info | ||
*.egg-info | ||
/pip-wheel-metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .vpype import cli | ||
# from .vpype import cli | ||
import vpype | ||
|
||
if __name__ == '__main__': | ||
cli() | ||
vpype.cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from typing import Tuple | ||
|
||
import click | ||
from shapely import affinity | ||
|
||
from .vpype import cli, block_processor, BlockProcessor, execute_processors, merge_mls | ||
|
||
|
||
@cli.command("matrix") | ||
@click.option("-n", "--number", nargs=2, default=(2, 2), type=int) | ||
@click.option("-d", "--delta", nargs=2, default=(100, 100), type=float) | ||
@block_processor | ||
class MatrixBlockProcessor(BlockProcessor): | ||
""" | ||
Arrange generated geometries on a cartesian matrix | ||
""" | ||
|
||
def __init__(self, number: Tuple[int, int], delta: Tuple[float, float]): | ||
self.number = number | ||
self.delta = delta | ||
|
||
def process(self, processors): | ||
mls_arr = [] | ||
for i in range(self.number[0]): | ||
for j in range(self.number[1]): | ||
mls = execute_processors(processors) | ||
mls_arr.append(affinity.translate(mls, self.delta[0] * i, self.delta[1] * j)) | ||
|
||
return merge_mls(mls_arr) | ||
|
||
|
||
@cli.command("repeat") | ||
@click.option("-n", "--number", default=1, type=int) | ||
@block_processor | ||
class RepeatBlockProcessor(BlockProcessor): | ||
""" | ||
Overlap generated geometries on top of each other. | ||
""" | ||
|
||
def __init__(self, number: int): | ||
self.number = number | ||
|
||
def process(self, processors): | ||
return merge_mls([execute_processors(processors) for _ in range(self.number)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters