Viewer

Struct 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)
32fn main() {
33    let mut curve = dim2::CubicBezierChain2D::new(
34        Pt2::new(0.0, 0.0),
35        Pt2::new(40.0, -20.0),
36        Pt2::new(40.0, 80.0),
37        Pt2::new(0.0, 40.0),
38        24,
39    );
40    curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);
41
42    let mut viewer = Viewer::new(0.5, 0.25, 6);
43    viewer.add_cubic_bezier_chain2d(&curve);
44    scad_file!(32, "output/view_cubic_bezier_chain.scad",
45        viewer.into_scad();
46    );
47}
More examples
Hide additional examples
examples/bezier_star_sweep.rs (line 44)
38fn main() {
39    let output_viewer = false;
40    let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
41    let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);
42
43    if output_viewer {
44        let mut viewer = Viewer::new(0.5, 0.25, 6);
45        viewer.add_bezier_star(&path);
46        let mut small_viewer = Viewer::new(0.05, 0.025, 6);
47        small_viewer.add_bezier_star(&profile);
48        scad_file!(32, "output/bezier_star_sweep.scad",
49            small_viewer.into_scad() + viewer.into_scad();
50        );
51    } else {
52        let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
53        let profile = profile.gen_points();
54        let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
55        scad_file!(32, "output/bezier_star_sweep.scad",
56            star_swept.into_scad();
57        );
58    }
59}
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)
32fn main() {
33    let mut curve = dim2::CubicBezierChain2D::new(
34        Pt2::new(0.0, 0.0),
35        Pt2::new(40.0, -20.0),
36        Pt2::new(40.0, 80.0),
37        Pt2::new(0.0, 40.0),
38        24,
39    );
40    curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);
41
42    let mut viewer = Viewer::new(0.5, 0.25, 6);
43    viewer.add_cubic_bezier_chain2d(&curve);
44    scad_file!(32, "output/view_cubic_bezier_chain.scad",
45        viewer.into_scad();
46    );
47}
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)
38fn main() {
39    let output_viewer = false;
40    let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
41    let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);
42
43    if output_viewer {
44        let mut viewer = Viewer::new(0.5, 0.25, 6);
45        viewer.add_bezier_star(&path);
46        let mut small_viewer = Viewer::new(0.05, 0.025, 6);
47        small_viewer.add_bezier_star(&profile);
48        scad_file!(32, "output/bezier_star_sweep.scad",
49            small_viewer.into_scad() + viewer.into_scad();
50        );
51    } else {
52        let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
53        let profile = profile.gen_points();
54        let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
55        scad_file!(32, "output/bezier_star_sweep.scad",
56            star_swept.into_scad();
57        );
58    }
59}
Source

pub fn into_scad(self) -> Scad

Examples found in repository?
examples/view_cubic_bezier_chain.rs (line 45)
32fn main() {
33    let mut curve = dim2::CubicBezierChain2D::new(
34        Pt2::new(0.0, 0.0),
35        Pt2::new(40.0, -20.0),
36        Pt2::new(40.0, 80.0),
37        Pt2::new(0.0, 40.0),
38        24,
39    );
40    curve.add(20.0, Pt2::new(-30.0, 50.0), Pt2::new(-50.0, 40.0), 12);
41
42    let mut viewer = Viewer::new(0.5, 0.25, 6);
43    viewer.add_cubic_bezier_chain2d(&curve);
44    scad_file!(32, "output/view_cubic_bezier_chain.scad",
45        viewer.into_scad();
46    );
47}
More examples
Hide additional examples
examples/bezier_star_sweep.rs (line 49)
38fn main() {
39    let output_viewer = false;
40    let path = BezierStar::new(7, 20.0, 9.0, 40.0, 15.0, 12);
41    let profile = BezierStar::new(7, 2.0, 0.9, 4.0, 1.5, 12);
42
43    if output_viewer {
44        let mut viewer = Viewer::new(0.5, 0.25, 6);
45        viewer.add_bezier_star(&path);
46        let mut small_viewer = Viewer::new(0.05, 0.025, 6);
47        small_viewer.add_bezier_star(&profile);
48        scad_file!(32, "output/bezier_star_sweep.scad",
49            small_viewer.into_scad() + viewer.into_scad();
50        );
51    } else {
52        let path = Pt3s::from_pt3s(path.gen_points().iter().map(|p| p.as_pt3(0.0)).collect());
53        let profile = profile.gen_points();
54        let star_swept = Polyhedron::sweep(&profile, &path, 7.0 * 360.0, true);
55        scad_file!(32, "output/bezier_star_sweep.scad",
56            star_swept.into_scad();
57        );
58    }
59}

Auto Trait Implementations§

§

impl Freeze for Viewer

§

impl RefUnwindSafe for Viewer

§

impl Send for Viewer

§

impl Sync for Viewer

§

impl Unpin for Viewer

§

impl UnwindSafe for Viewer

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> 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, 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.