Skip to main content

Structure

Trait Structure 

Source
pub trait Structure:
    Any
    + Send
    + Sync {
Show 20 methods // Required methods fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; fn name(&self) -> &str; fn type_name(&self) -> &'static str; fn bounding_box(&self) -> Option<(Vec3, Vec3)>; fn length_scale(&self) -> f32; fn transform(&self) -> Mat4; fn set_transform(&mut self, transform: Mat4); fn is_enabled(&self) -> bool; fn set_enabled(&mut self, enabled: bool); fn draw(&self, ctx: &mut dyn RenderContext); fn draw_pick(&self, ctx: &mut dyn RenderContext); fn build_ui(&mut self, ui: &dyn Any); fn build_pick_ui(&self, ui: &dyn Any, pick: &PickResult); fn refresh(&mut self); // Provided methods fn center_bounding_box(&mut self) { ... } fn reset_transform(&mut self) { ... } fn clear_gpu_resources(&mut self) { ... } fn material(&self) -> &str { ... } fn set_material(&mut self, _material: &str) { ... }
}
Expand description

A geometric object that can be visualized in polyscope.

Structures are the primary objects managed by polyscope. Each structure has:

  • A unique name within its type
  • A transform matrix for positioning in the scene
  • Visibility state
  • Methods for rendering and UI building

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns a reference to self as Any for downcasting.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to self as Any for downcasting.

Source

fn name(&self) -> &str

Returns the unique name of this structure.

Source

fn type_name(&self) -> &'static str

Returns the type name of this structure (e.g., “PointCloud”, “SurfaceMesh”).

Source

fn bounding_box(&self) -> Option<(Vec3, Vec3)>

Returns the axis-aligned bounding box in world coordinates.

Returns None if the structure has no spatial extent.

Source

fn length_scale(&self) -> f32

Returns a characteristic length scale for this structure.

Source

fn transform(&self) -> Mat4

Returns the current model transform matrix.

Source

fn set_transform(&mut self, transform: Mat4)

Sets the model transform matrix.

Source

fn is_enabled(&self) -> bool

Returns whether this structure is currently visible.

Source

fn set_enabled(&mut self, enabled: bool)

Sets the visibility of this structure.

Source

fn draw(&self, ctx: &mut dyn RenderContext)

Draws this structure to the scene.

Called during the main render pass.

Source

fn draw_pick(&self, ctx: &mut dyn RenderContext)

Draws this structure for picking/selection.

Called during the pick render pass.

Source

fn build_ui(&mut self, ui: &dyn Any)

Builds the ImGui UI for this structure.

Source

fn build_pick_ui(&self, ui: &dyn Any, pick: &PickResult)

Builds the ImGui UI for a picked element.

Source

fn refresh(&mut self)

Refreshes GPU resources after data changes.

Provided Methods§

Source

fn center_bounding_box(&mut self)

Centers the camera on this structure’s bounding box.

Source

fn reset_transform(&mut self)

Resets the transform to identity.

Source

fn clear_gpu_resources(&mut self)

Clears all GPU resources (render data, pick buffers, etc.).

After calling this, the structure’s GPU resources will be lazily re-initialized on the next render frame. This is needed when switching wgpu devices (e.g., between headless render calls).

Source

fn material(&self) -> &str

Returns the material name for this structure (e.g., “clay”, “wax”).

Source

fn set_material(&mut self, _material: &str)

Sets the material for this structure by name.

Implementors§