def getLighteningHoles(gearDerivation, pitchRadius, shaftRimRadius, teeth): 'Get cutout circles.' innerRadius = pitchRadius - gearDerivation.dedendum lighteningHoleOuterRadius = innerRadius - gearDerivation.rimWidth shaftRimRadius = max(shaftRimRadius, (lighteningHoleOuterRadius) * (0.5 - math.sqrt(0.1875))) lighteningHoleRadius = 0.5 * (lighteningHoleOuterRadius - shaftRimRadius) if lighteningHoleRadius < gearDerivation.lighteningHoleMinimumRadius: return [] lighteningHoles = [] numberOfLighteningHoles = 3 polygonRadius = lighteningHoleOuterRadius - lighteningHoleRadius rimDemiwidth = 0.5 * gearDerivation.lighteningHoleMargin axialMargin = getAxialMargin(lighteningHoleRadius, numberOfLighteningHoles, polygonRadius) if axialMargin < rimDemiwidth: while axialMargin < rimDemiwidth: lighteningHoleRadius *= 0.999 if lighteningHoleRadius < gearDerivation.lighteningHoleMinimumRadius: return [] axialMargin = getAxialMargin(lighteningHoleRadius, numberOfLighteningHoles, polygonRadius) else: newNumberOfLighteningHoles = numberOfLighteningHoles while axialMargin > rimDemiwidth: numberOfLighteningHoles = newNumberOfLighteningHoles newNumberOfLighteningHoles += 2 axialMargin = getAxialMargin(lighteningHoleRadius, newNumberOfLighteningHoles, polygonRadius) sideAngle = 2.0 * math.pi / float(numberOfLighteningHoles) startAngle = 0.0 for lighteningHoleIndex in xrange(numberOfLighteningHoles): unitPolar = euclidean.getWiddershinsUnitPolar(startAngle) lighteningHole = euclidean.getComplexPolygon(unitPolar * polygonRadius, lighteningHoleRadius, -13) lighteningHoles.append(lighteningHole) startAngle += sideAngle return euclidean.getVector3Paths(lighteningHoles)
def getTransformedPaths(self): "Get all transformed paths." importRadius = self.xmlElement.getCascadeFloat( 1.5 * evaluate.getLayerThickness(self.xmlElement), 'importRadius') return euclidean.getVector3Paths( self.getLoopsFromObjectLoopsList( importRadius, self.getComplexTransformedPathLists()))
def getManipulatedPaths(close, loop, prefix, sideLength, xmlElement): "Get path with overhangs removed or filled in." if len(loop) < 4: return [loop] loopComplex = euclidean.getComplexPath(loop) return euclidean.getVector3Paths([euclidean.getLoopConvex(loopComplex)], loop[0].z)
def getPaths(self): "Get all paths." importRadius = self.xmlElement.getCascadeFloat( 5.0 * evaluate.getPrecision(self.xmlElement), 'importradius') return euclidean.getVector3Paths( self.getLoopsFromObjectLoopsList(importRadius, self.getComplexPathLists()))
def getInsetLoopsFromVector3Loop(loop, radius, thresholdRatio=0.9): 'Get the inset loops from vector3 loop, which might overlap.' if len(loop) < 2: return [loop] loopComplex = euclidean.getComplexPath(loop) loopComplexes = getInsetLoopsFromLoop(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getTransformedPaths(self): "Get all transformed paths." importRadius = self.xmlElement.getCascadeFloat( 1.5 * evaluate.getLayerThickness(self.xmlElement), "importRadius" ) return euclidean.getVector3Paths( self.getLoopsFromObjectLoopsList(importRadius, self.getComplexTransformedPathLists()) )
def processXMLElementByDerivation(derivation, xmlElement): 'Process the xml element by derivation.' if derivation == None: derivation = DisjoinDerivation(xmlElement) targetXMLElement = derivation.targetXMLElement if targetXMLElement == None: print('Warning, disjoin could not get target for:') print(xmlElement) return xmlObject = targetXMLElement.xmlObject if xmlObject == None: print('Warning, processXMLElementByDerivation in disjoin could not get xmlObject for:') print(targetXMLElement) print(derivation.xmlElement) return transformedVertexes = xmlObject.getTransformedVertexes() if len(transformedVertexes) < 1: print('Warning, transformedVertexes is zero in processXMLElementByDerivation in disjoin for:') print(xmlObject) print(targetXMLElement) print(derivation.xmlElement) return xmlElement.localName = 'group' xmlElement.getXMLProcessor().processXMLElement(xmlElement) matrix.getBranchMatrixSetXMLElement(targetXMLElement) targetChainMatrix = matrix.Matrix(xmlObject.getMatrixChainTetragrid()) minimumZ = boolean_geometry.getMinimumZ(xmlObject) z = minimumZ + 0.5 * derivation.sheetThickness zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerThickness, transformedVertexes) oldVisibleString = targetXMLElement.attributeDictionary['visible'] targetXMLElement.attributeDictionary['visible'] = True loops = boolean_geometry.getEmptyZLoops([xmlObject], derivation.importRadius, False, z, zoneArrangement) targetXMLElement.attributeDictionary['visible'] = oldVisibleString vector3Loops = euclidean.getVector3Paths(loops, z) pathElement = getLinkedXMLElement('_sheet', xmlElement, targetXMLElement) path.convertXMLElement(vector3Loops, pathElement) targetOutput = xmlObject.getGeometryOutput() differenceElement = getLinkedXMLElement('_solid', xmlElement, targetXMLElement) targetElementCopy = targetXMLElement.getCopy('_positive', differenceElement) targetElementCopy.attributeDictionary['visible'] = True targetElementCopy.attributeDictionary.update(targetChainMatrix.getAttributeDictionary('matrix.')) complexMaximum = euclidean.getMaximumByVector3Path(transformedVertexes).dropAxis() complexMinimum = euclidean.getMinimumByVector3Path(transformedVertexes).dropAxis() centerComplex = 0.5 * (complexMaximum + complexMinimum) centerVector3 = Vector3(centerComplex.real, centerComplex.imag, minimumZ) slightlyMoreThanHalfExtent = 0.501 * (complexMaximum - complexMinimum) inradius = Vector3(slightlyMoreThanHalfExtent.real, slightlyMoreThanHalfExtent.imag, derivation.sheetThickness) cubeElement = xml_simple_reader.XMLElement() cubeElement.attributeDictionary['inradius'] = str(inradius) if not centerVector3.getIsDefault(): cubeElement.attributeDictionary['translate.'] = str(centerVector3) cubeElement.localName = 'cube' cubeElement.importName = differenceElement.importName cubeElement.setParentAddToChildNodes(differenceElement) difference.processXMLElement(differenceElement)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with outline." if len(loop) < 2: return [loop] derivation = OutlineDerivation(elementNode, prefix, sideLength) loopComplex = euclidean.getComplexPath(loop) if derivation.isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, derivation.radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, derivation.radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
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 getManipulatedPaths(close, loop, prefix, sideLength, xmlElement): "Get path with overhangs removed or filled in." if len(loop) < 2: return [loop] isClosed = evaluate.getEvaluatedBooleanDefault(False, prefix + 'closed', xmlElement) radius = lineation.getStrokeRadiusByPrefix(prefix, xmlElement ) loopComplex = euclidean.getComplexPath(loop) if isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with outline." if len(loop) < 2: return [loop] isClosed = evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'closed') radius = lineation.getStrokeRadiusByPrefix(elementNode, prefix ) loopComplex = euclidean.getComplexPath(loop) if isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with outline." if len(loop) < 2: return [loop] isClosed = evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'closed') radius = lineation.getStrokeRadiusByPrefix(elementNode, prefix) loopComplex = euclidean.getComplexPath(loop) if isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = CarveDerivation(elementNode) targetElementNode = derivation.targetElementNode if targetElementNode == None: print('Warning, carve could not get target for:') print(elementNode) return xmlObject = targetElementNode.xmlObject if xmlObject == None: print( 'Warning, processElementNodeByDerivation in carve could not get xmlObject for:' ) print(targetElementNode) print(derivation.elementNode) return matrix.getBranchMatrixSetElementNode(targetElementNode) transformedVertexes = xmlObject.getTransformedVertexes() if len(transformedVertexes) < 1: print( 'Warning, transformedVertexes is zero in processElementNodeByDerivation in carve for:' ) print(xmlObject) print(targetElementNode) print(derivation.elementNode) return elementNode.localName = 'group' elementNode.getXMLProcessor().processElementNode(elementNode) minimumZ = boolean_geometry.getMinimumZ(xmlObject) maximumZ = euclidean.getTopPath(transformedVertexes) zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerThickness, transformedVertexes) oldVisibleString = targetElementNode.attributes['visible'] targetElementNode.attributes['visible'] = True z = minimumZ + 0.5 * derivation.layerThickness loopLayers = boolean_geometry.getLoopLayers([xmlObject], derivation.importRadius, derivation.layerThickness, maximumZ, False, z, zoneArrangement) targetElementNode.attributes['visible'] = oldVisibleString for loopLayerIndex, loopLayer in enumerate(loopLayers): if len(loopLayer.loops) > 0: pathElement = getLinkedElementNode('_carve_%s' % loopLayerIndex, elementNode, targetElementNode) vector3Loops = euclidean.getVector3Paths(loopLayer.loops, loopLayer.z) path.convertElementNode(pathElement, vector3Loops)
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = CarveDerivation(elementNode) targetElementNode = derivation.targetElementNode if targetElementNode == None: print('Warning, carve could not get target for:') print(elementNode) return xmlObject = targetElementNode.xmlObject if xmlObject == None: print( 'Warning, processElementNodeByDerivation in carve could not get xmlObject for:' ) print(targetElementNode) print(derivation.elementNode) return matrix.getBranchMatrixSetElementNode(targetElementNode) transformedVertexes = xmlObject.getTransformedVertexes() if len(transformedVertexes) < 1: print( 'Warning, transformedVertexes is zero in processElementNodeByDerivation in carve for:' ) print(xmlObject) print(targetElementNode) print(derivation.elementNode) return elementNode.localName = 'group' elementNode.getXMLProcessor().processElementNode(elementNode) minimumZ = boolean_geometry.getMinimumZ(xmlObject) maximumZ = euclidean.getTopPath(transformedVertexes) zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerHeight, transformedVertexes) oldVisibleString = targetElementNode.attributes['visible'] targetElementNode.attributes['visible'] = True z = minimumZ + 0.5 * derivation.layerHeight loopLayers = boolean_geometry.getLoopLayers( [xmlObject], derivation.importRadius, derivation.layerHeight, maximumZ, False, z, zoneArrangement) targetElementNode.attributes['visible'] = oldVisibleString for loopLayerIndex, loopLayer in enumerate(loopLayers): if len(loopLayer.loops) > 0: pathElement = getLinkedElementNode('_carve_%s' % loopLayerIndex, elementNode, targetElementNode) vector3Loops = euclidean.getVector3Paths(loopLayer.loops, loopLayer.z) path.convertElementNode(pathElement, vector3Loops)
def addGroove(derivation, negatives): 'Add groove on each side of cage.' copyShallow = derivation.elementNode.getCopyShallow() extrude.setElementNodeToEndStart(copyShallow, Vector3(-derivation.demilength), Vector3(derivation.demilength)) extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) bottom = derivation.demiheight - 0.5 * derivation.grooveWidth outside = derivation.demiwidth top = derivation.demiheight leftGroove = [ complex(-outside, bottom), complex(-derivation.innerDemiwidth, derivation.demiheight), complex(-outside, top)] rightGroove = [ complex(outside, top), complex(derivation.innerDemiwidth, derivation.demiheight), complex(outside, bottom)] extrude.addNegatives(extrudeDerivation, negatives, euclidean.getVector3Paths([leftGroove, rightGroove]))
def addGroove(derivation, negatives): 'Add groove on each side of cage.' copyShallow = derivation.xmlElement.getCopyShallow() extrude.setXMLElementToEndStart(Vector3(-derivation.demilength), Vector3(derivation.demilength), copyShallow) extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) bottom = derivation.demiheight - 0.5 * derivation.grooveWidth outside = derivation.demiwidth top = derivation.demiheight leftGroove = [ complex(-outside, bottom), complex(-derivation.innerDemiwidth, derivation.demiheight), complex(-outside, top)] rightGroove = [ complex(outside, top), complex(derivation.innerDemiwidth, derivation.demiheight), complex(outside, bottom)] groovesComplex = [leftGroove, rightGroove] groovesVector3 = euclidean.getVector3Paths(groovesComplex) extrude.addPositives(extrudeDerivation, negatives, groovesVector3)
def addGroove(derivation, negatives): 'Add groove on each side of cage.' copyShallow = derivation.xmlElement.getCopyShallow() extrude.setXMLElementToEndStart(Vector3(-derivation.demilength), Vector3(derivation.demilength), copyShallow) extrudeDerivation = extrude.ExtrudeDerivation(copyShallow) bottom = derivation.demiheight - 0.5 * derivation.grooveWidth outside = derivation.demiwidth top = derivation.demiheight leftGroove = [ complex(-outside, bottom), complex(-derivation.innerDemiwidth, derivation.demiheight), complex(-outside, top)] rightGroove = [ complex(outside, top), complex(derivation.innerDemiwidth, derivation.demiheight), complex(outside, bottom)] groovesComplex = [leftGroove, rightGroove] groovesVector3 = euclidean.getVector3Paths(groovesComplex) extrude.addPositives(extrudeDerivation, groovesVector3, negatives)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with overhangs removed or filled in." if len(loop) < 4: return [loop] loopComplex = euclidean.getComplexPath(loop) return euclidean.getVector3Paths([euclidean.getLoopConvex(loopComplex)], loop[0].z)
def getTransformedPaths(self): 'Get all transformed paths.' importRadius = setting.getImportRadius(self.elementNode) loopsFromObjectLoopsList = self.getLoopsFromObjectLoopsList( importRadius, self.getComplexTransformedPathLists()) return euclidean.getVector3Paths(loopsFromObjectLoopsList)
def getTransformedPaths(self): 'Get all transformed paths.' importRadius = setting.getImportRadius(self.xmlElement) loopsFromObjectLoopsList = self.getLoopsFromObjectLoopsList(importRadius, self.getComplexTransformedPathLists()) return euclidean.getVector3Paths(loopsFromObjectLoopsList)
def getPaths( self ): "Get all paths." importRadius = self.xmlElement.getCascadeFloat( 5.0 * evaluate.getPrecision( self.xmlElement ), 'importradius') return euclidean.getVector3Paths( self.getLoopsFromObjectLoopsList( importRadius, self.getComplexPathLists() ) )