| 1 |
"""Contains a variety of cells to serve as examples. |
| 2 |
|
| 3 |
Functions that create single cell :class:`pyvista.UnstructuredGrid` objects which can |
| 4 |
be used to learn about VTK :class:`cell types <pyvista.CellType>`. |
| 5 |
|
| 6 |
""" |
| 7 |
|
| 8 |
from __future__ import annotations |
| 9 |
|
| 10 |
from collections.abc import Iterable |
| 11 |
from collections.abc import Sequence |
| 12 |
import itertools |
| 13 |
from typing import TYPE_CHECKING |
| 14 |
from typing import Literal |
| 15 |
from typing import cast |
| 16 |
from typing import get_args |
| 17 |
|
| 18 |
import numpy as np |
| 19 |
|
| 20 |
import pyvista as pv |
| 21 |
from pyvista import CellType |
| 22 |
from pyvista import UnstructuredGrid |
| 23 |
from pyvista import _vtk |
| 24 |
from pyvista._warn_external import warn_external |
| 25 |
from pyvista.core import _validation |
| 26 |
|
| 27 |
if TYPE_CHECKING: |
| 28 |
from pyvista import DataSet |
| 29 |
from pyvista import MultiBlock |
| 30 |
from pyvista import VectorLike |
| 31 |
from pyvista.plotting._typing import CameraPositionOptions |
| 32 |
|
| 33 |
|
| 34 |
_NOT_SUPPORTED_CELL_SOURCE = [ |
| 35 |
CellType.EMPTY_CELL, |
| 36 |
CellType.VERTEX, |
| 37 |
CellType.POLY_VERTEX, |
| 38 |
CellType.POLY_LINE, |
| 39 |
CellType.TRIANGLE_STRIP, |
| 40 |
CellType.QUADRATIC_LINEAR_QUAD, |
| 41 |
CellType.QUADRATIC_LINEAR_WEDGE, |
| 42 |
CellType.BIQUADRATIC_QUADRATIC_WEDGE, |
| 43 |
CellType.BIQUADRATIC_QUADRATIC_HEXAHEDRON, |
| 44 |
CellType.BIQUADRATIC_TRIANGLE, |
| 45 |
CellType.QUADRATIC_POLYGON, |
| 46 |
CellType.CONVEX_POINT_SET, |
| 47 |
] |
| 48 |
|
| 49 |
_NOT_SUPPORTED_PARAMETRIC = [ |
| 50 |
CellType.POLY_VERTEX, |
| 51 |
CellType.POLY_LINE, |
| 52 |
CellType.TRIANGLE_STRIP, |
| 53 |
CellType.POLYGON, |
| 54 |
CellType.QUADRATIC_POLYGON, |
| 55 |
CellType.CONVEX_POINT_SET, |
| 56 |
CellType.POLYHEDRON, |
| 57 |
] |
| 58 |
|
| 59 |
|
| 60 |
def plot_cell( |
| 61 |
grid: DataSet | MultiBlock, |
| 62 |
cpos: CameraPositionOptions | None = None, |
| 63 |
*, |
| 64 |
line_width: int | None = None, |
| 65 |
point_size: int | None = None, |
| 66 |
font_size: int | None = None, |
| 67 |
show_normals: bool = False, |
| 68 |
normals_scale: float | None = None, |
| 69 |
**kwargs, |
| 70 |
): |
| 71 |
"""Plot a mesh while displaying cell indices. |
| 72 |
|
| 73 |
.. versionchanged:: 0.45 |
| 74 |
The default line width, point size, and font size are increased from ``5``, ``30`` |
| 75 |
and ``20`` to ``10``, ``80``, and ``50``, respectively. |
| 76 |
|
| 77 |
.. versionchanged:: 0.47 |
| 78 |
The default line width, point size, and font size are restored to their original |
| 79 |
values prior to version 0.45. These values can now be customized with keywords. |
| 80 |
|
| 81 |
Parameters |
| 82 |
---------- |
| 83 |
grid : pyvista.DataSet | pyvista.MultiBlock |
| 84 |
Dataset containing one single cell (ideally), though plotting a mesh with multiple cells |
| 85 |
is supported. |
| 86 |
|
| 87 |
.. versionchanged:: 0.47 |
| 88 |
Plotting :class:`~pyvista.PolyData` is now supported. |
| 89 |
|
| 90 |
.. versionchanged:: 0.48 |
| 91 |
Plotting :class:`~pyvista.MultiBlock` is now supported. |
| 92 |
|
| 93 |
cpos : str, optional |
| 94 |
Camera position. |
| 95 |
|
| 96 |
line_width : int, default: 5 |
| 97 |
Line width of the cell's edges. |
| 98 |
|
| 99 |
.. versionadded:: 0.47 |
| 100 |
|
| 101 |
point_size : int, default: 30 |
| 102 |
Size of the cell's points. |
| 103 |
|
| 104 |
.. versionadded:: 0.47 |
| 105 |
|
| 106 |
font_size : int, default: 20 |
| 107 |
Size of the point labels. |
| 108 |
|
| 109 |
.. versionadded:: 0.47 |
| 110 |
|
| 111 |
show_normals : bool, optional |
| 112 |
Show the face normals of the cell. Only applies to 2D or 3D cells. |
| 113 |
Cell faces with correct orientation should have the normal pointing outward. |
| 114 |
|
| 115 |
The size of the normals is controlled by ``normals_scale``. |
| 116 |
|
| 117 |
.. versionadded:: 0.47 |
| 118 |
|
| 119 |
normals_scale : float, default: 0.1 |
| 120 |
Scale factor used when ``show_normals`` is enabled. The normals are |
| 121 |
scaled proportional to the diagonal length of the input ``grid``. |
| 122 |
|
| 123 |
.. versionadded:: 0.47 |
| 124 |
|
| 125 |
**kwargs : dict, optional |
| 126 |
Additional keyword arguments when showing. See :func:`pyvista.Plotter.show`. |
| 127 |
|
| 128 |
Examples |
| 129 |
-------- |
| 130 |
Create and plot a single hexahedron. |
| 131 |
|
| 132 |
>>> from pyvista import examples |
| 133 |
>>> grid = examples.cells.Hexahedron() |
| 134 |
>>> examples.plot_cell(grid) |
| 135 |
|
| 136 |
Show normals and customize the size of various elements in the rendering. |
| 137 |
|
| 138 |
>>> examples.plot_cell( |
| 139 |
... grid, |
| 140 |
... show_normals=True, |
| 141 |
... normals_scale=0.2, |
| 142 |
... line_width=8, |
| 143 |
... point_size=50, |
| 144 |
... font_size=30, |
| 145 |
... ) |
| 146 |
|
| 147 |
""" |
| 148 |
config = pv.global_theme._plot_cell |
| 149 |
line_width_ = config._line_width if line_width is None else line_width |
| 150 |
point_size_ = config._point_size if point_size is None else point_size |
| 151 |
font_size_ = config._font_size if font_size is None else font_size |
| 152 |
normals_scale_ = config._normals_scale if normals_scale is None else normals_scale |
| 153 |
|
| 154 |
def _extract_surface(cell_): |
| 155 |
if cell_.type == pv.CellType.POLYHEDRON: |
| 156 |
# For Polyhedron, we don't use ``extract_surface`` directly because that may alter |
| 157 |
# the face orientation, so we iterate over each face directly to create separate |
| 158 |
# PolyData faces instead. |
| 159 |
faces = pv.MultiBlock() |
| 160 |
for i in range(cell_.n_faces): |
| 161 |
face = cell_.GetFace(i) |
| 162 |
face_n_points = face.GetNumberOfPoints() |
| 163 |
point_ids = [face.GetPointId(i) for i in range(face_n_points)] |
| 164 |
poly = pv.PolyData(grid.points, [face_n_points, *point_ids]) |
| 165 |
faces.append(poly) |
| 166 |
return faces.extract_surface(algorithm=None, pass_pointid=False, pass_cellid=False) |
| 167 |
return cell_.cast_to_unstructured_grid().extract_surface( |
| 168 |
algorithm=None, pass_pointid=False, pass_cellid=False |
| 169 |
) |
| 170 |
|
| 171 |
if isinstance(grid, pv.MultiBlock): |
| 172 |
grid = grid.combine() |
| 173 |
elif not isinstance(grid, pv.UnstructuredGrid): |
| 174 |
grid = grid.cast_to_unstructured_grid() |
| 175 |
|
| 176 |
pl = pv.Plotter() |
| 177 |
for cell in grid.cell: |
| 178 |
# Use existing grid if it's already a grid with one cell |
| 179 |
cell_as_grid = grid if grid.n_cells == 1 else cell.cast_to_unstructured_grid() |
| 180 |
pl.add_mesh(cell_as_grid, opacity=0.5) |
| 181 |
if cell.type == CellType.CONVEX_POINT_SET: |
| 182 |
# Cell does not actually have edges, so convert it to a surface first |
| 183 |
edges = cell_as_grid.extract_surface(algorithm=None).extract_all_edges() |
| 184 |
else: |
| 185 |
edges = cell_as_grid.extract_all_edges() |
| 186 |
if edges.n_cells or cell.dimension == 1: |
| 187 |
pl.add_mesh( |
| 188 |
cell_as_grid, |
| 189 |
style='wireframe', |
| 190 |
line_width=line_width_, |
| 191 |
color='k', |
| 192 |
render_lines_as_tubes=True, |
| 193 |
) |
| 194 |
pl.add_points( |
| 195 |
cell.points, render_points_as_spheres=True, point_size=point_size_, color='r' |
| 196 |
) |
| 197 |
pl.add_point_labels( |
| 198 |
cell.points, |
| 199 |
cell.point_ids, |
| 200 |
always_visible=True, |
| 201 |
fill_shape=False, |
| 202 |
margin=0, |
| 203 |
shape_opacity=0.0, |
| 204 |
font_size=font_size_, |
| 205 |
) |
| 206 |
|
| 207 |
if show_normals and cell.dimension >= 2: |
| 208 |
surface = _extract_surface(cell) |
| 209 |
surface = surface.triangulate() if cell.type is CellType.TRIANGLE_STRIP else surface |
| 210 |
pl.add_arrows( |
| 211 |
surface.cell_centers().points, |
| 212 |
surface.cell_normals, |
| 213 |
mag=grid.length * normals_scale_, |
| 214 |
color='yellow', |
| 215 |
show_scalar_bar=False, |
| 216 |
) |
| 217 |
|
| 218 |
pl.enable_anti_aliasing() |
| 219 |
if cpos is None: |
| 220 |
pl.camera.azimuth = 20 |
| 221 |
pl.camera.elevation = -20 |
| 222 |
else: |
| 223 |
pl.camera_position = cpos |
| 224 |
pl.show(**kwargs) |
| 225 |
|
| 226 |
|
| 227 |
def Empty() -> UnstructuredGrid: |
| 228 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single empty cell. |
| 229 |
|
| 230 |
This cell corresponds to the :attr:`pyvista.CellType.EMPTY_CELL` cell type. |
| 231 |
|
| 232 |
Returns |
| 233 |
------- |
| 234 |
pyvista.UnstructuredGrid |
| 235 |
UnstructuredGrid containing a single empty cell. |
| 236 |
|
| 237 |
Examples |
| 238 |
-------- |
| 239 |
Create a single empty cell. |
| 240 |
|
| 241 |
>>> from pyvista import examples |
| 242 |
>>> grid = examples.cells.Empty() |
| 243 |
|
| 244 |
List the grid's cells. |
| 245 |
|
| 246 |
>>> grid.cells |
| 247 |
array([0]) |
| 248 |
|
| 249 |
List the grid's points. |
| 250 |
|
| 251 |
>>> grid.points |
| 252 |
pyvista_ndarray([], shape=(0, 3), dtype=float64) |
| 253 |
|
| 254 |
>>> grid.celltypes # same as pyvista.CellType.EMPTY_CELL |
| 255 |
array([0], dtype=uint8) |
| 256 |
|
| 257 |
""" |
| 258 |
return UnstructuredGrid([0], [CellType.EMPTY_CELL], []) |
| 259 |
|
| 260 |
|
| 261 |
def Vertex() -> UnstructuredGrid: |
| 262 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Vertex. |
| 263 |
|
| 264 |
This cell corresponds to the :attr:`pyvista.CellType.VERTEX` cell type. |
| 265 |
|
| 266 |
Returns |
| 267 |
------- |
| 268 |
pyvista.UnstructuredGrid |
| 269 |
UnstructuredGrid containing a single vertex. |
| 270 |
|
| 271 |
Examples |
| 272 |
-------- |
| 273 |
Create and plot a single vertex. |
| 274 |
|
| 275 |
>>> from pyvista import examples |
| 276 |
>>> grid = examples.cells.Vertex() |
| 277 |
>>> examples.plot_cell(grid) |
| 278 |
|
| 279 |
List the grid's cells. |
| 280 |
|
| 281 |
>>> grid.cells |
| 282 |
array([1, 0]) |
| 283 |
|
| 284 |
List the grid's points. |
| 285 |
|
| 286 |
>>> grid.points |
| 287 |
pyvista_ndarray([[0., 0., 0.]]) |
| 288 |
|
| 289 |
>>> grid.celltypes # same as pyvista.CellType.VERTEX |
| 290 |
array([1], dtype=uint8) |
| 291 |
|
| 292 |
""" |
| 293 |
points = [[0.0, 0.0, 0.0]] |
| 294 |
cells = [len(points), *list(range(len(points)))] |
| 295 |
return UnstructuredGrid(cells, [CellType.VERTEX], points) |
| 296 |
|
| 297 |
|
| 298 |
def PolyVertex() -> UnstructuredGrid: |
| 299 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single poly vertex. |
| 300 |
|
| 301 |
This represents a set of 3D vertices as a single cell. |
| 302 |
|
| 303 |
This cell corresponds to the :attr:`pyvista.CellType.POLY_VERTEX` cell type. |
| 304 |
|
| 305 |
Returns |
| 306 |
------- |
| 307 |
pyvista.UnstructuredGrid |
| 308 |
UnstructuredGrid containing a single poly vertex. |
| 309 |
|
| 310 |
Examples |
| 311 |
-------- |
| 312 |
Create and plot a single poly vertex. |
| 313 |
|
| 314 |
>>> from pyvista import examples |
| 315 |
>>> grid = examples.cells.PolyVertex() |
| 316 |
>>> examples.plot_cell(grid) |
| 317 |
|
| 318 |
List the grid's cells. This could be any number of points. |
| 319 |
|
| 320 |
>>> grid.cells |
| 321 |
array([6, 0, 1, 2, 3, 4, 5]) |
| 322 |
|
| 323 |
List the grid's points. |
| 324 |
|
| 325 |
>>> grid.points |
| 326 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 327 |
[1. , 0. , 0. ], |
| 328 |
[0. , 1. , 0. ], |
| 329 |
[0. , 0. , 1. ], |
| 330 |
[1. , 0. , 0.4], |
| 331 |
[0. , 1. , 0.6]]) |
| 332 |
|
| 333 |
>>> grid.celltypes # same as pyvista.CellType.POLY_VERTEX |
| 334 |
array([2], dtype=uint8) |
| 335 |
|
| 336 |
""" |
| 337 |
points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 0.4], [0, 1, 0.6]] |
| 338 |
cells = [len(points), *list(range(len(points)))] |
| 339 |
return UnstructuredGrid(cells, [CellType.POLY_VERTEX], points) |
| 340 |
|
| 341 |
|
| 342 |
def ConvexPointSet() -> UnstructuredGrid: |
| 343 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single convex point set. |
| 344 |
|
| 345 |
This represents a set of 3D vertices as a single convex cell. |
| 346 |
|
| 347 |
This cell corresponds to the :attr:`pyvista.CellType.CONVEX_POINT_SET` cell type. |
| 348 |
|
| 349 |
Returns |
| 350 |
------- |
| 351 |
pyvista.UnstructuredGrid |
| 352 |
UnstructuredGrid containing a single convex point set. |
| 353 |
|
| 354 |
Examples |
| 355 |
-------- |
| 356 |
Create and plot a single convex point set. |
| 357 |
|
| 358 |
>>> from pyvista import examples |
| 359 |
>>> grid = examples.cells.ConvexPointSet() |
| 360 |
>>> examples.plot_cell(grid) |
| 361 |
|
| 362 |
List the grid's cells. This could be any number of points. |
| 363 |
|
| 364 |
>>> grid.cells |
| 365 |
array([6, 0, 1, 2, 3, 4, 5]) |
| 366 |
|
| 367 |
List the grid's points. |
| 368 |
|
| 369 |
>>> grid.points |
| 370 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 371 |
[1. , 0. , 0. ], |
| 372 |
[0. , 1. , 0. ], |
| 373 |
[0. , 0. , 1. ], |
| 374 |
[1. , 0. , 0.4], |
| 375 |
[0. , 1. , 0.6]]) |
| 376 |
|
| 377 |
>>> grid.celltypes # same as pyvista.CellType.CONVEX_POINT_SET |
| 378 |
array([41], dtype=uint8) |
| 379 |
|
| 380 |
""" |
| 381 |
points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 0.4], [0, 1, 0.6]] |
| 382 |
cells = [len(points), *list(range(len(points)))] |
| 383 |
return UnstructuredGrid(cells, [CellType.CONVEX_POINT_SET], points) |
| 384 |
|
| 385 |
|
| 386 |
def Line() -> UnstructuredGrid: |
| 387 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Line. |
| 388 |
|
| 389 |
This cell corresponds to the :attr:`pyvista.CellType.LINE` cell type. |
| 390 |
|
| 391 |
Returns |
| 392 |
------- |
| 393 |
pyvista.UnstructuredGrid |
| 394 |
UnstructuredGrid containing a single line. |
| 395 |
|
| 396 |
Examples |
| 397 |
-------- |
| 398 |
Create and plot a single line. |
| 399 |
|
| 400 |
>>> from pyvista import examples |
| 401 |
>>> grid = examples.cells.Line() |
| 402 |
>>> examples.plot_cell(grid) |
| 403 |
|
| 404 |
List the grid's cells. |
| 405 |
|
| 406 |
>>> grid.cells |
| 407 |
array([2, 0, 1]) |
| 408 |
|
| 409 |
List the grid's points. |
| 410 |
|
| 411 |
>>> grid.points |
| 412 |
pyvista_ndarray([[0., 0., 0.], |
| 413 |
[1., 0., 0.]]) |
| 414 |
|
| 415 |
>>> grid.celltypes # same as pyvista.CellType.LINE |
| 416 |
array([3], dtype=uint8) |
| 417 |
|
| 418 |
""" |
| 419 |
points = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]] |
| 420 |
cells = [len(points), *list(range(len(points)))] |
| 421 |
return UnstructuredGrid(cells, [CellType.LINE], points) |
| 422 |
|
| 423 |
|
| 424 |
def PolyLine() -> UnstructuredGrid: |
| 425 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single poly line. |
| 426 |
|
| 427 |
This represents a set of line segments as a single cell. |
| 428 |
|
| 429 |
This cell corresponds to the :attr:`pyvista.CellType.POLY_LINE` cell type. |
| 430 |
|
| 431 |
Returns |
| 432 |
------- |
| 433 |
pyvista.UnstructuredGrid |
| 434 |
UnstructuredGrid containing a single polyline. |
| 435 |
|
| 436 |
Examples |
| 437 |
-------- |
| 438 |
Create and plot a single polyline. |
| 439 |
|
| 440 |
>>> from pyvista import examples |
| 441 |
>>> grid = examples.cells.PolyLine() |
| 442 |
>>> examples.plot_cell(grid) |
| 443 |
|
| 444 |
List the grid's cells. This could be any number of points. |
| 445 |
|
| 446 |
>>> grid.cells |
| 447 |
array([4, 0, 1, 2, 3]) |
| 448 |
|
| 449 |
List the grid's points. |
| 450 |
|
| 451 |
>>> grid.points |
| 452 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 453 |
[0.5, 0. , 0. ], |
| 454 |
[0.5, 1. , 0. ], |
| 455 |
[0. , 1. , 0. ]]) |
| 456 |
|
| 457 |
>>> grid.celltypes # same as pyvista.CellType.POLY_LINE |
| 458 |
array([4], dtype=uint8) |
| 459 |
|
| 460 |
""" |
| 461 |
points = [ |
| 462 |
[0.0, 0.0, 0.0], |
| 463 |
[0.5, 0.0, 0.0], |
| 464 |
[0.5, 1.0, 0.0], |
| 465 |
[0.0, 1.0, 0.0], |
| 466 |
] |
| 467 |
|
| 468 |
cells = [len(points), *list(range(len(points)))] |
| 469 |
return UnstructuredGrid(cells, [CellType.POLY_LINE], points) |
| 470 |
|
| 471 |
|
| 472 |
def Triangle() -> UnstructuredGrid: |
| 473 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Triangle. |
| 474 |
|
| 475 |
This cell corresponds to the :attr:`pyvista.CellType.TRIANGLE` cell type. |
| 476 |
|
| 477 |
Returns |
| 478 |
------- |
| 479 |
pyvista.UnstructuredGrid |
| 480 |
UnstructuredGrid containing a single triangle. |
| 481 |
|
| 482 |
Examples |
| 483 |
-------- |
| 484 |
Create and plot a single triangle. |
| 485 |
|
| 486 |
>>> from pyvista import examples |
| 487 |
>>> grid = examples.cells.Triangle() |
| 488 |
>>> examples.plot_cell(grid, cpos='xy') |
| 489 |
|
| 490 |
List the grid's cells. |
| 491 |
|
| 492 |
>>> grid.cells |
| 493 |
array([3, 0, 1, 2]) |
| 494 |
|
| 495 |
List the grid's points. |
| 496 |
|
| 497 |
>>> grid.points |
| 498 |
pyvista_ndarray([[ 0.5 , -0.28867513, 0. ], |
| 499 |
[ 0. , 0.57735027, 0. ], |
| 500 |
[-0.5 , -0.28867513, 0. ]]) |
| 501 |
|
| 502 |
>>> grid.celltypes # same as pyvista.CellType.TRIANGLE |
| 503 |
array([5], dtype=uint8) |
| 504 |
|
| 505 |
""" |
| 506 |
R33 = np.sqrt(3) / 3 |
| 507 |
points = [[0.5, -0.5 * R33, 0.0], [0.0, R33, 0.0], [-0.5, -0.5 * R33, 0.0]] |
| 508 |
|
| 509 |
cells = [len(points), *list(range(len(points)))] |
| 510 |
return UnstructuredGrid(cells, [CellType.TRIANGLE], points) |
| 511 |
|
| 512 |
|
| 513 |
def TriangleStrip() -> UnstructuredGrid: |
| 514 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single triangle strip. |
| 515 |
|
| 516 |
This cell corresponds to the :attr:`pyvista.CellType.TRIANGLE_STRIP` cell type. |
| 517 |
|
| 518 |
Returns |
| 519 |
------- |
| 520 |
pyvista.UnstructuredGrid |
| 521 |
UnstructuredGrid containing a single triangle strip. |
| 522 |
|
| 523 |
Examples |
| 524 |
-------- |
| 525 |
Create and plot a single triangle strip. |
| 526 |
|
| 527 |
>>> from pyvista import examples |
| 528 |
>>> grid = examples.cells.TriangleStrip() |
| 529 |
>>> examples.plot_cell(grid, cpos='xy') |
| 530 |
|
| 531 |
List the grid's cells. |
| 532 |
|
| 533 |
>>> grid.cells |
| 534 |
array([8, 0, 1, 2, 3, 4, 5, 6, 7]) |
| 535 |
|
| 536 |
List the grid's points. |
| 537 |
|
| 538 |
>>> grid.points |
| 539 |
pyvista_ndarray([[1., 0., 0.], |
| 540 |
[0., 0., 0.], |
| 541 |
[1., 1., 0.], |
| 542 |
[0., 1., 0.], |
| 543 |
[1., 2., 0.], |
| 544 |
[0., 2., 0.], |
| 545 |
[1., 3., 0.], |
| 546 |
[0., 3., 0.]]) |
| 547 |
|
| 548 |
>>> grid.celltypes # same as pyvista.CellType.TRIANGLE_STRIP |
| 549 |
array([6], dtype=uint8) |
| 550 |
|
| 551 |
""" |
| 552 |
points = [ |
| 553 |
[0.0, 0.0, 0.0], |
| 554 |
[1.0, 0.0, 0.0], |
| 555 |
[0.0, 1.0, 0.0], |
| 556 |
[1.0, 1.0, 0.0], |
| 557 |
[0.0, 2.0, 0.0], |
| 558 |
[1.0, 2.0, 0.0], |
| 559 |
[0.0, 3.0, 0.0], |
| 560 |
[1.0, 3.0, 0.0], |
| 561 |
] |
| 562 |
cells = [len(points), *list(range(len(points)))] |
| 563 |
return UnstructuredGrid(cells, [CellType.TRIANGLE_STRIP], points) |
| 564 |
|
| 565 |
|
| 566 |
def Polygon() -> UnstructuredGrid: |
| 567 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single polygon. |
| 568 |
|
| 569 |
This cell corresponds to the :attr:`pyvista.CellType.POLYGON` cell type. |
| 570 |
|
| 571 |
Returns |
| 572 |
------- |
| 573 |
pyvista.UnstructuredGrid |
| 574 |
UnstructuredGrid containing a single polygon. |
| 575 |
|
| 576 |
Examples |
| 577 |
-------- |
| 578 |
Create and plot a single polygon. |
| 579 |
|
| 580 |
>>> from pyvista import examples |
| 581 |
>>> grid = examples.cells.Polygon() |
| 582 |
>>> examples.plot_cell(grid) |
| 583 |
|
| 584 |
List the grid's cells. |
| 585 |
|
| 586 |
>>> grid.cells |
| 587 |
array([6, 0, 1, 2, 3, 4, 5]) |
| 588 |
|
| 589 |
List the grid's points. |
| 590 |
|
| 591 |
>>> grid.points |
| 592 |
pyvista_ndarray([[ 0. , 0. , 0. ], |
| 593 |
[ 1. , -0.1, 0. ], |
| 594 |
[ 1.4, 0.5, 0. ], |
| 595 |
[ 1. , 1. , 0. ], |
| 596 |
[ 0.6, 1.2, 0. ], |
| 597 |
[ 0. , 0.8, 0. ]]) |
| 598 |
|
| 599 |
>>> grid.celltypes # same as pyvista.CellType.POLYGON |
| 600 |
array([7], dtype=uint8) |
| 601 |
|
| 602 |
""" |
| 603 |
points = [[0, 0, 0], [1, -0.1, 0], [1.4, 0.5, 0], [1, 1, 0], [0.6, 1.2, 0], [0, 0.8, 0]] |
| 604 |
cells = [len(points), *list(range(len(points)))] |
| 605 |
return UnstructuredGrid(cells, [CellType.POLYGON], points) |
| 606 |
|
| 607 |
|
| 608 |
def Polyhedron() -> UnstructuredGrid: |
| 609 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single polyhedron. |
| 610 |
|
| 611 |
This cell corresponds to the :attr:`pyvista.CellType.POLYHEDRON` cell type. |
| 612 |
|
| 613 |
Returns |
| 614 |
------- |
| 615 |
pyvista.UnstructuredGrid |
| 616 |
UnstructuredGrid containing a single polyhedron. |
| 617 |
|
| 618 |
Examples |
| 619 |
-------- |
| 620 |
Create and plot a single polyhedron. |
| 621 |
|
| 622 |
>>> from pyvista import examples |
| 623 |
>>> grid = examples.cells.Polyhedron() |
| 624 |
>>> examples.plot_cell(grid) |
| 625 |
|
| 626 |
A polyhedron is defined by it's faces. List the grid's faces. |
| 627 |
|
| 628 |
>>> grid.get_cell(0).faces # doctest: +ELLIPSIS |
| 629 |
[Cell... |
| 630 |
..., Cell... |
| 631 |
..., Cell... |
| 632 |
...] |
| 633 |
|
| 634 |
>>> grid.celltypes # same as pyvista.CellType.POLYHEDRON |
| 635 |
array([42], dtype=uint8) |
| 636 |
|
| 637 |
""" |
| 638 |
points = [[0, 0, 0], [1, 0, 0], [0.5, 0.5, 0], [0, 0, 1]] |
| 639 |
cells = [4, 3, 0, 2, 1, 3, 0, 1, 3, 3, 0, 3, 2, 3, 1, 2, 3] |
| 640 |
cells = [len(cells), *cells] |
| 641 |
return UnstructuredGrid(cells, [CellType.POLYHEDRON], points) |
| 642 |
|
| 643 |
|
| 644 |
def Pixel() -> UnstructuredGrid: |
| 645 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single pixel. |
| 646 |
|
| 647 |
This cell corresponds to the :attr:`pyvista.CellType.PIXEL` cell type. |
| 648 |
|
| 649 |
Returns |
| 650 |
------- |
| 651 |
pyvista.UnstructuredGrid |
| 652 |
UnstructuredGrid containing a single pixel. |
| 653 |
|
| 654 |
Examples |
| 655 |
-------- |
| 656 |
Create and plot a single pixel. |
| 657 |
|
| 658 |
>>> from pyvista import examples |
| 659 |
>>> grid = examples.cells.Pixel() |
| 660 |
>>> examples.plot_cell(grid, cpos='xy') |
| 661 |
|
| 662 |
List the grid's cells. |
| 663 |
|
| 664 |
>>> grid.cells |
| 665 |
array([4, 0, 1, 2, 3]) |
| 666 |
|
| 667 |
List the grid's points. |
| 668 |
|
| 669 |
>>> grid.points |
| 670 |
pyvista_ndarray([[0., 0., 0.], |
| 671 |
[1., 0., 0.], |
| 672 |
[0., 1., 0.], |
| 673 |
[1., 1., 0.]]) |
| 674 |
|
| 675 |
>>> grid.celltypes # same as pyvista.CellType.PIXEL |
| 676 |
array([8], dtype=uint8) |
| 677 |
|
| 678 |
""" |
| 679 |
points = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]] |
| 680 |
cells = [len(points), *list(range(len(points)))] |
| 681 |
return UnstructuredGrid(cells, [CellType.PIXEL], points) |
| 682 |
|
| 683 |
|
| 684 |
def Quadrilateral() -> UnstructuredGrid: |
| 685 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadrilateral. |
| 686 |
|
| 687 |
This cell corresponds to the :attr:`pyvista.CellType.QUAD` cell type. |
| 688 |
|
| 689 |
Returns |
| 690 |
------- |
| 691 |
pyvista.UnstructuredGrid |
| 692 |
UnstructuredGrid containing a single quadrilateral. |
| 693 |
|
| 694 |
Examples |
| 695 |
-------- |
| 696 |
Create and plot a single quad. |
| 697 |
|
| 698 |
>>> from pyvista import examples |
| 699 |
>>> grid = examples.cells.Quadrilateral() |
| 700 |
>>> examples.plot_cell(grid, cpos='xy') |
| 701 |
|
| 702 |
List the grid's cells. |
| 703 |
|
| 704 |
>>> grid.cells |
| 705 |
array([4, 0, 1, 2, 3]) |
| 706 |
|
| 707 |
List the grid's points. |
| 708 |
|
| 709 |
>>> grid.points |
| 710 |
pyvista_ndarray([[0., 0., 0.], |
| 711 |
[1., 0., 0.], |
| 712 |
[1., 1., 0.], |
| 713 |
[0., 1., 0.]]) |
| 714 |
|
| 715 |
>>> grid.celltypes # same as pyvista.CellType.QUAD |
| 716 |
array([9], dtype=uint8) |
| 717 |
|
| 718 |
""" |
| 719 |
points = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]] |
| 720 |
cells = [len(points), *list(range(len(points)))] |
| 721 |
return UnstructuredGrid(cells, [CellType.QUAD], points) |
| 722 |
|
| 723 |
|
| 724 |
def Tetrahedron() -> UnstructuredGrid: |
| 725 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Tetrahedron. |
| 726 |
|
| 727 |
This cell corresponds to the :attr:`pyvista.CellType.TETRA` cell type. |
| 728 |
|
| 729 |
Returns |
| 730 |
------- |
| 731 |
pyvista.UnstructuredGrid |
| 732 |
UnstructuredGrid containing a single Tetrahedron. |
| 733 |
|
| 734 |
Examples |
| 735 |
-------- |
| 736 |
Create and plot a single tetrahedron. |
| 737 |
|
| 738 |
>>> from pyvista import examples |
| 739 |
>>> grid = examples.cells.Tetrahedron() |
| 740 |
>>> examples.plot_cell(grid) |
| 741 |
|
| 742 |
List the grid's cells. |
| 743 |
|
| 744 |
>>> grid.cells |
| 745 |
array([4, 0, 1, 2, 3]) |
| 746 |
|
| 747 |
List the grid's points. |
| 748 |
|
| 749 |
>>> grid.points |
| 750 |
pyvista_ndarray([[ 0.35355339, -0.35355339, -0.35355339], |
| 751 |
[ 0.35355339, 0.35355339, 0.35355339], |
| 752 |
[-0.35355339, 0.35355339, -0.35355339], |
| 753 |
[-0.35355339, -0.35355339, 0.35355339]]) |
| 754 |
|
| 755 |
>>> grid.celltypes # same as pyvista.CellType.TETRA |
| 756 |
array([10], dtype=uint8) |
| 757 |
|
| 758 |
""" |
| 759 |
# Original points |
| 760 |
points = np.array( |
| 761 |
[ |
| 762 |
[1.0, -1.0, -1.0], |
| 763 |
[1.0, 1.0, 1.0], |
| 764 |
[-1.0, 1.0, -1.0], |
| 765 |
[-1.0, -1.0, 1.0], |
| 766 |
] |
| 767 |
) |
| 768 |
|
| 769 |
# Normalize points to have edge length one |
| 770 |
edge_length = np.linalg.norm(points[1] - points[0]) |
| 771 |
points /= edge_length |
| 772 |
|
| 773 |
cells = [len(points), *list(range(len(points)))] |
| 774 |
return UnstructuredGrid(cells, [CellType.TETRA], points) |
| 775 |
|
| 776 |
|
| 777 |
def Hexahedron() -> UnstructuredGrid: |
| 778 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single hexahedron. |
| 779 |
|
| 780 |
This cell corresponds to the :attr:`pyvista.CellType.HEXAHEDRON` cell type. |
| 781 |
|
| 782 |
Returns |
| 783 |
------- |
| 784 |
pyvista.UnstructuredGrid |
| 785 |
UnstructuredGrid containing a single hexahedron. |
| 786 |
|
| 787 |
Examples |
| 788 |
-------- |
| 789 |
Create and plot a single hexahedron. |
| 790 |
|
| 791 |
>>> from pyvista import examples |
| 792 |
>>> grid = examples.cells.Hexahedron() |
| 793 |
>>> examples.plot_cell(grid) |
| 794 |
|
| 795 |
List the grid's cells. |
| 796 |
|
| 797 |
>>> grid.cells |
| 798 |
array([8, 0, 1, 2, 3, 4, 5, 6, 7]) |
| 799 |
|
| 800 |
List the grid's points. |
| 801 |
|
| 802 |
>>> grid.points |
| 803 |
pyvista_ndarray([[0., 0., 0.], |
| 804 |
[1., 0., 0.], |
| 805 |
[1., 1., 0.], |
| 806 |
[0., 1., 0.], |
| 807 |
[0., 0., 1.], |
| 808 |
[1., 0., 1.], |
| 809 |
[1., 1., 1.], |
| 810 |
[0., 1., 1.]]) |
| 811 |
|
| 812 |
>>> grid.celltypes # same as pyvista.CellType.HEXAHEDRON |
| 813 |
array([12], dtype=uint8) |
| 814 |
|
| 815 |
""" |
| 816 |
points = [ |
| 817 |
[0.0, 0.0, 0.0], |
| 818 |
[1.0, 0.0, 0.0], |
| 819 |
[1.0, 1.0, 0.0], |
| 820 |
[0.0, 1.0, 0.0], |
| 821 |
[0.0, 0.0, 1.0], |
| 822 |
[1.0, 0.0, 1.0], |
| 823 |
[1.0, 1.0, 1.0], |
| 824 |
[0.0, 1.0, 1.0], |
| 825 |
] |
| 826 |
cells = [len(points), *list(range(len(points)))] |
| 827 |
return UnstructuredGrid(cells, [CellType.HEXAHEDRON], points) |
| 828 |
|
| 829 |
|
| 830 |
def HexagonalPrism() -> UnstructuredGrid: |
| 831 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single hexagonal prism. |
| 832 |
|
| 833 |
This cell corresponds to the :attr:`pyvista.CellType.HEXAGONAL_PRISM` cell type. |
| 834 |
|
| 835 |
Returns |
| 836 |
------- |
| 837 |
pyvista.UnstructuredGrid |
| 838 |
UnstructuredGrid containing a single hexagonal prism. |
| 839 |
|
| 840 |
Examples |
| 841 |
-------- |
| 842 |
Create and plot a single hexagonal prism. |
| 843 |
|
| 844 |
>>> from pyvista import examples |
| 845 |
>>> grid = examples.cells.HexagonalPrism() |
| 846 |
>>> examples.plot_cell(grid) |
| 847 |
|
| 848 |
List the grid's cells. |
| 849 |
|
| 850 |
>>> grid.cells |
| 851 |
array([12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) |
| 852 |
|
| 853 |
List the grid's points. |
| 854 |
|
| 855 |
>>> grid.points |
| 856 |
pyvista_ndarray([[ 0. , 0. , 1. ], |
| 857 |
[-0.5, 0.5, 1. ], |
| 858 |
[ 0. , 1. , 1. ], |
| 859 |
[ 1. , 1. , 1. ], |
| 860 |
[ 1.5, 0.5, 1. ], |
| 861 |
[ 1. , 0. , 1. ], |
| 862 |
[ 0. , 0. , 0. ], |
| 863 |
[-0.5, 0.5, 0. ], |
| 864 |
[ 0. , 1. , 0. ], |
| 865 |
[ 1. , 1. , 0. ], |
| 866 |
[ 1.5, 0.5, 0. ], |
| 867 |
[ 1. , 0. , 0. ]]) |
| 868 |
|
| 869 |
>>> grid.celltypes # same as pyvista.CellType.HEXAGONAL_PRISM |
| 870 |
array([16], dtype=uint8) |
| 871 |
|
| 872 |
""" |
| 873 |
points = [ |
| 874 |
# Top face (z=1.0) |
| 875 |
[0.0, 0.0, 1.0], |
| 876 |
[-0.5, 0.5, 1.0], |
| 877 |
[0.0, 1.0, 1.0], |
| 878 |
[1.0, 1.0, 1.0], |
| 879 |
[1.5, 0.5, 1.0], |
| 880 |
[1.0, 0.0, 1.0], |
| 881 |
# Bottom face (z=0.0) |
| 882 |
[0.0, 0.0, 0.0], |
| 883 |
[-0.5, 0.5, 0.0], |
| 884 |
[0.0, 1.0, 0.0], |
| 885 |
[1.0, 1.0, 0.0], |
| 886 |
[1.5, 0.5, 0.0], |
| 887 |
[1.0, 0.0, 0.0], |
| 888 |
] |
| 889 |
cells = [len(points), *list(range(len(points)))] |
| 890 |
return UnstructuredGrid(cells, [CellType.HEXAGONAL_PRISM], points) |
| 891 |
|
| 892 |
|
| 893 |
def Wedge() -> UnstructuredGrid: |
| 894 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single wedge. |
| 895 |
|
| 896 |
This cell corresponds to the :attr:`pyvista.CellType.WEDGE` cell type. |
| 897 |
|
| 898 |
Returns |
| 899 |
------- |
| 900 |
pyvista.UnstructuredGrid |
| 901 |
UnstructuredGrid containing a single wedge. |
| 902 |
|
| 903 |
Examples |
| 904 |
-------- |
| 905 |
Create and plot a single wedge. |
| 906 |
|
| 907 |
>>> from pyvista import examples |
| 908 |
>>> grid = examples.cells.Wedge() |
| 909 |
>>> examples.plot_cell(grid) |
| 910 |
|
| 911 |
List the grid's cells. |
| 912 |
|
| 913 |
>>> grid.cells |
| 914 |
array([6, 0, 1, 2, 3, 4, 5]) |
| 915 |
|
| 916 |
List the grid's points. |
| 917 |
|
| 918 |
>>> grid.points |
| 919 |
pyvista_ndarray([[0. , 1. , 0. ], |
| 920 |
[0. , 0. , 0. ], |
| 921 |
[0. , 0.5 , 0.8660254], |
| 922 |
[1. , 1. , 0. ], |
| 923 |
[1. , 0. , 0. ], |
| 924 |
[1. , 0.5 , 0.8660254]]) |
| 925 |
|
| 926 |
>>> grid.celltypes # same as pyvista.CellType.WEDGE |
| 927 |
array([13], dtype=uint8) |
| 928 |
|
| 929 |
""" |
| 930 |
R32 = np.sqrt(3) / 2 |
| 931 |
points = [[0, 1, 0], [0, 0.5, R32], [0, 0, 0], [1, 1, 0], [1, 0.5, R32], [1, 0.0, 0.0]] |
| 932 |
if pv.vtk_version_info < (9, 6, 99): # < (9, 7, 0) |
| 933 |
points[1], points[2] = points[2], points[1] |
| 934 |
points[4], points[5] = points[5], points[4] |
| 935 |
cells = [len(points), *list(range(len(points)))] |
| 936 |
return UnstructuredGrid(cells, [CellType.WEDGE], points) |
| 937 |
|
| 938 |
|
| 939 |
def PentagonalPrism() -> UnstructuredGrid: |
| 940 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single pentagonal prism. |
| 941 |
|
| 942 |
This cell corresponds to the :attr:`pyvista.CellType.PENTAGONAL_PRISM` cell type. |
| 943 |
|
| 944 |
Returns |
| 945 |
------- |
| 946 |
pyvista.UnstructuredGrid |
| 947 |
UnstructuredGrid containing a single pentagonal prism. |
| 948 |
|
| 949 |
Examples |
| 950 |
-------- |
| 951 |
Create and plot a single pentagonal prism. |
| 952 |
|
| 953 |
>>> from pyvista import examples |
| 954 |
>>> grid = examples.cells.PentagonalPrism() |
| 955 |
>>> examples.plot_cell(grid) |
| 956 |
|
| 957 |
List the grid's cells. |
| 958 |
|
| 959 |
>>> grid.cells |
| 960 |
array([10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) |
| 961 |
|
| 962 |
List the grid's points. |
| 963 |
|
| 964 |
>>> grid.points |
| 965 |
pyvista_ndarray([[1., 0., 0.], |
| 966 |
[3., 0., 0.], |
| 967 |
[4., 2., 0.], |
| 968 |
[2., 4., 0.], |
| 969 |
[0., 2., 0.], |
| 970 |
[1., 0., 4.], |
| 971 |
[3., 0., 4.], |
| 972 |
[4., 2., 4.], |
| 973 |
[2., 4., 4.], |
| 974 |
[0., 2., 4.]]) |
| 975 |
|
| 976 |
>>> grid.celltypes # same as pyvista.CellType.PENTAGONAL_PRISM |
| 977 |
array([15], dtype=uint8) |
| 978 |
|
| 979 |
""" |
| 980 |
points = [ |
| 981 |
[1.0, 0.0, 0.0], |
| 982 |
[3.0, 0.0, 0.0], |
| 983 |
[4.0, 2.0, 0.0], |
| 984 |
[2.0, 4.0, 0.0], |
| 985 |
[0.0, 2.0, 0.0], |
| 986 |
[1.0, 0.0, 4.0], |
| 987 |
[3.0, 0.0, 4.0], |
| 988 |
[4.0, 2.0, 4.0], |
| 989 |
[2.0, 4.0, 4.0], |
| 990 |
[0.0, 2.0, 4.0], |
| 991 |
] |
| 992 |
cells = [len(points), *list(range(len(points)))] |
| 993 |
return UnstructuredGrid(cells, [CellType.PENTAGONAL_PRISM], points) |
| 994 |
|
| 995 |
|
| 996 |
def Pyramid() -> UnstructuredGrid: |
| 997 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single pyramid. |
| 998 |
|
| 999 |
This cell corresponds to the :attr:`pyvista.CellType.PYRAMID` cell type. |
| 1000 |
|
| 1001 |
Returns |
| 1002 |
------- |
| 1003 |
pyvista.UnstructuredGrid |
| 1004 |
UnstructuredGrid containing a single pyramid. |
| 1005 |
|
| 1006 |
Examples |
| 1007 |
-------- |
| 1008 |
Create and plot a single pyramid. |
| 1009 |
|
| 1010 |
>>> from pyvista import examples |
| 1011 |
>>> grid = examples.cells.Pyramid() |
| 1012 |
>>> examples.plot_cell(grid) |
| 1013 |
|
| 1014 |
List the grid's cells. |
| 1015 |
|
| 1016 |
>>> grid.cells |
| 1017 |
array([5, 0, 1, 2, 3, 4]) |
| 1018 |
|
| 1019 |
List the grid's points. |
| 1020 |
|
| 1021 |
>>> grid.points |
| 1022 |
pyvista_ndarray([[ 0.5 , 0.5 , 0. ], |
| 1023 |
[-0.5 , 0.5 , 0. ], |
| 1024 |
[-0.5 , -0.5 , 0. ], |
| 1025 |
[ 0.5 , -0.5 , 0. ], |
| 1026 |
[ 0. , 0. , 0.70710678]]) |
| 1027 |
|
| 1028 |
>>> grid.celltypes # same as pyvista.CellType.PYRAMID |
| 1029 |
array([14], dtype=uint8) |
| 1030 |
|
| 1031 |
""" |
| 1032 |
points = [ |
| 1033 |
[0.5, 0.5, 0.0], |
| 1034 |
[-0.5, 0.5, 0.0], |
| 1035 |
[-0.5, -0.5, 0.0], |
| 1036 |
[0.5, -0.5, 0.0], |
| 1037 |
[0.0, 0.0, np.sqrt(2) / 2], |
| 1038 |
] |
| 1039 |
cells = [len(points), *list(range(len(points)))] |
| 1040 |
return UnstructuredGrid(cells, [CellType.PYRAMID], points) |
| 1041 |
|
| 1042 |
|
| 1043 |
def Voxel() -> UnstructuredGrid: |
| 1044 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single voxel. |
| 1045 |
|
| 1046 |
This cell corresponds to the :attr:`pyvista.CellType.VOXEL` cell type. |
| 1047 |
|
| 1048 |
Returns |
| 1049 |
------- |
| 1050 |
pyvista.UnstructuredGrid |
| 1051 |
UnstructuredGrid containing a single voxel. |
| 1052 |
|
| 1053 |
Examples |
| 1054 |
-------- |
| 1055 |
Create and plot a single voxel. |
| 1056 |
|
| 1057 |
>>> from pyvista import examples |
| 1058 |
>>> grid = examples.cells.Voxel() |
| 1059 |
>>> examples.plot_cell(grid) |
| 1060 |
|
| 1061 |
List the grid's cells. |
| 1062 |
|
| 1063 |
>>> grid.cells |
| 1064 |
array([8, 0, 1, 2, 3, 4, 5, 6, 7]) |
| 1065 |
|
| 1066 |
List the grid's points. |
| 1067 |
|
| 1068 |
>>> grid.points |
| 1069 |
pyvista_ndarray([[0., 0., 0.], |
| 1070 |
[1., 0., 0.], |
| 1071 |
[1., 1., 0.], |
| 1072 |
[0., 1., 0.], |
| 1073 |
[0., 0., 1.], |
| 1074 |
[1., 0., 1.], |
| 1075 |
[1., 1., 1.], |
| 1076 |
[0., 1., 1.]]) |
| 1077 |
|
| 1078 |
>>> grid.celltypes # same as pyvista.CellType.VOXEL |
| 1079 |
array([11], dtype=uint8) |
| 1080 |
|
| 1081 |
""" |
| 1082 |
points = [ |
| 1083 |
[0.0, 0.0, 0.0], |
| 1084 |
[1.0, 0.0, 0.0], |
| 1085 |
[0.0, 1.0, 0.0], |
| 1086 |
[1.0, 1.0, 0.0], |
| 1087 |
[0.0, 0.0, 1.0], |
| 1088 |
[1.0, 0.0, 1.0], |
| 1089 |
[0.0, 1.0, 1.0], |
| 1090 |
[1.0, 1.0, 1.0], |
| 1091 |
] |
| 1092 |
cells = [len(points), *list(range(len(points)))] |
| 1093 |
return UnstructuredGrid(cells, [CellType.VOXEL], points) |
| 1094 |
|
| 1095 |
|
| 1096 |
def QuadraticEdge() -> UnstructuredGrid: |
| 1097 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic edge. |
| 1098 |
|
| 1099 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_EDGE` cell type. |
| 1100 |
|
| 1101 |
Returns |
| 1102 |
------- |
| 1103 |
pyvista.UnstructuredGrid |
| 1104 |
UnstructuredGrid containing a single quadratic edge. |
| 1105 |
|
| 1106 |
Examples |
| 1107 |
-------- |
| 1108 |
Create and plot a single quadratic edge. |
| 1109 |
|
| 1110 |
>>> from pyvista import examples |
| 1111 |
>>> grid = examples.cells.QuadraticEdge() |
| 1112 |
>>> examples.plot_cell(grid) |
| 1113 |
|
| 1114 |
List the grid's cells. |
| 1115 |
|
| 1116 |
>>> grid.cells |
| 1117 |
array([3, 0, 1, 2]) |
| 1118 |
|
| 1119 |
List the grid's points. |
| 1120 |
|
| 1121 |
>>> grid.points |
| 1122 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1123 |
[1. , 0. , 0. ], |
| 1124 |
[0.5, 0. , 0. ]]) |
| 1125 |
|
| 1126 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_EDGE |
| 1127 |
array([21], dtype=uint8) |
| 1128 |
|
| 1129 |
""" |
| 1130 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_EDGE)) |
| 1131 |
|
| 1132 |
|
| 1133 |
def QuadraticTriangle() -> UnstructuredGrid: |
| 1134 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic triangle. |
| 1135 |
|
| 1136 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_TRIANGLE` cell type. |
| 1137 |
|
| 1138 |
Returns |
| 1139 |
------- |
| 1140 |
pyvista.UnstructuredGrid |
| 1141 |
UnstructuredGrid containing a single quadratic triangle. |
| 1142 |
|
| 1143 |
Examples |
| 1144 |
-------- |
| 1145 |
Create and plot a single quadratic triangle. |
| 1146 |
|
| 1147 |
>>> from pyvista import examples |
| 1148 |
>>> grid = examples.cells.QuadraticTriangle() |
| 1149 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1150 |
|
| 1151 |
List the grid's cells. |
| 1152 |
|
| 1153 |
>>> grid.cells |
| 1154 |
array([6, 0, 1, 2, 3, 4, 5]) |
| 1155 |
|
| 1156 |
List the grid's points. |
| 1157 |
|
| 1158 |
>>> grid.points |
| 1159 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1160 |
[1. , 0. , 0. ], |
| 1161 |
[0. , 1. , 0. ], |
| 1162 |
[0.5, 0. , 0. ], |
| 1163 |
[0.5, 0.5, 0. ], |
| 1164 |
[0. , 0.5, 0. ]]) |
| 1165 |
|
| 1166 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_TRIANGLE |
| 1167 |
array([22], dtype=uint8) |
| 1168 |
|
| 1169 |
""" |
| 1170 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_TRIANGLE)) |
| 1171 |
|
| 1172 |
|
| 1173 |
def QuadraticQuadrilateral() -> UnstructuredGrid: |
| 1174 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic quadrilateral. |
| 1175 |
|
| 1176 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_QUAD` cell type. |
| 1177 |
|
| 1178 |
Returns |
| 1179 |
------- |
| 1180 |
pyvista.UnstructuredGrid |
| 1181 |
UnstructuredGrid containing a single quadratic quadrilateral. |
| 1182 |
|
| 1183 |
Examples |
| 1184 |
-------- |
| 1185 |
Create and plot a single quadratic quadrilateral. |
| 1186 |
|
| 1187 |
>>> from pyvista import examples |
| 1188 |
>>> grid = examples.cells.QuadraticQuadrilateral() |
| 1189 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1190 |
|
| 1191 |
List the grid's cells. |
| 1192 |
|
| 1193 |
>>> grid.cells |
| 1194 |
array([8, 0, 1, 2, 3, 4, 5, 6, 7]) |
| 1195 |
|
| 1196 |
List the grid's points. |
| 1197 |
|
| 1198 |
>>> grid.points |
| 1199 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1200 |
[1. , 0. , 0. ], |
| 1201 |
[1. , 1. , 0. ], |
| 1202 |
[0. , 1. , 0. ], |
| 1203 |
[0.5, 0. , 0. ], |
| 1204 |
[1. , 0.5, 0. ], |
| 1205 |
[0.5, 1. , 0. ], |
| 1206 |
[0. , 0.5, 0. ]]) |
| 1207 |
|
| 1208 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_QUAD |
| 1209 |
array([23], dtype=uint8) |
| 1210 |
|
| 1211 |
""" |
| 1212 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_QUAD)) |
| 1213 |
|
| 1214 |
|
| 1215 |
def QuadraticPolygon() -> UnstructuredGrid: |
| 1216 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic polygon. |
| 1217 |
|
| 1218 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_POLYGON` cell type. |
| 1219 |
|
| 1220 |
Returns |
| 1221 |
------- |
| 1222 |
pyvista.UnstructuredGrid |
| 1223 |
UnstructuredGrid containing a single quadratic polygon. |
| 1224 |
|
| 1225 |
Examples |
| 1226 |
-------- |
| 1227 |
Create and plot a single quadratic polygon. |
| 1228 |
|
| 1229 |
>>> from pyvista import examples |
| 1230 |
>>> grid = examples.cells.QuadraticPolygon() |
| 1231 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1232 |
|
| 1233 |
List the grid's cells. |
| 1234 |
|
| 1235 |
>>> grid.cells |
| 1236 |
array([8, 0, 1, 2, 3, 4, 5, 6, 7]) |
| 1237 |
|
| 1238 |
List the grid's points. |
| 1239 |
|
| 1240 |
>>> grid.points |
| 1241 |
pyvista_ndarray([[0., 0., 0.], |
| 1242 |
[2., 0., 0.], |
| 1243 |
[2., 2., 0.], |
| 1244 |
[0., 2., 0.], |
| 1245 |
[1., 0., 0.], |
| 1246 |
[3., 1., 0.], |
| 1247 |
[1., 2., 0.], |
| 1248 |
[0., 1., 0.]]) |
| 1249 |
|
| 1250 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_POLYGON |
| 1251 |
array([36], dtype=uint8) |
| 1252 |
|
| 1253 |
""" |
| 1254 |
points = [ |
| 1255 |
[0.0, 0.0, 0.0], |
| 1256 |
[2.0, 0.0, 0.0], |
| 1257 |
[2.0, 2.0, 0.0], |
| 1258 |
[0.0, 2.0, 0.0], |
| 1259 |
[1.0, 0.0, 0.0], |
| 1260 |
[3.0, 1.0, 0.0], |
| 1261 |
[1.0, 2.0, 0.0], |
| 1262 |
[0.0, 1.0, 0.0], |
| 1263 |
] |
| 1264 |
cells = [len(points), *list(range(len(points)))] |
| 1265 |
return UnstructuredGrid(cells, [CellType.QUADRATIC_POLYGON], points) |
| 1266 |
|
| 1267 |
|
| 1268 |
def QuadraticTetrahedron() -> UnstructuredGrid: |
| 1269 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic tetrahedron. |
| 1270 |
|
| 1271 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_TETRA` cell type. |
| 1272 |
|
| 1273 |
Returns |
| 1274 |
------- |
| 1275 |
pyvista.UnstructuredGrid |
| 1276 |
UnstructuredGrid containing a single quadratic tetrahedron. |
| 1277 |
|
| 1278 |
Examples |
| 1279 |
-------- |
| 1280 |
Create and plot a single quadratic tetrahedron. |
| 1281 |
|
| 1282 |
>>> from pyvista import examples |
| 1283 |
>>> grid = examples.cells.QuadraticTetrahedron() |
| 1284 |
>>> examples.plot_cell(grid) |
| 1285 |
|
| 1286 |
List the grid's cells. |
| 1287 |
|
| 1288 |
>>> grid.cells |
| 1289 |
array([10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) |
| 1290 |
|
| 1291 |
List the grid's points. |
| 1292 |
|
| 1293 |
>>> grid.points |
| 1294 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1295 |
[1. , 0. , 0. ], |
| 1296 |
[0. , 1. , 0. ], |
| 1297 |
[0. , 0. , 1. ], |
| 1298 |
[0.5, 0. , 0. ], |
| 1299 |
[0.5, 0.5, 0. ], |
| 1300 |
[0. , 0.5, 0. ], |
| 1301 |
[0. , 0. , 0.5], |
| 1302 |
[0.5, 0. , 0.5], |
| 1303 |
[0. , 0.5, 0.5]]) |
| 1304 |
|
| 1305 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_TETRA |
| 1306 |
array([24], dtype=uint8) |
| 1307 |
|
| 1308 |
""" |
| 1309 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_TETRA)) |
| 1310 |
|
| 1311 |
|
| 1312 |
def QuadraticHexahedron() -> UnstructuredGrid: |
| 1313 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic hexahedron. |
| 1314 |
|
| 1315 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_HEXAHEDRON` cell type. |
| 1316 |
|
| 1317 |
Returns |
| 1318 |
------- |
| 1319 |
pyvista.UnstructuredGrid |
| 1320 |
UnstructuredGrid containing a single quadratic hexahedron. |
| 1321 |
|
| 1322 |
Examples |
| 1323 |
-------- |
| 1324 |
Create and plot a single quadratic hexahedron. |
| 1325 |
|
| 1326 |
>>> from pyvista import examples |
| 1327 |
>>> grid = examples.cells.QuadraticHexahedron() |
| 1328 |
>>> examples.plot_cell(grid) |
| 1329 |
|
| 1330 |
List the grid's cells. |
| 1331 |
|
| 1332 |
>>> grid.cells |
| 1333 |
array([20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1334 |
16, 17, 18, 19]) |
| 1335 |
|
| 1336 |
List the grid's points. |
| 1337 |
|
| 1338 |
>>> grid.points |
| 1339 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1340 |
[1. , 0. , 0. ], |
| 1341 |
[1. , 1. , 0. ], |
| 1342 |
[0. , 1. , 0. ], |
| 1343 |
[0. , 0. , 1. ], |
| 1344 |
[1. , 0. , 1. ], |
| 1345 |
[1. , 1. , 1. ], |
| 1346 |
[0. , 1. , 1. ], |
| 1347 |
[0.5, 0. , 0. ], |
| 1348 |
[1. , 0.5, 0. ], |
| 1349 |
[0.5, 1. , 0. ], |
| 1350 |
[0. , 0.5, 0. ], |
| 1351 |
[0.5, 0. , 1. ], |
| 1352 |
[1. , 0.5, 1. ], |
| 1353 |
[0.5, 1. , 1. ], |
| 1354 |
[0. , 0.5, 1. ], |
| 1355 |
[0. , 0. , 0.5], |
| 1356 |
[1. , 0. , 0.5], |
| 1357 |
[1. , 1. , 0.5], |
| 1358 |
[0. , 1. , 0.5]]) |
| 1359 |
|
| 1360 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_HEXAHEDRON |
| 1361 |
array([25], dtype=uint8) |
| 1362 |
|
| 1363 |
""" |
| 1364 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_HEXAHEDRON)) |
| 1365 |
|
| 1366 |
|
| 1367 |
def QuadraticWedge() -> UnstructuredGrid: |
| 1368 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic wedge. |
| 1369 |
|
| 1370 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_WEDGE` cell type. |
| 1371 |
|
| 1372 |
Returns |
| 1373 |
------- |
| 1374 |
pyvista.UnstructuredGrid |
| 1375 |
UnstructuredGrid containing a single quadratic wedge. |
| 1376 |
|
| 1377 |
Examples |
| 1378 |
-------- |
| 1379 |
Create and plot a single quadratic wedge. |
| 1380 |
|
| 1381 |
>>> from pyvista import examples |
| 1382 |
>>> grid = examples.cells.QuadraticWedge() |
| 1383 |
>>> examples.plot_cell(grid) |
| 1384 |
|
| 1385 |
List the grid's cells. |
| 1386 |
|
| 1387 |
>>> grid.cells |
| 1388 |
array([15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) |
| 1389 |
|
| 1390 |
List the grid's points. |
| 1391 |
|
| 1392 |
>>> grid.points |
| 1393 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1394 |
[1. , 0. , 0. ], |
| 1395 |
[0. , 1. , 0. ], |
| 1396 |
[0. , 0. , 1. ], |
| 1397 |
[1. , 0. , 1. ], |
| 1398 |
[0. , 1. , 1. ], |
| 1399 |
[0.5, 0. , 0. ], |
| 1400 |
[0.5, 0.5, 0. ], |
| 1401 |
[0. , 0.5, 0. ], |
| 1402 |
[0.5, 0. , 1. ], |
| 1403 |
[0.5, 0.5, 1. ], |
| 1404 |
[0. , 0.5, 1. ], |
| 1405 |
[0. , 0. , 0.5], |
| 1406 |
[1. , 0. , 0.5], |
| 1407 |
[0. , 1. , 0.5]]) |
| 1408 |
|
| 1409 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_WEDGE |
| 1410 |
array([26], dtype=uint8) |
| 1411 |
|
| 1412 |
""" |
| 1413 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_WEDGE)) |
| 1414 |
|
| 1415 |
|
| 1416 |
def QuadraticPyramid() -> UnstructuredGrid: |
| 1417 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic pyramid. |
| 1418 |
|
| 1419 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_PYRAMID` cell type. |
| 1420 |
|
| 1421 |
Returns |
| 1422 |
------- |
| 1423 |
pyvista.UnstructuredGrid |
| 1424 |
UnstructuredGrid containing a single quadratic pyramid. |
| 1425 |
|
| 1426 |
Examples |
| 1427 |
-------- |
| 1428 |
Create and plot a single quadratic pyramid. |
| 1429 |
|
| 1430 |
>>> from pyvista import examples |
| 1431 |
>>> grid = examples.cells.QuadraticPyramid() |
| 1432 |
>>> examples.plot_cell(grid) |
| 1433 |
|
| 1434 |
List the grid's cells. |
| 1435 |
|
| 1436 |
>>> grid.cells |
| 1437 |
array([13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) |
| 1438 |
|
| 1439 |
List the grid's points. |
| 1440 |
|
| 1441 |
>>> grid.points |
| 1442 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1443 |
[1. , 0. , 0. ], |
| 1444 |
[1. , 1. , 0. ], |
| 1445 |
[0. , 1. , 0. ], |
| 1446 |
[0. , 0. , 1. ], |
| 1447 |
[0.5, 0. , 0. ], |
| 1448 |
[1. , 0.5, 0. ], |
| 1449 |
[0.5, 1. , 0. ], |
| 1450 |
[0. , 0.5, 0. ], |
| 1451 |
[0. , 0. , 0.5], |
| 1452 |
[1. , 0. , 0.5], |
| 1453 |
[1. , 1. , 0.5], |
| 1454 |
[0. , 1. , 0.5]]) |
| 1455 |
|
| 1456 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_POLYGON |
| 1457 |
array([27], dtype=uint8) |
| 1458 |
|
| 1459 |
""" |
| 1460 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_PYRAMID)) |
| 1461 |
|
| 1462 |
|
| 1463 |
def BiQuadraticQuadrilateral() -> UnstructuredGrid: |
| 1464 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single biquadratic quadrilateral. |
| 1465 |
|
| 1466 |
This cell corresponds to the :attr:`pyvista.CellType.BIQUADRATIC_QUAD` cell type. |
| 1467 |
|
| 1468 |
Returns |
| 1469 |
------- |
| 1470 |
pyvista.UnstructuredGrid |
| 1471 |
UnstructuredGrid containing a single biquadratic quadrilateral. |
| 1472 |
|
| 1473 |
Examples |
| 1474 |
-------- |
| 1475 |
Create and plot a single biquadratic quadrilateral. |
| 1476 |
|
| 1477 |
>>> from pyvista import examples |
| 1478 |
>>> grid = examples.cells.BiQuadraticQuadrilateral() |
| 1479 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1480 |
|
| 1481 |
List the grid's cells. |
| 1482 |
|
| 1483 |
>>> grid.cells |
| 1484 |
array([9, 0, 1, 2, 3, 4, 5, 6, 7, 8]) |
| 1485 |
|
| 1486 |
List the grid's points. |
| 1487 |
|
| 1488 |
>>> grid.points |
| 1489 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1490 |
[1. , 0. , 0. ], |
| 1491 |
[1. , 1. , 0. ], |
| 1492 |
[0. , 1. , 0. ], |
| 1493 |
[0.5, 0. , 0. ], |
| 1494 |
[1. , 0.5, 0. ], |
| 1495 |
[0.5, 1. , 0. ], |
| 1496 |
[0. , 0.5, 0. ], |
| 1497 |
[0.5, 0.5, 0. ]]) |
| 1498 |
|
| 1499 |
>>> grid.celltypes # same as pyvista.CellType.BIQUADRATIC_QUAD |
| 1500 |
array([28], dtype=uint8) |
| 1501 |
|
| 1502 |
""" |
| 1503 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.BIQUADRATIC_QUAD)) |
| 1504 |
|
| 1505 |
|
| 1506 |
def TriQuadraticHexahedron() -> UnstructuredGrid: |
| 1507 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single triquadratic hexahedron. |
| 1508 |
|
| 1509 |
This cell corresponds to the :attr:`pyvista.CellType.TRIQUADRATIC_HEXAHEDRON` cell type. |
| 1510 |
|
| 1511 |
Returns |
| 1512 |
------- |
| 1513 |
pyvista.UnstructuredGrid |
| 1514 |
UnstructuredGrid containing a single triquadratic hexahedron. |
| 1515 |
|
| 1516 |
Examples |
| 1517 |
-------- |
| 1518 |
Create and plot a single triquadratic hexahedron. |
| 1519 |
|
| 1520 |
>>> from pyvista import examples |
| 1521 |
>>> grid = examples.cells.TriQuadraticHexahedron() |
| 1522 |
>>> examples.plot_cell(grid) |
| 1523 |
|
| 1524 |
List the grid's cells. |
| 1525 |
|
| 1526 |
>>> grid.cells |
| 1527 |
array([27, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1528 |
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) |
| 1529 |
|
| 1530 |
List the grid's points. |
| 1531 |
|
| 1532 |
>>> grid.points |
| 1533 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1534 |
[1. , 0. , 0. ], |
| 1535 |
[1. , 1. , 0. ], |
| 1536 |
[0. , 1. , 0. ], |
| 1537 |
[0. , 0. , 1. ], |
| 1538 |
[1. , 0. , 1. ], |
| 1539 |
[1. , 1. , 1. ], |
| 1540 |
[0. , 1. , 1. ], |
| 1541 |
[0.5, 0. , 0. ], |
| 1542 |
[1. , 0.5, 0. ], |
| 1543 |
[0.5, 1. , 0. ], |
| 1544 |
[0. , 0.5, 0. ], |
| 1545 |
[0.5, 0. , 1. ], |
| 1546 |
[1. , 0.5, 1. ], |
| 1547 |
[0.5, 1. , 1. ], |
| 1548 |
[0. , 0.5, 1. ], |
| 1549 |
[0. , 0. , 0.5], |
| 1550 |
[1. , 0. , 0.5], |
| 1551 |
[1. , 1. , 0.5], |
| 1552 |
[0. , 1. , 0.5], |
| 1553 |
[0. , 0.5, 0.5], |
| 1554 |
[1. , 0.5, 0.5], |
| 1555 |
[0.5, 0. , 0.5], |
| 1556 |
[0.5, 1. , 0.5], |
| 1557 |
[0.5, 0.5, 0. ], |
| 1558 |
[0.5, 0.5, 1. ], |
| 1559 |
[0.5, 0.5, 0.5]]) |
| 1560 |
|
| 1561 |
>>> grid.celltypes # same as pyvista.CellType.TRIQUADRATIC_HEXAHEDRON |
| 1562 |
array([29], dtype=uint8) |
| 1563 |
|
| 1564 |
""" |
| 1565 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.TRIQUADRATIC_HEXAHEDRON)) |
| 1566 |
|
| 1567 |
|
| 1568 |
def TriQuadraticPyramid() -> UnstructuredGrid: |
| 1569 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single triquadratic pyramid. |
| 1570 |
|
| 1571 |
This cell corresponds to the :attr:`pyvista.CellType.TRIQUADRATIC_PYRAMID` cell type. |
| 1572 |
|
| 1573 |
Returns |
| 1574 |
------- |
| 1575 |
pyvista.UnstructuredGrid |
| 1576 |
UnstructuredGrid containing a single triquadratic pyramid. |
| 1577 |
|
| 1578 |
Examples |
| 1579 |
-------- |
| 1580 |
Create and plot a single triquadratic pyramid. |
| 1581 |
|
| 1582 |
>>> from pyvista import examples |
| 1583 |
>>> grid = examples.cells.TriQuadraticPyramid() |
| 1584 |
>>> examples.plot_cell(grid) |
| 1585 |
|
| 1586 |
List the grid's cells. |
| 1587 |
|
| 1588 |
>>> grid.cells |
| 1589 |
array([19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1590 |
16, 17, 18]) |
| 1591 |
|
| 1592 |
List the grid's points. |
| 1593 |
|
| 1594 |
>>> grid.points |
| 1595 |
pyvista_ndarray([[0. , 0. , 0.5 ], |
| 1596 |
[1. , 0. , 0.5 ], |
| 1597 |
[1. , 1. , 0.5 ], |
| 1598 |
[0. , 1. , 0.5 ], |
| 1599 |
[0.5 , 0.5 , 1. ], |
| 1600 |
[0.5 , 0. , 0.5 ], |
| 1601 |
[1. , 0.5 , 0.5 ], |
| 1602 |
[0.5 , 1. , 0.5 ], |
| 1603 |
[0. , 0.5 , 0.5 ], |
| 1604 |
[0.25 , 0.25 , 0.75 ], |
| 1605 |
[0.75 , 0.25 , 0.75 ], |
| 1606 |
[0.75 , 0.75 , 0.75 ], |
| 1607 |
[0.25 , 0.75 , 0.75 ], |
| 1608 |
[0.5 , 0.5 , 0.5 ], |
| 1609 |
[0.5 , 0.16666667, 0.66666667], |
| 1610 |
[0.83333333, 0.5 , 0.66666667], |
| 1611 |
[0.5 , 0.83333333, 0.66666667], |
| 1612 |
[0.16666667, 0.5 , 0.66666667], |
| 1613 |
[0.5 , 0.5 , 0.625 ]]) |
| 1614 |
|
| 1615 |
>>> grid.celltypes # same as pyvista.CellType.TRIQUADRATIC_PYRAMID |
| 1616 |
array([37], dtype=uint8) |
| 1617 |
|
| 1618 |
""" |
| 1619 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.TRIQUADRATIC_PYRAMID)) |
| 1620 |
|
| 1621 |
|
| 1622 |
def QuadraticLinearQuadrilateral() -> UnstructuredGrid: |
| 1623 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic linear quadrilateral. |
| 1624 |
|
| 1625 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_LINEAR_QUAD` cell type. |
| 1626 |
|
| 1627 |
Returns |
| 1628 |
------- |
| 1629 |
pyvista.UnstructuredGrid |
| 1630 |
UnstructuredGrid containing a single quadratic linear quadrilateral. |
| 1631 |
|
| 1632 |
Examples |
| 1633 |
-------- |
| 1634 |
Create and plot a single quadratic linear quadrilateral. |
| 1635 |
|
| 1636 |
>>> from pyvista import examples |
| 1637 |
>>> grid = examples.cells.QuadraticLinearQuadrilateral() |
| 1638 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1639 |
|
| 1640 |
List the grid's cells. |
| 1641 |
|
| 1642 |
>>> grid.cells |
| 1643 |
array([6, 0, 1, 2, 3, 4, 5]) |
| 1644 |
|
| 1645 |
List the grid's points. |
| 1646 |
|
| 1647 |
>>> grid.points |
| 1648 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1649 |
[1. , 0. , 0. ], |
| 1650 |
[1. , 1. , 0. ], |
| 1651 |
[0. , 1. , 0. ], |
| 1652 |
[0.5, 0. , 0. ], |
| 1653 |
[0.5, 1. , 0. ]]) |
| 1654 |
|
| 1655 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_LINEAR_QUAD |
| 1656 |
array([30], dtype=uint8) |
| 1657 |
|
| 1658 |
""" # noqa: E501 |
| 1659 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_LINEAR_QUAD)) |
| 1660 |
|
| 1661 |
|
| 1662 |
def QuadraticLinearWedge() -> UnstructuredGrid: |
| 1663 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single quadratic linear wedge. |
| 1664 |
|
| 1665 |
This cell corresponds to the :attr:`pyvista.CellType.QUADRATIC_LINEAR_WEDGE` cell type. |
| 1666 |
|
| 1667 |
Returns |
| 1668 |
------- |
| 1669 |
pyvista.UnstructuredGrid |
| 1670 |
UnstructuredGrid containing a single quadratic linear wedge. |
| 1671 |
|
| 1672 |
Examples |
| 1673 |
-------- |
| 1674 |
Create and plot a single quadratic linear wedge. |
| 1675 |
|
| 1676 |
>>> from pyvista import examples |
| 1677 |
>>> grid = examples.cells.QuadraticLinearWedge() |
| 1678 |
>>> examples.plot_cell(grid) |
| 1679 |
|
| 1680 |
List the grid's cells. |
| 1681 |
|
| 1682 |
>>> grid.cells |
| 1683 |
array([12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) |
| 1684 |
|
| 1685 |
List the grid's points. |
| 1686 |
|
| 1687 |
>>> grid.points |
| 1688 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1689 |
[1. , 0. , 0. ], |
| 1690 |
[0. , 1. , 0. ], |
| 1691 |
[0. , 0. , 1. ], |
| 1692 |
[1. , 0. , 1. ], |
| 1693 |
[0. , 1. , 1. ], |
| 1694 |
[0.5, 0. , 0. ], |
| 1695 |
[0.5, 0.5, 0. ], |
| 1696 |
[0. , 0.5, 0. ], |
| 1697 |
[0.5, 0. , 1. ], |
| 1698 |
[0.5, 0.5, 1. ], |
| 1699 |
[0. , 0.5, 1. ]]) |
| 1700 |
|
| 1701 |
>>> grid.celltypes # same as pyvista.CellType.QUADRATIC_LINEAR_WEDGE |
| 1702 |
array([31], dtype=uint8) |
| 1703 |
|
| 1704 |
""" |
| 1705 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.QUADRATIC_LINEAR_WEDGE)) |
| 1706 |
|
| 1707 |
|
| 1708 |
def BiQuadraticQuadraticWedge() -> UnstructuredGrid: |
| 1709 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single biquadratic quadratic wedge. |
| 1710 |
|
| 1711 |
This cell corresponds to the :attr:`pyvista.CellType.BIQUADRATIC_QUADRATIC_WEDGE` cell type. |
| 1712 |
|
| 1713 |
Returns |
| 1714 |
------- |
| 1715 |
pyvista.UnstructuredGrid |
| 1716 |
UnstructuredGrid containing a single biquadratic quadratic wedge. |
| 1717 |
|
| 1718 |
Examples |
| 1719 |
-------- |
| 1720 |
Create and plot a single biquadratic quadratic wedge. |
| 1721 |
|
| 1722 |
>>> from pyvista import examples |
| 1723 |
>>> grid = examples.cells.BiQuadraticQuadraticWedge() |
| 1724 |
>>> examples.plot_cell(grid) |
| 1725 |
|
| 1726 |
List the grid's cells. |
| 1727 |
|
| 1728 |
>>> grid.cells |
| 1729 |
array([18, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1730 |
16, 17]) |
| 1731 |
|
| 1732 |
List the grid's points. |
| 1733 |
|
| 1734 |
>>> grid.points |
| 1735 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1736 |
[1. , 0. , 0. ], |
| 1737 |
[0. , 1. , 0. ], |
| 1738 |
[0. , 0. , 1. ], |
| 1739 |
[1. , 0. , 1. ], |
| 1740 |
[0. , 1. , 1. ], |
| 1741 |
[0.5, 0. , 0. ], |
| 1742 |
[0.5, 0.5, 0. ], |
| 1743 |
[0. , 0.5, 0. ], |
| 1744 |
[0.5, 0. , 1. ], |
| 1745 |
[0.5, 0.5, 1. ], |
| 1746 |
[0. , 0.5, 1. ], |
| 1747 |
[0. , 0. , 0.5], |
| 1748 |
[1. , 0. , 0.5], |
| 1749 |
[0. , 1. , 0.5], |
| 1750 |
[0.5, 0. , 0.5], |
| 1751 |
[0.5, 0.5, 0.5], |
| 1752 |
[0. , 0.5, 0.5]]) |
| 1753 |
|
| 1754 |
>>> grid.celltypes # same as pyvista.CellType.BIQUADRATIC_QUADRATIC_WEDGE |
| 1755 |
array([32], dtype=uint8) |
| 1756 |
|
| 1757 |
""" |
| 1758 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.BIQUADRATIC_QUADRATIC_WEDGE)) |
| 1759 |
|
| 1760 |
|
| 1761 |
def BiQuadraticQuadraticHexahedron() -> UnstructuredGrid: |
| 1762 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single biquadratic quadratic hexahedron. |
| 1763 |
|
| 1764 |
This cell corresponds to the :attr:`pyvista.CellType.BIQUADRATIC_QUADRATIC_HEXAHEDRON` |
| 1765 |
cell type. |
| 1766 |
|
| 1767 |
Returns |
| 1768 |
------- |
| 1769 |
pyvista.UnstructuredGrid |
| 1770 |
UnstructuredGrid containing a single biquadratic quadratic hexahedron. |
| 1771 |
|
| 1772 |
Examples |
| 1773 |
-------- |
| 1774 |
Create and plot a single biquadratic quadratic hexahedron. |
| 1775 |
|
| 1776 |
>>> from pyvista import examples |
| 1777 |
>>> grid = examples.cells.BiQuadraticQuadraticHexahedron() |
| 1778 |
>>> examples.plot_cell(grid) |
| 1779 |
|
| 1780 |
List the grid's cells. |
| 1781 |
|
| 1782 |
>>> grid.cells |
| 1783 |
array([24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1784 |
16, 17, 18, 19, 20, 21, 22, 23]) |
| 1785 |
|
| 1786 |
List the grid's points. |
| 1787 |
|
| 1788 |
>>> grid.points |
| 1789 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1790 |
[1. , 0. , 0. ], |
| 1791 |
[1. , 1. , 0. ], |
| 1792 |
[0. , 1. , 0. ], |
| 1793 |
[0. , 0. , 1. ], |
| 1794 |
[1. , 0. , 1. ], |
| 1795 |
[1. , 1. , 1. ], |
| 1796 |
[0. , 1. , 1. ], |
| 1797 |
[0.5, 0. , 0. ], |
| 1798 |
[1. , 0.5, 0. ], |
| 1799 |
[0.5, 1. , 0. ], |
| 1800 |
[0. , 0.5, 0. ], |
| 1801 |
[0.5, 0. , 1. ], |
| 1802 |
[1. , 0.5, 1. ], |
| 1803 |
[0.5, 1. , 1. ], |
| 1804 |
[0. , 0.5, 1. ], |
| 1805 |
[0. , 0. , 0.5], |
| 1806 |
[1. , 0. , 0.5], |
| 1807 |
[1. , 1. , 0.5], |
| 1808 |
[0. , 1. , 0.5], |
| 1809 |
[0. , 0.5, 0.5], |
| 1810 |
[1. , 0.5, 0.5], |
| 1811 |
[0.5, 0. , 0.5], |
| 1812 |
[0.5, 1. , 0.5]]) |
| 1813 |
|
| 1814 |
>>> grid.celltypes # same as pyvista.CellType.BIQUADRATIC_QUADRATIC_HEXAHEDRON |
| 1815 |
array([33], dtype=uint8) |
| 1816 |
|
| 1817 |
""" # noqa: E501 |
| 1818 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.BIQUADRATIC_QUADRATIC_HEXAHEDRON)) |
| 1819 |
|
| 1820 |
|
| 1821 |
def BiQuadraticTriangle() -> UnstructuredGrid: |
| 1822 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single biquadratic triangle. |
| 1823 |
|
| 1824 |
This cell corresponds to the :attr:`pyvista.CellType.BIQUADRATIC_TRIANGLE` cell type. |
| 1825 |
|
| 1826 |
Returns |
| 1827 |
------- |
| 1828 |
pyvista.UnstructuredGrid |
| 1829 |
UnstructuredGrid containing a single biquadratic triangle. |
| 1830 |
|
| 1831 |
Examples |
| 1832 |
-------- |
| 1833 |
Create and plot a single biquadratic triangle. |
| 1834 |
|
| 1835 |
>>> from pyvista import examples |
| 1836 |
>>> grid = examples.cells.BiQuadraticTriangle() |
| 1837 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1838 |
|
| 1839 |
List the grid's cells. |
| 1840 |
|
| 1841 |
>>> grid.cells |
| 1842 |
array([7, 0, 1, 2, 3, 4, 5, 6]) |
| 1843 |
|
| 1844 |
List the grid's points. |
| 1845 |
|
| 1846 |
>>> grid.points |
| 1847 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1848 |
[1. , 0. , 0. ], |
| 1849 |
[0. , 1. , 0. ], |
| 1850 |
[0.5 , 0. , 0. ], |
| 1851 |
[0.5 , 0.5 , 0. ], |
| 1852 |
[0. , 0.5 , 0. ], |
| 1853 |
[0.33333333, 0.33333333, 0. ]]) |
| 1854 |
|
| 1855 |
>>> grid.celltypes # same as pyvista.CellType.BIQUADRATIC_TRIANGLE |
| 1856 |
array([34], dtype=uint8) |
| 1857 |
|
| 1858 |
""" |
| 1859 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.BIQUADRATIC_TRIANGLE)) |
| 1860 |
|
| 1861 |
|
| 1862 |
def CubicLine() -> UnstructuredGrid: |
| 1863 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single cubic line. |
| 1864 |
|
| 1865 |
This cell corresponds to the :attr:`pyvista.CellType.CUBIC_LINE` cell type. |
| 1866 |
|
| 1867 |
Returns |
| 1868 |
------- |
| 1869 |
pyvista.UnstructuredGrid |
| 1870 |
UnstructuredGrid containing a single cubic line. |
| 1871 |
|
| 1872 |
Examples |
| 1873 |
-------- |
| 1874 |
Create and plot a single cubic line. |
| 1875 |
|
| 1876 |
>>> from pyvista import examples |
| 1877 |
>>> grid = examples.cells.CubicLine() |
| 1878 |
>>> examples.plot_cell(grid) |
| 1879 |
|
| 1880 |
List the grid's cells. |
| 1881 |
|
| 1882 |
>>> grid.cells |
| 1883 |
array([4, 0, 1, 2, 3]) |
| 1884 |
|
| 1885 |
List the grid's points. |
| 1886 |
|
| 1887 |
>>> grid.points |
| 1888 |
pyvista_ndarray([[-1. , 0. , 0. ], |
| 1889 |
[ 1. , 0. , 0. ], |
| 1890 |
[-0.33333333, 0. , 0. ], |
| 1891 |
[ 0.33333333, 0. , 0. ]]) |
| 1892 |
|
| 1893 |
>>> grid.celltypes # same as pyvista.CellType.CUBIC_LINE |
| 1894 |
array([35], dtype=uint8) |
| 1895 |
|
| 1896 |
""" |
| 1897 |
return cast('UnstructuredGrid', _isoparametric_grid(CellType.CUBIC_LINE)) |
| 1898 |
|
| 1899 |
|
| 1900 |
def LagrangeCurve(*, cell_order: int = 3) -> UnstructuredGrid: |
| 1901 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Lagrange curve. |
| 1902 |
|
| 1903 |
This cell corresponds to the :attr:`pyvista.CellType.LAGRANGE_CURVE` cell type. |
| 1904 |
|
| 1905 |
Parameters |
| 1906 |
---------- |
| 1907 |
cell_order : int, default: 3 |
| 1908 |
Order of interpolation to use. |
| 1909 |
|
| 1910 |
Returns |
| 1911 |
------- |
| 1912 |
pyvista.UnstructuredGrid |
| 1913 |
UnstructuredGrid containing a single Lagrange curve. |
| 1914 |
|
| 1915 |
Examples |
| 1916 |
-------- |
| 1917 |
Create and plot a single Lagrange curve. |
| 1918 |
|
| 1919 |
>>> from pyvista import examples |
| 1920 |
>>> grid = examples.cells.LagrangeCurve() |
| 1921 |
>>> examples.plot_cell(grid) |
| 1922 |
|
| 1923 |
List the grid's cells. |
| 1924 |
|
| 1925 |
>>> grid.cells |
| 1926 |
array([4, 0, 1, 2, 3]) |
| 1927 |
|
| 1928 |
List the grid's points. |
| 1929 |
|
| 1930 |
>>> grid.points |
| 1931 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1932 |
[1. , 0. , 0. ], |
| 1933 |
[0.33333334, 0. , 0. ], |
| 1934 |
[0.66666669, 0. , 0. ]]) |
| 1935 |
|
| 1936 |
>>> grid.celltypes # same as pyvista.CellType.LAGRANGE_CURVE |
| 1937 |
array([68], dtype=uint8) |
| 1938 |
|
| 1939 |
""" |
| 1940 |
return cast( |
| 1941 |
'UnstructuredGrid', _vtkCellTypeSource(CellType.LAGRANGE_CURVE, cell_order=cell_order) |
| 1942 |
) |
| 1943 |
|
| 1944 |
|
| 1945 |
def LagrangeTriangle(*, cell_order: int = 3) -> UnstructuredGrid: |
| 1946 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Lagrange triangle. |
| 1947 |
|
| 1948 |
This cell corresponds to the :attr:`pyvista.CellType.LAGRANGE_TRIANGLE` cell type. |
| 1949 |
|
| 1950 |
Parameters |
| 1951 |
---------- |
| 1952 |
cell_order : int, default: 3 |
| 1953 |
Order of interpolation to use. |
| 1954 |
|
| 1955 |
Returns |
| 1956 |
------- |
| 1957 |
pyvista.UnstructuredGrid |
| 1958 |
UnstructuredGrid containing a single Lagrange triangle. |
| 1959 |
|
| 1960 |
Examples |
| 1961 |
-------- |
| 1962 |
Create and plot a single Lagrange triangle. |
| 1963 |
|
| 1964 |
>>> from pyvista import examples |
| 1965 |
>>> grid = examples.cells.LagrangeTriangle() |
| 1966 |
>>> examples.plot_cell(grid, cpos='xy') |
| 1967 |
|
| 1968 |
List the grid's cells. |
| 1969 |
|
| 1970 |
>>> grid.cells |
| 1971 |
array([10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) |
| 1972 |
|
| 1973 |
List the grid's points. |
| 1974 |
|
| 1975 |
>>> grid.points |
| 1976 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 1977 |
[1. , 0. , 0. ], |
| 1978 |
[0. , 1. , 0. ], |
| 1979 |
[0.33333334, 0. , 0. ], |
| 1980 |
[0.66666669, 0. , 0. ], |
| 1981 |
[0.66666669, 0.33333334, 0. ], |
| 1982 |
[0.33333334, 0.66666669, 0. ], |
| 1983 |
[0. , 0.66666669, 0. ], |
| 1984 |
[0. , 0.33333334, 0. ], |
| 1985 |
[0.33333334, 0.33333334, 0. ]]) |
| 1986 |
|
| 1987 |
>>> grid.celltypes # same as pyvista.CellType.LAGRANGE_TRIANGLE |
| 1988 |
array([69], dtype=uint8) |
| 1989 |
|
| 1990 |
""" |
| 1991 |
return cast( |
| 1992 |
'UnstructuredGrid', |
| 1993 |
_vtkCellTypeSource(CellType.LAGRANGE_TRIANGLE, cell_order=cell_order), |
| 1994 |
) |
| 1995 |
|
| 1996 |
|
| 1997 |
def LagrangeQuadrilateral(*, cell_order: int = 3) -> UnstructuredGrid: |
| 1998 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Lagrange quadrilateral. |
| 1999 |
|
| 2000 |
This cell corresponds to the :attr:`pyvista.CellType.LAGRANGE_QUADRILATERAL` cell type. |
| 2001 |
|
| 2002 |
Parameters |
| 2003 |
---------- |
| 2004 |
cell_order : int, default: 3 |
| 2005 |
Order of interpolation to use. |
| 2006 |
|
| 2007 |
Returns |
| 2008 |
------- |
| 2009 |
pyvista.UnstructuredGrid |
| 2010 |
UnstructuredGrid containing a single Lagrange quadrilateral. |
| 2011 |
|
| 2012 |
Examples |
| 2013 |
-------- |
| 2014 |
Create and plot a single Lagrange quadrilateral. |
| 2015 |
|
| 2016 |
>>> from pyvista import examples |
| 2017 |
>>> grid = examples.cells.LagrangeQuadrilateral() |
| 2018 |
>>> examples.plot_cell(grid, cpos='xy') |
| 2019 |
|
| 2020 |
List the grid's cells. |
| 2021 |
|
| 2022 |
>>> grid.cells |
| 2023 |
array([16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) |
| 2024 |
|
| 2025 |
List the grid's points. |
| 2026 |
|
| 2027 |
>>> grid.points |
| 2028 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2029 |
[1. , 0. , 0. ], |
| 2030 |
[1. , 1. , 0. ], |
| 2031 |
[0. , 1. , 0. ], |
| 2032 |
[0.33333334, 0. , 0. ], |
| 2033 |
[0.66666669, 0. , 0. ], |
| 2034 |
[1. , 0.33333334, 0. ], |
| 2035 |
[1. , 0.66666669, 0. ], |
| 2036 |
[0.33333334, 1. , 0. ], |
| 2037 |
[0.66666669, 1. , 0. ], |
| 2038 |
[0. , 0.33333334, 0. ], |
| 2039 |
[0. , 0.66666669, 0. ], |
| 2040 |
[0.33333334, 0.33333334, 0. ], |
| 2041 |
[0.66666669, 0.33333334, 0. ], |
| 2042 |
[0.33333334, 0.66666669, 0. ], |
| 2043 |
[0.66666669, 0.66666669, 0. ]]) |
| 2044 |
|
| 2045 |
>>> grid.celltypes # same as pyvista.CellType.LAGRANGE_QUADRILATERAL |
| 2046 |
array([70], dtype=uint8) |
| 2047 |
|
| 2048 |
""" |
| 2049 |
return cast( |
| 2050 |
'UnstructuredGrid', |
| 2051 |
_vtkCellTypeSource(CellType.LAGRANGE_QUADRILATERAL, cell_order=cell_order), |
| 2052 |
) |
| 2053 |
|
| 2054 |
|
| 2055 |
def LagrangeTetrahedron(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2056 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Lagrange tetrahedron. |
| 2057 |
|
| 2058 |
This cell corresponds to the :attr:`pyvista.CellType.LAGRANGE_TETRAHEDRON` cell type. |
| 2059 |
|
| 2060 |
Parameters |
| 2061 |
---------- |
| 2062 |
cell_order : int, default: 3 |
| 2063 |
Order of interpolation to use. |
| 2064 |
|
| 2065 |
Returns |
| 2066 |
------- |
| 2067 |
pyvista.UnstructuredGrid |
| 2068 |
UnstructuredGrid containing a single Lagrange tetrahedron. |
| 2069 |
|
| 2070 |
Examples |
| 2071 |
-------- |
| 2072 |
Create and plot a single Lagrange tetrahedron. |
| 2073 |
|
| 2074 |
>>> from pyvista import examples |
| 2075 |
>>> grid = examples.cells.LagrangeTetrahedron() |
| 2076 |
>>> examples.plot_cell(grid) |
| 2077 |
|
| 2078 |
List the grid's cells. |
| 2079 |
|
| 2080 |
>>> grid.cells |
| 2081 |
array([20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2082 |
16, 17, 18, 19]) |
| 2083 |
|
| 2084 |
List the grid's points. |
| 2085 |
|
| 2086 |
>>> grid.points |
| 2087 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2088 |
[1. , 0. , 0. ], |
| 2089 |
[1. , 1. , 0. ], |
| 2090 |
[0.5 , 0.5 , 0.5 ], |
| 2091 |
[0.33333334, 0. , 0. ], |
| 2092 |
[0.66666669, 0. , 0. ], |
| 2093 |
[1. , 0.33333334, 0. ], |
| 2094 |
[1. , 0.66666669, 0. ], |
| 2095 |
[0.66666669, 0.66666669, 0. ], |
| 2096 |
[0.33333334, 0.33333334, 0. ], |
| 2097 |
[0.16666667, 0.16666667, 0.16666667], |
| 2098 |
[0.33333334, 0.33333334, 0.33333334], |
| 2099 |
[0.83333331, 0.16666667, 0.16666667], |
| 2100 |
[0.66666669, 0.33333334, 0.33333334], |
| 2101 |
[0.83333331, 0.83333331, 0.16666667], |
| 2102 |
[0.66666669, 0.66666669, 0.33333334], |
| 2103 |
[0.5 , 0.16666667, 0.16666667], |
| 2104 |
[0.83333331, 0.5 , 0.16666667], |
| 2105 |
[0.5 , 0.5 , 0.16666667], |
| 2106 |
[0.66666669, 0.33333334, 0. ]]) |
| 2107 |
|
| 2108 |
>>> grid.celltypes # same as pyvista.CellType.LAGRANGE_TETRAHEDRON |
| 2109 |
array([71], dtype=uint8) |
| 2110 |
|
| 2111 |
""" |
| 2112 |
return cast( |
| 2113 |
'UnstructuredGrid', |
| 2114 |
_vtkCellTypeSource(CellType.LAGRANGE_TETRAHEDRON, cell_order=cell_order), |
| 2115 |
) |
| 2116 |
|
| 2117 |
|
| 2118 |
def LagrangeHexahedron(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2119 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Lagrange hexahedron. |
| 2120 |
|
| 2121 |
This cell corresponds to the :attr:`pyvista.CellType.LAGRANGE_HEXAHEDRON` cell type. |
| 2122 |
|
| 2123 |
Parameters |
| 2124 |
---------- |
| 2125 |
cell_order : int, default: 3 |
| 2126 |
Order of interpolation to use. |
| 2127 |
|
| 2128 |
Returns |
| 2129 |
------- |
| 2130 |
pyvista.UnstructuredGrid |
| 2131 |
UnstructuredGrid containing a single Lagrange hexahedron. |
| 2132 |
|
| 2133 |
Examples |
| 2134 |
-------- |
| 2135 |
Create and plot a single Lagrange hexahedron. |
| 2136 |
|
| 2137 |
>>> from pyvista import examples |
| 2138 |
>>> grid = examples.cells.LagrangeHexahedron() |
| 2139 |
>>> examples.plot_cell(grid) |
| 2140 |
|
| 2141 |
List the grid's cells. |
| 2142 |
|
| 2143 |
>>> grid.cells |
| 2144 |
array([64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2145 |
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, |
| 2146 |
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, |
| 2147 |
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) |
| 2148 |
|
| 2149 |
List the grid's points. |
| 2150 |
|
| 2151 |
>>> grid.points |
| 2152 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2153 |
[1. , 0. , 0. ], |
| 2154 |
[1. , 1. , 0. ], |
| 2155 |
[0. , 1. , 0. ], |
| 2156 |
[0. , 0. , 1. ], |
| 2157 |
[1. , 0. , 1. ], |
| 2158 |
[1. , 1. , 1. ], |
| 2159 |
[0. , 1. , 1. ], |
| 2160 |
[0.33333334, 0. , 0. ], |
| 2161 |
[0.66666669, 0. , 0. ], |
| 2162 |
[1. , 0.33333334, 0. ], |
| 2163 |
[1. , 0.66666669, 0. ], |
| 2164 |
[0.33333334, 1. , 0. ], |
| 2165 |
[0.66666669, 1. , 0. ], |
| 2166 |
[0. , 0.33333334, 0. ], |
| 2167 |
[0. , 0.66666669, 0. ], |
| 2168 |
[0.33333334, 0. , 1. ], |
| 2169 |
[0.66666669, 0. , 1. ], |
| 2170 |
[1. , 0.33333334, 1. ], |
| 2171 |
[1. , 0.66666669, 1. ], |
| 2172 |
[0.33333334, 1. , 1. ], |
| 2173 |
[0.66666669, 1. , 1. ], |
| 2174 |
[0. , 0.33333334, 1. ], |
| 2175 |
[0. , 0.66666669, 1. ], |
| 2176 |
[0. , 0. , 0.33333334], |
| 2177 |
[0. , 0. , 0.66666669], |
| 2178 |
[1. , 0. , 0.33333334], |
| 2179 |
[1. , 0. , 0.66666669], |
| 2180 |
[1. , 1. , 0.33333334], |
| 2181 |
[1. , 1. , 0.66666669], |
| 2182 |
[0. , 1. , 0.33333334], |
| 2183 |
[0. , 1. , 0.66666669], |
| 2184 |
[0. , 0.33333334, 0.33333334], |
| 2185 |
[0. , 0.66666669, 0.33333334], |
| 2186 |
[0. , 0.33333334, 0.66666669], |
| 2187 |
[0. , 0.66666669, 0.66666669], |
| 2188 |
[1. , 0.33333334, 0.33333334], |
| 2189 |
[1. , 0.66666669, 0.33333334], |
| 2190 |
[1. , 0.33333334, 0.66666669], |
| 2191 |
[1. , 0.66666669, 0.66666669], |
| 2192 |
[0.33333334, 0. , 0.33333334], |
| 2193 |
[0.66666669, 0. , 0.33333334], |
| 2194 |
[0.33333334, 0. , 0.66666669], |
| 2195 |
[0.66666669, 0. , 0.66666669], |
| 2196 |
[0.33333334, 1. , 0.33333334], |
| 2197 |
[0.66666669, 1. , 0.33333334], |
| 2198 |
[0.33333334, 1. , 0.66666669], |
| 2199 |
[0.66666669, 1. , 0.66666669], |
| 2200 |
[0.33333334, 0.33333334, 0. ], |
| 2201 |
[0.66666669, 0.33333334, 0. ], |
| 2202 |
[0.33333334, 0.66666669, 0. ], |
| 2203 |
[0.66666669, 0.66666669, 0. ], |
| 2204 |
[0.33333334, 0.33333334, 1. ], |
| 2205 |
[0.66666669, 0.33333334, 1. ], |
| 2206 |
[0.33333334, 0.66666669, 1. ], |
| 2207 |
[0.66666669, 0.66666669, 1. ], |
| 2208 |
[0.33333334, 0.33333334, 0.33333334], |
| 2209 |
[0.66666669, 0.33333334, 0.33333334], |
| 2210 |
[0.33333334, 0.66666669, 0.33333334], |
| 2211 |
[0.66666669, 0.66666669, 0.33333334], |
| 2212 |
[0.33333334, 0.33333334, 0.66666669], |
| 2213 |
[0.66666669, 0.33333334, 0.66666669], |
| 2214 |
[0.33333334, 0.66666669, 0.66666669], |
| 2215 |
[0.66666669, 0.66666669, 0.66666669]]) |
| 2216 |
|
| 2217 |
>>> grid.celltypes # same as pyvista.CellType.LAGRANGE_HEXAHEDRON |
| 2218 |
array([72], dtype=uint8) |
| 2219 |
|
| 2220 |
""" |
| 2221 |
return cast( |
| 2222 |
'UnstructuredGrid', |
| 2223 |
_vtkCellTypeSource(CellType.LAGRANGE_HEXAHEDRON, cell_order=cell_order), |
| 2224 |
) |
| 2225 |
|
| 2226 |
|
| 2227 |
def LagrangeWedge(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2228 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Lagrange wedge. |
| 2229 |
|
| 2230 |
This cell corresponds to the :attr:`pyvista.CellType.LAGRANGE_WEDGE` cell type. |
| 2231 |
|
| 2232 |
Parameters |
| 2233 |
---------- |
| 2234 |
cell_order : int, default: 3 |
| 2235 |
Order of interpolation to use. |
| 2236 |
|
| 2237 |
Returns |
| 2238 |
------- |
| 2239 |
pyvista.UnstructuredGrid |
| 2240 |
UnstructuredGrid containing a single Lagrange wedge. |
| 2241 |
|
| 2242 |
Examples |
| 2243 |
-------- |
| 2244 |
Create and plot a single Lagrange wedge. |
| 2245 |
|
| 2246 |
>>> from pyvista import examples |
| 2247 |
>>> grid = examples.cells.LagrangeWedge() |
| 2248 |
>>> examples.plot_cell(grid) |
| 2249 |
|
| 2250 |
List the grid's cells. |
| 2251 |
|
| 2252 |
>>> grid.cells |
| 2253 |
array([40, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2254 |
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, |
| 2255 |
33, 34, 35, 36, 37, 38, 39]) |
| 2256 |
|
| 2257 |
List the grid's points. |
| 2258 |
|
| 2259 |
>>> grid.points |
| 2260 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2261 |
[1. , 0. , 0. ], |
| 2262 |
[0. , 1. , 0. ], |
| 2263 |
[0. , 0. , 1. ], |
| 2264 |
[1. , 0. , 1. ], |
| 2265 |
[0. , 1. , 1. ], |
| 2266 |
[0.33333334, 0. , 0. ], |
| 2267 |
[0.66666669, 0. , 0. ], |
| 2268 |
[0.66666669, 0.33333334, 0. ], |
| 2269 |
[0.33333334, 0.66666669, 0. ], |
| 2270 |
[0. , 0.66666669, 0. ], |
| 2271 |
[0. , 0.33333334, 0. ], |
| 2272 |
[0.33333334, 0. , 1. ], |
| 2273 |
[0.66666669, 0. , 1. ], |
| 2274 |
[0.66666669, 0.33333334, 1. ], |
| 2275 |
[0.33333334, 0.66666669, 1. ], |
| 2276 |
[0. , 0.66666669, 1. ], |
| 2277 |
[0. , 0.33333334, 1. ], |
| 2278 |
[0. , 0. , 0.33333334], |
| 2279 |
[0. , 0. , 0.66666669], |
| 2280 |
[1. , 0. , 0.33333334], |
| 2281 |
[1. , 0. , 0.66666669], |
| 2282 |
[0. , 1. , 0.33333334], |
| 2283 |
[0. , 1. , 0.66666669], |
| 2284 |
[0.33333334, 0.33333334, 0. ], |
| 2285 |
[0.33333334, 0.33333334, 1. ], |
| 2286 |
[0.33333334, 0. , 0.33333334], |
| 2287 |
[0.66666669, 0. , 0.33333334], |
| 2288 |
[0.33333334, 0. , 0.66666669], |
| 2289 |
[0.66666669, 0. , 0.66666669], |
| 2290 |
[0.66666669, 0.33333334, 0.33333334], |
| 2291 |
[0.33333334, 0.66666669, 0.33333334], |
| 2292 |
[0.66666669, 0.33333334, 0.66666669], |
| 2293 |
[0.33333334, 0.66666669, 0.66666669], |
| 2294 |
[0. , 0.66666669, 0.33333334], |
| 2295 |
[0. , 0.33333334, 0.33333334], |
| 2296 |
[0. , 0.66666669, 0.66666669], |
| 2297 |
[0. , 0.33333334, 0.66666669], |
| 2298 |
[0.33333334, 0.33333334, 0.33333334], |
| 2299 |
[0.33333334, 0.33333334, 0.66666669]]) |
| 2300 |
|
| 2301 |
>>> grid.celltypes # same as pyvista.CellType.LAGRANGE_WEDGE |
| 2302 |
array([73], dtype=uint8) |
| 2303 |
|
| 2304 |
""" |
| 2305 |
return cast( |
| 2306 |
'UnstructuredGrid', _vtkCellTypeSource(CellType.LAGRANGE_WEDGE, cell_order=cell_order) |
| 2307 |
) |
| 2308 |
|
| 2309 |
|
| 2310 |
def BezierCurve(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2311 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Bezier curve. |
| 2312 |
|
| 2313 |
This cell corresponds to the :attr:`pyvista.CellType.BEZIER_CURVE` cell type. |
| 2314 |
|
| 2315 |
Parameters |
| 2316 |
---------- |
| 2317 |
cell_order : int, default: 3 |
| 2318 |
Order of interpolation to use. |
| 2319 |
|
| 2320 |
Returns |
| 2321 |
------- |
| 2322 |
pyvista.UnstructuredGrid |
| 2323 |
UnstructuredGrid containing a single Bezier curve. |
| 2324 |
|
| 2325 |
Examples |
| 2326 |
-------- |
| 2327 |
Create and plot a single Bezier curve. |
| 2328 |
|
| 2329 |
>>> from pyvista import examples |
| 2330 |
>>> grid = examples.cells.BezierCurve() |
| 2331 |
>>> examples.plot_cell(grid) |
| 2332 |
|
| 2333 |
List the grid's cells. |
| 2334 |
|
| 2335 |
>>> grid.cells |
| 2336 |
array([4, 0, 1, 2, 3]) |
| 2337 |
|
| 2338 |
List the grid's points. |
| 2339 |
|
| 2340 |
>>> grid.points |
| 2341 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2342 |
[1. , 0. , 0. ], |
| 2343 |
[0.33333334, 0. , 0. ], |
| 2344 |
[0.66666669, 0. , 0. ]]) |
| 2345 |
|
| 2346 |
>>> grid.celltypes # same as pyvista.CellType.BEZIER_CURVE |
| 2347 |
array([75], dtype=uint8) |
| 2348 |
|
| 2349 |
""" |
| 2350 |
return cast( |
| 2351 |
'UnstructuredGrid', _vtkCellTypeSource(CellType.BEZIER_CURVE, cell_order=cell_order) |
| 2352 |
) |
| 2353 |
|
| 2354 |
|
| 2355 |
def BezierTriangle(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2356 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Bezier triangle. |
| 2357 |
|
| 2358 |
This cell corresponds to the :attr:`pyvista.CellType.BEZIER_TRIANGLE` cell type. |
| 2359 |
|
| 2360 |
Parameters |
| 2361 |
---------- |
| 2362 |
cell_order : int, default: 3 |
| 2363 |
Order of interpolation to use. |
| 2364 |
|
| 2365 |
Returns |
| 2366 |
------- |
| 2367 |
pyvista.UnstructuredGrid |
| 2368 |
UnstructuredGrid containing a single Bezier triangle. |
| 2369 |
|
| 2370 |
Examples |
| 2371 |
-------- |
| 2372 |
Create and plot a single Bezier triangle. |
| 2373 |
|
| 2374 |
>>> from pyvista import examples |
| 2375 |
>>> grid = examples.cells.BezierTriangle() |
| 2376 |
>>> examples.plot_cell(grid, cpos='xy') |
| 2377 |
|
| 2378 |
List the grid's cells. |
| 2379 |
|
| 2380 |
>>> grid.cells |
| 2381 |
array([10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) |
| 2382 |
|
| 2383 |
List the grid's points. |
| 2384 |
|
| 2385 |
>>> grid.points |
| 2386 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2387 |
[1. , 0. , 0. ], |
| 2388 |
[0. , 1. , 0. ], |
| 2389 |
[0.33333334, 0. , 0. ], |
| 2390 |
[0.66666669, 0. , 0. ], |
| 2391 |
[0.66666669, 0.33333334, 0. ], |
| 2392 |
[0.33333334, 0.66666669, 0. ], |
| 2393 |
[0. , 0.66666669, 0. ], |
| 2394 |
[0. , 0.33333334, 0. ], |
| 2395 |
[0.33333334, 0.33333334, 0. ]]) |
| 2396 |
|
| 2397 |
>>> grid.celltypes # same as pyvista.CellType.BEZIER_TRIANGLE |
| 2398 |
array([76], dtype=uint8) |
| 2399 |
|
| 2400 |
""" |
| 2401 |
return cast( |
| 2402 |
'UnstructuredGrid', _vtkCellTypeSource(CellType.BEZIER_TRIANGLE, cell_order=cell_order) |
| 2403 |
) |
| 2404 |
|
| 2405 |
|
| 2406 |
def BezierQuadrilateral(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2407 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Bezier quadrilateral. |
| 2408 |
|
| 2409 |
This cell corresponds to the :attr:`pyvista.CellType.BEZIER_QUADRILATERAL` cell type. |
| 2410 |
|
| 2411 |
Parameters |
| 2412 |
---------- |
| 2413 |
cell_order : int, default: 3 |
| 2414 |
Order of interpolation to use. |
| 2415 |
|
| 2416 |
Returns |
| 2417 |
------- |
| 2418 |
pyvista.UnstructuredGrid |
| 2419 |
UnstructuredGrid containing a single Bezier quadrilateral. |
| 2420 |
|
| 2421 |
Examples |
| 2422 |
-------- |
| 2423 |
Create and plot a single Bezier quadrilateral. |
| 2424 |
|
| 2425 |
>>> from pyvista import examples |
| 2426 |
>>> grid = examples.cells.BezierQuadrilateral() |
| 2427 |
>>> examples.plot_cell(grid, cpos='xy') |
| 2428 |
|
| 2429 |
List the grid's cells. |
| 2430 |
|
| 2431 |
>>> grid.cells |
| 2432 |
array([16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) |
| 2433 |
|
| 2434 |
List the grid's points. |
| 2435 |
|
| 2436 |
>>> grid.points |
| 2437 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2438 |
[1. , 0. , 0. ], |
| 2439 |
[1. , 1. , 0. ], |
| 2440 |
[0. , 1. , 0. ], |
| 2441 |
[0.33333334, 0. , 0. ], |
| 2442 |
[0.66666669, 0. , 0. ], |
| 2443 |
[1. , 0.33333334, 0. ], |
| 2444 |
[1. , 0.66666669, 0. ], |
| 2445 |
[0.33333334, 1. , 0. ], |
| 2446 |
[0.66666669, 1. , 0. ], |
| 2447 |
[0. , 0.33333334, 0. ], |
| 2448 |
[0. , 0.66666669, 0. ], |
| 2449 |
[0.33333334, 0.33333334, 0. ], |
| 2450 |
[0.66666669, 0.33333334, 0. ], |
| 2451 |
[0.33333334, 0.66666669, 0. ], |
| 2452 |
[0.66666669, 0.66666669, 0. ]]) |
| 2453 |
|
| 2454 |
>>> grid.celltypes # same as pyvista.CellType.BEZIER_QUADRILATERAL |
| 2455 |
array([77], dtype=uint8) |
| 2456 |
|
| 2457 |
""" |
| 2458 |
return cast( |
| 2459 |
'UnstructuredGrid', |
| 2460 |
_vtkCellTypeSource(CellType.BEZIER_QUADRILATERAL, cell_order=cell_order), |
| 2461 |
) |
| 2462 |
|
| 2463 |
|
| 2464 |
def BezierTetrahedron(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2465 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Bezier tetrahedron. |
| 2466 |
|
| 2467 |
This cell corresponds to the :attr:`pyvista.CellType.BEZIER_TETRAHEDRON` cell type. |
| 2468 |
|
| 2469 |
Parameters |
| 2470 |
---------- |
| 2471 |
cell_order : int, default: 3 |
| 2472 |
Order of interpolation to use. |
| 2473 |
|
| 2474 |
Returns |
| 2475 |
------- |
| 2476 |
pyvista.UnstructuredGrid |
| 2477 |
UnstructuredGrid containing a single Bezier tetrahedron. |
| 2478 |
|
| 2479 |
Examples |
| 2480 |
-------- |
| 2481 |
Create and plot a single Bezier tetrahedron. |
| 2482 |
|
| 2483 |
>>> from pyvista import examples |
| 2484 |
>>> grid = examples.cells.BezierTetrahedron() |
| 2485 |
>>> examples.plot_cell(grid) |
| 2486 |
|
| 2487 |
List the grid's cells. |
| 2488 |
|
| 2489 |
>>> grid.cells |
| 2490 |
array([20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2491 |
16, 17, 18, 19]) |
| 2492 |
|
| 2493 |
List the grid's points. |
| 2494 |
|
| 2495 |
>>> grid.points |
| 2496 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2497 |
[1. , 0. , 0. ], |
| 2498 |
[1. , 1. , 0. ], |
| 2499 |
[0.5 , 0.5 , 0.5 ], |
| 2500 |
[0.33333334, 0. , 0. ], |
| 2501 |
[0.66666669, 0. , 0. ], |
| 2502 |
[1. , 0.33333334, 0. ], |
| 2503 |
[1. , 0.66666669, 0. ], |
| 2504 |
[0.66666669, 0.66666669, 0. ], |
| 2505 |
[0.33333334, 0.33333334, 0. ], |
| 2506 |
[0.16666667, 0.16666667, 0.16666667], |
| 2507 |
[0.33333334, 0.33333334, 0.33333334], |
| 2508 |
[0.83333331, 0.16666667, 0.16666667], |
| 2509 |
[0.66666669, 0.33333334, 0.33333334], |
| 2510 |
[0.83333331, 0.83333331, 0.16666667], |
| 2511 |
[0.66666669, 0.66666669, 0.33333334], |
| 2512 |
[0.5 , 0.16666667, 0.16666667], |
| 2513 |
[0.83333331, 0.5 , 0.16666667], |
| 2514 |
[0.5 , 0.5 , 0.16666667], |
| 2515 |
[0.66666669, 0.33333334, 0. ]]) |
| 2516 |
|
| 2517 |
>>> grid.celltypes # same as pyvista.CellType.BEZIER_TETRAHEDRON |
| 2518 |
array([78], dtype=uint8) |
| 2519 |
|
| 2520 |
""" |
| 2521 |
return cast( |
| 2522 |
'UnstructuredGrid', |
| 2523 |
_vtkCellTypeSource(CellType.BEZIER_TETRAHEDRON, cell_order=cell_order), |
| 2524 |
) |
| 2525 |
|
| 2526 |
|
| 2527 |
def BezierHexahedron(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2528 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Bezier hexahedron. |
| 2529 |
|
| 2530 |
This cell corresponds to the :attr:`pyvista.CellType.BEZIER_HEXAHEDRON` cell type. |
| 2531 |
|
| 2532 |
Parameters |
| 2533 |
---------- |
| 2534 |
cell_order : int, default: 3 |
| 2535 |
Order of interpolation to use. |
| 2536 |
|
| 2537 |
Returns |
| 2538 |
------- |
| 2539 |
pyvista.UnstructuredGrid |
| 2540 |
UnstructuredGrid containing a single Bezier hexahedron. |
| 2541 |
|
| 2542 |
Examples |
| 2543 |
-------- |
| 2544 |
Create and plot a single Bezier hexahedron. |
| 2545 |
|
| 2546 |
>>> from pyvista import examples |
| 2547 |
>>> grid = examples.cells.BezierHexahedron() |
| 2548 |
>>> examples.plot_cell(grid) |
| 2549 |
|
| 2550 |
List the grid's cells. |
| 2551 |
|
| 2552 |
>>> grid.cells |
| 2553 |
array([64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2554 |
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, |
| 2555 |
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, |
| 2556 |
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) |
| 2557 |
|
| 2558 |
List the grid's points. |
| 2559 |
|
| 2560 |
>>> grid.points |
| 2561 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2562 |
[1. , 0. , 0. ], |
| 2563 |
[1. , 1. , 0. ], |
| 2564 |
[0. , 1. , 0. ], |
| 2565 |
[0. , 0. , 1. ], |
| 2566 |
[1. , 0. , 1. ], |
| 2567 |
[1. , 1. , 1. ], |
| 2568 |
[0. , 1. , 1. ], |
| 2569 |
[0.33333334, 0. , 0. ], |
| 2570 |
[0.66666669, 0. , 0. ], |
| 2571 |
[1. , 0.33333334, 0. ], |
| 2572 |
[1. , 0.66666669, 0. ], |
| 2573 |
[0.33333334, 1. , 0. ], |
| 2574 |
[0.66666669, 1. , 0. ], |
| 2575 |
[0. , 0.33333334, 0. ], |
| 2576 |
[0. , 0.66666669, 0. ], |
| 2577 |
[0.33333334, 0. , 1. ], |
| 2578 |
[0.66666669, 0. , 1. ], |
| 2579 |
[1. , 0.33333334, 1. ], |
| 2580 |
[1. , 0.66666669, 1. ], |
| 2581 |
[0.33333334, 1. , 1. ], |
| 2582 |
[0.66666669, 1. , 1. ], |
| 2583 |
[0. , 0.33333334, 1. ], |
| 2584 |
[0. , 0.66666669, 1. ], |
| 2585 |
[0. , 0. , 0.33333334], |
| 2586 |
[0. , 0. , 0.66666669], |
| 2587 |
[1. , 0. , 0.33333334], |
| 2588 |
[1. , 0. , 0.66666669], |
| 2589 |
[1. , 1. , 0.33333334], |
| 2590 |
[1. , 1. , 0.66666669], |
| 2591 |
[0. , 1. , 0.33333334], |
| 2592 |
[0. , 1. , 0.66666669], |
| 2593 |
[0. , 0.33333334, 0.33333334], |
| 2594 |
[0. , 0.66666669, 0.33333334], |
| 2595 |
[0. , 0.33333334, 0.66666669], |
| 2596 |
[0. , 0.66666669, 0.66666669], |
| 2597 |
[1. , 0.33333334, 0.33333334], |
| 2598 |
[1. , 0.66666669, 0.33333334], |
| 2599 |
[1. , 0.33333334, 0.66666669], |
| 2600 |
[1. , 0.66666669, 0.66666669], |
| 2601 |
[0.33333334, 0. , 0.33333334], |
| 2602 |
[0.66666669, 0. , 0.33333334], |
| 2603 |
[0.33333334, 0. , 0.66666669], |
| 2604 |
[0.66666669, 0. , 0.66666669], |
| 2605 |
[0.33333334, 1. , 0.33333334], |
| 2606 |
[0.66666669, 1. , 0.33333334], |
| 2607 |
[0.33333334, 1. , 0.66666669], |
| 2608 |
[0.66666669, 1. , 0.66666669], |
| 2609 |
[0.33333334, 0.33333334, 0. ], |
| 2610 |
[0.66666669, 0.33333334, 0. ], |
| 2611 |
[0.33333334, 0.66666669, 0. ], |
| 2612 |
[0.66666669, 0.66666669, 0. ], |
| 2613 |
[0.33333334, 0.33333334, 1. ], |
| 2614 |
[0.66666669, 0.33333334, 1. ], |
| 2615 |
[0.33333334, 0.66666669, 1. ], |
| 2616 |
[0.66666669, 0.66666669, 1. ], |
| 2617 |
[0.33333334, 0.33333334, 0.33333334], |
| 2618 |
[0.66666669, 0.33333334, 0.33333334], |
| 2619 |
[0.33333334, 0.66666669, 0.33333334], |
| 2620 |
[0.66666669, 0.66666669, 0.33333334], |
| 2621 |
[0.33333334, 0.33333334, 0.66666669], |
| 2622 |
[0.66666669, 0.33333334, 0.66666669], |
| 2623 |
[0.33333334, 0.66666669, 0.66666669], |
| 2624 |
[0.66666669, 0.66666669, 0.66666669]]) |
| 2625 |
|
| 2626 |
>>> grid.celltypes # same as pyvista.CellType.BEZIER_HEXAHEDRON |
| 2627 |
array([79], dtype=uint8) |
| 2628 |
|
| 2629 |
""" |
| 2630 |
return cast( |
| 2631 |
'UnstructuredGrid', |
| 2632 |
_vtkCellTypeSource(CellType.BEZIER_HEXAHEDRON, cell_order=cell_order), |
| 2633 |
) |
| 2634 |
|
| 2635 |
|
| 2636 |
def BezierWedge(*, cell_order: int = 3) -> UnstructuredGrid: |
| 2637 |
"""Create a :class:`pyvista.UnstructuredGrid` containing a single Bezier wedge. |
| 2638 |
|
| 2639 |
This cell corresponds to the :attr:`pyvista.CellType.BEZIER_WEDGE` cell type. |
| 2640 |
|
| 2641 |
Parameters |
| 2642 |
---------- |
| 2643 |
cell_order : int, default: 3 |
| 2644 |
Order of interpolation to use. |
| 2645 |
|
| 2646 |
Returns |
| 2647 |
------- |
| 2648 |
pyvista.UnstructuredGrid |
| 2649 |
UnstructuredGrid containing a single Bezier wedge. |
| 2650 |
|
| 2651 |
Examples |
| 2652 |
-------- |
| 2653 |
Create and plot a single Bezier wedge. |
| 2654 |
|
| 2655 |
>>> from pyvista import examples |
| 2656 |
>>> grid = examples.cells.BezierWedge() |
| 2657 |
>>> examples.plot_cell(grid) |
| 2658 |
|
| 2659 |
List the grid's cells. |
| 2660 |
|
| 2661 |
>>> grid.cells |
| 2662 |
array([40, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2663 |
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, |
| 2664 |
33, 34, 35, 36, 37, 38, 39]) |
| 2665 |
|
| 2666 |
List the grid's points. |
| 2667 |
|
| 2668 |
>>> grid.points |
| 2669 |
pyvista_ndarray([[0. , 0. , 0. ], |
| 2670 |
[1. , 0. , 0. ], |
| 2671 |
[0. , 1. , 0. ], |
| 2672 |
[0. , 0. , 1. ], |
| 2673 |
[1. , 0. , 1. ], |
| 2674 |
[0. , 1. , 1. ], |
| 2675 |
[0.33333334, 0. , 0. ], |
| 2676 |
[0.66666669, 0. , 0. ], |
| 2677 |
[0.66666669, 0.33333334, 0. ], |
| 2678 |
[0.33333334, 0.66666669, 0. ], |
| 2679 |
[0. , 0.66666669, 0. ], |
| 2680 |
[0. , 0.33333334, 0. ], |
| 2681 |
[0.33333334, 0. , 1. ], |
| 2682 |
[0.66666669, 0. , 1. ], |
| 2683 |
[0.66666669, 0.33333334, 1. ], |
| 2684 |
[0.33333334, 0.66666669, 1. ], |
| 2685 |
[0. , 0.66666669, 1. ], |
| 2686 |
[0. , 0.33333334, 1. ], |
| 2687 |
[0. , 0. , 0.33333334], |
| 2688 |
[0. , 0. , 0.66666669], |
| 2689 |
[1. , 0. , 0.33333334], |
| 2690 |
[1. , 0. , 0.66666669], |
| 2691 |
[0. , 1. , 0.33333334], |
| 2692 |
[0. , 1. , 0.66666669], |
| 2693 |
[0.33333334, 0.33333334, 0. ], |
| 2694 |
[0.33333334, 0.33333334, 1. ], |
| 2695 |
[0.33333334, 0. , 0.33333334], |
| 2696 |
[0.66666669, 0. , 0.33333334], |
| 2697 |
[0.33333334, 0. , 0.66666669], |
| 2698 |
[0.66666669, 0. , 0.66666669], |
| 2699 |
[0.66666669, 0.33333334, 0.33333334], |
| 2700 |
[0.33333334, 0.66666669, 0.33333334], |
| 2701 |
[0.66666669, 0.33333334, 0.66666669], |
| 2702 |
[0.33333334, 0.66666669, 0.66666669], |
| 2703 |
[0. , 0.66666669, 0.33333334], |
| 2704 |
[0. , 0.33333334, 0.33333334], |
| 2705 |
[0. , 0.66666669, 0.66666669], |
| 2706 |
[0. , 0.33333334, 0.66666669], |
| 2707 |
[0.33333334, 0.33333334, 0.33333334], |
| 2708 |
[0.33333334, 0.33333334, 0.66666669]]) |
| 2709 |
|
| 2710 |
>>> grid.celltypes # same as pyvista.CellType.BEZIER_WEDGE |
| 2711 |
array([80], dtype=uint8) |
| 2712 |
|
| 2713 |
""" |
| 2714 |
return cast( |
| 2715 |
'UnstructuredGrid', _vtkCellTypeSource(CellType.BEZIER_WEDGE, cell_order=cell_order) |
| 2716 |
) |
| 2717 |
|
| 2718 |
|
| 2719 |
_GeneratorOptions = Literal['examples', 'source', 'parametric'] |
| 2720 |
_FillModeOptions = Literal['exact', 'cycle', 'stop'] |
| 2721 |
_UnsupportedActionOptions = Literal['squeeze', 'skip', 'warn', 'error'] |
| 2722 |
|
| 2723 |
|
| 2724 |
def generate_cell_blocks( # numpydoc ignore=RT01 |
| 2725 |
cell_types: int | Sequence[int], |
| 2726 |
generator: _GeneratorOptions = 'examples', |
| 2727 |
*, |
| 2728 |
block_dimensions: VectorLike[int] | None = None, |
| 2729 |
shrink_factor: float | None = None, |
| 2730 |
fill_mode: _FillModeOptions = 'exact', |
| 2731 |
unsupported_action: _UnsupportedActionOptions = 'error', |
| 2732 |
) -> MultiBlock: |
| 2733 |
"""Generate a :class:`~pyvista.MultiBlock` mesh comprised of one or more cell types. |
| 2734 |
|
| 2735 |
A separate :class:`~pyvista.UnstructuredGrid` block is generated for each input cell type. |
| 2736 |
Cell types may be repeated or mixed in any order. By default, all blocks are stacked |
| 2737 |
sequentially along the x-axis, though ``block_dimensions`` may be specified to control this. |
| 2738 |
|
| 2739 |
.. versionadded:: 0.48 |
| 2740 |
|
| 2741 |
Parameters |
| 2742 |
---------- |
| 2743 |
cell_types : int | sequence[int] |
| 2744 |
Cell type(s) to generate. By default, only :class:`~pyvista.CellType` values are supported. |
| 2745 |
Invalid cell type values may also be specified; these can be ignored by using the |
| 2746 |
``unsupported_action`` keyword. |
| 2747 |
|
| 2748 |
generator : 'examples' | 'source' | 'parametric', default: 'examples' |
| 2749 |
Method for generating cell type blocks. |
| 2750 |
|
| 2751 |
- ``'examples'``: generate blocks using examples from :mod:`pyvista.examples.cells`. This |
| 2752 |
is a mixed collected of manually-defined linear cells, quadratic and cubic cells |
| 2753 |
generated with ``'paramatric'``, and higher order cells generated with ``'source'``. |
| 2754 |
- ``'parametric'``: generate blocks using :vtk:`vtkCell.GetParametricCoords`. |
| 2755 |
- ``'source'``: generate blocks using :vtk:`vtkCellTypeSource`. |
| 2756 |
|
| 2757 |
.. note:: |
| 2758 |
|
| 2759 |
- ``'examples'`` supports all concrete :class:`cell types <pyvista.CellType>`, but |
| 2760 |
the other generators only support a subset. |
| 2761 |
- Both ``'examples'`` and ``'parametric'`` only generate a `single` cell per block, |
| 2762 |
whereas ``'source'`` may generate multiple cells of the same type in order to fill a |
| 2763 |
unit block (e.g. two triangles to fill a square, two wedges to fill a cube). |
| 2764 |
|
| 2765 |
block_dimensions : VectorLike[int], optional |
| 2766 |
Output dimensions of blocks to generate. By default, all blocks are stacked sequentially |
| 2767 |
along the x-axis. The dimensions should be compatible with the number of input cell types. |
| 2768 |
Use ``fill_mode`` to handle cases where the dimensions are `not` compatible. |
| 2769 |
|
| 2770 |
shrink_factor : float, optional |
| 2771 |
Shrink each block by applying a scaling factor. By default, no shrink factor is applied, |
| 2772 |
and each generated cell type is scaled to fit inside a unit cube. |
| 2773 |
|
| 2774 |
fill_mode : 'exact' | 'cycle' | 'stop', default: 'exact' |
| 2775 |
Select how to handle mismatched dimensions. |
| 2776 |
|
| 2777 |
- ``'exact'``: the number of cell types must match the specified block dimensions exactly. |
| 2778 |
- ``'cycle'``: cycle through and duplicate cell types as required to ensure the |
| 2779 |
specified block dimensions are completely filled. |
| 2780 |
- ``'stop'``: stop iterating when all specified cell types have been generated. |
| 2781 |
|
| 2782 |
unsupported_action : 'skip' | 'squeeze' | 'warn' | 'error', default: 'error' |
| 2783 |
Select how to handle unsupported cell types. |
| 2784 |
|
| 2785 |
- ``'skip'``: Skip generating a block for unsupported cell types. A ``None`` block is |
| 2786 |
included instead. This will create a gap in the output. |
| 2787 |
- ``'squeeze'``: Similar to ``'skip'``, but no ``None`` block is appended. Since no block |
| 2788 |
is included, there are no gaps and the output appears to be "squeezed" together. |
| 2789 |
- ``'warn'``: Similar to ``skip``, but a warning is emitted when an unsupported type is |
| 2790 |
encountered. |
| 2791 |
- ``'error'``: Raise a ValueError when an unsupported cell type is encountered. |
| 2792 |
|
| 2793 |
Examples |
| 2794 |
-------- |
| 2795 |
Generate a single :attr:`~pyvista.CellType.TRIANGLE` cell. |
| 2796 |
|
| 2797 |
>>> import pyvista as pv |
| 2798 |
>>> from pyvista.examples import cells, generate_cell_blocks, plot_cell |
| 2799 |
>>> triangle = generate_cell_blocks(pv.CellType.TRIANGLE) |
| 2800 |
>>> plot_cell(triangle, cpos='xy') |
| 2801 |
|
| 2802 |
This is similar to the :func:`~pyvista.examples.cells.Triangle` grid, except it's a |
| 2803 |
:class:`~pyvista.MultiBlock` and its bounds are normalized to fit inside a 1x1x1 grid. |
| 2804 |
|
| 2805 |
>>> triangle |
| 2806 |
MultiBlock (...) |
| 2807 |
N Blocks: 1 |
| 2808 |
X Bounds: 0.000e+00, 1.000e+00 |
| 2809 |
Y Bounds: -5.551e-17, 1.000e+00 |
| 2810 |
Z Bounds: 0.000e+00, 0.000e+00 |
| 2811 |
|
| 2812 |
Compare to the un-normalized bounds. |
| 2813 |
|
| 2814 |
>>> cells.Triangle() |
| 2815 |
UnstructuredGrid (...) |
| 2816 |
N Cells: 1 |
| 2817 |
N Points: 3 |
| 2818 |
X Bounds: -5.000e-01, 5.000e-01 |
| 2819 |
Y Bounds: -2.887e-01, 5.774e-01 |
| 2820 |
Z Bounds: 0.000e+00, 0.000e+00 |
| 2821 |
N Arrays: 0 |
| 2822 |
|
| 2823 |
Use the ``'parametric'`` generator instead. |
| 2824 |
|
| 2825 |
>>> triangle = generate_cell_blocks(pv.CellType.TRIANGLE, 'parametric') |
| 2826 |
>>> plot_cell(triangle, cpos='xy') |
| 2827 |
|
| 2828 |
Use the ``'source'`` generator instead. |
| 2829 |
|
| 2830 |
>>> triangle = generate_cell_blocks(pv.CellType.TRIANGLE, 'source') |
| 2831 |
>>> plot_cell(triangle, cpos='xy') |
| 2832 |
|
| 2833 |
Generate multiple cell types. Here we generate all concrete linear 2D cells. |
| 2834 |
|
| 2835 |
>>> cell_types = [ |
| 2836 |
... ctype |
| 2837 |
... for ctype in pv.CellType |
| 2838 |
... if ctype.dimension == 2 and ctype.is_linear |
| 2839 |
... ] |
| 2840 |
>>> cell_types # doctest: +NORMALIZE_WHITESPACE |
| 2841 |
[<CellType.TRIANGLE: 5>, |
| 2842 |
<CellType.TRIANGLE_STRIP: 6>, |
| 2843 |
<CellType.POLYGON: 7>, |
| 2844 |
<CellType.PIXEL: 8>, |
| 2845 |
<CellType.QUAD: 9>] |
| 2846 |
|
| 2847 |
>>> cell_blocks = generate_cell_blocks(cell_types, shrink_factor=0.8) |
| 2848 |
>>> plot_cell(cell_blocks, cpos='xy') |
| 2849 |
|
| 2850 |
Each block's name matches the name of the cell type. |
| 2851 |
|
| 2852 |
>>> cell_blocks.keys() |
| 2853 |
['TRIANGLE', 'TRIANGLE_STRIP', 'POLYGON', 'PIXEL', 'QUAD'] |
| 2854 |
|
| 2855 |
Generate the same cell types using the parametric generator. This generator does not support |
| 2856 |
triangle strip or polygon cells, so we skip these. |
| 2857 |
|
| 2858 |
>>> cell_blocks = generate_cell_blocks( |
| 2859 |
... cell_types, 'parametric', shrink_factor=0.8, unsupported_action='skip' |
| 2860 |
... ) |
| 2861 |
>>> plot_cell(cell_blocks, cpos='xy') |
| 2862 |
|
| 2863 |
Use the source generator. It also does not support triangle strip, but it does support polygon. |
| 2864 |
This time, we squeeze the blocks together instead of skipping them, and do not shrink them. |
| 2865 |
This combination generates a continuous grid with no gaps. |
| 2866 |
|
| 2867 |
>>> cell_blocks = generate_cell_blocks( |
| 2868 |
... cell_types, 'source', unsupported_action='squeeze' |
| 2869 |
... ) |
| 2870 |
>>> plot_cell(cell_blocks, cpos='xy') |
| 2871 |
|
| 2872 |
Generate cell types on a dimensioned grid. |
| 2873 |
|
| 2874 |
>>> lines = [pv.CellType.LINE] * 3 |
| 2875 |
>>> polygons = [pv.CellType.POLYGON] * 3 |
| 2876 |
>>> wedges = [pv.CellType.WEDGE] * 3 |
| 2877 |
>>> pyramids = [pv.CellType.PYRAMID] * 3 |
| 2878 |
>>> cell_types = [*lines, *polygons, *wedges, *pyramids] |
| 2879 |
|
| 2880 |
Plot them with 3 cells in the x-direction, and 4 cells in the y-direction. |
| 2881 |
|
| 2882 |
>>> cell_blocks = generate_cell_blocks(cell_types, block_dimensions=(3, 4, 1)) |
| 2883 |
>>> size_kwargs = dict(point_size=40, font_size=20) |
| 2884 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2885 |
|
| 2886 |
Reverse the x and y dimension. |
| 2887 |
|
| 2888 |
>>> cell_blocks = generate_cell_blocks(cell_types, block_dimensions=(4, 3, 1)) |
| 2889 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2890 |
|
| 2891 |
Use the ``'stop'`` fill mode if there is a mismatch between the number of cell types and block |
| 2892 |
dimensions. Here, the last two pyramid cell types are omitted. |
| 2893 |
|
| 2894 |
>>> cell_blocks = generate_cell_blocks( |
| 2895 |
... cell_types[:-2], block_dimensions=(3, 4, 1), fill_mode='stop' |
| 2896 |
... ) |
| 2897 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2898 |
|
| 2899 |
Alternatively, cycle through the cell types again to completely fill the dimensions. In this |
| 2900 |
case, the line type is reused to fill the gap. |
| 2901 |
|
| 2902 |
>>> cell_blocks = generate_cell_blocks( |
| 2903 |
... cell_types[:-2], block_dimensions=(3, 4, 1), fill_mode='cycle' |
| 2904 |
... ) |
| 2905 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2906 |
|
| 2907 |
Generate a 5x5x5 grid comprised of all 3D cell types with no gaps. |
| 2908 |
|
| 2909 |
>>> cell_types = [ctype for ctype in pv.CellType if ctype.dimension == 3] |
| 2910 |
>>> cell_blocks = generate_cell_blocks( |
| 2911 |
... cell_types, |
| 2912 |
... 'source', |
| 2913 |
... block_dimensions=(5, 5, 5), |
| 2914 |
... unsupported_action='squeeze', |
| 2915 |
... fill_mode='cycle', |
| 2916 |
... ) |
| 2917 |
>>> cell_blocks.plot(show_edges=True, opacity=0.5, line_width=3) |
| 2918 |
|
| 2919 |
Combine into a single grid and show :attr:`~pyvista.DataSet.distinct_cell_types`. |
| 2920 |
|
| 2921 |
>>> cell_blocks.combine().distinct_cell_types # doctest: +NORMALIZE_WHITESPACE |
| 2922 |
{<CellType.TETRA: 10>, <CellType.VOXEL: 11>, <CellType.HEXAHEDRON: 12>, <CellType.WEDGE: 13>, |
| 2923 |
<CellType.PYRAMID: 14>, <CellType.PENTAGONAL_PRISM: 15>, <CellType.HEXAGONAL_PRISM: 16>, |
| 2924 |
<CellType.QUADRATIC_TETRA: 24>, <CellType.QUADRATIC_HEXAHEDRON: 25>, |
| 2925 |
<CellType.QUADRATIC_WEDGE: 26>, <CellType.QUADRATIC_PYRAMID: 27>, |
| 2926 |
<CellType.TRIQUADRATIC_HEXAHEDRON: 29>, <CellType.TRIQUADRATIC_PYRAMID: 37>, |
| 2927 |
<CellType.POLYHEDRON: 42>, <CellType.LAGRANGE_TETRAHEDRON: 71>, |
| 2928 |
<CellType.LAGRANGE_HEXAHEDRON: 72>, <CellType.LAGRANGE_WEDGE: 73>, |
| 2929 |
<CellType.BEZIER_TETRAHEDRON: 78>, <CellType.BEZIER_HEXAHEDRON: 79>, |
| 2930 |
<CellType.BEZIER_WEDGE: 80>} |
| 2931 |
|
| 2932 |
Compare the first 25 cell types from the different generators. Note that some values, e.g. |
| 2933 |
``17``, do not correspond to any cell type, so gaps are expected in all outputs. |
| 2934 |
|
| 2935 |
>>> kwargs = dict( |
| 2936 |
... cell_types=range(1, 26), |
| 2937 |
... block_dimensions=(5, 5, 1), |
| 2938 |
... unsupported_action='skip', |
| 2939 |
... ) |
| 2940 |
>>> cell_blocks = generate_cell_blocks(generator='examples', **kwargs) |
| 2941 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2942 |
|
| 2943 |
>>> cell_blocks = generate_cell_blocks(generator='parametric', **kwargs) |
| 2944 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2945 |
|
| 2946 |
>>> cell_blocks = generate_cell_blocks(generator='source', **kwargs) |
| 2947 |
>>> plot_cell(cell_blocks, cpos='xy', **size_kwargs) |
| 2948 |
|
| 2949 |
""" |
| 2950 |
|
| 2951 |
def _examples_grid(cell_type: CellType) -> UnstructuredGrid | None: |
| 2952 |
if (example := cell_type._example) is None: |
| 2953 |
return None |
| 2954 |
return globals()[example]() |
| 2955 |
|
| 2956 |
def _parametric_grid(cell_type: CellType) -> UnstructuredGrid | None: |
| 2957 |
return _isoparametric_grid(cell_type) |
| 2958 |
|
| 2959 |
def _blocks_grid(cell_type: CellType) -> UnstructuredGrid | None: |
| 2960 |
return _vtkCellTypeSource(cell_type, cell_order=3, single_cell=False) |
| 2961 |
|
| 2962 |
_validation.check_contains( |
| 2963 |
get_args(_GeneratorOptions), must_contain=generator, name='generator' |
| 2964 |
) |
| 2965 |
_validation.check_contains( |
| 2966 |
get_args(_UnsupportedActionOptions), |
| 2967 |
must_contain=unsupported_action, |
| 2968 |
name='unsupported action', |
| 2969 |
) |
| 2970 |
_validation.check_contains( |
| 2971 |
get_args(_FillModeOptions), must_contain=fill_mode, name='fill mode' |
| 2972 |
) |
| 2973 |
|
| 2974 |
_shrink_factor = ( |
| 2975 |
1.0 |
| 2976 |
if shrink_factor is None |
| 2977 |
else _validation.validate_number(shrink_factor, must_be_in_range=[0.0, 1.0]) |
| 2978 |
) |
| 2979 |
ctypes: list[int] = [] |
| 2980 |
for ctype in cell_types if isinstance(cell_types, Iterable) else [cell_types]: |
| 2981 |
try: |
| 2982 |
ctypes.append(CellType(ctype)) |
| 2983 |
except ValueError: |
| 2984 |
ctypes.append(ctype) |
| 2985 |
|
| 2986 |
if block_dimensions is None: |
| 2987 |
dimension: int | VectorLike[int] = (len(ctypes), 1, 1) |
| 2988 |
else: |
| 2989 |
requested_size = np.prod(block_dimensions) |
| 2990 |
actual_size = len(ctypes) |
| 2991 |
if requested_size < actual_size: |
| 2992 |
msg = ( |
| 2993 |
f'Requested dimension {block_dimensions} is too small. ' |
| 2994 |
f'Number of cell types to generate ({actual_size}) exceeds ' |
| 2995 |
f'the number of blocks requested ({requested_size}).' |
| 2996 |
) |
| 2997 |
raise ValueError(msg) |
| 2998 |
elif requested_size > actual_size: |
| 2999 |
if fill_mode == 'exact': |
| 3000 |
msg = ( |
| 3001 |
f'Requested dimension {block_dimensions} is too large. ' |
| 3002 |
f'Number of cell types to generate ({actual_size}) is less than ' |
| 3003 |
f'the number of blocks requested ({requested_size}).\n' |
| 3004 |
f'Use `fill_mode` to prevent an error from being raised.' |
| 3005 |
) |
| 3006 |
raise ValueError(msg) |
| 3007 |
dimension = block_dimensions |
| 3008 |
dims = _validation.validate_array3(dimension, name='block_dimensions') |
| 3009 |
cell_centers = pv.ImageData(dimensions=dims + 1).cell_centers().points |
| 3010 |
|
| 3011 |
if generator == 'examples': |
| 3012 |
generate_grid = _examples_grid |
| 3013 |
elif generator == 'parametric': |
| 3014 |
generate_grid = _parametric_grid |
| 3015 |
elif generator == 'source': |
| 3016 |
generate_grid = _blocks_grid |
| 3017 |
|
| 3018 |
# Generate mesh for each cell type |
| 3019 |
distinct_meshes = pv.MultiBlock() |
| 3020 |
for ctype in ctypes: |
| 3021 |
if isinstance(ctype, CellType): |
| 3022 |
grid = generate_grid(ctype) |
| 3023 |
name = ctype.name |
| 3024 |
else: |
| 3025 |
grid = None |
| 3026 |
name = 'None' |
| 3027 |
if grid is None: |
| 3028 |
if unsupported_action in ['warn', 'error']: |
| 3029 |
invalid = ' ' if isinstance(ctype, CellType) else ' is not a valid cell type and ' |
| 3030 |
msg = f'{ctype!r}{invalid}is not supported by the {generator!r} generator.' |
| 3031 |
if unsupported_action == 'error': |
| 3032 |
raise ValueError(msg) |
| 3033 |
warn_external(msg) |
| 3034 |
elif grid.bounds_size != (1.0, 1.0, 1.0) or _shrink_factor != 1.0: |
| 3035 |
grid = grid.resize(bounds_size=_shrink_factor) |
| 3036 |
distinct_meshes.append(grid, name) |
| 3037 |
|
| 3038 |
# Build output from distinct meshes |
| 3039 |
output = pv.MultiBlock() |
| 3040 |
iterator = distinct_meshes.recursive_iterator('items') |
| 3041 |
iterator = itertools.cycle(iterator) if fill_mode == 'cycle' else iterator |
| 3042 |
|
| 3043 |
center_iter = iter(cell_centers) |
| 3044 |
name_counts: dict[str, int] = {} |
| 3045 |
for name, block in iterator: |
| 3046 |
if block is None: |
| 3047 |
if unsupported_action == 'squeeze': |
| 3048 |
continue # preserve center |
| 3049 |
|
| 3050 |
center = next(center_iter, None) |
| 3051 |
if center is None: |
| 3052 |
break |
| 3053 |
|
| 3054 |
# Ensure unique names |
| 3055 |
count = name_counts.get(name, 0) |
| 3056 |
block_name = name if count == 0 else f'{name}_{count}' |
| 3057 |
name_counts[name] = count + 1 |
| 3058 |
|
| 3059 |
if block is None: |
| 3060 |
block_mesh = None |
| 3061 |
else: |
| 3062 |
# Ensure block is independent |
| 3063 |
block_mesh = block.copy() if block in output else block |
| 3064 |
# Position block on the grid |
| 3065 |
block_mesh.center = center |
| 3066 |
output[block_name] = block_mesh |
| 3067 |
|
| 3068 |
# Maybe translate output |
| 3069 |
x_size, y_size, z_size = output.bounds_size |
| 3070 |
translate = [0.0, 0.0, 0.0] |
| 3071 |
if np.isclose(z_size, 0): |
| 3072 |
# Ensure 2D outputs lie in xy plane |
| 3073 |
translate[2] = -output.bounds.z_min |
| 3074 |
if np.isclose(y_size, 0): |
| 3075 |
# Ensure 1D outputs lie along x-axis |
| 3076 |
translate[1] = -output.bounds.y_min |
| 3077 |
if np.isclose(x_size, 0): |
| 3078 |
# Ensure 0D outputs are at the origin |
| 3079 |
translate[0] = -output.bounds.x_min |
| 3080 |
if any(translate): |
| 3081 |
output.translate(translate, inplace=True) |
| 3082 |
return output |
| 3083 |
|
| 3084 |
|
| 3085 |
def _isoparametric_grid(celltype: CellType) -> UnstructuredGrid | None: |
| 3086 |
if celltype.vtk_class is None or celltype in _NOT_SUPPORTED_PARAMETRIC: |
| 3087 |
return None |
| 3088 |
cell = celltype.vtk_class() |
| 3089 |
|
| 3090 |
# Create points |
| 3091 |
cell.Initialize() |
| 3092 |
pcoords = cell.GetParametricCoords() |
| 3093 |
points = np.zeros((cell.GetNumberOfPoints(), 3)) |
| 3094 |
for i in range(len(points)): |
| 3095 |
points[i] = (pcoords[3 * i], pcoords[3 * i + 1], pcoords[3 * i + 2]) |
| 3096 |
|
| 3097 |
cells = [len(points), *list(range(len(points)))] |
| 3098 |
return UnstructuredGrid(cells, [celltype], points) |
| 3099 |
|
| 3100 |
|
| 3101 |
def _vtkCellTypeSource( |
| 3102 |
celltype: CellType, *, cell_order: int = 3, single_cell: bool = True |
| 3103 |
) -> UnstructuredGrid | None: |
| 3104 |
"""Use vtkCellTypeSource to generate UnstructuredGrid with a single cell type.""" |
| 3105 |
if celltype.vtk_class is None or celltype in _NOT_SUPPORTED_CELL_SOURCE: |
| 3106 |
return None |
| 3107 |
src = _vtk.vtkCellTypeSource() |
| 3108 |
src.SetBlocksDimensions(1, 1, 1) |
| 3109 |
src.SetCellOrder(cell_order) |
| 3110 |
src.SetCellType(celltype) |
| 3111 |
src.Update() |
| 3112 |
ugrid = cast('_vtk.vtkUnstructuredGrid', src.GetOutput()) |
| 3113 |
|
| 3114 |
if single_cell: |
| 3115 |
cell0 = ugrid.GetCell(0) |
| 3116 |
ugrid = _vtk.vtkUnstructuredGrid() |
| 3117 |
ugrid.SetPoints(cell0.GetPoints()) |
| 3118 |
ids = _vtk.vtkIdList() |
| 3119 |
for i in range(cell0.GetNumberOfPoints()): |
| 3120 |
ids.InsertNextId(i) |
| 3121 |
ugrid.InsertNextCell(cell0.GetCellType(), ids) |
| 3122 |
|
| 3123 |
return pv.wrap(ugrid) |