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 addNegatives(derivation, negatives, paths): "Add pillars output to negatives." portionDirections = getSpacedPortionDirections(derivation.interpolationDictionary) for path in paths: endMultiplier = 1.000001 geometryOutput = trianglemesh.getPillarsOutput(getLoopListsByPath(endMultiplier, derivation, path, portionDirections)) negatives.append(geometryOutput)
def addPositives(derivation, positives, paths): 'Add pillars output to positives.' portionDirections = getSpacedPortionDirections(derivation.interpolationDictionary) for path in paths: loopLists = getLoopListsByPath(derivation, None, path, portionDirections) geometryOutput = trianglemesh.getPillarsOutput(loopLists) positives.append(geometryOutput)
def getGeometryOutputByPath( endMultiplier, extrude, path, portionDirections ): "Get vector3 vertices from attribute dictionary." vertices = [] loopLists = [ [] ] extrude.oldProjectiveSpace = None for portionDirectionIndex in xrange( len( portionDirections ) ): addLoop( endMultiplier, extrude, loopLists, path, portionDirectionIndex, portionDirections, vertices ) return trianglemesh.getPillarsOutput( loopLists )
def getGeometryOutputByPath( endMultiplier, extrudeDerivation, path, portionDirections ): "Get vector3 vertexes from attribute dictionary." vertexes = [] loopLists = [ [] ] extrudeDerivation.oldProjectiveSpace = None for portionDirectionIndex in xrange( len( portionDirections ) ): addLoop( endMultiplier, extrudeDerivation, loopLists, path, portionDirectionIndex, portionDirections, vertexes ) return trianglemesh.getPillarsOutput(loopLists)
def addNegativesPositives(derivation, negatives, paths, positives): "Add pillars output to negatives and positives." for path in paths: endMultiplier = None normal = euclidean.getNormalByPath(path) if normal.dot(derivation.normal) < 0.0: endMultiplier = 1.000001 loopListsByPath = getLoopListsByPath(derivation, endMultiplier, path) geometryOutput = trianglemesh.getPillarsOutput(loopListsByPath) if endMultiplier == None: positives.append(geometryOutput) else: negatives.append(geometryOutput)
def addNegativesPositives(derivation, negatives, paths, positives): "Add pillars output to negatives and positives." portionDirections = getSpacedPortionDirections(derivation.interpolationDictionary) for path in paths: endMultiplier = None if not euclidean.getIsWiddershinsByVector3(path): endMultiplier = 1.000001 loopLists = getLoopListsByPath(derivation, endMultiplier, path, portionDirections) geometryOutput = trianglemesh.getPillarsOutput(loopLists) if endMultiplier == None: positives.append(geometryOutput) else: negatives.append(geometryOutput)
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)
def addPositives(derivation, positives, paths): "Add pillars output to positives." for path in paths: loopListsByPath = getLoopListsByPath(derivation, None, path) geometryOutput = trianglemesh.getPillarsOutput(loopListsByPath) positives.append(geometryOutput)
def addNegatives(derivation, negatives, paths): "Add pillars output to negatives." for path in paths: loopListsByPath = getLoopListsByPath(derivation, 1.000001, path) geometryOutput = trianglemesh.getPillarsOutput(loopListsByPath) negatives.append(geometryOutput)