icplot 0.2.4__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {icplot-0.2.4/src/icplot.egg-info → icplot-0.3.1}/PKG-INFO +66 -18
- icplot-0.3.1/README.md +103 -0
- {icplot-0.2.4 → icplot-0.3.1}/pyproject.toml +14 -7
- icplot-0.3.1/setup.cfg +4 -0
- {icplot-0.2.4/src/icplot/gantt → icplot-0.3.1/src/icplot/charts}/gantt.py +2 -3
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/charts}/tree.py +2 -3
- icplot-0.3.1/src/icplot/converter/__init__.py +3 -0
- icplot-0.3.1/src/icplot/converter/cli.py +27 -0
- icplot-0.3.1/src/icplot/converter/convert.py +32 -0
- icplot-0.2.4/src/icplot/image_utils.py → icplot-0.3.1/src/icplot/converter/image.py +26 -10
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/geometry/base.py +6 -0
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/edge.py +1 -1
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/mesh.py +30 -4
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/openfoam/blockmesh.py +2 -3
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/openfoam/polymesh.py +4 -6
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/shapes.py +87 -7
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/vertex.py +16 -1
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/geometry/shapes.py +29 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/geometry/transform.py +2 -2
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/graph/__init__.py +3 -4
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/graph/plot.py +2 -53
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/graph/series.py +3 -4
- icplot-0.3.1/src/icplot/main_cli.py +39 -0
- icplot-0.3.1/src/icplot/renderer/__init__.py +5 -0
- icplot-0.3.1/src/icplot/renderer/charts/pgfgantt.py +71 -0
- icplot-0.2.4/src/icplot/gantt/gantt_renderer.py → icplot-0.3.1/src/icplot/renderer/charts/svggantt.py +8 -6
- icplot-0.3.1/src/icplot/renderer/cli.py +58 -0
- icplot-0.3.1/src/icplot/renderer/config.py +41 -0
- icplot-0.3.1/src/icplot/renderer/formats/__init__.py +1 -0
- icplot-0.3.1/src/icplot/renderer/formats/mermaid.py +47 -0
- icplot-0.3.1/src/icplot/renderer/formats/plantuml.py +37 -0
- icplot-0.3.1/src/icplot/renderer/formats/tex.py +120 -0
- icplot-0.3.1/src/icplot/renderer/graph/__init__.py +3 -0
- icplot-0.3.1/src/icplot/renderer/graph/color.py +17 -0
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/renderer}/graph/matplotlib.py +15 -7
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/renderer}/graph/mpl.py +8 -8
- icplot-0.2.4/src/icplot/graph/generator.py → icplot-0.3.1/src/icplot/renderer/graph/renderer.py +43 -8
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/renderer}/graph/vtk.py +2 -3
- icplot-0.3.1/src/icplot/renderer/render.py +149 -0
- icplot-0.2.4/src/icplot/cairo_interface.py → icplot-0.3.1/src/icplot/renderer/scene/cairo.py +5 -5
- {icplot-0.2.4/src/icplot/graph → icplot-0.3.1/src/icplot/renderer}/video.py +2 -3
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/scene.py +1 -1
- icplot-0.3.1/src/icplot/theme/__init__.py +0 -0
- icplot-0.3.1/src/icplot/theme/cli.py +50 -0
- icplot-0.3.1/src/icplot/theme/color.py +97 -0
- icplot-0.3.1/src/icplot/theme/templates/puml.j2 +91 -0
- icplot-0.3.1/src/icplot/theme/templates/tikz.j2 +100 -0
- icplot-0.3.1/src/icplot/theme/theme.json +81 -0
- icplot-0.3.1/src/icplot/theme/theme.py +117 -0
- icplot-0.3.1/src/icplot/theme/theme_generator.py +119 -0
- {icplot-0.2.4 → icplot-0.3.1/src/icplot.egg-info}/PKG-INFO +66 -18
- icplot-0.3.1/src/icplot.egg-info/SOURCES.txt +80 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot.egg-info/requires.txt +2 -0
- icplot-0.2.4/test/test_cairo_interface.py → icplot-0.3.1/test/test_cairo.py +5 -5
- {icplot-0.2.4 → icplot-0.3.1}/test/test_gantt_chart.py +1 -3
- {icplot-0.2.4 → icplot-0.3.1}/test/test_geometry.py +1 -1
- icplot-0.2.4/test/test_image_utils.py → icplot-0.3.1/test/test_image.py +1 -1
- {icplot-0.2.4 → icplot-0.3.1}/test/test_line_plots.py +2 -2
- icplot-0.3.1/test/test_mermaid.py +36 -0
- {icplot-0.2.4 → icplot-0.3.1}/test/test_meshing.py +50 -12
- {icplot-0.2.4 → icplot-0.3.1}/test/test_openfoam.py +2 -2
- {icplot-0.2.4 → icplot-0.3.1}/test/test_plot_group.py +3 -2
- {icplot-0.2.4 → icplot-0.3.1}/test/test_polymesh.py +24 -16
- icplot-0.3.1/test/test_tex.py +26 -0
- {icplot-0.2.4 → icplot-0.3.1}/test/test_tree.py +2 -2
- icplot-0.2.4/README.md +0 -57
- icplot-0.2.4/setup.cfg +0 -9
- icplot-0.2.4/src/icplot/color.py +0 -50
- icplot-0.2.4/src/icplot/convert.py +0 -51
- icplot-0.2.4/src/icplot/gantt/__init__.py +0 -1
- icplot-0.2.4/src/icplot/gantt/pgfgantt.py +0 -15
- icplot-0.2.4/src/icplot/main_cli.py +0 -88
- icplot-0.2.4/src/icplot/mermaid.py +0 -39
- icplot-0.2.4/src/icplot/tex.py +0 -78
- icplot-0.2.4/src/icplot/trace/__init__.py +0 -1
- icplot-0.2.4/src/icplot.egg-info/SOURCES.txt +0 -66
- icplot-0.2.4/test/test_mermaid.py +0 -24
- icplot-0.2.4/test/test_tex.py +0 -23
- {icplot-0.2.4 → icplot-0.3.1}/LICENSE +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/__init__.py +0 -0
- icplot-0.2.4/src/icplot/py.typed → icplot-0.3.1/src/icplot/charts/__init__.py +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/geometry/__init__.py +0 -0
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/__init__.py +1 -1
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/cell.py +0 -0
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/openfoam/__init__.py +1 -1
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/openfoam/foamfile.py +0 -0
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/operations.py +1 -1
- {icplot-0.2.4/src/icplot → icplot-0.3.1/src/icplot/geometry}/mesh/vtk.py +2 -2
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/geometry/operations.py +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/graph/axis.py +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot/graph/plot_group.py +1 -1
- /icplot-0.2.4/src/icplot/trace/trace.py → /icplot-0.3.1/src/icplot/py.typed +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot.egg-info/dependency_links.txt +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot.egg-info/entry_points.txt +0 -0
- {icplot-0.2.4 → icplot-0.3.1}/src/icplot.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: icplot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Utilities for generating plots and graphics for technical reports.
|
|
5
5
|
Author-email: "James Grogan, Irish Centre for High End Computing" <james.grogan@ichec.ie>
|
|
6
6
|
Project-URL: Repository, https://git.ichec.ie/performance/toolshed/icplot
|
|
@@ -21,11 +21,13 @@ Requires-Dist: moviepy
|
|
|
21
21
|
Requires-Dist: scipy
|
|
22
22
|
Requires-Dist: iccore==0.2.3
|
|
23
23
|
Requires-Dist: graphviz
|
|
24
|
+
Requires-Dist: Jinja2
|
|
24
25
|
Provides-Extra: test
|
|
25
26
|
Requires-Dist: pytest; extra == "test"
|
|
26
27
|
Requires-Dist: pytest-cov; extra == "test"
|
|
27
28
|
Requires-Dist: pytest-sugar; extra == "test"
|
|
28
29
|
Requires-Dist: black; extra == "test"
|
|
30
|
+
Requires-Dist: isort; extra == "test"
|
|
29
31
|
Requires-Dist: mypy; extra == "test"
|
|
30
32
|
Requires-Dist: flake8; extra == "test"
|
|
31
33
|
Requires-Dist: pylint; extra == "test"
|
|
@@ -36,16 +38,18 @@ Dynamic: license-file
|
|
|
36
38
|
|
|
37
39
|
# icplot
|
|
38
40
|
|
|
39
|
-
This is a library used at [The Irish Centre for High End Computing (ICHEC)](https://www.ichec.ie) for generating plots and graphics for technical documents.
|
|
41
|
+
This is a library used at [The Irish Centre for High End Computing (ICHEC)](https://www.ichec.ie) for generating plots, diagrams and other graphics for technical documents.
|
|
40
42
|
|
|
41
43
|
# Features #
|
|
42
44
|
|
|
43
|
-
The project has
|
|
45
|
+
The project has three primary modules:
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
`converter`: Converts between image formats, such as pdf, svg and png
|
|
48
|
+
`renderer`: Render text based inputs as svg, pdf or png images or videos
|
|
49
|
+
`theme`: Generate and apply themes from a design system
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Converter ##
|
|
49
53
|
|
|
50
54
|
To covert between image formats you can do:
|
|
51
55
|
|
|
@@ -53,24 +57,68 @@ To covert between image formats you can do:
|
|
|
53
57
|
icplot convert --source my_image.svg --target my_image.png
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
Supported conversions are:
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
* svg -> png
|
|
63
|
+
* svg -> pdf
|
|
64
|
+
* pdf -> png
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
``` shell
|
|
65
|
-
icplot convert --source my_mermaid.mmd
|
|
66
|
-
```
|
|
66
|
+
## Renderer ##
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Render a range of text based formats to images or videos. For example,
|
|
69
69
|
|
|
70
70
|
``` shell
|
|
71
|
-
icplot
|
|
71
|
+
icplot render --file uml_diagram.puml
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
renders the PlantUML file to png and svg.
|
|
75
|
+
|
|
76
|
+
Supported render inputs and targets are:
|
|
77
|
+
|
|
78
|
+
* PlantUml
|
|
79
|
+
* SVG
|
|
80
|
+
* PNG
|
|
81
|
+
* Latex/Tikz
|
|
82
|
+
* PDF
|
|
83
|
+
* SVG
|
|
84
|
+
* PNG
|
|
85
|
+
* Mermaid
|
|
86
|
+
* SVG
|
|
87
|
+
* PNG
|
|
88
|
+
* Custom JSON
|
|
89
|
+
* Graph
|
|
90
|
+
* Backends:
|
|
91
|
+
* Matplotlib
|
|
92
|
+
* VTK
|
|
93
|
+
* Output formats:
|
|
94
|
+
* SVG
|
|
95
|
+
* PNG
|
|
96
|
+
* MP4
|
|
97
|
+
* Tree
|
|
98
|
+
* Backends:
|
|
99
|
+
* Graphviz
|
|
100
|
+
* Output formats:
|
|
101
|
+
* SVG
|
|
102
|
+
* PNG
|
|
103
|
+
* Gantt
|
|
104
|
+
* Backends:
|
|
105
|
+
* Cairo
|
|
106
|
+
* PgfGantt
|
|
107
|
+
* Output formats:
|
|
108
|
+
* SVG
|
|
109
|
+
* PNG
|
|
110
|
+
* Scene
|
|
111
|
+
* Backends:
|
|
112
|
+
* Cairo
|
|
113
|
+
* VTK
|
|
114
|
+
* Output formats:
|
|
115
|
+
* SVG
|
|
116
|
+
* VTK
|
|
117
|
+
|
|
118
|
+
## Themes ##
|
|
119
|
+
|
|
120
|
+
The library supports themeing with an Angular Material 3 motivated design system. Plots can be themed by adapting a version of `theme.json` included in this module's source. Currently Tikz and PlantUML support themeing.
|
|
121
|
+
|
|
74
122
|
# Installation #
|
|
75
123
|
|
|
76
124
|
The package is available on PyPI. For a minimal installation you can do:
|
icplot-0.3.1/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# icplot
|
|
2
|
+
|
|
3
|
+
This is a library used at [The Irish Centre for High End Computing (ICHEC)](https://www.ichec.ie) for generating plots, diagrams and other graphics for technical documents.
|
|
4
|
+
|
|
5
|
+
# Features #
|
|
6
|
+
|
|
7
|
+
The project has three primary modules:
|
|
8
|
+
|
|
9
|
+
`converter`: Converts between image formats, such as pdf, svg and png
|
|
10
|
+
`renderer`: Render text based inputs as svg, pdf or png images or videos
|
|
11
|
+
`theme`: Generate and apply themes from a design system
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Converter ##
|
|
15
|
+
|
|
16
|
+
To covert between image formats you can do:
|
|
17
|
+
|
|
18
|
+
``` shell
|
|
19
|
+
icplot convert --source my_image.svg --target my_image.png
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Supported conversions are:
|
|
23
|
+
|
|
24
|
+
* svg -> png
|
|
25
|
+
* svg -> pdf
|
|
26
|
+
* pdf -> png
|
|
27
|
+
|
|
28
|
+
## Renderer ##
|
|
29
|
+
|
|
30
|
+
Render a range of text based formats to images or videos. For example,
|
|
31
|
+
|
|
32
|
+
``` shell
|
|
33
|
+
icplot render --file uml_diagram.puml
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
renders the PlantUML file to png and svg.
|
|
37
|
+
|
|
38
|
+
Supported render inputs and targets are:
|
|
39
|
+
|
|
40
|
+
* PlantUml
|
|
41
|
+
* SVG
|
|
42
|
+
* PNG
|
|
43
|
+
* Latex/Tikz
|
|
44
|
+
* PDF
|
|
45
|
+
* SVG
|
|
46
|
+
* PNG
|
|
47
|
+
* Mermaid
|
|
48
|
+
* SVG
|
|
49
|
+
* PNG
|
|
50
|
+
* Custom JSON
|
|
51
|
+
* Graph
|
|
52
|
+
* Backends:
|
|
53
|
+
* Matplotlib
|
|
54
|
+
* VTK
|
|
55
|
+
* Output formats:
|
|
56
|
+
* SVG
|
|
57
|
+
* PNG
|
|
58
|
+
* MP4
|
|
59
|
+
* Tree
|
|
60
|
+
* Backends:
|
|
61
|
+
* Graphviz
|
|
62
|
+
* Output formats:
|
|
63
|
+
* SVG
|
|
64
|
+
* PNG
|
|
65
|
+
* Gantt
|
|
66
|
+
* Backends:
|
|
67
|
+
* Cairo
|
|
68
|
+
* PgfGantt
|
|
69
|
+
* Output formats:
|
|
70
|
+
* SVG
|
|
71
|
+
* PNG
|
|
72
|
+
* Scene
|
|
73
|
+
* Backends:
|
|
74
|
+
* Cairo
|
|
75
|
+
* VTK
|
|
76
|
+
* Output formats:
|
|
77
|
+
* SVG
|
|
78
|
+
* VTK
|
|
79
|
+
|
|
80
|
+
## Themes ##
|
|
81
|
+
|
|
82
|
+
The library supports themeing with an Angular Material 3 motivated design system. Plots can be themed by adapting a version of `theme.json` included in this module's source. Currently Tikz and PlantUML support themeing.
|
|
83
|
+
|
|
84
|
+
# Installation #
|
|
85
|
+
|
|
86
|
+
The package is available on PyPI. For a minimal installation you can do:
|
|
87
|
+
|
|
88
|
+
``` shell
|
|
89
|
+
pip install icplot
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For full functionality, particularly conversion of image formats, `imagemagick` and `cairo` are required. On Mac you can install them with:
|
|
93
|
+
|
|
94
|
+
``` shell
|
|
95
|
+
brew install imagemagick cairo
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
# Copyright #
|
|
99
|
+
|
|
100
|
+
Copyright 2024 Irish Centre for High End Computing
|
|
101
|
+
|
|
102
|
+
The software in this repository can be used under the conditions of the GPLv3+ license, which is available for reading in the accompanying LICENSE file.
|
|
103
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "icplot"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.1"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name="James Grogan, Irish Centre for High End Computing", email="james.grogan@ichec.ie" },
|
|
6
6
|
]
|
|
@@ -22,7 +22,8 @@ dependencies = ["wand",
|
|
|
22
22
|
"moviepy",
|
|
23
23
|
"scipy",
|
|
24
24
|
"iccore==0.2.3",
|
|
25
|
-
"graphviz"
|
|
25
|
+
"graphviz",
|
|
26
|
+
"Jinja2"]
|
|
26
27
|
|
|
27
28
|
[project.urls]
|
|
28
29
|
Repository = "https://git.ichec.ie/performance/toolshed/icplot"
|
|
@@ -34,6 +35,7 @@ test = [
|
|
|
34
35
|
"pytest-cov",
|
|
35
36
|
"pytest-sugar",
|
|
36
37
|
"black",
|
|
38
|
+
"isort",
|
|
37
39
|
"mypy",
|
|
38
40
|
"flake8",
|
|
39
41
|
"pylint"
|
|
@@ -52,7 +54,7 @@ build-backend = "setuptools.build_meta"
|
|
|
52
54
|
icplot = "icplot.main_cli:main_cli"
|
|
53
55
|
|
|
54
56
|
[tool.setuptools.package-data]
|
|
55
|
-
"icplot" = ["py.typed", "controlDict"]
|
|
57
|
+
"icplot" = ["py.typed", "controlDict", "theme/theme.json", "theme/templates/*.j2"]
|
|
56
58
|
|
|
57
59
|
[tool.setuptools.packages.find]
|
|
58
60
|
where = ["src"]
|
|
@@ -122,16 +124,21 @@ commands = [["pytest", "test"]]
|
|
|
122
124
|
[tool.tox.env.format_apply]
|
|
123
125
|
description = "Run Format Apply"
|
|
124
126
|
skip_install = true
|
|
125
|
-
deps = ["black"]
|
|
126
|
-
commands = [["black", "src"], ["black", "test"]]
|
|
127
|
+
deps = ["black", "isort"]
|
|
128
|
+
commands = [["black", "src"], ["black", "test"], ["isort", "src"], ["isort", "test"]]
|
|
127
129
|
|
|
128
130
|
[tool.tox.env.format_check]
|
|
129
131
|
description = "Run Format Check"
|
|
130
132
|
skip_install = true
|
|
131
|
-
deps = ["black"]
|
|
133
|
+
deps = ["black", "isort"]
|
|
132
134
|
commands = [
|
|
133
135
|
["black", "--check", "--diff", "src"],
|
|
134
|
-
["black", "--check", "--diff", "test"]
|
|
136
|
+
["black", "--check", "--diff", "test"],
|
|
137
|
+
["isort", "--check", "--diff", "src"],
|
|
138
|
+
["isort", "--check", "--diff", "test"]]
|
|
139
|
+
|
|
140
|
+
[tool.isort]
|
|
141
|
+
profile = "black"
|
|
135
142
|
|
|
136
143
|
[tool.tox.env.lint]
|
|
137
144
|
description = "Run Linter"
|
icplot-0.3.1/setup.cfg
ADDED
|
@@ -4,11 +4,10 @@ This module represents a gantt chard
|
|
|
4
4
|
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
|
|
7
|
-
from pydantic import BaseModel
|
|
8
|
-
|
|
9
7
|
from iccore.project import Milestone
|
|
8
|
+
from pydantic import BaseModel
|
|
10
9
|
|
|
11
|
-
from icplot.color import Color
|
|
10
|
+
from icplot.theme.color import Color
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
class GanttChart(BaseModel, frozen=True):
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import os
|
|
2
3
|
import shutil
|
|
3
|
-
import logging
|
|
4
4
|
from dataclasses import dataclass
|
|
5
|
-
from typing import Callable
|
|
6
5
|
from pathlib import Path
|
|
6
|
+
from typing import Callable
|
|
7
7
|
|
|
8
8
|
import graphviz
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
logger = logging.getLogger(__name__)
|
|
12
11
|
|
|
13
12
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from .convert import convert
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def convert_cli(args):
|
|
7
|
+
|
|
8
|
+
source = args.source.resolve()
|
|
9
|
+
target = Path(args.target).resolve() if args.target else None
|
|
10
|
+
convert(source, target)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def register_parser(subparsers):
|
|
14
|
+
|
|
15
|
+
convert_parser = subparsers.add_parser("convert")
|
|
16
|
+
convert_parser.add_argument(
|
|
17
|
+
"source",
|
|
18
|
+
type=Path,
|
|
19
|
+
help="Path to file to be converted from",
|
|
20
|
+
)
|
|
21
|
+
convert_parser.add_argument(
|
|
22
|
+
"--target",
|
|
23
|
+
type=str,
|
|
24
|
+
default="",
|
|
25
|
+
help="Path to file to be converted to",
|
|
26
|
+
)
|
|
27
|
+
convert_parser.set_defaults(func=convert_cli)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module supporting conversion between image formats
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from .image import pdf_to_png, svg_to_pdf, svg_to_png
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def convert(source: Path, target: Path | None = None):
|
|
14
|
+
"""
|
|
15
|
+
Convert between image formats using the source and target
|
|
16
|
+
file extensions as format hints.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
logger.info("Converting %s", source)
|
|
20
|
+
|
|
21
|
+
if source.suffix == ".pdf":
|
|
22
|
+
pdf_to_png(source, target)
|
|
23
|
+
elif source.suffix == ".svg":
|
|
24
|
+
if target:
|
|
25
|
+
if target.suffix == ".png":
|
|
26
|
+
svg_to_png(source, target)
|
|
27
|
+
elif target.suffix == ".pdf":
|
|
28
|
+
svg_to_pdf(source, target)
|
|
29
|
+
else:
|
|
30
|
+
svg_to_png(source)
|
|
31
|
+
|
|
32
|
+
logger.info("Finished conversion")
|
|
@@ -5,34 +5,36 @@ formats
|
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
7
|
import os
|
|
8
|
+
import shutil
|
|
9
|
+
import subprocess
|
|
8
10
|
from pathlib import Path
|
|
9
11
|
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
10
14
|
_HAS_WAND = True
|
|
11
15
|
try:
|
|
12
|
-
from wand.image import Image
|
|
13
16
|
from wand.color import Color
|
|
17
|
+
from wand.image import Image
|
|
14
18
|
except ImportError as e:
|
|
15
|
-
|
|
16
|
-
"Disabling Wand stupport. Failed to load with: %s", e
|
|
17
|
-
)
|
|
19
|
+
logger.debug("wand not available: %s", e)
|
|
18
20
|
_HAS_WAND = False
|
|
19
21
|
|
|
20
22
|
_HAS_CAIRO_SVG = True
|
|
21
23
|
try:
|
|
22
24
|
import cairosvg
|
|
23
25
|
except ImportError as e:
|
|
24
|
-
|
|
25
|
-
"Disabling CairoSVG stupport. Failed to load with: %s", e
|
|
26
|
-
)
|
|
26
|
+
logger.debug("cairosvg not available: %s", e)
|
|
27
27
|
_HAS_CAIRO_SVG = False
|
|
28
28
|
|
|
29
|
-
logger = logging.getLogger(__name__)
|
|
30
|
-
|
|
31
29
|
|
|
32
30
|
def has_wand() -> bool:
|
|
33
31
|
return _HAS_WAND
|
|
34
32
|
|
|
35
33
|
|
|
34
|
+
def has_magick() -> bool:
|
|
35
|
+
return bool(shutil.which("magick"))
|
|
36
|
+
|
|
37
|
+
|
|
36
38
|
def has_cairo_svg() -> bool:
|
|
37
39
|
return _HAS_CAIRO_SVG
|
|
38
40
|
|
|
@@ -43,13 +45,27 @@ def _get_out_filename(source: Path, target: Path | None, extension: str) -> Path
|
|
|
43
45
|
return source.parent / f"{source.stem}.{extension}"
|
|
44
46
|
|
|
45
47
|
|
|
48
|
+
def _pdf_to_png(source: Path, target: Path | None = None, resolution: int = 300):
|
|
49
|
+
|
|
50
|
+
outfile = _get_out_filename(source, target, "png")
|
|
51
|
+
os.makedirs(outfile.parent, exist_ok=True)
|
|
52
|
+
cmd = (
|
|
53
|
+
f"magick -density {resolution} -background white -alpha off {source} {outfile}"
|
|
54
|
+
)
|
|
55
|
+
subprocess.run(cmd, shell=True, check=True)
|
|
56
|
+
|
|
57
|
+
|
|
46
58
|
def pdf_to_png(source: Path, target: Path | None = None, resolution: int = 300):
|
|
47
59
|
"""
|
|
48
60
|
Convert a pdf to png with white background
|
|
49
61
|
"""
|
|
50
62
|
|
|
51
63
|
if not has_wand():
|
|
52
|
-
|
|
64
|
+
if has_magick():
|
|
65
|
+
_pdf_to_png(source, target, resolution)
|
|
66
|
+
return
|
|
67
|
+
else:
|
|
68
|
+
raise RuntimeError("Loading Wand failed - no pdf to png support")
|
|
53
69
|
|
|
54
70
|
outfile = _get_out_filename(source, target, "png")
|
|
55
71
|
os.makedirs(outfile.parent, exist_ok=True)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
2
3
|
from dataclasses import dataclass
|
|
3
4
|
|
|
4
5
|
import numpy as np
|
|
5
6
|
|
|
7
|
+
from .operations import get_point_distance
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
@dataclass(frozen=True)
|
|
8
11
|
class Vector:
|
|
@@ -47,6 +50,9 @@ class Point:
|
|
|
47
50
|
def subtract(self, v: Vector) -> Vector:
|
|
48
51
|
return Vector(self.x - v.x, self.y - v.y, self.z - v.z)
|
|
49
52
|
|
|
53
|
+
def get_distance(self, p: Point) -> float:
|
|
54
|
+
return get_point_distance(p.as_array(), self.as_array())
|
|
55
|
+
|
|
50
56
|
|
|
51
57
|
@dataclass(frozen=True)
|
|
52
58
|
class Bounds:
|
|
@@ -4,13 +4,14 @@ over performance. Consider something else for high performance meshing.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
|
+
|
|
7
8
|
from dataclasses import dataclass
|
|
8
9
|
|
|
9
|
-
from icplot.geometry import Point,
|
|
10
|
+
from icplot.geometry import Bounds, Point, Shape, Transform, Vector
|
|
10
11
|
|
|
11
|
-
from .vertex import Vertex, find_closest_vertex
|
|
12
12
|
from .cell import Cell, flip_normals
|
|
13
13
|
from .edge import Edge, contains_point, get_distance
|
|
14
|
+
from .vertex import Vertex, find_closest_vertex
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
@dataclass(frozen=True)
|
|
@@ -49,7 +50,7 @@ class Mesh:
|
|
|
49
50
|
ymin = min(ymin, v.y)
|
|
50
51
|
ymax = max(ymax, v.y)
|
|
51
52
|
zmin = min(zmin, v.z)
|
|
52
|
-
zmax =
|
|
53
|
+
zmax = max(zmax, v.z)
|
|
53
54
|
return Bounds(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax)
|
|
54
55
|
|
|
55
56
|
def flip_normals(self) -> Mesh:
|
|
@@ -67,8 +68,28 @@ class Mesh:
|
|
|
67
68
|
vertices=tuple(v.translate(delta) for v in self.vertices), cells=self.cells
|
|
68
69
|
)
|
|
69
70
|
|
|
70
|
-
def
|
|
71
|
+
def scale_by(self, factor: float) -> Mesh:
|
|
72
|
+
return Mesh(
|
|
73
|
+
vertices=tuple(v.scale(factor) for v in self.vertices), cells=self.cells
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def rotate_to(self, vec: Vector) -> Mesh:
|
|
77
|
+
return Mesh(
|
|
78
|
+
vertices=tuple(v.rotate_to(vec) for v in self.vertices), cells=self.cells
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def move_by(
|
|
82
|
+
self, x: float, y: float, z: float, selection: list[int] | None = None
|
|
83
|
+
) -> Mesh:
|
|
71
84
|
delta = Vector(x, y, z)
|
|
85
|
+
if selection:
|
|
86
|
+
return Mesh(
|
|
87
|
+
vertices=tuple(
|
|
88
|
+
v.translate(delta) if v.id in selection else v.copy()
|
|
89
|
+
for v in self.vertices
|
|
90
|
+
),
|
|
91
|
+
cells=self.cells,
|
|
92
|
+
)
|
|
72
93
|
return Mesh(
|
|
73
94
|
vertices=tuple(v.translate(delta) for v in self.vertices), cells=self.cells
|
|
74
95
|
)
|
|
@@ -105,3 +126,8 @@ class Mesh:
|
|
|
105
126
|
vertices=tuple(Vertex(v.x, v.y, v.z, v.id) for v in self.vertices),
|
|
106
127
|
cells=tuple(Cell(c.vertices, c.type) for c in self.cells),
|
|
107
128
|
)
|
|
129
|
+
|
|
130
|
+
def select_region(self, region: Shape) -> list[int]:
|
|
131
|
+
return [
|
|
132
|
+
v.id for v in self.vertices if region.contains_point(Point(v.x, v.y, v.z))
|
|
133
|
+
]
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Meshing utilities for use in openfoam
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import os
|
|
5
6
|
import shutil
|
|
6
7
|
import subprocess
|
|
7
|
-
import os
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import cast
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
from icplot.mesh import Edge, HexCell, Mesh, Patch
|
|
11
|
+
from icplot.geometry.mesh import Edge, HexCell, Mesh, Patch
|
|
13
12
|
|
|
14
13
|
from .foamfile import FoamFile, write_header
|
|
15
14
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from pathlib import Path
|
|
3
2
|
from functools import cmp_to_key
|
|
3
|
+
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
from icplot.geometry import Point
|
|
6
|
-
from icplot.mesh import
|
|
6
|
+
from icplot.geometry.mesh import Mesh, Vertex, get_hex_faces
|
|
7
7
|
|
|
8
|
-
from .foamfile import
|
|
8
|
+
from .foamfile import FoamFile, read_foamfile, write_header
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@dataclass(frozen=True)
|
|
@@ -65,10 +65,8 @@ class PolymeshPatch:
|
|
|
65
65
|
|
|
66
66
|
def read_polymesh(path: Path) -> Polymesh:
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
_ = read_foamfile(path / "points")
|
|
69
69
|
# faces_file = read_foamfile(path / "faces")
|
|
70
|
-
print(points_file)
|
|
71
|
-
# print(faces_file)
|
|
72
70
|
return Polymesh((), (), ())
|
|
73
71
|
|
|
74
72
|
|