def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): 'Get inset geometryOutput.' derivation = InsetDerivation(elementNode, prefix) if derivation.radius == 0.0: return geometryOutput copyShallow = elementNode.getCopyShallow() solid.processElementNodeByGeometry(copyShallow, geometryOutput) targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode) matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix) transformedVertexes = copyShallow.xmlObject.getTransformedVertexes() minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject) maximumZ = euclidean.getTopPath(transformedVertexes) layerThickness = setting.getLayerThickness(elementNode) importRadius = setting.getImportRadius(elementNode) zoneArrangement = triangle_mesh.ZoneArrangement(layerThickness, transformedVertexes) copyShallow.attributes['visible'] = True copyShallowObjects = [copyShallow.xmlObject] bottomLoopLayer = euclidean.LoopLayer(minimumZ) z = minimumZ + 0.1 * layerThickness bottomLoopLayer.loops = boolean_geometry.getEmptyZLoops(copyShallowObjects, importRadius, False, z, zoneArrangement) loopLayers = [bottomLoopLayer] z = minimumZ + layerThickness loopLayers += boolean_geometry.getLoopLayers(copyShallowObjects, importRadius, layerThickness, maximumZ, False, z, zoneArrangement) copyShallow.parentNode.xmlObject.archivableObjects.remove(copyShallow.xmlObject) belowLoop = [] diagonalRadius = math.sqrt(0.5) * derivation.radius insetDiagonalLoops = [] loops = [] vertexes = [] for loopLayer in loopLayers: insetDiagonalLoops.append(intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], diagonalRadius)) for loopLayerIndex, loopLayer in enumerate(loopLayers): vector3Loop = [] insetLoop = intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], derivation.radius) loopLists = [[getLoopOrEmpty(loopLayerIndex - 1, insetDiagonalLoops)], [insetLoop]] largestLoop = euclidean.getLargestLoop(boolean_solid.getLoopsIntersection(importRadius, loopLists)) if evaluate.getEvaluatedBoolean(True, elementNode, prefix + 'insetTop'): loopLists = [[getLoopOrEmpty(loopLayerIndex + 1, insetDiagonalLoops)], [largestLoop]] largestLoop = euclidean.getLargestLoop(boolean_solid.getLoopsIntersection(importRadius, loopLists)) for point in largestLoop: vector3Index = Vector3Index(len(vertexes), point.real, point.imag, loopLayer.z) vector3Loop.append(vector3Index) vertexes.append(vector3Index) if len(vector3Loop) > 0: loops.append(vector3Loop) if evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'addExtraTopLayer') and len(loops) > 0: topLoop = loops[-1] vector3Loop = [] loops.append(vector3Loop) z = topLoop[0].z + layerThickness for point in topLoop: vector3Index = Vector3Index(len(vertexes), point.x, point.y, z) vector3Loop.append(vector3Index) vertexes.append(vector3Index) geometryOutput = triangle_mesh.getMeldedPillarOutput(loops) return geometryOutput
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): 'Get inset geometryOutput.' derivation = InsetDerivation(elementNode, prefix) if derivation.radius == 0.0: return geometryOutput halfLayerHeight = 0.5 * derivation.radius importRadius = 0.5 * derivation.radius * setting.getImportCoarseness(elementNode) loopLayers = solid.getLoopLayersSetCopy(elementNode, geometryOutput, importRadius, derivation.radius) triangleAltitude = math.sqrt(0.75) * derivation.radius loops = [] vertexes = [] for loopLayerIndex in xrange(1, len(loopLayers), 2): loopLayer = loopLayers[loopLayerIndex] loopLayer.loops[0] = intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], triangleAltitude) for loopLayerIndex in xrange(0, len(loopLayers), 2): loopLayer = loopLayers[loopLayerIndex] loopLists = [[solid.getLoopOrEmpty(loopLayerIndex - 2, loopLayers)]] loopLists.append([solid.getLoopOrEmpty(loopLayerIndex - 1, loopLayers)]) loopLists.append([intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], derivation.radius)]) if evaluate.getEvaluatedBoolean(True, elementNode, prefix + 'insetTop'): loopLists.append([solid.getLoopOrEmpty(loopLayerIndex + 1, loopLayers)]) loopLists.append([solid.getLoopOrEmpty(loopLayerIndex + 2, loopLayers)]) largestLoop = euclidean.getLargestLoop(boolean_solid.getLoopsIntersection(importRadius, loopLists)) triangle_mesh.addVector3Loop(largestLoop, loops, vertexes, loopLayer.z) if evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'addExtraTopLayer') and len(loops) > 0: topLoop = loops[-1] vector3Loop = [] loops.append(vector3Loop) z = topLoop[0].z + derivation.radius for point in topLoop: vector3Index = Vector3Index(len(vertexes), point.x, point.y, z) vector3Loop.append(vector3Index) vertexes.append(vector3Index) return triangle_mesh.getMeldedPillarOutput(loops)
def addCoolOrbits(self, remainingOrbitTime): 'Add the minimum radius cool orbits.' if len(self.boundaryLayer.loops) < 1: return insetBoundaryLoops = self.boundaryLayer.loops if abs(self.repository.orbitalOutset.value) > 0.1 * abs(self.edgeWidth): insetBoundaryLoops = intercircle.getInsetLoopsFromLoops(self.boundaryLayer.loops, -self.repository.orbitalOutset.value) if len(insetBoundaryLoops) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop(insetBoundaryLoops) loopArea = euclidean.getAreaLoopAbsolute(largestLoop) if loopArea < self.minimumArea: center = 0.5 * (euclidean.getMaximumByComplexPath(largestLoop) + euclidean.getMinimumByComplexPath(largestLoop)) centerXBounded = max(center.real, self.boundingRectangle.cornerMinimum.real) centerXBounded = min(centerXBounded, self.boundingRectangle.cornerMaximum.real) centerYBounded = max(center.imag, self.boundingRectangle.cornerMinimum.imag) centerYBounded = min(centerYBounded, self.boundingRectangle.cornerMaximum.imag) center = complex(centerXBounded, centerYBounded) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoopWiddershins(minimumCorner, maximumCorner) pointComplex = euclidean.getXYComplexFromVector3(self.oldLocation) if pointComplex != None: largestLoop = euclidean.getLoopStartingClosest(self.edgeWidth, pointComplex, largestLoop) intercircle.addOrbitsIfLarge( self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ)
def addCoolOrbits(self, remainingOrbitTime): 'Add the minimum radius cool orbits.' if len(self.boundaryLayer.loops) < 1: return insetBoundaryLoops = intercircle.getInsetLoopsFromLoops( self.perimeterWidth, self.boundaryLayer.loops) if len(insetBoundaryLoops) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop(insetBoundaryLoops) loopArea = euclidean.getAreaLoopAbsolute(largestLoop) if loopArea < self.minimumArea: center = 0.5 * (euclidean.getMaximumByComplexPath(largestLoop) + euclidean.getMinimumByComplexPath(largestLoop)) centerXBounded = max(center.real, self.boundingRectangle.cornerMinimum.real) centerXBounded = min(centerXBounded, self.boundingRectangle.cornerMaximum.real) centerYBounded = max(center.imag, self.boundingRectangle.cornerMinimum.imag) centerYBounded = min(centerYBounded, self.boundingRectangle.cornerMaximum.imag) center = complex(centerXBounded, centerYBounded) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoopWiddershins( minimumCorner, maximumCorner) pointComplex = euclidean.getXYComplexFromVector3(self.oldLocation) if pointComplex != None: largestLoop = euclidean.getLoopStartingNearest( self.perimeterWidth, pointComplex, largestLoop) intercircle.addOrbitsIfLarge(self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ)
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): 'Get outset geometryOutput.' derivation = OutsetDerivation(elementNode, prefix) if derivation.radius == 0.0: return geometryOutput halfLayerHeight = 0.5 * derivation.radius importRadius = 0.5 * derivation.radius * setting.getImportCoarseness(elementNode) loopLayers = solid.getLoopLayersSetCopy(elementNode, geometryOutput, importRadius, derivation.radius) if len(loopLayers) == 0: return triangle_mesh.getMeldedPillarOutput([]) triangleAltitude = math.sqrt(0.75) * derivation.radius loops = [] vertexes = [] for loopLayerIndex in xrange(1, len(loopLayers), 2): loopLayer = loopLayers[loopLayerIndex] loopLayer.loops[0] = intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], triangleAltitude) z = loopLayers[0].z - derivation.radius for loopIndex in xrange(-2, len(loopLayers) + 2, 2): loopLists = [[solid.getLoopOrEmpty(loopIndex - 2, loopLayers)]] loopLists.append([solid.getLoopOrEmpty(loopIndex - 1, loopLayers)]) loopLists.append([intercircle.getLargestInsetLoopFromLoop(solid.getLoopOrEmpty(loopIndex, loopLayers), -derivation.radius)]) loopLists.append([solid.getLoopOrEmpty(loopIndex + 1, loopLayers)]) loopLists.append([solid.getLoopOrEmpty(loopIndex + 2, loopLayers)]) largestLoop = euclidean.getLargestLoop(boolean_solid.getLoopsUnion(importRadius, loopLists)) triangle_mesh.addVector3Loop(largestLoop, loops, vertexes, z) z += derivation.radius return triangle_mesh.getMeldedPillarOutput(loops)
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): 'Get outset geometryOutput.' derivation = OutsetDerivation(elementNode, prefix) if derivation.radius == 0.0: return geometryOutput halfLayerHeight = 0.5 * derivation.radius importRadius = 0.5 * derivation.radius * setting.getImportCoarseness( elementNode) loopLayers = solid.getLoopLayersSetCopy(elementNode, geometryOutput, importRadius, derivation.radius) if len(loopLayers) == 0: return triangle_mesh.getMeldedPillarOutput([]) triangleAltitude = math.sqrt(0.75) * derivation.radius loops = [] vertexes = [] for loopLayerIndex in xrange(1, len(loopLayers), 2): loopLayer = loopLayers[loopLayerIndex] loopLayer.loops[0] = intercircle.getLargestInsetLoopFromLoop( loopLayer.loops[0], triangleAltitude) z = loopLayers[0].z - derivation.radius for loopIndex in xrange(-2, len(loopLayers) + 2, 2): loopLists = [[solid.getLoopOrEmpty(loopIndex - 2, loopLayers)]] loopLists.append([solid.getLoopOrEmpty(loopIndex - 1, loopLayers)]) loopLists.append([ intercircle.getLargestInsetLoopFromLoop( solid.getLoopOrEmpty(loopIndex, loopLayers), -derivation.radius) ]) loopLists.append([solid.getLoopOrEmpty(loopIndex + 1, loopLayers)]) loopLists.append([solid.getLoopOrEmpty(loopIndex + 2, loopLayers)]) largestLoop = euclidean.getLargestLoop( boolean_solid.getLoopsUnion(importRadius, loopLists)) triangle_mesh.addVector3Loop(largestLoop, loops, vertexes, z) z += derivation.radius return triangle_mesh.getMeldedPillarOutput(loops)
def cool(self, layer): '''Apply the cooling by moving the nozzle around the print.''' if layer.index == 0: # We don't have to slow down on the first layer return (layerDistance, layerDuration) = layer.getDistanceAndDuration() remainingOrbitTime = max(self.minimumLayerTime - layerDuration, 0.0) boundaryLayerLoops = [] for nestedRing in layer.nestedRings: boundaryLayerLoops.append(nestedRing.getXYBoundaries()) if remainingOrbitTime > 0.0 and boundaryLayerLoops != None: if len(boundaryLayerLoops) < 1: return largestLoop = euclidean.getLargestLoop(boundaryLayerLoops) cornerMinimum = euclidean.getMinimumByComplexPath(largestLoop) - self.oribitalMargin cornerMaximum = euclidean.getMaximumByComplexPath(largestLoop) + self.oribitalMargin largestLoop = euclidean.getSquareLoopWiddershins(cornerMaximum, cornerMinimum) if len(largestLoop) > 1 and remainingOrbitTime > 1.5 : timeInOrbit = 0.0 while timeInOrbit < remainingOrbitTime: for point in largestLoop: gcodeArgs = [('X', round(point.real, self.decimalPlaces)), ('Y', round(point.imag, self.decimalPlaces)), ('Z', round(layer.z, self.decimalPlaces)), ('F', round(self.orbitalFeedRateMinute, self.decimalPlaces))] layer.preLayerGcodeCommands.append(GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT, gcodeArgs)) timeInOrbit += euclidean.getLoopLength(largestLoop) / self.orbitalFeedRateSecond
def getWidenedLoop(loop, loopList, outsetLoop, radius): 'Get the widened loop.' intersectingWithinLoops = getIntersectingWithinLoops(loop, loopList, outsetLoop) if len(intersectingWithinLoops) < 1: return loop loopsUnified = boolean_solid.getLoopsUnified(radius, [[loop], intersectingWithinLoops]) if len(loopsUnified) < 1: return loop return euclidean.getLargestLoop(loopsUnified)
def getWidenedLoop( loop, loopList, outsetLoop, radius ): "Get the widened loop." intersectingWithinLoops = getIntersectingWithinLoops( loop, loopList, outsetLoop ) if len( intersectingWithinLoops ) < 1: return loop loopsUnified = booleansolid.getLoopsUnified( radius, [ [loop], intersectingWithinLoops ] ) if len( loopsUnified ) < 1: return loop return euclidean.getLargestLoop( loopsUnified )
def addCoolOrbits( self, remainingOrbitTime ): "Add the minimum radius cool orbits." if len( self.boundaryLayer.loops ) < 1: return insetBoundaryLoops = intercircle.getInsetLoopsFromLoops( self.perimeterWidth, self.boundaryLayer.loops ) if len( insetBoundaryLoops ) < 1: insetBoundaryLoops = self.boundaryLayer.loops largestLoop = euclidean.getLargestLoop( insetBoundaryLoops ) loopArea = abs( euclidean.getPolygonArea( largestLoop ) ) if loopArea < self.minimumArea: center = 0.5 * ( euclidean.getMaximumFromPoints( largestLoop ) + euclidean.getMinimumFromPoints( largestLoop ) ) centerXBounded = max( center.real, self.boundingRectangle.cornerMinimum.real ) centerXBounded = min( centerXBounded, self.boundingRectangle.cornerMaximum.real ) centerYBounded = max( center.imag, self.boundingRectangle.cornerMinimum.imag ) centerYBounded = min( centerYBounded, self.boundingRectangle.cornerMaximum.imag ) center = complex( centerXBounded, centerYBounded ) maximumCorner = center + self.halfCorner minimumCorner = center - self.halfCorner largestLoop = euclidean.getSquareLoop( minimumCorner, maximumCorner ) pointComplex = euclidean.getXYComplexFromVector3( self.oldLocation ) if pointComplex != None: largestLoop = euclidean.getLoopStartingNearest( self.perimeterWidth, pointComplex, largestLoop ) intercircle.addOrbitsIfLarge( self.distanceFeedRate, largestLoop, self.orbitalFeedRatePerSecond, remainingOrbitTime, self.highestZ )
def getLargestInsetLoopFromLoop(loop, radius): "Get the largest inset loop from the loop." loops = getInsetLoopsFromLoop(radius, loop) return euclidean.getLargestLoop(loops)
def getLargestInsetLoopFromLoop(loop, radius): 'Get the largest inset loop from the loop.' loops = getInsetLoopsFromLoop(loop, radius) return euclidean.getLargestLoop(loops)
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): 'Get inset geometryOutput.' derivation = InsetDerivation(elementNode, prefix) if derivation.radius == 0.0: return geometryOutput copyShallow = elementNode.getCopyShallow() solid.processElementNodeByGeometry(copyShallow, geometryOutput) targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode) matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix) transformedVertexes = copyShallow.xmlObject.getTransformedVertexes() minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject) maximumZ = euclidean.getTopPath(transformedVertexes) layerThickness = setting.getLayerThickness(elementNode) importRadius = setting.getImportRadius(elementNode) zoneArrangement = triangle_mesh.ZoneArrangement(layerThickness, transformedVertexes) copyShallow.attributes['visible'] = True copyShallowObjects = [copyShallow.xmlObject] bottomLoopLayer = euclidean.LoopLayer(minimumZ) z = minimumZ + 0.1 * layerThickness bottomLoopLayer.loops = boolean_geometry.getEmptyZLoops( copyShallowObjects, importRadius, False, z, zoneArrangement) loopLayers = [bottomLoopLayer] z = minimumZ + layerThickness loopLayers += boolean_geometry.getLoopLayers(copyShallowObjects, importRadius, layerThickness, maximumZ, False, z, zoneArrangement) copyShallow.parentNode.xmlObject.archivableObjects.remove( copyShallow.xmlObject) belowLoop = [] diagonalRadius = math.sqrt(0.5) * derivation.radius insetDiagonalLoops = [] loops = [] vertexes = [] for loopLayer in loopLayers: insetDiagonalLoops.append( intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], diagonalRadius)) for loopLayerIndex, loopLayer in enumerate(loopLayers): vector3Loop = [] insetLoop = intercircle.getLargestInsetLoopFromLoop( loopLayer.loops[0], derivation.radius) loopLists = [[getLoopOrEmpty(loopLayerIndex - 1, insetDiagonalLoops)], [insetLoop]] largestLoop = euclidean.getLargestLoop( boolean_solid.getLoopsIntersection(importRadius, loopLists)) if evaluate.getEvaluatedBoolean(True, elementNode, prefix + 'insetTop'): loopLists = [[ getLoopOrEmpty(loopLayerIndex + 1, insetDiagonalLoops) ], [largestLoop]] largestLoop = euclidean.getLargestLoop( boolean_solid.getLoopsIntersection(importRadius, loopLists)) for point in largestLoop: vector3Index = Vector3Index(len(vertexes), point.real, point.imag, loopLayer.z) vector3Loop.append(vector3Index) vertexes.append(vector3Index) if len(vector3Loop) > 0: loops.append(vector3Loop) if evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'addExtraTopLayer') and len(loops) > 0: topLoop = loops[-1] vector3Loop = [] loops.append(vector3Loop) z = topLoop[0].z + layerThickness for point in topLoop: vector3Index = Vector3Index(len(vertexes), point.x, point.y, z) vector3Loop.append(vector3Index) vertexes.append(vector3Index) geometryOutput = triangle_mesh.getMeldedPillarOutput(loops) return geometryOutput