66import compas_slicer
77from compas_slicer .geometry import Layer , Path
88
9- __all__ = [' generate_raft' ]
9+ __all__ = [" generate_raft" ]
1010
1111
12- def generate_raft (slicer ,
13- raft_offset = 10 ,
14- distance_between_paths = 10 ,
15- direction = "xy_diagonal" ,
16- raft_layers = 1 ,
17- raft_layer_height = None ):
12+ def generate_raft (
13+ slicer , raft_offset = 10 , distance_between_paths = 10 , direction = "xy_diagonal" , raft_layers = 1 , raft_layer_height = None
14+ ):
1815 """Creates a raft.
1916
2017 Parameters
@@ -76,7 +73,7 @@ def generate_raft(slicer,
7673
7774 # create starting line for diagonal direction
7875 if direction == "xy_diagonal" :
79- c = math .sqrt (2 * (distance_between_paths ** 2 ))
76+ c = math .sqrt (2 * (distance_between_paths ** 2 ))
8077
8178 pt1 = Point (raft_start_pt [0 ] + c , raft_start_pt [1 ], raft_start_pt [2 ])
8279 pt2 = Point (pt1 [0 ] - y_range , pt1 [1 ] + y_range , pt1 [2 ])
@@ -86,10 +83,9 @@ def generate_raft(slicer,
8683 for i , layer in enumerate (slicer .layers ):
8784 for j , path in enumerate (layer .paths ):
8885 for k , pt in enumerate (path .points ):
89- slicer .layers [i ].paths [j ].points [k ] = Point (pt [0 ], pt [1 ], pt [2 ] + (raft_layers )* raft_layer_height )
86+ slicer .layers [i ].paths [j ].points [k ] = Point (pt [0 ], pt [1 ], pt [2 ] + (raft_layers ) * raft_layer_height )
9087
9188 for i in range (raft_layers ):
92-
9389 iter = 0
9490 raft_points = []
9591
@@ -99,8 +95,16 @@ def generate_raft(slicer,
9995 # VERTICAL RAFT
10096 # ===============
10197 if direction == "y_axis" :
102- raft_pt1 = Point (raft_start_pt [0 ] + iter * distance_between_paths , raft_start_pt [1 ], raft_start_pt [2 ] + i * raft_layer_height )
103- raft_pt2 = Point (raft_start_pt [0 ] + iter * distance_between_paths , raft_start_pt [1 ] + y_range , raft_start_pt [2 ] + i * raft_layer_height )
98+ raft_pt1 = Point (
99+ raft_start_pt [0 ] + iter * distance_between_paths ,
100+ raft_start_pt [1 ],
101+ raft_start_pt [2 ] + i * raft_layer_height ,
102+ )
103+ raft_pt2 = Point (
104+ raft_start_pt [0 ] + iter * distance_between_paths ,
105+ raft_start_pt [1 ] + y_range ,
106+ raft_start_pt [2 ] + i * raft_layer_height ,
107+ )
104108
105109 if raft_pt2 [0 ] > bb_max_x_right or raft_pt1 [0 ] > bb_max_x_right :
106110 break
@@ -109,8 +113,16 @@ def generate_raft(slicer,
109113 # HORIZONTAL RAFT
110114 # ===============
111115 elif direction == "x_axis" :
112- raft_pt1 = Point (raft_start_pt [0 ], raft_start_pt [1 ] + iter * distance_between_paths , raft_start_pt [2 ] + i * raft_layer_height )
113- raft_pt2 = Point (raft_start_pt [0 ] + x_range , raft_start_pt [1 ] + iter * distance_between_paths , raft_start_pt [2 ] + i * raft_layer_height )
116+ raft_pt1 = Point (
117+ raft_start_pt [0 ],
118+ raft_start_pt [1 ] + iter * distance_between_paths ,
119+ raft_start_pt [2 ] + i * raft_layer_height ,
120+ )
121+ raft_pt2 = Point (
122+ raft_start_pt [0 ] + x_range ,
123+ raft_start_pt [1 ] + iter * distance_between_paths ,
124+ raft_start_pt [2 ] + i * raft_layer_height ,
125+ )
114126
115127 if raft_pt2 [1 ] > bb_max_y_top or raft_pt1 [1 ] > bb_max_y_top :
116128 break
@@ -120,21 +132,21 @@ def generate_raft(slicer,
120132 # ===============
121133 elif direction == "xy_diagonal" :
122134 # create offset of the initial diagonal line
123- offset_l = offset_line (line , iter * distance_between_paths , Vector (0 , 0 , - 1 ))
135+ offset_l = offset_line (line , iter * distance_between_paths , Vector (0 , 0 , - 1 ))
124136
125137 # get intersections for the initial diagonal line with the left and bottom of the bb
126138 int_left = intersection_line_line (offset_l , [bb_xy_offset [0 ], bb_xy_offset [3 ]])
127139 int_bottom = intersection_line_line (offset_l , [bb_xy_offset [0 ], bb_xy_offset [1 ]])
128140
129141 # get the points at the intersections
130- raft_pt1 = Point (int_left [0 ][0 ], int_left [0 ][1 ], int_left [0 ][2 ] + i * raft_layer_height )
131- raft_pt2 = Point (int_bottom [0 ][0 ], int_bottom [0 ][1 ], int_bottom [0 ][2 ] + i * raft_layer_height )
142+ raft_pt1 = Point (int_left [0 ][0 ], int_left [0 ][1 ], int_left [0 ][2 ] + i * raft_layer_height )
143+ raft_pt2 = Point (int_bottom [0 ][0 ], int_bottom [0 ][1 ], int_bottom [0 ][2 ] + i * raft_layer_height )
132144
133145 # if the intersection goes beyond the height of the left side of the bounding box:
134146 if int_left [0 ][1 ] > bb_max_y_top :
135147 # create intersection with the top side
136148 int_top = intersection_line_line (offset_l , [bb_xy_offset [3 ], bb_xy_offset [2 ]])
137- raft_pt1 = Point (int_top [0 ][0 ], int_top [0 ][1 ], int_top [0 ][2 ] + i * raft_layer_height )
149+ raft_pt1 = Point (int_top [0 ][0 ], int_top [0 ][1 ], int_top [0 ][2 ] + i * raft_layer_height )
138150
139151 # if intersection goes beyond the length of the top side, break
140152 if raft_pt1 [0 ] > bb_max_x_right :
@@ -144,7 +156,7 @@ def generate_raft(slicer,
144156 if int_bottom [0 ][0 ] > bb_max_x_right :
145157 # create intersection with the right side
146158 int_right = intersection_line_line (offset_l , [bb_xy_offset [1 ], bb_xy_offset [2 ]])
147- raft_pt2 = Point (int_right [0 ][0 ], int_right [0 ][1 ], int_right [0 ][2 ] + i * raft_layer_height )
159+ raft_pt2 = Point (int_right [0 ][0 ], int_right [0 ][1 ], int_right [0 ][2 ] + i * raft_layer_height )
148160
149161 # if intersection goes beyond the height of the right side, break
150162 if raft_pt2 [1 ] > bb_xy_offset [2 ][1 ]:
0 commit comments