Struct ParamSet

Source
pub struct ParamSet { /* private fields */ }
Expand description

ParamSet provides a generic way to pass data between the scene files and the factory functions that create various pieces of the rendering pipeline. It enables the renderer to be extensible, many of the constructor methods on Pbrt take a name and a ParamSet. This allows new types of Textures, Cameras, Shapes, etc. to be added without haven’t to change and method signatures.

Implementations§

Source§

impl ParamSet

Source

pub fn find_one_bool(&self, name: &str, default: bool) -> bool

find_one_bool will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type bool then default will be returned.

§Examples
use pbrt::core::paramset::testutils::make_bool_param_set;

let ps = make_bool_param_set("value", vec![true]);
assert_eq!(ps.find_one_bool("value", false), true);
assert_eq!(ps.find_one_bool("non-existent", false), false);
Source

pub fn find_one_float(&self, name: &str, default: Float) -> Float

find_one_float will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Float then default will be returned.

§Examples
use pbrt::core::paramset::testutils::make_float_param_set;

let ps = make_float_param_set("value", vec![1.]);
assert_eq!(ps.find_one_float("value", 2.), 1.);
assert_eq!(ps.find_one_float("non-existent", 2.), 2.);
Source

pub fn find_one_int(&self, name: &str, default: isize) -> isize

find_one_int will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type isize then default will be returned.

§Examples
use pbrt::core::paramset::testutils::make_int_param_set;

let ps = make_int_param_set("value", vec![1]);
assert_eq!(ps.find_one_int("value", 2), 1);
assert_eq!(ps.find_one_int("non-existent", 2), 2);
Source

pub fn find_one_point2f(&self, name: &str, default: Point2f) -> Point2f

find_one_point2f will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Point2f then default will be returned.

§Examples
use pbrt::core::geometry::Point2f;
use pbrt::core::paramset::testutils::make_point2f_param_set;

let ps = make_point2f_param_set("value", vec![Point2f::from([1., 1.])]);
assert_eq!(
    ps.find_one_point2f("value", Point2f::from([2., 2.])),
    Point2f::from([1., 1.])
);
assert_eq!(
    ps.find_one_point2f("non-existent", Point2f::from([2., 2.])),
    Point2f::from([2., 2.])
);
Source

pub fn find_one_vector2f(&self, name: &str, default: Vector2f) -> Vector2f

find_one_vector2f will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Vector2f then default will be returned.

§Examples
use pbrt::core::geometry::Vector2f;
use pbrt::core::paramset::testutils::make_vector2f_param_set;

let ps = make_vector2f_param_set("value", vec![Vector2f::from([1., 1.])]);
assert_eq!(
    ps.find_one_vector2f("value", Vector2f::from([2., 2.])),
    Vector2f::from([1., 1.])
);
assert_eq!(
    ps.find_one_vector2f("non-existent", Vector2f::from([2., 2.])),
    Vector2f::from([2., 2.])
);
Source

pub fn find_one_point3f(&self, name: &str, default: Point3f) -> Point3f

find_one_point3f will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Point3f then default will be returned.

§Examples
use pbrt::core::geometry::Point3f;
use pbrt::core::paramset::testutils::make_point3f_param_set;

let ps = make_point3f_param_set("value", vec![Point3f::from([1., 1., 1.])]);
assert_eq!(
    ps.find_one_point3f("value", Point3f::from([2., 2., 2.])),
    Point3f::from([1., 1., 1.])
);
assert_eq!(
    ps.find_one_point3f("non-existent", Point3f::from([2., 2., 2.])),
    Point3f::from([2., 2., 2.])
);
Source

pub fn find_one_vector3f(&self, name: &str, default: Vector3f) -> Vector3f

find_one_vector3f will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Vector3f then default will be returned.

§Examples
use pbrt::core::geometry::Vector3f;
use pbrt::core::paramset::testutils::make_vector3f_param_set;

let ps = make_vector3f_param_set("value", vec![Vector3f::from([1., 1., 1.])]);
assert_eq!(
    ps.find_one_vector3f("value", Vector3f::from([2., 2., 2.])),
    Vector3f::from([1., 1., 1.])
);
assert_eq!(
    ps.find_one_vector3f("non-existent", Vector3f::from([2., 2., 2.])),
    Vector3f::from([2., 2., 2.])
);
Source

pub fn find_one_normal3f(&self, name: &str, default: Normal3f) -> Normal3f

find_one_normal3f will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Normal3f then default will be returned.

§Examples
use pbrt::core::geometry::Normal3f;
use pbrt::core::paramset::testutils::make_normal3f_param_set;

let ps = make_normal3f_param_set("value", vec![Normal3f::from([1., 1., 1.])]);
assert_eq!(
    ps.find_one_normal3f("value", Normal3f::from([2., 2., 2.])),
    Normal3f::from([1., 1., 1.])
);
assert_eq!(
    ps.find_one_normal3f("non-existent", Normal3f::from([2., 2., 2.])),
    Normal3f::from([2., 2., 2.])
);
Source

pub fn find_one_spectrum(&self, name: &str, default: Spectrum) -> Spectrum

find_one_spectrum will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type Spectrum then default will be returned.

§Examples
use pbrt::core::paramset::testutils::make_spectrum_param_set;
use pbrt::core::spectrum::Spectrum;

let ps = make_spectrum_param_set("value", vec![Spectrum::from_rgb([1., 1., 1.])]);
assert_eq!(
    ps.find_one_spectrum("value", Spectrum::from_rgb([2., 2., 2.])),
    Spectrum::from_rgb([1., 1., 1.])
);
assert_eq!(
    ps.find_one_spectrum("non-existent", Spectrum::from_rgb([2., 2., 2.])),
    Spectrum::from_rgb([2., 2., 2.])
);
Source

pub fn find_one_string(&self, name: &str, default: String) -> String

find_one_string will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type String then default will be returned.

§Examples
use pbrt::core::paramset::testutils::make_string_param_set;

let ps = make_string_param_set("value", vec!["found".to_string()]);
assert_eq!(
    ps.find_one_string("value", "default".to_string()),
    "found".to_string()
);
assert_eq!(
    ps.find_one_string("non-existent", "default".to_string()),
    "default".to_string()
);
Source

pub fn find_one_texture(&self, name: &str, default: String) -> String

find_one_texture will return the first parameter in the set for the given name. If no values are found default is returned. If the value by that name is found but isn’t of type String then default will be returned.

§Examples
use pbrt::core::paramset::testutils::make_texture_param_set;

let ps = make_texture_param_set("value", vec!["found".to_string()]);
assert_eq!(
    ps.find_one_texture("value", "default".to_string()),
    "found".to_string()
);
assert_eq!(
    ps.find_one_texture("non-existent", "default".to_string()),
    "default".to_string()
);
Source

pub fn report_unused(&self) -> bool

report_unused will print out all values in this ParamSet that have not been accessed, will return true if any unused values are found. Useful after parsing a scene to see what configuration data was superfluous, or for detecting incomplete implementations of scene factory fuctions.

Trait Implementations§

Source§

impl Clone for ParamSet

Source§

fn clone(&self) -> ParamSet

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParamSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParamSet

Source§

fn default() -> ParamSet

Returns the “default value” for a type. Read more
Source§

impl From<Vec<ParamSetItem>> for ParamSet

Source§

fn from(psis: Vec<ParamSetItem>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ParamSet

Source§

fn eq(&self, other: &ParamSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ParamSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.