Skip to content

Commit c68dc15

Browse files
AlejandroFernandezLucespre-commit-ci[bot]pyansys-ci-botRobPasMue
authored
feat: Adapt to ansys-visualizer (#959)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent b5cdb22 commit c68dc15

File tree

30 files changed

+247
-1705
lines changed

30 files changed

+247
-1705
lines changed

.github/workflows/ci_cd.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ env:
1717
ANSRV_GEO_PORT: 700
1818
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
1919
GEO_CONT_NAME: ans_geo
20-
RESET_IMAGE_CACHE: 0
20+
RESET_IMAGE_CACHE: 1
2121
IS_WORKFLOW_RUNNING: True
2222
ARTIFACTORY_VERSION: v242
2323
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
2424
MEILISEARCH_HOST_URL: ${{ vars.MEILISEARCH_HOST_URL }}
2525
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
26+
PYANSYS_VISUALIZER_TESTMODE: true
2627

2728
concurrency:
2829
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/nightly_docker_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
ANSRV_GEO_PORT: 710
1212
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
1313
GEO_CONT_NAME: ans_geo_nightly
14+
PYANSYS_VISUALIZER_TESTMODE: true
1415

1516
concurrency:
1617
group: ${{ github.workflow }}-${{ github.ref }}

doc/changelog.d/959.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: Adapt to ansys-visualizer

doc/source/examples/01_getting_started/05_plotter_picker.mystnb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ from ansys.geometry.core.connection.defaults import GEOMETRY_SERVICE_DOCKER_IMAG
3636
from ansys.geometry.core.connection.docker_instance import LocalDockerInstance
3737
from ansys.geometry.core.math import Point2D
3838
from ansys.geometry.core.misc import UNITS
39-
from ansys.geometry.core.plotting import PlotterHelper
39+
from ansys.geometry.core.plotting import GeomPlotter
4040
from ansys.geometry.core.sketch import Sketch
4141
```
4242

@@ -158,25 +158,26 @@ You can simply plot one of the created objects.
158158

159159
```{code-cell} ipython3
160160

161-
plotter = PlotterHelper()
162-
plotter.plot(box_body2)
161+
plotter = GeomPlotter()
162+
plotter.show(box_body2)
163163
```
164164

165165
You can plot the whole list of objects.
166166

167167
```{code-cell} ipython3
168168

169-
plotter = PlotterHelper()
170-
plotter.plot(plot_list)
169+
plotter = GeomPlotter()
170+
plotter.show(plot_list)
171171
```
172172

173173
The Python visualizer is used by default. However, you can also use
174174
[trame](https://kitware.github.io/trame/index.html) for visualization.
175175

176176
```python
177177

178-
plotter = PlotterHelper(use_trame=True)
179-
plotter.plot(plot_list)
178+
plotter = GeomPlotter
179+
(use_trame=True)
180+
plotter.show(plot_list)
180181
```
181182

182183
## Clip objects
@@ -187,7 +188,7 @@ intersects the target object.
187188
```{code-cell} ipython
188189

189190
from ansys.geometry.core.math import Plane, Point3D
190-
ph = PlotterHelper()
191+
pl = GeomPlotter()
191192

192193
# Define PyAnsys Geometry box
193194
box2 = Sketch()
@@ -199,8 +200,8 @@ origin = Point3D([-10., 20., 5.], UNITS.m)
199200
plane = Plane(origin=origin, direction_x=[1, 1, 1], direction_y=[-1, 0, 1])
200201

201202
# Add the object with the clipping plane
202-
ph.add(box_body2, clipping_plane=plane)
203-
ph.plot()
203+
pl.plot(box_body2, clipping_plane=plane)
204+
pl.show()
204205
```
205206

206207
## Select objects interactively
@@ -210,10 +211,10 @@ This enables you to pick objects for subsequent script manipulation.
210211

211212
```{code-cell} ipython3
212213

213-
plotter = PlotterHelper(allow_picking=True)
214+
plotter = GeomPlotter(allow_picking=True)
214215

215216
# Plotter returns picked bodies
216-
picked_list = plotter.plot(plot_list)
217+
picked_list = plotter.show(plot_list)
217218
print(picked_list)
218219
```
219220

doc/source/examples/02_sketching/advanced_sketching_gears.mystnb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ from ansys.geometry.core import Modeler
2929
from ansys.geometry.core.math import Plane, Point2D, Point3D
3030
from ansys.geometry.core.misc import UNITS, Distance
3131
from ansys.geometry.core.sketch import Sketch
32-
from ansys.geometry.core.plotting import Plotter
32+
from ansys.geometry.core.plotting import GeomPlotter
3333

3434
# Start a modeler session
3535
modeler = Modeler()

doc/source/examples/02_sketching/basic_usage.mystnb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Perform the required imports.
2424
```{code-cell} ipython3
2525
from ansys.geometry.core.misc.units import UNITS as u
2626
from ansys.geometry.core.sketch import Sketch
27-
from ansys.geometry.core.plotting import Plotter
2827
```
2928

3029
## Create a sketch
@@ -172,7 +171,9 @@ showing the plane of the sketch and its frame.
172171

173172
```{code-cell} ipython3
174173
# Plot the sketch in the whole scene
175-
pl = Plotter()
176-
pl.plot_sketch(sketch, show_plane=True, show_frame=True)
177-
pl.scene.show(jupyter_backend="panel")
174+
from ansys.geometry.core.plotting import GeomPlotter
175+
176+
pl = GeomPlotter()
177+
pl.add_sketch(sketch, show_plane=True, show_frame=True)
178+
pl.show()
178179
```

doc/source/examples/03_modeling/boolean_operations.mystnb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ from ansys.geometry.core import launch_docker_modeler
2525
from ansys.geometry.core.designer import Body
2626
from ansys.geometry.core.math import Point2D
2727
from ansys.geometry.core.misc import UNITS
28-
from ansys.geometry.core.plotting import PlotterHelper
28+
from ansys.geometry.core.plotting import GeomPlotter
2929
from ansys.geometry.core.sketch import Sketch
3030
```
3131
+++
@@ -87,7 +87,10 @@ example. As shown in this example, the plotter preserves the picking order, mean
8787
output list is sorted according to the picking order.
8888

8989
```python
90-
bodies: List[Body] = PlotterHelper(allow_picking=True).plot(design.bodies)
90+
pl = GeomPlotter(allow_picking=True)
91+
pl.plot(design.bodies)
92+
pl.show()
93+
bodies: List[Body] = GeomPlotter(allow_picking=True).show(design.bodies)
9194
```
9295

9396
Otherwise, you can select bodies from the design directly.
@@ -121,7 +124,7 @@ Perform the intersection and plot the results.
121124

122125
```{code-cell} ipython3
123126
prism.intersect(cylin)
124-
_ = PlotterHelper().plot(design.bodies)
127+
_ = GeomPlotter().show(design.bodies)
125128
```
126129

127130
The final remaining body is the ``prism`` body because
@@ -149,7 +152,7 @@ Perform the union and plot the results.
149152

150153
```{code-cell} ipython3
151154
prism.unite(cylin)
152-
_ = PlotterHelper().plot(design.bodies)
155+
_ = GeomPlotter().show(design.bodies)
153156
```
154157

155158
The final remaining body is the ``prism`` body because
@@ -177,7 +180,7 @@ Perform the subtraction and plot the results.
177180

178181
```{code-cell} ipython3
179182
prism.subtract(cylin)
180-
_ = PlotterHelper().plot(design.bodies)
183+
_ = GeomPlotter().show(design.bodies)
181184
```
182185

183186
The final remaining body is the ``prism`` body because
@@ -201,7 +204,7 @@ cylin = design.extrude_sketch("Cylinder", sketch_circle, 50 * UNITS.m)
201204

202205
# Invert subtraction
203206
cylin.subtract(prism)
204-
_ = PlotterHelper().plot(design.bodies)
207+
_ = GeomPlotter().show(design.bodies)
205208
```
206209

207210
In this case, the final remaining body is the ``cylin`` body because

doc/source/examples/03_modeling/tessellation_usage.mystnb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ from pint import Quantity
2828
from ansys.geometry.core import Modeler
2929
from ansys.geometry.core.math import Point2D, Point3D, Plane
3030
from ansys.geometry.core.misc import UNITS
31-
from ansys.geometry.core.plotting import Plotter
3231
from ansys.geometry.core.sketch import Sketch
3332

3433
```

doc/source/examples/04_applied/02_naca_fluent.mystnb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,18 @@ design.create_named_selection("Airfoil Faces", faces=airfoil.faces)
117117
## Display the geometry
118118

119119
The geometry is now ready for the simulation. The following code displays the geometry in the notebook.
120-
This example uses the ``PlotterHelper`` class to display the geometry for
120+
This example uses the ``GeomPlotter`` class to display the geometry for
121121
the airfoil and fluid domain in different colors with a specified opacity level.
122122

123123
The airfoil is displayed in green, and the fluid domain is displayed in blue with an opacity of 0.25.
124124

125125
```{code-cell} ipython3
126-
from ansys.geometry.core.plotting import PlotterHelper
126+
from ansys.geometry.core.plotting import GeomPlotter
127127

128-
plotter_helper = PlotterHelper()
129-
plotter_helper.add(airfoil, color="green")
130-
plotter_helper.add(fluid, color="blue", opacity=0.15)
131-
plotter_helper.show_plotter()
128+
plotter = GeomPlotter()
129+
plotter.plot(airfoil, color="green")
130+
plotter.plot(fluid, color="blue", opacity=0.15)
131+
plotter.show()
132132
```
133133

134134
## Export the geometry

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ classifiers = [
2626
dependencies = [
2727
"ansys-api-geometry==0.4.2",
2828
"ansys-tools-path>=0.3,<1",
29+
"ansys-tools-visualization-interface>=0.2,<1",
2930
"beartype>=0.11.0,<0.19",
3031
"grpcio>=1.35.0,<2",
3132
"grpcio-health-checking>=1.45.0,<2",
@@ -49,6 +50,7 @@ all = [
4950
tests = [
5051
"ansys-platform-instancemanagement==1.1.2",
5152
"ansys-tools-path==0.5.2",
53+
"ansys-tools-visualization-interface==0.2.0",
5254
"beartype==0.18.5",
5355
"docker==7.1.0",
5456
"grpcio==1.64.0",
@@ -75,6 +77,7 @@ tests-minimal = [
7577
]
7678
doc = [
7779
"ansys-sphinx-theme[autoapi]==0.16.2",
80+
"ansys-tools-visualization-interface==0.2.0",
7881
"beartype==0.18.5",
7982
"docker==7.1.0",
8083
"ipyvtklink==0.2.3",

0 commit comments

Comments
 (0)