Geometry#

PyVista includes several functions to generate simple geometric objects. The API reference for these functions is on this page. For additional details see Geometric Objects example.

PyVista provides both geometric objects and geometric sources. These two types serve similar but distinct purposes. Both allow you to create various types of geometry, but they differ mainly in their level of abstraction and usage scenarios.

If you are looking for an easy and Pythonic way to generate geometric shapes, PyVista’s geometric objects may be more appropriate. If you need more control over the geometry or are building a complex VTK pipeline, then using geometric sources would be more suitable.

Geometric Objects#

  • High-Level Abstraction: Geometric objects like Box, Circle, Arrow, etc., in PyVista are high-level Pythonic wrappers around VTK’s underlying geometric constructs. They provide a more user-friendly way to create geometries and might include additional utility functions or attributes.

  • Self-contained: Geometric objects are often intended to be stand-alone entities, fully encapsulating the properties of the shape they represent.

  • Quick Prototyping: These are often used for quick and simple tasks where complex control over the geometry is not required.

  • Specific to PyVista: While they may be built on top of VTK, these high-level abstractions might be unique to PyVista and not directly translatable to raw VTK code.

Arrow([start, direction, tip_length, ...])

Create an arrow.

Box([bounds, level, quads])

Create a box with solid faces for the given bounds.

Capsule([center, direction, radius, ...])

Create the surface of a capsule.

Circle([radius, resolution])

Create a single PolyData circle defined by radius in the XY plane.

CircularArc(pointa, pointb, center[, ...])

Create a circular arc defined by two endpoints and a center.

CircularArcFromNormal(center[, resolution, ...])

Create a circular arc defined by normal to the plane of the arc, and an angle.

Cone([center, direction, height, radius, ...])

Create a cone.

Cube([center, x_length, y_length, z_length, ...])

Create a cube.

Cylinder([center, direction, radius, ...])

Create the surface of a cylinder.

CylinderStructured([radius, height, center, ...])

Create a cylinder mesh as a pyvista.StructuredGrid.

Disc([center, inner, outer, normal, r_res, ...])

Create a polygonal disk with a hole in the center.

Dodecahedron([radius, center])

Create a dodecahedron of a given size.

Icosahedron([radius, center])

Create an icosahedron of a given size.

Icosphere([radius, center, nsub])

Create an icosphere.

KochanekSpline(points[, tension, bias, ...])

Create a Kochanek spline from points.

Line([pointa, pointb, resolution])

Create a line.

MultipleLines([points])

Create multiple lines.

Octahedron([radius, center])

Create an octahedron of a given size.

Plane([center, direction, i_size, j_size, ...])

Create a plane.

PlatonicSolid([kind, radius, center])

Create a Platonic solid of a given size.

Polygon([center, radius, normal, n_sides, fill])

Create a polygon.

Pyramid([points])

Create a pyramid defined by 5 points.

Rectangle([points])

Create a rectangle defined by 3 points.

SolidSphere([outer_radius, inner_radius, ...])

Create a solid sphere.

SolidSphereGeneric([radius, theta, phi, ...])

Create a solid sphere with flexible sampling.

Sphere([radius, center, direction, ...])

Create a sphere.

Spline(points[, n_points])

Create a spline from points.

Superquadric([center, scale, size, ...])

Create a superquadric.

Tetrahedron([radius, center])

Create a tetrahedron of a given size.

Text3D(string[, depth, width, height, ...])

Create 3D text from a string.

Triangle([points])

Create a triangle defined by 3 points.

Tube([pointa, pointb, resolution, radius, ...])

Create a tube.

Wavelet([extent, center, maximum, x_freq, ...])

Create a wavelet.

Geometric Sources#

Geometric sources are closer to the actual VTK pipeline. They serve as the ‘source’ nodes in a VTK pipeline and generate specific types of geometry.

  • Pipeline Integration: These sources are meant to be integrated into a VTK pipeline, and their output can be directly connected to other pipeline stages like filters, mappers, etc.

  • Fine Control: They often offer more parameters to control the geometry and may be more suitable for scenarios where you need to have fine-grained control over the generated geometry.

  • VTK Compatible: Since they are closer to raw VTK, transitioning from PyVista to VTK or vice versa might be smoother when using geometric sources.

ArrowSource([tip_length, tip_radius, ...])

Create a arrow source.

AxesGeometrySource(*[, shaft_type, ...])

Create axes geometry source.

BoxSource([bounds, level, quads])

Create a box source.

ConeSource([center, direction, height, ...])

Cone source algorithm class.

CubeSource([center, x_length, y_length, ...])

Cube source algorithm class.

CylinderSource([center, direction, radius, ...])

Cylinder source algorithm class.

DiscSource([center, inner, outer, r_res, c_res])

Disc source algorithm class.

LineSource([pointa, pointb, resolution])

Create a line.

MultipleLinesSource([points])

Multiple lines source algorithm class.

PlaneSource([i_resolution, j_resolution])

Create a plane source.

PlatonicSolidSource([kind])

Platonic solid source algorithm class.

PolygonSource([center, radius, normal, ...])

Polygon source algorithm class.

SphereSource([radius, center, ...])

Sphere source algorithm class.

SuperquadricSource([center, scale, size, ...])

Create superquadric source.

Text3DSource([string, depth, width, height, ...])

3D text from a string.