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§
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Returns a mutable reference to self as Any for downcasting.
Sourcefn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Returns the type name of this structure (e.g., “PointCloud”, “SurfaceMesh”).
Sourcefn bounding_box(&self) -> Option<(Vec3, Vec3)>
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.
Sourcefn length_scale(&self) -> f32
fn length_scale(&self) -> f32
Returns a characteristic length scale for this structure.
Sourcefn set_transform(&mut self, transform: Mat4)
fn set_transform(&mut self, transform: Mat4)
Sets the model transform matrix.
Sourcefn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Returns whether this structure is currently visible.
Sourcefn set_enabled(&mut self, enabled: bool)
fn set_enabled(&mut self, enabled: bool)
Sets the visibility of this structure.
Sourcefn draw(&self, ctx: &mut dyn RenderContext)
fn draw(&self, ctx: &mut dyn RenderContext)
Draws this structure to the scene.
Called during the main render pass.
Sourcefn draw_pick(&self, ctx: &mut dyn RenderContext)
fn draw_pick(&self, ctx: &mut dyn RenderContext)
Draws this structure for picking/selection.
Called during the pick render pass.
Sourcefn build_pick_ui(&self, ui: &dyn Any, pick: &PickResult)
fn build_pick_ui(&self, ui: &dyn Any, pick: &PickResult)
Builds the ImGui UI for a picked element.
Provided Methods§
Sourcefn center_bounding_box(&mut self)
fn center_bounding_box(&mut self)
Centers the camera on this structure’s bounding box.
Sourcefn reset_transform(&mut self)
fn reset_transform(&mut self)
Resets the transform to identity.
Sourcefn clear_gpu_resources(&mut self)
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).
Sourcefn set_material(&mut self, _material: &str)
fn set_material(&mut self, _material: &str)
Sets the material for this structure by name.