Struct scad_tree::Viewer

source ·
pub struct Viewer { /* private fields */ }
Expand description

Viewer struct is used to view points, edges, and curves in OpenSCAD.

Implementations§

source§

impl Viewer

source

pub fn new(point_radius: f64, edge_radius: f64, segments: u64) -> Self

Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 42)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
fn main() {
    let mut curve = dim2::CubicBezierChain2D::new(
        Pt2::new(0.0, 0.0),
        Pt2::new(40.0, -20.0),
        Pt2::new(40.0, 80.0),
        Pt2::new(0.0, 40.0),
        24,
    );
    curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);

    let mut viewer = Viewer::new(0.5, 0.25, 6);
    viewer.add_cubic_bezier_chain2d(&curve);
    scad_file!("output/view_cubic_bezier_chain.scad",
        viewer.into_scad();
    );
}
More examples
Hide additional examples
examples/bezier_star_sweep.rs (line 44)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
fn main() {
    let output_viewer = false;
    let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
    let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);

    if output_viewer {
        let mut viewer = Viewer::new(0.5, 0.25, 6);
        viewer.add_bezier_star(&path);
        let mut small_viewer = Viewer::new(0.05, 0.025, 6);
        small_viewer.add_bezier_star(&profile);
        scad_file!("output/bezier_star_sweep.scad",
            small_viewer.into_scad() + viewer.into_scad();
        );
    } else {
        let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
        let profile = profile.gen_points();
        let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
        scad_file!("output/bezier_star_sweep.scad",
            star_swept.into_scad();
        );
    }
}
source

pub fn add_pt2(&mut self, point: Pt2, color: ScadColor)

source

pub fn add_pt3(&mut self, point: Pt3, color: ScadColor)

source

pub fn add_pt2s(&mut self, points: &Pt2s, color: ScadColor)

source

pub fn add_pt3s(&mut self, points: &Pt3s, color: ScadColor)

source

pub fn add_lines2d(&mut self, edges: &Vec<(Pt2, Pt2)>, color: ScadColor)

source

pub fn add_lines3d(&mut self, edges: &Vec<(Pt3, Pt3)>, color: ScadColor)

source

pub fn add_quadratic_bezier2d(&mut self, curve: &QuadraticBezier2D)

source

pub fn add_quadratic_bezier3d(&mut self, curve: &QuadraticBezier3D)

source

pub fn add_cubic_bezier2d(&mut self, curve: &CubicBezier2D)

source

pub fn add_cubic_bezier3d(&mut self, curve: &CubicBezier3D)

source

pub fn add_cubic_bezier_chain2d(&mut self, curve: &CubicBezierChain2D)

Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 43)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
fn main() {
    let mut curve = dim2::CubicBezierChain2D::new(
        Pt2::new(0.0, 0.0),
        Pt2::new(40.0, -20.0),
        Pt2::new(40.0, 80.0),
        Pt2::new(0.0, 40.0),
        24,
    );
    curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);

    let mut viewer = Viewer::new(0.5, 0.25, 6);
    viewer.add_cubic_bezier_chain2d(&curve);
    scad_file!("output/view_cubic_bezier_chain.scad",
        viewer.into_scad();
    );
}
source

pub fn add_cubic_bezier_chain3d(&mut self, curve: &CubicBezierChain3D)

source

pub fn add_bezier_star(&mut self, star: &BezierStar)

Examples found in repository?
examples/bezier_star_sweep.rs (line 45)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
fn main() {
    let output_viewer = false;
    let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
    let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);

    if output_viewer {
        let mut viewer = Viewer::new(0.5, 0.25, 6);
        viewer.add_bezier_star(&path);
        let mut small_viewer = Viewer::new(0.05, 0.025, 6);
        small_viewer.add_bezier_star(&profile);
        scad_file!("output/bezier_star_sweep.scad",
            small_viewer.into_scad() + viewer.into_scad();
        );
    } else {
        let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
        let profile = profile.gen_points();
        let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
        scad_file!("output/bezier_star_sweep.scad",
            star_swept.into_scad();
        );
    }
}
source

pub fn into_scad(self) -> Scad

Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 45)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
fn main() {
    let mut curve = dim2::CubicBezierChain2D::new(
        Pt2::new(0.0, 0.0),
        Pt2::new(40.0, -20.0),
        Pt2::new(40.0, 80.0),
        Pt2::new(0.0, 40.0),
        24,
    );
    curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);

    let mut viewer = Viewer::new(0.5, 0.25, 6);
    viewer.add_cubic_bezier_chain2d(&curve);
    scad_file!("output/view_cubic_bezier_chain.scad",
        viewer.into_scad();
    );
}
More examples
Hide additional examples
examples/bezier_star_sweep.rs (line 49)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
fn main() {
    let output_viewer = false;
    let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
    let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);

    if output_viewer {
        let mut viewer = Viewer::new(0.5, 0.25, 6);
        viewer.add_bezier_star(&path);
        let mut small_viewer = Viewer::new(0.05, 0.025, 6);
        small_viewer.add_bezier_star(&profile);
        scad_file!("output/bezier_star_sweep.scad",
            small_viewer.into_scad() + viewer.into_scad();
        );
    } else {
        let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
        let profile = profile.gen_points();
        let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
        scad_file!("output/bezier_star_sweep.scad",
            star_swept.into_scad();
        );
    }
}

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.