Source code for fury.actor.polyhedron

"""Polyhedron actors for FURY."""

from fury.actor import actor_from_primitive
import fury.primitive as fp


[docs] def box( centers, *, directions=(1, 0, 0), colors=(1, 0, 0), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, detailed=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many boxes with different features. Parameters ---------- centers : ndarray, shape (N, 3) Box positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the box. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the box in each dimension. If a single value is provided, the same size will be used for all boxes. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the boxes. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the boxes should be pickable in a 3D scene. detailed : bool, optional Whether to create a detailed box with 24 vertices or a simple box with 8 vertices. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated boxes, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> scales = np.random.rand(5, 3) >>> box_actor = actor.box(centers=centers, scales=scales) >>> _ = scene.add(box_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_box(detailed=detailed) return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def frustum( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many frustums with different features. Parameters ---------- centers : ndarray, shape (N, 3) Frustum positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the frustum. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the frustum in each dimension. If a single value is provided, the same size will be used for all frustums. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the frustums. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the frustums should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated frustums, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> frustum_actor = actor.frustum(centers=centers, colors=colors) >>> _ = scene.add(frustum_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_frustum() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def tetrahedron( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many tetrahedrons with different features. Parameters ---------- centers : ndarray, shape (N, 3) Tetrahedron positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the tetrahedron. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the tetrahedron in each dimension. If a single value is provided, the same size will be used for all tetrahedrons. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the tetrahedrons. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the tetrahedrons should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated tetrahedrons, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> tetrahedron_actor = actor.tetrahedron(centers=centers, colors=colors) >>> _ = scene.add(tetrahedron_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_tetrahedron() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def icosahedron( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many icosahedrons with different features. Parameters ---------- centers : ndarray, shape (N, 3) Icosahedron positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the icosahedron. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the icosahedron in each dimension. If a single value is provided, the same size will be used for all icosahedrons. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the icosahedrons. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the icosahedrons should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated icosahedrons, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> icosahedron_actor = actor.icosahedron(centers=centers, colors=colors) >>> _ = scene.add(icosahedron_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_icosahedron() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def rhombicuboctahedron( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many rhombicuboctahedrons with different features. Parameters ---------- centers : ndarray, shape (N, 3) Rhombicuboctahedron positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the rhombicuboctahedron. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the rhombicuboctahedron in each dimension. If a single value is provided, the same size will be used for all rhombicuboctahedrons. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the rhombicuboctahedrons. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the rhombicuboctahedrons should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated rhombicuboctahedrons, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> rhombicuboctahedron_actor = actor.rhombicuboctahedron( ... centers=centers, colors=colors) >>> _ = scene.add(rhombicuboctahedron_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_rhombicuboctahedron() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def triangularprism( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many triangular prisms with different features. Parameters ---------- centers : ndarray, shape (N, 3) Triangular prism positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the triangular prism. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the triangular prism in each dimension. If a single value is provided, the same size will be used for all triangular prisms. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the triangular prisms. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the triangular prisms should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated triangular prisms, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> triangularprism_actor = actor.triangularprism(centers=centers, colors=colors) >>> _ = scene.add(triangularprism_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_triangularprism() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def pentagonalprism( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many pentagonal prisms with different features. Parameters ---------- centers : ndarray, shape (N, 3) Pentagonal prism positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the pentagonal prism. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the pentagonal prism in each dimension. If a single value is provided, the same size will be used for all pentagonal prisms. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the pentagonal prisms. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the pentagonal prisms should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated pentagonal prisms, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> pentagonalprism_actor = actor.pentagonalprism(centers=centers, colors=colors) >>> _ = scene.add(pentagonalprism_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_pentagonalprism() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def octagonalprism( centers, *, directions=(0, 0, 0), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many octagonal prisms with different features. Parameters ---------- centers : ndarray, shape (N, 3) Octagonal prism positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the octagonal prism. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the octagonal prism in each dimension. If a single value is provided, the same size will be used for all octagonal prisms. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the octagonal prisms. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the octagonal prisms should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated octagonal prisms, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> octagonalprism_actor = actor.octagonalprism(centers=centers, colors=colors) >>> _ = scene.add(octagonalprism_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_octagonalprism() return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )
[docs] def superquadric( centers, *, directions=(0, 0, 0), roundness=(1, 1), colors=(1, 1, 1), scales=(1, 1, 1), opacity=None, material="phong", enable_picking=True, wireframe=False, wireframe_thickness=1.0, ): """ Create one or many superquadrics with different features. Parameters ---------- centers : ndarray, shape (N, 3) Superquadric positions. directions : ndarray, shape (N, 3) or tuple (3,), optional The orientation vector of the superquadric. roundness : tuple, optional Parameters (Phi and Theta) that control the shape of the superquadric. colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional RGB or RGBA colors. Accepts values in [0, 255] (int), [0, 1] (float), or hex strings (e.g. "#FF0000"). Values above 1.0 are treated as [0, 255] and normalized internally. scales : ndarray, shape (N, 3) or tuple (3,) or float, optional The size of the superquadric in each dimension. If a single value is provided, the same size will be used for all superquadrics. opacity : float, optional Takes values from 0 (fully transparent) to 1 (opaque). If both `opacity` and RGBA are provided, the final alpha will be: final_alpha = alpha_in_RGBA * opacity. material : str, optional The material type for the superquadrics. Options are 'phong' and 'basic'. enable_picking : bool, optional Whether the superquadrics should be pickable in a 3D scene. wireframe : bool, optional Whether to render the mesh as a wireframe. wireframe_thickness : float, optional The thickness of the wireframe lines. Returns ------- Actor A mesh actor containing the generated superquadrics, with the specified material and properties. Examples -------- >>> from fury import window, actor >>> import numpy as np >>> scene = window.Scene() >>> centers = np.random.rand(5, 3) * 10 >>> colors = np.random.rand(5, 3) >>> superquadric_actor = actor.superquadric(centers=centers, colors=colors) >>> _ = scene.add(superquadric_actor) >>> show_manager = window.ShowManager(scene=scene, size=(600, 600)) >>> show_manager.start() """ vertices, faces = fp.prim_superquadric(roundness=roundness) return actor_from_primitive( vertices, faces, centers=centers, colors=colors, scales=scales, directions=directions, opacity=opacity, material=material, enable_picking=enable_picking, wireframe=wireframe, wireframe_thickness=wireframe_thickness, )