def getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attribute dictionary." if derivation is None: derivation = SpongeSliceDerivation(elementNode) awayPoints = [] vector3Path = euclidean.getVector3Path(euclidean.getSquareLoopWiddershins(-derivation.inradius, derivation.inradius)) geometryOutput = lineation.SideLoop(vector3Path).getManipulationPluginLoops(elementNode) minimumDistanceFromOther = derivation.wallThickness + derivation.minimumRadius + derivation.minimumRadius if derivation.inradiusMinusRadiusThickness.real <= 0.0 or derivation.inradiusMinusRadiusThickness.imag <= 0.0: return geometryOutput for point in derivation.path: if abs(point.x) <= derivation.inradiusMinusRadiusThickness.real and abs(point.y) <= derivation.inradiusMinusRadiusThickness.imag: awayPoints.append(point) awayCircles = [] for point in awayPoints: if getIsPointAway(minimumDistanceFromOther, point, awayCircles): awayCircles.append(SpongeCircle(point, derivation.minimumRadius)) averagePotentialBubbleArea = derivation.potentialBubbleArea / float(len(awayCircles)) averageBubbleRadius = math.sqrt(averagePotentialBubbleArea / math.pi) - 0.5 * derivation.wallThickness sides = -4 * (max(evaluate.getSidesBasedOnPrecision(elementNode, averageBubbleRadius), 4) / 4) sideAngle = math.pi / sides cosSide = math.cos(sideAngle) overlapArealRatio = (1 - cosSide) / cosSide for circleIndex, circle in enumerate(awayCircles): otherCircles = awayCircles[: circleIndex] + awayCircles[circleIndex + 1 :] circle.radius = circle.getRadius(circle.center, derivation, otherCircles, overlapArealRatio) if derivation.searchAttempts > 0: for circleIndex, circle in enumerate(awayCircles): otherCircles = awayCircles[: circleIndex] + awayCircles[circleIndex + 1 :] circle.moveCircle(derivation, otherCircles, overlapArealRatio) for circle in awayCircles: vector3Path = euclidean.getVector3Path(euclidean.getComplexPolygon(circle.center.dropAxis(), circle.radius, sides, sideAngle)) geometryOutput += lineation.SideLoop(vector3Path).getManipulationPluginLoops(elementNode) return geometryOutput
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." gearDerivation = GearDerivation() gearDerivation.setToXMLElement(xmlElement) creationFirst = gearDerivation.creationType.lower()[: 1] pitchRadiusSecond = gearDerivation.pitchRadius * float(gearDerivation.teethSecond) / float(gearDerivation.teethPinion) toothProfileFirst = getToothProfileCylinder(gearDerivation, gearDerivation.pitchRadius, gearDerivation.teethPinion) toothProfileSecond = getToothProfile(gearDerivation, pitchRadiusSecond, gearDerivation.teethSecond) gearProfileFirst = getGearProfileCylinder(gearDerivation.teethPinion, toothProfileFirst) gearProfileSecond = getGearProfile(gearDerivation, gearDerivation.teethSecond, toothProfileSecond) vector3GearProfileFirst = euclidean.getVector3Path(gearProfileFirst) vector3GearProfileSecond = euclidean.getVector3Path(gearProfileSecond) translation = Vector3() moveFirst = gearDerivation.moveType.lower()[: 1] if moveFirst != 'n': distance = gearDerivation.pitchRadius + pitchRadiusSecond if moveFirst != 'm': decimalPlaces = 1 - int(math.floor(math.log10(distance))) distance += gearDerivation.halfWavelength + gearDerivation.halfWavelength distance = round(1.15 * distance, decimalPlaces) translation = Vector3(0.0, -distance) if gearDerivation.thickness <=0.0: return getPathOutput( creationFirst, gearDerivation, translation, vector3GearProfileFirst, vector3GearProfileSecond, xmlElement) shaftRimRadius = gearDerivation.shaftRadius + gearDerivation.collarWidth vector3ShaftPath = getShaftPath(gearDerivation) pitchRadius = gearDerivation.pitchRadius teeth = gearDerivation.teethPinion twist = gearDerivation.helixThickness / gearDerivation.pitchRadius extrudeOutputFirst = getOutputCylinder( gearDerivation, pitchRadius, shaftRimRadius, teeth, twist, vector3GearProfileFirst, vector3ShaftPath, xmlElement) if creationFirst == 'f': return extrudeOutputFirst pitchRadius = pitchRadiusSecond teeth = gearDerivation.teethSecond extrudeOutputSecond = None if teeth == 0: extrudeOutputSecond = getOutputRack(gearDerivation, vector3GearProfileSecond, xmlElement) else: twist = -gearDerivation.helixThickness / pitchRadiusSecond extrudeOutputSecond = getOutputCylinder( gearDerivation, pitchRadius, shaftRimRadius, teeth, twist, vector3GearProfileSecond, vector3ShaftPath, xmlElement) if creationFirst == 's': return extrudeOutputSecond if moveFirst == 'v': connectionVertexes = matrix.getConnectionVertexes(extrudeOutputSecond) translation = Vector3(0.0, 0.0, euclidean.getTop(connectionVertexes)) euclidean.translateVector3Path(matrix.getConnectionVertexes(extrudeOutputFirst), translation) else: euclidean.translateVector3Path(matrix.getConnectionVertexes(extrudeOutputSecond), translation) return {'group' : {'shapes' : [extrudeOutputFirst, extrudeOutputSecond]}}
def getGeometryOutput(elementNode): 'Get vector3 vertexes from attribute dictionary.' derivation = GridDerivation(elementNode) diameter = derivation.radius + derivation.radius typeStringTwoCharacters = derivation.typeString.lower()[:2] typeStringFirstCharacter = typeStringTwoCharacters[:1] topRight = derivation.inradius loopsComplex = [euclidean.getSquareLoopWiddershins(-topRight, topRight)] if len(derivation.target) > 0: loopsComplex = euclidean.getComplexPaths(derivation.target) maximumComplex = euclidean.getMaximumByComplexPaths(loopsComplex) minimumComplex = euclidean.getMinimumByComplexPaths(loopsComplex) gridPath = None if typeStringTwoCharacters == 'he': gridPath = getHexagonalGrid(diameter, loopsComplex, maximumComplex, minimumComplex, derivation.zigzag) elif typeStringTwoCharacters == 'ra' or typeStringFirstCharacter == 'a': gridPath = getRandomGrid(derivation, diameter, elementNode, loopsComplex, maximumComplex, minimumComplex) elif typeStringTwoCharacters == 're' or typeStringFirstCharacter == 'e': gridPath = getRectangularGrid(diameter, loopsComplex, maximumComplex, minimumComplex, derivation.zigzag) if gridPath == None: print( 'Warning, the step type was not one of (hexagonal, random or rectangular) in getGeometryOutput in grid for:' ) print(derivation.typeString) print(elementNode) return [] loop = euclidean.getVector3Path(gridPath) elementNode.attributes['closed'] = 'false' return lineation.getGeometryOutputByLoop( elementNode, lineation.SideLoop(loop, 0.5 * math.pi))
def getShaftPath(depthBottom, depthTop, radius, sides): 'Get shaft with the option of a flat on the top and/or bottom.' if radius <= 0.0: return [] sideAngle = 2.0 * math.pi / float(abs(sides)) startAngle = 0.5 * sideAngle endAngle = math.pi - 0.1 * sideAngle shaftProfile = [] while startAngle < endAngle: unitPolar = euclidean.getWiddershinsUnitPolar(startAngle) shaftProfile.append(unitPolar * radius) startAngle += sideAngle if abs(sides) % 2 == 1: shaftProfile.append(complex(-radius, 0.0)) horizontalBegin = radius - depthTop horizontalEnd = depthBottom - radius shaftProfile = euclidean.getHorizontallyBoundedPath( horizontalBegin, horizontalEnd, shaftProfile) for shaftPointIndex, shaftPoint in enumerate(shaftProfile): shaftProfile[shaftPointIndex] = complex(shaftPoint.imag, shaftPoint.real) shaftPath = euclidean.getVector3Path(euclidean.getMirrorPath(shaftProfile)) if sides > 0: shaftPath.reverse() return shaftPath
def getGeometryOutput(derivation, xmlElement): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = GridDerivation() derivation.setToXMLElement(xmlElement) diameter = derivation.radius + derivation.radius typeStringTwoCharacters = derivation.typeString.lower()[: 2] typeStringFirstCharacter = typeStringTwoCharacters[: 1] topRight = complex(derivation.demiwidth, derivation.demiheight) bottomLeft = -topRight loopsComplex = [euclidean.getSquareLoopWiddershins(bottomLeft, topRight)] if len(derivation.target) > 0: loopsComplex = euclidean.getComplexPaths(derivation.target) maximumComplex = euclidean.getMaximumByPathsComplex(loopsComplex) minimumComplex = euclidean.getMinimumByPathsComplex(loopsComplex) gridPath = None if typeStringTwoCharacters == 'he': gridPath = getHexagonalGrid(diameter, loopsComplex, maximumComplex, minimumComplex, derivation.zigzag) elif typeStringTwoCharacters == 'ra' or typeStringFirstCharacter == 'a': gridPath = getRandomGrid(derivation, diameter, loopsComplex, maximumComplex, minimumComplex, xmlElement) elif typeStringTwoCharacters == 're' or typeStringFirstCharacter == 'e': gridPath = getRectangularGrid(diameter, loopsComplex, maximumComplex, minimumComplex, derivation.zigzag) if gridPath == None: print('Warning, the step type was not one of (hexagonal, random or rectangular) in getGeometryOutput in grid for:') print(derivation.typeString) print(xmlElement) return [] loop = euclidean.getVector3Path(gridPath) xmlElement.attributeDictionary['closed'] = 'false' return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def getTeardropPath(inclination, radius, xmlElement): "Get vector3 teardrop path." teardropSides = evaluate.getSidesMinimumThreeBasedOnPrecision(radius, xmlElement) sideAngle = 2.0 * math.pi / float(teardropSides) overhangAngle = evaluate.getOverhangSupportAngle(xmlElement) overhangPlaneAngle = euclidean.getWiddershinsUnitPolar(overhangAngle) overhangAngle = math.atan2(overhangPlaneAngle.imag, overhangPlaneAngle.real * math.cos(inclination)) tanOverhangAngle = math.tan(overhangAngle) beginAngle = overhangAngle beginMinusEndAngle = math.pi + overhangAngle + overhangAngle withinSides = int(math.ceil(beginMinusEndAngle / sideAngle)) withinSideAngle = -beginMinusEndAngle / float(withinSides) teardropPath = [] for side in xrange(withinSides + 1): unitPolar = euclidean.getWiddershinsUnitPolar(beginAngle) teardropPath.append(unitPolar * radius) beginAngle += withinSideAngle firstPoint = teardropPath[0] overhangSpan = evaluate.getOverhangSpan(xmlElement) if overhangSpan <= 0.0: teardropPath.append(complex(0.0, firstPoint.imag + firstPoint.real / tanOverhangAngle)) else: deltaX = (radius - firstPoint.imag) * tanOverhangAngle overhangPoint = complex(firstPoint.real - deltaX, radius) remainingDeltaX = max(0.0, overhangPoint.real - 0.5 * overhangSpan ) overhangPoint += complex(-remainingDeltaX, remainingDeltaX / tanOverhangAngle) teardropPath.append(complex(-overhangPoint.real, overhangPoint.imag)) teardropPath.append(overhangPoint) return euclidean.getVector3Path(teardropPath)
def getTeardropPath(inclination, overhangRadians, overhangSpan, radiusArealized, sides): "Get vector3 teardrop path." sideAngle = 2.0 * math.pi / float(sides) overhangPlaneAngle = euclidean.getWiddershinsUnitPolar(overhangRadians) overhangRadians = math.atan2( overhangPlaneAngle.imag, overhangPlaneAngle.real * math.cos(inclination)) tanOverhangAngle = math.tan(overhangRadians) beginAngle = overhangRadians beginMinusEndAngle = math.pi + overhangRadians + overhangRadians withinSides = int(math.ceil(beginMinusEndAngle / sideAngle)) withinSideAngle = -beginMinusEndAngle / float(withinSides) teardropPath = [] for side in xrange(withinSides + 1): unitPolar = euclidean.getWiddershinsUnitPolar(beginAngle) teardropPath.append(unitPolar * radiusArealized) beginAngle += withinSideAngle firstPoint = teardropPath[0] if overhangSpan <= 0.0: teardropPath.append( complex(0.0, firstPoint.imag + firstPoint.real / tanOverhangAngle)) else: deltaX = (radiusArealized - firstPoint.imag) * tanOverhangAngle overhangPoint = complex(firstPoint.real - deltaX, radiusArealized) remainingDeltaX = max(0.0, overhangPoint.real - 0.5 * overhangSpan) overhangPoint += complex(-remainingDeltaX, remainingDeltaX / tanOverhangAngle) teardropPath.append(complex(-overhangPoint.real, overhangPoint.imag)) teardropPath.append(overhangPoint) return euclidean.getVector3Path(teardropPath)
def getTeardropPath(inclination, overhangRadians, overhangSpan, radiusArealized, sides): "Get vector3 teardrop path." sideAngle = 2.0 * math.pi / float(sides) overhangPlaneAngle = euclidean.getWiddershinsUnitPolar(overhangRadians) overhangRadians = math.atan2(overhangPlaneAngle.imag, overhangPlaneAngle.real * math.cos(inclination)) tanOverhangAngle = math.tan(overhangRadians) beginAngle = overhangRadians beginMinusEndAngle = math.pi + overhangRadians + overhangRadians withinSides = int(math.ceil(beginMinusEndAngle / sideAngle)) withinSideAngle = -beginMinusEndAngle / float(withinSides) teardropPath = [] for side in xrange(withinSides + 1): unitPolar = euclidean.getWiddershinsUnitPolar(beginAngle) teardropPath.append(unitPolar * radiusArealized) beginAngle += withinSideAngle firstPoint = teardropPath[0] if overhangSpan <= 0.0: teardropPath.append(complex(0.0, firstPoint.imag + firstPoint.real / tanOverhangAngle)) else: deltaX = (radiusArealized - firstPoint.imag) * tanOverhangAngle overhangPoint = complex(firstPoint.real - deltaX, radiusArealized) remainingDeltaX = max(0.0, overhangPoint.real - 0.5 * overhangSpan ) overhangPoint += complex(-remainingDeltaX, remainingDeltaX / tanOverhangAngle) teardropPath.append(complex(-overhangPoint.real, overhangPoint.imag)) teardropPath.append(overhangPoint) return euclidean.getVector3Path(teardropPath)
def getGeometryOutput(elementNode): 'Get vector3 vertexes from attribute dictionary.' derivation = GridDerivation(elementNode) diameter = derivation.radius + derivation.radius typeStringTwoCharacters = derivation.typeString.lower()[: 2] typeStringFirstCharacter = typeStringTwoCharacters[: 1] topRight = complex(derivation.demiwidth, derivation.demiheight) loopsComplex = [euclidean.getSquareLoopWiddershins(-topRight, topRight)] if len(derivation.target) > 0: loopsComplex = euclidean.getComplexPaths(derivation.target) maximumComplex = euclidean.getMaximumByComplexPaths(loopsComplex) minimumComplex = euclidean.getMinimumByComplexPaths(loopsComplex) gridPath = None if typeStringTwoCharacters == 'he': gridPath = getHexagonalGrid(diameter, loopsComplex, maximumComplex, minimumComplex, derivation.zigzag) elif typeStringTwoCharacters == 'ra' or typeStringFirstCharacter == 'a': gridPath = getRandomGrid(derivation, diameter, elementNode, loopsComplex, maximumComplex, minimumComplex) elif typeStringTwoCharacters == 're' or typeStringFirstCharacter == 'e': gridPath = getRectangularGrid(diameter, loopsComplex, maximumComplex, minimumComplex, derivation.zigzag) if gridPath == None: print('Warning, the step type was not one of (hexagonal, random or rectangular) in getGeometryOutput in grid for:') print(derivation.typeString) print(elementNode) return [] loop = euclidean.getVector3Path(gridPath) elementNode.attributes['closed'] = 'false' return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(loop, 0.5 * math.pi))
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." fontFamily = evaluate.getEvaluatedStringDefault('Gentium Basic Regular', 'font-family', xmlElement) fontFamily = evaluate.getEvaluatedStringDefault(fontFamily, 'fontFamily', xmlElement) fontSize = evaluate.getEvaluatedFloatDefault(12.0, 'font-size', xmlElement) fontSize = evaluate.getEvaluatedFloatDefault(fontSize, 'fontSize', xmlElement) textString = evaluate.getEvaluatedStringDefault(xmlElement.text, 'text', xmlElement) if textString == '': print('Warning, textString is empty in getGeometryOutput in text for:') print(xmlElement) return [] geometryOutput = [] for textComplexLoop in svg_reader.getTextComplexLoops( fontFamily, fontSize, textString): textComplexLoop.reverse() vector3Path = euclidean.getVector3Path(textComplexLoop) sideLoop = lineation.SideLoop(vector3Path, None, None) sideLoop.rotate(xmlElement) geometryOutput += lineation.getGeometryOutputByManipulation( sideLoop, xmlElement) return geometryOutput
def getTeardropPath(inclination, radius, xmlElement): "Get vector3 teardrop path." teardropSides = evaluate.getSidesMinimumThreeBasedOnPrecision( radius, xmlElement) sideAngle = 2.0 * math.pi / float(teardropSides) overhangAngle = evaluate.getOverhangSupportAngle(xmlElement) overhangPlaneAngle = euclidean.getWiddershinsUnitPolar(overhangAngle) overhangAngle = math.atan2(overhangPlaneAngle.imag, overhangPlaneAngle.real * math.cos(inclination)) tanOverhangAngle = math.tan(overhangAngle) beginAngle = overhangAngle beginMinusEndAngle = math.pi + overhangAngle + overhangAngle withinSides = int(math.ceil(beginMinusEndAngle / sideAngle)) withinSideAngle = -beginMinusEndAngle / float(withinSides) teardropPath = [] for side in xrange(withinSides + 1): unitPolar = euclidean.getWiddershinsUnitPolar(beginAngle) teardropPath.append(unitPolar * radius) beginAngle += withinSideAngle firstPoint = teardropPath[0] overhangSpan = evaluate.getOverhangSpan(xmlElement) if overhangSpan <= 0.0: teardropPath.append( complex(0.0, firstPoint.imag + firstPoint.real / tanOverhangAngle)) else: deltaX = (radius - firstPoint.imag) * tanOverhangAngle overhangPoint = complex(firstPoint.real - deltaX, radius) remainingDeltaX = max(0.0, overhangPoint.real - 0.5 * overhangSpan) overhangPoint += complex(-remainingDeltaX, remainingDeltaX / tanOverhangAngle) teardropPath.append(complex(-overhangPoint.real, overhangPoint.imag)) teardropPath.append(overhangPoint) return euclidean.getVector3Path(teardropPath)
def addSlab(derivation, positives): 'Add slab.' copyShallow = derivation.xmlElement.getCopyShallow() copyShallow.attributeDictionary['path'] = [Vector3(), Vector3(0.0, 0.0, derivation.height)] extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) beveledRectangle = getBeveledRectangle(derivation.bevel, -derivation.topRight) outsidePath = euclidean.getVector3Path(beveledRectangle) extrude.addPositives(extrudeDerivation, [outsidePath], positives)
def addSlab(derivation, positives): """Add slab.""" copyShallow = derivation.xmlElement.getCopyShallow() copyShallow.attributeDictionary['path'] = [Vector3(), Vector3(0.0, 0.0, derivation.height)] extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) beveledRectangle = getBeveledRectangle(derivation.bevel, -derivation.topRight) outsidePath = euclidean.getVector3Path(beveledRectangle) extrude.addPositives(extrudeDerivation, [outsidePath], positives)
def getGeometryOutputBySVGReader(svgReader, xmlElement): "Get vector3 vertexes from svgReader." geometryOutput = [] for rotatedLoopLayer in svgReader.rotatedLoopLayers: for loop in rotatedLoopLayer.loops: vector3Path = euclidean.getVector3Path(loop, rotatedLoopLayer.z) sideLoop = lineation.SideLoop(vector3Path, None, None) sideLoop.rotate(xmlElement) geometryOutput += lineation.getGeometryOutputByManipulation(sideLoop, xmlElement) return geometryOutput
def addCage(derivation, height, negatives, positives): 'Add linear bearing cage.' copyShallow = derivation.elementNode.getCopyShallow() copyShallow.attributes['path'] = [Vector3(), Vector3(0.0, 0.0, height)] extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) roundedExtendedRectangle = getRoundedExtendedRectangle(derivation.demiwidth, derivation.rectangleCenterX, 14) outsidePath = euclidean.getVector3Path(roundedExtendedRectangle) extrude.addPositives(extrudeDerivation, [outsidePath], positives) for bearingCenterX in derivation.bearingCenterXs: addNegativeSphere(derivation, negatives, bearingCenterX)
def addCage(derivation, height, negatives, positives): 'Add linear bearing cage.' copyShallow = derivation.xmlElement.getCopyShallow() copyShallow.attributeDictionary['path'] = [Vector3(), Vector3(0.0, 0.0, height)] extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) roundedExtendedRectangle = getRoundedExtendedRectangle(derivation.demiwidth, derivation.rectangleCenterX, 14) outsidePath = euclidean.getVector3Path(roundedExtendedRectangle) extrude.addPositives(extrudeDerivation, positives, [outsidePath]) for bearingCenterX in derivation.bearingCenterXs: addNegativeSphere(derivation, negatives, bearingCenterX)
def getGeometryOutputBySVGReader(elementNode, svgReader): "Get vector3 vertexes from svgReader." geometryOutput = [] for loopLayer in svgReader.loopLayers: for loop in loopLayer.loops: vector3Path = euclidean.getVector3Path(loop, loopLayer.z) sideLoop = lineation.SideLoop(vector3Path) sideLoop.rotate(elementNode) geometryOutput += lineation.getGeometryOutputByManipulation(elementNode, sideLoop) return geometryOutput
def getGeometryOutput(derivation, xmlElement): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = GearDerivation() derivation.setToXMLElement(xmlElement) creationFirst = derivation.creationType.lower()[: 1] toothProfileGear = getToothProfile(derivation, derivation.pitchRadiusGear, derivation.teethGear) gearProfileFirst = getGearProfileCylinder(derivation.teethPinion, derivation.pinionToothProfile) gearPaths = getGearPaths(derivation, derivation.pitchRadiusGear, derivation.teethGear, toothProfileGear) vector3GearProfileFirst = euclidean.getVector3Path(gearProfileFirst) vector3GearPaths = euclidean.getVector3Paths(gearPaths) translation = Vector3() moveFirst = derivation.moveType.lower()[: 1] if moveFirst != 'n': distance = derivation.pitchRadius + derivation.pitchRadiusGear if moveFirst != 'm': decimalPlaces = 1 - int(math.floor(math.log10(derivation.pitchRadius + abs(derivation.pitchRadiusGear)))) distance += derivation.halfWavelength + derivation.halfWavelength distance = round(1.15 * distance, decimalPlaces) translation = Vector3(0.0, -distance) if derivation.pinionThickness <=0.0: return getPathOutput( creationFirst, derivation, translation, vector3GearProfileFirst, vector3GearPaths, xmlElement) pitchRadius = derivation.pitchRadius teeth = derivation.teethPinion twist = derivation.helixThickness / derivation.pitchRadius extrudeOutputFirst = getOutputCylinder( derivation.pinionCollarThickness, derivation, None, pitchRadius, teeth, twist, [vector3GearProfileFirst], xmlElement) if creationFirst == 'f': return extrudeOutputFirst teeth = derivation.teethGear extrudeOutputSecond = None if teeth == 0: extrudeOutputSecond = getOutputRack(derivation, vector3GearPaths[0], xmlElement) else: twist = -derivation.helixThickness / derivation.pitchRadiusGear extrudeOutputSecond = getOutputCylinder( derivation.gearCollarThickness, derivation, derivation.gearHolePaths, derivation.pitchRadiusGear, teeth, twist, vector3GearPaths, xmlElement) if creationFirst == 's': return extrudeOutputSecond gearVertexes = matrix.getConnectionVertexes(extrudeOutputSecond) if moveFirst == 'v': translation = Vector3(0.0, 0.0, euclidean.getTopPath(gearVertexes)) euclidean.translateVector3Path(matrix.getConnectionVertexes(extrudeOutputFirst), translation) else: euclidean.translateVector3Path(gearVertexes, translation) return {'group' : {'shapes' : [extrudeOutputFirst, extrudeOutputSecond]}}
def getGeometryOutputBySVGReader(elementNode, svgReader): "Get vector3 vertexes from svgReader." geometryOutput = [] for loopLayer in svgReader.loopLayers: for loop in loopLayer.loops: vector3Path = euclidean.getVector3Path(loop, loopLayer.z) sideLoop = lineation.SideLoop(vector3Path) sideLoop.rotate(elementNode) geometryOutput += lineation.getGeometryOutputByManipulation( elementNode, sideLoop) return geometryOutput
def addCollarShaftSetDerivation(collarDerivation, collarThickness, derivation, negatives, positives, xmlElement): 'Add collar and shaft.' collarSides = evaluate.getSidesMinimumThreeBasedOnPrecision(derivation.shaftRimRadius, xmlElement) collarProfile = euclidean.getComplexPolygon(complex(), derivation.shaftRimRadius, collarSides) vector3CollarProfile = euclidean.getVector3Path(collarProfile) extrude.addNegativesPositives(collarDerivation, negatives, [vector3CollarProfile], positives) addShaft(derivation, negatives, positives) drillZ = derivation.pinionThickness + 0.5 * collarThickness drillEnd = Vector3(0.0, derivation.shaftRimRadius, drillZ) drillStart = Vector3(0.0, 0.0, drillZ) teardrop.addNegativesByRadius(drillEnd, negatives, derivation.keywayRadius, drillStart, xmlElement)
def getGeometryOutput(derivation, xmlElement): """Get vector3 vertexes from attribute dictionary.""" if derivation is None: derivation = TextDerivation(xmlElement) if derivation.textString == '': print('Warning, textString is empty in getGeometryOutput in text for:') print(xmlElement) return [] geometryOutput = [] for textComplexLoop in svg_reader.getTextComplexLoops(derivation.fontFamily, derivation.fontSize, derivation.textString): textComplexLoop.reverse() vector3Path = euclidean.getVector3Path(textComplexLoop) sideLoop = lineation.SideLoop(vector3Path, None, None) sideLoop.rotate(xmlElement) geometryOutput += lineation.getGeometryOutputByManipulation(sideLoop, xmlElement) return geometryOutput
def getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attributes." if derivation == None: derivation = TextDerivation(elementNode) if derivation.textString == '': print('Warning, textString is empty in getGeometryOutput in text for:') print(elementNode) return [] geometryOutput = [] for textComplexLoop in svg_reader.getTextComplexLoops(derivation.fontFamily, derivation.fontSize, derivation.textString): textComplexLoop.reverse() vector3Path = euclidean.getVector3Path(textComplexLoop) sideLoop = lineation.SideLoop(vector3Path) sideLoop.rotate(elementNode) geometryOutput += lineation.getGeometryOutputByManipulation(elementNode, sideLoop) return geometryOutput
def getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attributes." if derivation == None: derivation = TextDerivation(elementNode) if derivation.textString == '': print('Warning, textString is empty in getGeometryOutput in text for:') print(elementNode) return [] geometryOutput = [] for textComplexLoop in svg_reader.getTextComplexLoops(derivation.fontFamily, derivation.fontSize, derivation.textString): textComplexLoop.reverse() vector3Path = euclidean.getVector3Path(textComplexLoop) sideLoop = lineation.SideLoop(vector3Path, None, None) sideLoop.rotate(elementNode) geometryOutput += lineation.getGeometryOutputByManipulation(elementNode, sideLoop) return geometryOutput
def getGeometryOutput(elementNode): 'Get vector3 vertexes from attribute dictionary.' derivation = VoronoiDerivation(elementNode) complexPath = euclidean.getConcatenatedList(euclidean.getComplexPaths(derivation.target)) geometryOutput = [] topRight = derivation.inradius squareLoop = euclidean.getSquareLoopWiddershins(-topRight, topRight) loopComplexes = [] for pointIndex, point in enumerate(complexPath): outsides = complexPath[: pointIndex] + complexPath[pointIndex + 1 :] loopComplex = getVoronoiLoopByPoints(point, squareLoop, outsides) loopComplex = intercircle.getLargestInsetLoopFromLoop(loopComplex, derivation.radius) loopComplexes.append(loopComplex) elementNode.attributes['closed'] = 'true' for loopComplex in loopComplexes: vector3Path = euclidean.getVector3Path(loopComplex) geometryOutput += lineation.SideLoop(vector3Path).getManipulationPluginLoops(elementNode) return geometryOutput
def getShaftPath(gearDerivation): 'Get shaft with the option of a flat on the top and/or bottom.' sideAngle = 2.0 * math.pi / float(gearDerivation.shaftSides) startAngle = 0.5 * sideAngle endAngle = math.pi - 0.1 * sideAngle shaftProfile = [] while startAngle < endAngle: unitPolar = euclidean.getWiddershinsUnitPolar(startAngle) shaftProfile.append(unitPolar * gearDerivation.shaftRadius) startAngle += sideAngle if gearDerivation.shaftSides % 2 == 1: shaftProfile.append(complex(-gearDerivation.shaftRadius, 0.0)) horizontalBegin = gearDerivation.shaftRadius - gearDerivation.shaftDepthTop horizontalEnd = gearDerivation.shaftDepthBottom - gearDerivation.shaftRadius shaftProfile = getHorizontallyBoundedPath(horizontalBegin, horizontalEnd, shaftProfile) for shaftPointIndex, shaftPoint in enumerate(shaftProfile): shaftProfile[shaftPointIndex] = complex(shaftPoint.imag, shaftPoint.real) return euclidean.getVector3Path(getMirrorPath(shaftProfile))
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." fontFamily = evaluate.getEvaluatedStringDefault('Gentium Basic Regular', 'font-family', xmlElement) fontFamily = evaluate.getEvaluatedStringDefault(fontFamily, 'fontFamily', xmlElement) fontSize = evaluate.getEvaluatedFloatDefault(12.0, 'font-size', xmlElement) fontSize = evaluate.getEvaluatedFloatDefault(fontSize, 'fontSize', xmlElement) textString = evaluate.getEvaluatedStringDefault(xmlElement.text, 'text', xmlElement) if textString == '': print('Warning, textString is empty in getGeometryOutput in text for:') print(xmlElement) return [] geometryOutput = [] for textComplexLoop in svg_reader.getTextComplexLoops(fontFamily, fontSize, textString): textComplexLoop.reverse() vector3Path = euclidean.getVector3Path(textComplexLoop) sideLoop = lineation.SideLoop(vector3Path, None, None) sideLoop.rotate(xmlElement) geometryOutput += lineation.getGeometryOutputByManipulation(sideLoop, xmlElement) return geometryOutput
def getShaftPath(depthBottom, depthTop, radius, sides): 'Get shaft with the option of a flat on the top and/or bottom.' if radius <= 0.0: return [] sideAngle = 2.0 * math.pi / float(abs(sides)) startAngle = 0.5 * sideAngle endAngle = math.pi - 0.1 * sideAngle shaftProfile = [] while startAngle < endAngle: unitPolar = euclidean.getWiddershinsUnitPolar(startAngle) shaftProfile.append(unitPolar * radius) startAngle += sideAngle if abs(sides) % 2 == 1: shaftProfile.append(complex(-radius, 0.0)) horizontalBegin = radius - depthTop horizontalEnd = depthBottom - radius shaftProfile = euclidean.getHorizontallyBoundedPath(horizontalBegin, horizontalEnd, shaftProfile) for shaftPointIndex, shaftPoint in enumerate(shaftProfile): shaftProfile[shaftPointIndex] = complex(shaftPoint.imag, shaftPoint.real) shaftPath = euclidean.getVector3Path(euclidean.getMirrorPath(shaftProfile)) if sides > 0: shaftPath.reverse() return shaftPath
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(5.0, 5.0), xmlElement) inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', inradius, xmlElement) demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', inradius.real, xmlElement) demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', inradius.imag, xmlElement) radius = lineation.getComplexByPrefixBeginEnd('elementRadius', 'elementDiameter', complex(1.0, 1.0), xmlElement) radius = lineation.getComplexByPrefixBeginEnd('radius', 'diameter', radius, xmlElement) diameter = radius + radius typeString = evaluate.getEvaluatedStringDefault('rectangular', 'type', xmlElement) typeStringTwoCharacters = typeString.lower()[: 2] typeStringFirstCharacter = typeStringTwoCharacters[: 1] zigzag = evaluate.getEvaluatedBooleanDefault(True, 'zigzag', xmlElement) topRight = complex(demiwidth, demiheight) bottomLeft = -topRight loopsComplex = [euclidean.getSquareLoopWiddershins(bottomLeft, topRight)] paths = evaluate.getTransformedPathsByKey('target', xmlElement) if len(paths) > 0: loopsComplex = euclidean.getComplexPaths(paths) maximumComplex = euclidean.getMaximumByPathsComplex(loopsComplex) minimumComplex = euclidean.getMinimumByPathsComplex(loopsComplex) gridPath = None if typeStringTwoCharacters == 'he': gridPath = getHexagonalGrid(diameter, loopsComplex, maximumComplex, minimumComplex, zigzag) elif typeStringTwoCharacters == 'ra' or typeStringFirstCharacter == 'a': gridPath = getRandomGrid(diameter, loopsComplex, maximumComplex, minimumComplex, xmlElement) elif typeStringTwoCharacters == 're' or typeStringFirstCharacter == 'e': gridPath = getRectangularGrid(diameter, loopsComplex, maximumComplex, minimumComplex, zigzag) if gridPath == None: print('Warning, the step type was not one of (hexagonal, random or rectangular) in getGeometryOutput in grid for:') print(typeString) print(xmlElement) return [] loop = euclidean.getVector3Path(gridPath) xmlElement.attributeDictionary['closed'] = 'false' return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." gearDerivation = GearDerivation() gearDerivation.setToXMLElement(xmlElement) creationFirst = gearDerivation.creationType.lower()[:1] pitchRadiusSecond = gearDerivation.pitchRadius * float( gearDerivation.teethSecond) / float(gearDerivation.teethPinion) toothProfileFirst = getToothProfileCylinder(gearDerivation, gearDerivation.pitchRadius, gearDerivation.teethPinion) toothProfileSecond = getToothProfile(gearDerivation, pitchRadiusSecond, gearDerivation.teethSecond) gearProfileFirst = getGearProfileCylinder(gearDerivation.teethPinion, toothProfileFirst) gearProfileSecond = getGearProfile(gearDerivation, gearDerivation.teethSecond, toothProfileSecond) vector3GearProfileFirst = euclidean.getVector3Path(gearProfileFirst) vector3GearProfileSecond = euclidean.getVector3Path(gearProfileSecond) translation = Vector3() moveFirst = gearDerivation.moveType.lower()[:1] if moveFirst != 'n': distance = gearDerivation.pitchRadius + pitchRadiusSecond if moveFirst != 'm': decimalPlaces = 1 - int(math.floor(math.log10(distance))) distance += gearDerivation.halfWavelength + gearDerivation.halfWavelength distance = round(1.15 * distance, decimalPlaces) translation = Vector3(0.0, -distance) if gearDerivation.thickness <= 0.0: return getPathOutput(creationFirst, gearDerivation, translation, vector3GearProfileFirst, vector3GearProfileSecond, xmlElement) shaftRimRadius = gearDerivation.shaftRadius + gearDerivation.collarWidth vector3ShaftPath = getShaftPath(gearDerivation) pitchRadius = gearDerivation.pitchRadius teeth = gearDerivation.teethPinion twist = gearDerivation.helixThickness / gearDerivation.pitchRadius extrudeOutputFirst = getOutputCylinder(gearDerivation, pitchRadius, shaftRimRadius, teeth, twist, vector3GearProfileFirst, vector3ShaftPath, xmlElement) if creationFirst == 'f': return extrudeOutputFirst pitchRadius = pitchRadiusSecond teeth = gearDerivation.teethSecond extrudeOutputSecond = None if teeth == 0: extrudeOutputSecond = getOutputRack(gearDerivation, vector3GearProfileSecond, xmlElement) else: twist = -gearDerivation.helixThickness / pitchRadiusSecond extrudeOutputSecond = getOutputCylinder(gearDerivation, pitchRadius, shaftRimRadius, teeth, twist, vector3GearProfileSecond, vector3ShaftPath, xmlElement) if creationFirst == 's': return extrudeOutputSecond if moveFirst == 'v': connectionVertexes = matrix.getConnectionVertexes(extrudeOutputSecond) translation = Vector3(0.0, 0.0, euclidean.getTop(connectionVertexes)) euclidean.translateVector3Path( matrix.getConnectionVertexes(extrudeOutputFirst), translation) else: euclidean.translateVector3Path( matrix.getConnectionVertexes(extrudeOutputSecond), translation) return {'group': {'shapes': [extrudeOutputFirst, extrudeOutputSecond]}}
def addRackHole(derivation, vector3RackProfiles, x, xmlElement): "Add rack hole to vector3RackProfiles." rackHole = euclidean.getComplexPolygon(complex(x, -derivation.rackHoleBelow), derivation.rackHoleRadius, -13) vector3RackProfiles.append(euclidean.getVector3Path(rackHole))