skeinforge_tools.slice_shape ($Date: 2008/02/05 $)
index
/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/slice_shape.py

Slice shape is a script to slice a GNU Triangulated Surface file.
 
Slice slices a GNU Triangulated Surface file into gcode extrusion layers.  The 'Extrusion Diameter' is the diameter of the extrusion at the
default extruder speed, this is the most important slice preference.  The 'Extrusion Density' is the density of the extruded shape over the
density of the filament.  The 'Extrusion Width Over Thickness' ratio is the ratio of the extrusion width over the layer thickness.  A ratio of
one means the extrusion is a circle, a typical ratio of 1.5 means the extrusion is a wide oval.
 
Rarely changed preferences are Import Coarseness, Mesh Type, Infill Bridge Width Over Thickness & Infill in Direction
of Bridges.  When the triangle mesh has holes in it, slice switches over to a slow algorithm that spans gaps in the mesh.  The higher the
import coarseness, the wider the gaps in the mesh it will span.  An import coarseness of one means it will span gaps the width of the
extrusion.  When the Mesh Type preference is correct, the mesh will be accurately sliced, and if a hole is found, slice will switch over to
the algorithm that spans gaps.  If the Mesh Type preference is Unproven, slice will use the gap spanning algorithm from the start.  The
problem with the gap spanning algothm is that it will span gaps, even if there actually is a gap in the model.  Infill bridge width
over thickness ratio is the ratio of the extrusion width over the layer thickness on a bridge layer.  If the infill in direction of bridges
preference is chosen, the infill will be in the direction of bridges across gaps, so that the fill will be able to span a bridge easier.
 
When slice is generating the code, if there is a file start.txt, it will add that to the very beginning of the gcode. After it has added some
initialization code and just before it adds the extrusion gcode, it will add the file endofthebeginning.txt if it exists. At the very end, it will
add the file end.txt if it exists. Slice does not care if the text file names are capitalized, but some file systems do not handle file name
cases properly, so to be on the safe side you should give them lower case names.  It will first look for the file in the same directory as
slice, if it does not find it it will look in ~/.skeinforge/gcode_scripts.  To run slice, in a shell type:
> python slice.py
 
The following examples slice the GNU Triangulated Surface file Hollow Square.gts.  The examples are run in a terminal in the folder which
contains Hollow Square.gts and slice.py.  The preferences can be set in the dialog or by changing the preferences file 'slice.csv' with a text editor
or a spreadsheet program set to separate tabs.
 
 
> python slice.py
This brings up the dialog, after clicking 'Slice', the following is printed:
File Hollow Square.gcode is being sliced.
The sliced file is saved as Hollow Square_slice.gcode
 
 
>python
Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import slice
>>> slice.main()
File Hollow Square.gts is being sliced.
The sliced file is saved as Hollow Square_slice.gcode
It took 3 seconds to slice the file.
 
 
>>> slice.writeOutput()
File Hollow Square.gcode is being sliced.
The sliced file is saved as Hollow Square_slice.gcode
It took 3 seconds to slice the file.
 
 
>>> slice.getSliceGcode("
54 162 108 Number of Vertices,Number of Edges,Number of Faces
-5.800000000000001 5.341893939393939 4.017841892579603 Vertex Coordinates XYZ
5.800000000000001 5.341893939393939 4.017841892579603
..
many lines of GNU Triangulated Surface vertices, edges and faces
..
")

 
Modules
       
__init__
skeinforge_tools.analyze
cStringIO
cmath
skeinforge_tools.skeinforge_utilities.euclidean
skeinforge_tools.skeinforge_utilities.gcodec
skeinforge_tools.import_translator
skeinforge_tools.skeinforge_utilities.intercircle
math
os
skeinforge_tools.polyfile
skeinforge_tools.skeinforge_utilities.preferences
sys
time
skeinforge_tools.skeinforge_utilities.triangle_mesh

 
Classes
       
SlicePreferences
SliceSkein

 
class SlicePreferences
    A class to handle the slice preferences.
 
  Methods defined here:
__init__(self)
Set the default preferences, execute title & preferences filename.
execute(self)
Slice button has been clicked.

 
class SliceSkein
    A class to slice a GNU Triangulated Surface.
 
  Methods defined here:
__init__(self)
addFromFile(self, filename)
Add lines of text from the filename.
addFromUpperLowerFile(self, filename)
Add lines of text from the filename or the lowercase filename, if there is no file by the original filename in the directory.
addGcodeFromPerimeterPaths(self, loop, loopLists, radius)
Add the perimeter paths to the output.
addGcodeFromRemainingLoop(self, loop, loopLists, radius)
Add the remainder of the loop which does not overlap the alreadyFilledArounds loops.
addGcodeFromThread(self, thread)
Add a thread to the output.
addGcodeMovement(self, point)
Add a movement to the output.
addInitializationToOutput(self)
Add initialization gcode to the output.
addLine(self, line)
Add a line of text and a newline to the output.
addShutdownToOutput(self)
Add shutdown gcode to the output.
addToZoneArray(self, point, zoneArray, z)
Add a height to the zone array.
getBridgeDirection(self, layerLoops)
Get span direction for the majority of the overhanging extrusion perimeter, if any.
getExtrudateLoops(self, halfWidth, loop)
Get the inset extrudate loops from the loop.
getLoopsFromMesh(self, z)
Get loops from a slice of a mesh.
getRounded(self, number)
Get number rounded to the number of carried decimal places as a string.
getZAddExtruderPaths(self, z)
Get next z and add extruder loops.
parseTriangleMesh(self, slicePreferences, triangleMesh)
Parse gnu triangulated surface text and store the sliced gcode.

 
Functions
       
addAlreadyFilledArounds(alreadyFilledArounds, loop, radius)
Add already filled loops around loop to alreadyFilledArounds.
addEdgePair(edgePairTable, edges, faceEdgeIndex, remainingEdgeIndex, remainingEdgeTable)
Add edge pair to the edge pair table.
addPointsAtZ(edgePair, points, radius, vertices, z)
Add points on the segment between the edge intersections with z.
getCommonVertexIndex(edgeFirst, edgeSecond)
Get the vertex index that both edges have in common.
getDoubledRoundZ(overhangingSegment, segmentRoundZ)
Get doubled plane angle around z of the overhanging segment.
getLoopsFromCorrectMesh(edges, faces, vertices, z)
Get loops from a slice of a correct mesh.
getLoopsFromUnprovenMesh(edges, extrusionWidth, faces, vertices, slicePreferences, z)
Get loops from a slice of an unproven mesh.
getLowestZoneIndex(zoneArray, z)
Get the lowest zone index.
getNextEdgeIndexAroundZ(edge, faces, remainingEdgeTable)
Get the next edge index in the mesh slice.
getOverhangDirection(belowOutsetLoops, segmentBegin, segmentEnd)
Add to span direction from the endpoint segments which overhang the layer below.
getPath(edges, pathIndexes, loop, z)
Get the path from the edge intersections.
getPathIndexesAddPath(edges, faces, loops, remainingEdgeTable, vertices, z)
Get the path indexes around a triangle mesh slice and add the path to the loops.
getRemainingEdgeTable(edges, vertices, z)
Get the remaining edge hashtable.
getSegmentsFromPoints(loopLists, pointBegin, pointEnd)
Get enpoint segments from the beginning and end of a line segment.
getSharedFace(firstEdge, faces, secondEdge)
Get the face which is shared by two edges.
getSliceGcode(filename, slicePreferences=None)
Slice a shape file.
getSliceIntersectionFromEdge(edge, loop, z)
Get the point where the slice intersects the edge.
isCloseToLast(paths, point, radius)
Determine if the point is close to the last point of the last path.
isIntersectingWithinList(loop, loopList)
Determine if the loop is intersecting or is within the loop list.
isIntersectingWithinLists(loop, loopLists)
Determine if the loop is intersecting or is within the loop lists.
isZInEdge(edge, vertices, z)
Determine if z is inside the edge.
main()
Display the slice dialog.
writeOutput(filename='')
Slice a GNU Triangulated Surface file.  If no filename is specified, slice the first GNU Triangulated Surface file in this folder.

 
Data
        __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
__date__ = '$Date: 2008/02/05 $'
__license__ = 'GPL 3.0'
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)

 
Author
        Enrique Perez (perez_enrique@yahoo.com)