# Writing slice elements to an RP3-style text file. # Last edited on 2021-09-30 13:11:23 by stolfi import txt_write_IMP def write(wr, OCRS, OPHS, CTS, Z, angle): # Writes to file handle {wr} a description of a single object slice at # nominal height {Z}, consisting of the contours {OCRS}, the filling # elements {OPHS}, the contacts {CTS}, and the link paths associated # to {OPHS}, # # ??? Describe the file format ??? # # Each element {ocr} in the list {OCRS} (written as a line with the 'C' # code) must be a /contour/, a closed path without jumps that follows # the boundary of the slice. The contours must be properly oriented # and must have the same trace parameters. # # Each element {oph} in the filling list {OPHS} (written as a line # with 'R' code) must be a /raster/, an oriented path with a single # trace move, whose axis makes the specified {angle} (in radians, # counterclockwise) with the horizontal. If rotated by {-angle}, these # rasters must fall on equally spaced horizontal scanlines, sorted in # scanline order (increasing {Y} with ties broken by {X}). All these # traces must have the same parameters, including the same nominal # width that should be equal to the spacing of the scanlines. # # Each raster {oph} is written out with the first endpoint being the # one that would be the leftmost one in the urotated view; but its # orientaton is recorded in the 'rbit' field of the line. The # procedure also writes in the 'R' line the 'group' index assocated to # {oph} by {path_hp.get_group}. # # The procedure also writes a line with 'L' code for each pair of # rasters that have either a contact or a connecting link path. The # contacts of each element {oph} are obtained with # {path_hp.get_contacts}, and the links that end at each endpoint are # obtaned with {path.get_links(oph)} and # {path.get_links(path.rev(oph))} All the links are supposed to # have the same move parameters as the rasters. # return txt_write_IMP.write(wr, OCRS, OPHS, CTS, Z, angle)