def getOutputCylinder( collarThickness, derivation, gearHolePaths, pitchRadius, teeth, twist, vector3GearProfile, xmlElement): "Get extrude output for a cylinder gear." extrudeDerivation = extrude.ExtrudeDerivation() extrudeDerivation.offsetPathDefault = [Vector3(), Vector3(0.0, 0.0, derivation.pinionThickness)] extrudeDerivation.setToXMLElement(derivation.copyShallow) negatives = [] positives = [] if twist != 0.0: twistDegrees = math.degrees(twist) extrudeDerivation.twistPathDefault = [] for complexPoint in derivation.helixPath: extrudeDerivation.twistPathDefault.append(Vector3(complexPoint.real, twistDegrees * complexPoint.imag)) extrude.insertTwistPortions(extrudeDerivation, xmlElement) if derivation.operatingAngle != 180.0: addBevelGear(derivation, extrudeDerivation, pitchRadius, positives, teeth, vector3GearProfile) addCollarShaft(collarThickness, derivation, negatives, positives, xmlElement) return extrude.getGeometryOutputByNegativesPositives(extrudeDerivation, negatives, positives, xmlElement) if pitchRadius > 0: extrude.addNegativesPositives(extrudeDerivation, negatives, vector3GearProfile, positives) addLighteningHoles(derivation, gearHolePaths, negatives, pitchRadius, positives) addCollarShaft(collarThickness, derivation, negatives, positives, xmlElement) return extrude.getGeometryOutputByNegativesPositives(extrudeDerivation, negatives, positives, xmlElement) if derivation.plateThickness <= 0.0: extrude.addNegativesPositives(extrudeDerivation, negatives, vector3GearProfile, positives) return extrude.getGeometryOutputByNegativesPositives(extrudeDerivation, negatives, positives, xmlElement) portionDirections = extrude.getSpacedPortionDirections(extrudeDerivation.interpolationDictionary) outerGearProfile = vector3GearProfile[0] outerLoopLists = extrude.getLoopListsByPath(extrudeDerivation, None, outerGearProfile, portionDirections) addBottomLoop(-derivation.plateClearance, outerLoopLists[0]) geometryOutput = trianglemesh.getPillarsOutput(outerLoopLists) positives.append(geometryOutput) innerLoopLists = extrude.getLoopListsByPath(extrudeDerivation, None, vector3GearProfile[1], portionDirections) addBottomLoop(-derivation.plateClearance, innerLoopLists[0]) geometryOutput = trianglemesh.getPillarsOutput(innerLoopLists) negatives.append(geometryOutput) connectionStart = Vector3(0.0, 0.0, -derivation.plateThickness) plateDerivation = extrude.ExtrudeDerivation() plateDerivation.offsetPathDefault = [connectionStart, Vector3(0.0, 0.0, -derivation.plateClearance)] plateDerivation.setToXMLElement(derivation.copyShallow) extrude.addNegativesPositives(plateDerivation, negatives, [outerGearProfile], positives) vector3LighteningHoles = getLighteningHoles(derivation, gearHolePaths, pitchRadius) extrude.addNegativesPositives(plateDerivation, negatives, vector3LighteningHoles, positives) addShaft(derivation, negatives, positives) connectionEnd = Vector3(0.0, 0.0, derivation.pinionThickness) positiveOutput = trianglemesh.getUnifiedOutput(positives) annulusPlateOutput = {'difference' : {'shapes' : [positiveOutput] + negatives}} if collarThickness <= 0.0: outputCylinder = extrude.getGeometryOutputByConnection(connectionEnd, connectionStart, annulusPlateOutput, xmlElement) return getLiftedOutput(derivation, outputCylinder, xmlElement) negatives = [] positives = [] connectionEnd = Vector3(0.0, 0.0, derivation.pinionThickness + collarThickness) collarDerivation = extrude.ExtrudeDerivation() collarDerivation.offsetPathDefault = [Vector3(0.0, 0.0, -derivation.plateClearance), connectionEnd] addCollarShaftSetDerivation(collarDerivation, collarThickness, derivation, negatives, positives, xmlElement) collarOutput = {'difference' : {'shapes' : positives + negatives}} cylinderOutput = {'union' : {'shapes' : [annulusPlateOutput, collarOutput]}} outputCylinder = extrude.getGeometryOutputByConnection(connectionEnd, connectionStart, cylinderOutput, xmlElement) return getLiftedOutput(derivation, outputCylinder, xmlElement)
def addBevelGear(derivation, extrudeDerivation, pitchRadius, positives, teeth, vector3GearProfile): "Get extrude output for a cylinder gear." totalPitchRadius = derivation.pitchRadiusGear + derivation.pitchRadius totalTeeth = derivation.teethPinion + derivation.teethGear portionDirections = extrude.getSpacedPortionDirections(extrudeDerivation.interpolationDictionary) loopLists = extrude.getLoopListsByPath(extrudeDerivation, None, vector3GearProfile[0], portionDirections) firstLoopList = loopLists[0] gearOverPinion = float(totalTeeth - teeth) / float(teeth) thirdLayerThickness = 0.33333333333 * evaluate.getLayerThickness(derivation.xmlElement) pitchRadian = math.atan(math.sin(derivation.operatingRadian) / (gearOverPinion + math.cos(derivation.operatingRadian))) coneDistance = pitchRadius / math.sin(pitchRadian) apex = Vector3(0.0, 0.0, math.sqrt(coneDistance * coneDistance - pitchRadius * pitchRadius)) cosPitch = apex.z / coneDistance sinPitch = math.sin(pitchRadian) for loop in firstLoopList: for point in loop: alongWay = point.z / coneDistance oneMinusAlongWay = 1.0 - alongWay pointComplex = point.dropAxis() pointComplexLength = abs(pointComplex) deltaRadius = pointComplexLength - pitchRadius cosDeltaRadius = cosPitch * deltaRadius sinDeltaRadius = sinPitch * deltaRadius pointComplex *= (cosDeltaRadius + pitchRadius) / pointComplexLength point.x = pointComplex.real point.y = pointComplex.imag point.z += sinDeltaRadius point.x *= oneMinusAlongWay point.y *= oneMinusAlongWay addBottomLoop(-thirdLayerThickness, firstLoopList) topLoop = firstLoopList[-1] topAddition = [] topZ = euclidean.getTopPath(topLoop) + thirdLayerThickness oldIndex = topLoop[-1].index for point in topLoop: oldIndex += 1 topAddition.append(Vector3Index(oldIndex, 0.8 * point.x, 0.8 * point.y, topZ)) firstLoopList.append(topAddition) translation = Vector3(0.0, 0.0, -euclidean.getBottomPaths(firstLoopList)) euclidean.translateVector3Paths(firstLoopList, translation) geometryOutput = trianglemesh.getPillarsOutput(loopLists) positives.append(geometryOutput)