def getLiftedOutput(derivation, geometryOutput, xmlElement): "Get extrude output for a rack." if derivation.moveType.lower()[: 1] == 'm': return geometryOutput geometryOutputVertexes = matrix.getConnectionVertexes(geometryOutput) translation = Vector3(0.0, 0.0, -euclidean.getBottomPath(geometryOutputVertexes)) euclidean.translateVector3Path(geometryOutputVertexes, translation) return geometryOutput
def addNegativeSphere(derivation, negatives, x): 'Add negative sphere at x.' radius = Vector3(derivation.radiusPlusClearance, derivation.radiusPlusClearance, derivation.radiusPlusClearance) sphereOutput = sphere.getGeometryOutput( radius, derivation.xmlElement.getCopyShallow()) euclidean.translateVector3Path(matrix.getVertexes(sphereOutput), Vector3(x, 0.0, derivation.demiheight)) negatives.append(sphereOutput)
def getPathOutput(creationFirst, gearDerivation, translation, vector3GearProfileFirst, vector3GearProfileSecond, xmlElement): "Get gear path output." vector3GearProfileFirst = lineation.getGeometryOutputByLoop(lineation.SideLoop(vector3GearProfileFirst), xmlElement) if creationFirst == 'f': return vector3GearProfileFirst vector3GearProfileSecond = lineation.getGeometryOutputByLoop(lineation.SideLoop(vector3GearProfileSecond), xmlElement) if creationFirst == 's': return vector3GearProfileSecond euclidean.translateVector3Path(vector3GearProfileSecond, translation) return [vector3GearProfileFirst, vector3GearProfileSecond]
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 getGeometryOutputByEndStart(endZ, inradiusComplex, start, topOverBottom, xmlElement): 'Get cylinder triangle mesh by endZ, inradius and start.' inradius = Vector3(inradiusComplex.real, inradiusComplex.imag, 0.5 * abs(endZ - start.z)) cylinderOutput = getGeometryOutput(inradius, topOverBottom, xmlElement) vertexes = matrix.getVertexes(cylinderOutput) if endZ < start.z: for vertex in vertexes: vertex.z = -vertex.z translation = Vector3(start.x, start.y, inradius.z + min(start.z, endZ)) euclidean.translateVector3Path(vertexes, translation) return cylinderOutput
def addCylinderOutputByEndStart(endZ, inradiusComplex, outputs, sides, start, topOverBottom=1.0): 'Add cylinder triangle mesh by endZ, inradius and start.' inradius = Vector3(inradiusComplex.real, inradiusComplex.imag, 0.5 * abs(endZ - start.z)) cylinderOutput = getGeometryOutput(inradius, sides, topOverBottom) vertexes = matrix.getVertexes(cylinderOutput) if endZ < start.z: for vertex in vertexes: vertex.z = -vertex.z translation = Vector3(start.x, start.y, inradius.z + min(start.z, endZ)) euclidean.translateVector3Path(vertexes, translation) outputs.append(cylinderOutput)
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 getPathOutput(creationFirst, gearDerivation, translation, vector3GearProfileFirst, vector3GearProfileSecond, xmlElement): "Get gear path output." vector3GearProfileFirst = lineation.getGeometryOutputByLoop( lineation.SideLoop(vector3GearProfileFirst), xmlElement) if creationFirst == 'f': return vector3GearProfileFirst vector3GearProfileSecond = lineation.getGeometryOutputByLoop( lineation.SideLoop(vector3GearProfileSecond), xmlElement) if creationFirst == 's': return vector3GearProfileSecond euclidean.translateVector3Path(vector3GearProfileSecond, translation) return [vector3GearProfileFirst, vector3GearProfileSecond]
def addNegativeSphere(derivation, negatives, x): 'Add negative sphere at x.' radius = Vector3(derivation.radiusPlusClearance, derivation.radiusPlusClearance, derivation.radiusPlusClearance) sphereOutput = sphere.getGeometryOutput(radius, derivation.xmlElement.getCopyShallow()) euclidean.translateVector3Path(matrix.getVertexes(sphereOutput), Vector3(x, 0.0, derivation.demiheight)) negatives.append(sphereOutput)
def translatePoints(elementNode, points, prefix): "Translate the points." translateVector3 = matrix.getCumulativeVector3Remove(Vector3(), elementNode, prefix) if abs(translateVector3) > 0.0: euclidean.translateVector3Path(points, translateVector3)
def translateNegativesPositives(negatives, positives, translation): 'Translate the negatives and postives.' euclidean.translateVector3Path(matrix.getVertexes(negatives), translation) euclidean.translateVector3Path(matrix.getVertexes(positives), translation)
def translatePoints(points, prefix, xmlElement): "Translate the points." translateVector3 = matrix.getCumulativeVector3Remove( Vector3(), prefix, xmlElement) if abs(translateVector3) > 0.0: euclidean.translateVector3Path(points, translateVector3)
def translatePoints(points, prefix, xmlElement): "Translate the points." translateVector3 = matrix.getCumulativeVector3Remove(prefix, Vector3(), xmlElement) if abs(translateVector3) > 0.0: euclidean.translateVector3Path(points, translateVector3)
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]}}