def getCarveRotatedBoundaryLayers(self): "Get the rotated boundary layers." vertexes = [] for visibleObject in evaluate.getVisibleObjects(self.archivableObjects): vertexes += visibleObject.getTransformedVertexes() if len(vertexes) < 1: return [] self.cornerMaximum = Vector3(-999999999.0, - 999999999.0, - 9999999999.9) self.cornerMinimum = Vector3(999999999.0, 999999999.0, 9999999999.9) for vertex in vertexes: self.cornerMaximum.z = max(self.cornerMaximum.z, vertex.z) self.cornerMinimum.z = min(self.cornerMinimum.z, vertex.z) trianglemesh.initializeZoneIntervalTable(self, vertexes) halfHeight = 0.5 * self.layerThickness self.setActualMinimumZ(halfHeight) z = self.cornerMinimum.z + halfHeight while z < self.cornerMaximum.z: z = self.getZAddExtruderPaths(z) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) self.cornerMaximum = euclidean.getPointMaximum(self.cornerMaximum, pointVector3) self.cornerMinimum = euclidean.getPointMinimum(self.cornerMinimum, pointVector3) for rotatedBoundaryLayerIndex in xrange(len(self.rotatedBoundaryLayers) -1, -1, -1): rotatedBoundaryLayer = self.rotatedBoundaryLayers[rotatedBoundaryLayerIndex] if len(rotatedBoundaryLayer.loops) > 0: return self.rotatedBoundaryLayers[: rotatedBoundaryLayerIndex + 1] return []
def getCarveRotatedBoundaryLayers( self ): "Get the rotated boundary layers." vertices = evaluate.getVerticesFromArchivableObjects( self.archivableObjects ) if len( vertices ) < 1: return [] self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, - 9999999999.9 ) self.cornerMinimum = Vector3( 999999999.0, 999999999.0, 9999999999.9 ) for vertex in vertices: self.cornerMaximum.z = max( self.cornerMaximum.z, vertex.z ) self.cornerMinimum.z = min( self.cornerMinimum.z, vertex.z ) halfHeight = 0.5 * self.layerThickness layerTop = self.cornerMaximum.z - halfHeight self.setActualMinimumZ( halfHeight, layerTop ) trianglemesh.initializeZoneIntervalTable( self, vertices ) z = self.cornerMinimum.z + halfHeight while z < layerTop: z = self.getZAddExtruderPaths( z ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3( point.real, point.imag, rotatedBoundaryLayer.z ) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3 ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3 ) self.cornerMaximum.z = layerTop + halfHeight for rotatedBoundaryLayerIndex in xrange( len( self.rotatedBoundaryLayers ) - 1, - 1, - 1 ): rotatedBoundaryLayer = self.rotatedBoundaryLayers[ rotatedBoundaryLayerIndex ] if len( rotatedBoundaryLayer.loops ) > 0: return self.rotatedBoundaryLayers[ : rotatedBoundaryLayerIndex + 1 ] return []
def linearCorner( self, splitLine ): "Update the bounding corners." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.extruderActive or self.repository.goAroundExtruderOffTravel.value: self.cornerHigh = euclidean.getPointMaximum( self.cornerHigh, location ) self.cornerLow = euclidean.getPointMinimum( self.cornerLow, location ) self.oldLocation = location
def linearCorner( self, splitLine ): "Update the bounding corners." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) if self.extruderActive or self.repository.goAroundExtruderOffTravel.value: self.cornerHigh = euclidean.getPointMaximum( self.cornerHigh, location ) self.cornerLow = euclidean.getPointMinimum( self.cornerLow, location ) self.oldLocation = location
def setSVGCarvingCorners(rotatedLoopLayers, svgCarving): "Parse SVG text and store the layers." for rotatedBoundaryLayer in rotatedLoopLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) svgCarving.cornerMaximum = euclidean.getPointMaximum(svgCarving.cornerMaximum, pointVector3) svgCarving.cornerMinimum = euclidean.getPointMinimum(svgCarving.cornerMinimum, pointVector3)
def linearMove( self, splitLine ): "Get statistics for a linear move." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, location ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, location ) if self.extruderActive: if len( self.thread ) == 0: self.thread = [ self.oldLocation.dropAxis(2) ] self.thread.append( location.dropAxis(2) ) self.oldLocation = location
def linearMove( self, splitLine ): "Get statistics for a linear move." location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, location ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, location ) if self.extruderActive: if len( self.thread ) == 0: self.thread = [ self.oldLocation.dropAxis(2) ] self.thread.append( location.dropAxis(2) ) self.oldLocation = location
def setSVGCarvingCorners(rotatedLoopLayers, svgCarving): "Parse SVG text and store the layers." for rotatedBoundaryLayer in rotatedLoopLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) svgCarving.cornerMaximum = euclidean.getPointMaximum( svgCarving.cornerMaximum, pointVector3) svgCarving.cornerMinimum = euclidean.getPointMinimum( svgCarving.cornerMinimum, pointVector3)
def addToPath( self, location ): "Add a point to travel and maybe extrusion." if self.oldLocation != None: travel = location.distance( self.oldLocation ) if self.feedRateMinute > 0.0: self.totalBuildTime += 60.0 * travel / self.feedRateMinute self.totalDistanceTraveled += travel if self.extruderActive: self.totalDistanceExtruded += travel self.cornerHigh = euclidean.getPointMaximum( self.cornerHigh, location ) self.cornerLow = euclidean.getPointMinimum( self.cornerLow, location ) self.oldLocation = location
def parseSVG( self, fileName, svgText ): "Parse SVG text and store the layers." if svgText == '': return self.svgReader.parseSVG( fileName, svgText ) self.parseInitialization() self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, self.maximumZ ) self.cornerMinimum = Vector3( 999999999.0, 999999999.0, self.minimumZ ) for rotatedBoundaryLayer in self.svgReader.rotatedLoopLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3( point.real, point.imag, rotatedBoundaryLayer.z ) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3 ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3 )
def getCarveRotatedBoundaryLayers(self): "Get the rotated boundary layers." self.cornerMaximum = Vector3(-999999999.0, -999999999.0, -999999999.0) self.cornerMinimum = Vector3(999999999.0, 999999999.0, 999999999.0) for point in self.getTransformedVertexes(): self.cornerMaximum = euclidean.getPointMaximum(self.cornerMaximum, point) self.cornerMinimum = euclidean.getPointMinimum(self.cornerMinimum, point) halfHeight = 0.5 * self.layerThickness initializeZoneIntervalTable(self, self.getTransformedVertexes()) layerTop = self.cornerMaximum.z - halfHeight * 0.5 z = self.cornerMinimum.z + halfHeight while z < layerTop: z = self.getZAddExtruderPaths(z) return self.rotatedBoundaryLayers
def getCarveRotatedBoundaryLayers( self ): "Get the rotated boundary layers." self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, - 999999999.0 ) self.cornerMinimum = Vector3( 999999999.0, 999999999.0, 999999999.0 ) for point in self.getVertices(): self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, point ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, point ) halfHeight = 0.5 * self.layerThickness initializeZoneIntervalTable( self, self.getVertices() ) layerTop = self.cornerMaximum.z - halfHeight * 0.5 z = self.cornerMinimum.z + halfHeight while z < layerTop: z = self.getZAddExtruderPaths( z ) return self.rotatedBoundaryLayers
def getCarveRotatedBoundaryLayers( self ): "Get the rotated boundary layers." self.importModule() self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, self.maximumZ ) self.cornerMinimum = Vector3( 999999999.0, 999999999.0, self.minimumZ ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3( point.real, point.imag, rotatedBoundaryLayer.z ) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3 ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3 ) halfLayerThickness = 0.5 * self.layerThickness self.cornerMaximum.z += halfLayerThickness self.cornerMinimum.z -= halfLayerThickness return self.rotatedBoundaryLayers
def getCarveRotatedBoundaryLayers(self): "Get the rotated boundary layers." self.importModule() self.cornerMaximum = Vector3(-999999999.0, -999999999.0, self.maximumZ) self.cornerMinimum = Vector3(999999999.0, 999999999.0, self.minimumZ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3) halfLayerThickness = 0.5 * self.layerThickness self.cornerMaximum.z += halfLayerThickness self.cornerMinimum.z -= halfLayerThickness return self.rotatedBoundaryLayers
def parseSVG( self, fileName, svgText ): "Parse SVG text and store the layers." self.fileName = fileName if svgText == '': return None svgText = svgText.replace( '\t', ' ' ) svgText = svgText.replace( ';', ' ' ) self.lines = gcodec.getTextLines( svgText ) self.parseInitialization() for lineIndex in xrange( self.lineIndex, len( self.lines ) ): self.parseLine( lineIndex ) self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, self.maximumZ ) self.cornerMinimum = Vector3( 999999999.0, 999999999.0, self.minimumZ ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3( point.real, point.imag, rotatedBoundaryLayer.z ) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3 ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3 )
def readFile( self, fileName ): "Read SLC and store the layers." self.fileName = fileName pslcfile = open( fileName, 'rb') readHeader( pslcfile ) pslcfile.read( 256 ) #Go past the 256 byte 3D Reserved Section. self.readTableEntry( pslcfile ) self.processContourLayers( pslcfile ) pslcfile.close() self.cornerMaximum = Vector3( - 999999999.0, - 999999999.0, self.maximumZ ) self.cornerMinimum = Vector3( 999999999.0, 999999999.0, self.minimumZ ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3( point.real, point.imag, rotatedBoundaryLayer.z ) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3 ) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3 ) halfLayerThickness = 0.5 * self.layerThickness self.cornerMaximum.z += halfLayerThickness self.cornerMinimum.z -= halfLayerThickness
def readFile( self, fileName ): "Read SLC and store the layers." self.fileName = fileName pslcfile = open( fileName, 'rb') readHeader( pslcfile ) pslcfile.read( 256 ) #Go past the 256 byte 3D Reserved Section. self.readTableEntry( pslcfile ) self.processContourLayers( pslcfile ) pslcfile.close() self.cornerMaximum = Vector3(-999999999.0, -999999999.0, self.maximumZ) self.cornerMinimum = Vector3(999999999.0, 999999999.0, self.minimumZ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) self.cornerMaximum = euclidean.getPointMaximum(self.cornerMaximum, pointVector3) self.cornerMinimum = euclidean.getPointMinimum(self.cornerMinimum, pointVector3) halfLayerThickness = 0.5 * self.layerThickness self.cornerMaximum.z += halfLayerThickness self.cornerMinimum.z -= halfLayerThickness
def getCarveRotatedBoundaryLayers(self): "Get the rotated boundary layers." if len(self.carvableObjects) < 1: return [] self.cornerMaximum = Vector3(-999999999.0, -999999999.0, -9999999999.9) self.cornerMinimum = Vector3(999999999.0, 999999999.0, 9999999999.9) for carvableObject in self.carvableObjects: self.cornerMaximum.z = max(self.cornerMaximum.z, carvableObject.top) self.cornerMinimum.z = min(self.cornerMinimum.z, carvableObject.bottom) halfHeight = 0.5 * self.layerThickness layerTop = self.cornerMaximum.z - halfHeight self.setActualMinimumZ(halfHeight, layerTop) vertices = [] for carvableObject in self.carvableObjects: vertices += carvableObject.getVertices() triangle_mesh.initializeZoneIntervalTable(self, vertices) z = self.cornerMinimum.z + halfHeight while z < layerTop: z = self.getZAddExtruderPaths(z) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3) self.cornerMaximum.z = layerTop + halfHeight for rotatedBoundaryLayerIndex in xrange( len(self.rotatedBoundaryLayers) - 1, -1, -1): rotatedBoundaryLayer = self.rotatedBoundaryLayers[ rotatedBoundaryLayerIndex] if len(rotatedBoundaryLayer.loops) > 0: return self.rotatedBoundaryLayers[:rotatedBoundaryLayerIndex + 1] return []
def parseSVG(self, fileName, svgText): "Parse SVG text and store the layers." self.fileName = fileName if svgText == '': return None svgText = svgText.replace('\t', ' ') svgText = svgText.replace(';', ' ') self.lines = gcodec.getTextLines(svgText) self.parseInitialization() for lineIndex in xrange(self.lineIndex, len(self.lines)): self.parseLine(lineIndex) self.cornerMaximum = Vector3(-999999999.0, -999999999.0, self.maximumZ) self.cornerMinimum = Vector3(999999999.0, 999999999.0, self.minimumZ) for rotatedBoundaryLayer in self.rotatedBoundaryLayers: for loop in rotatedBoundaryLayer.loops: for point in loop: pointVector3 = Vector3(point.real, point.imag, rotatedBoundaryLayer.z) self.cornerMaximum = euclidean.getPointMaximum( self.cornerMaximum, pointVector3) self.cornerMinimum = euclidean.getPointMinimum( self.cornerMinimum, pointVector3)