dxf_model/geometry/
points.rs

1#[macro_export]
2macro_rules! point {
3    ($x:expr, $y:expr, $z:expr) => {
4        Point{
5            x: $x,
6            y: $y,
7            z: $y
8        }
9    };
10    ($x:expr, $y:expr) => {
11        Point{
12            x: $x,
13            y: $y,
14            z: 0.0
15        }
16    };
17    ($x:expr) => {
18        Point{
19            x: $x,
20            y: 0.0,
21            z: 0.0
22        }
23    };
24}
25
26#[macro_export]
27macro_rules! shape {
28    ($( $point:expr ), * ) => {
29        {
30            let mut points = Vec::new();
31            $(
32                points.push($point);
33             )*
34                let mut drawing = Drawing::new();
35            for i in 0..points.len()-1 {
36                let new_line = Line::new(points[i].clone(), points[i+1].clone());
37                drawing.add_entity(Entity::new(EntityType::Line(new_line)));
38            }
39            let new_line = Line::new(points[points.len()-1].clone(), points[0].clone());
40            drawing.add_entity(Entity::new(EntityType::Line(new_line)));
41
42            drawing
43        }
44    };
45    ($points:expr) => {
46        {
47            let mut drawing = Drawing::new();
48            for i in 0..points.len()-1 {
49                let new_line = Line::new(points[i].clone(), points[i+1].clone());
50                drawing.add_entity(Entity::new(EntityType::Line(new_line)));
51            }
52            let new_line = Line::new(points[points.len()-1].clone(), points[0].clone());
53            drawing.add_entity(Entity::new(EntityType::Line(new_line)));
54
55            drawing
56        }
57    };
58}