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 getPathOutput(creationFirst, derivation, translation, vector3GearProfileFirst, vector3GearPaths, xmlElement): "Get gear path output." vector3GearProfileFirst = lineation.getPackedGeometryOutputByLoop(lineation.SideLoop(vector3GearProfileFirst), xmlElement) if creationFirst == 'f': return vector3GearProfileFirst packedGearGeometry = [] for vector3GearPath in vector3GearPaths: packedGearGeometry += lineation.getPackedGeometryOutputByLoop(lineation.SideLoop(vector3GearPath), xmlElement) if creationFirst == 's': return packedGearGeometry euclidean.translateVector3Paths(packedGearGeometry, translation) return vector3GearProfileFirst + packedGearGeometry
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 = CircleDerivation(xmlElement) loop = [] angleTotal = math.radians(derivation.start) sidesCeiling = int( math.ceil(abs(derivation.sides) * derivation.extent / 360.0)) sideAngle = math.radians(derivation.extent) / sidesCeiling if derivation.sides < 0.0: sideAngle = -sideAngle spiral = lineation.Spiral(derivation.spiral, 0.5 * sideAngle / math.pi) for side in xrange(sidesCeiling + 1): unitPolar = euclidean.getWiddershinsUnitPolar(angleTotal) vertex = spiral.getSpiralPoint( unitPolar, Vector3(unitPolar.real * derivation.radius.real, unitPolar.imag * derivation.radius.imag)) angleTotal += sideAngle loop.append(vertex) loop = euclidean.getLoopWithoutCloseEnds( 0.000001 * max(derivation.radius.real, derivation.radius.imag), loop) sideLength = sideAngle * lineation.getRadiusAverage(derivation.radius) lineation.setClosedAttribute(derivation.revolutions, xmlElement) return lineation.getGeometryOutputByLoop( lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
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 getGeometryOutput(derivation, xmlElement): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = TeardropDerivation() derivation.setToXMLElement(xmlElement) teardropPath = getTeardropPath(derivation.inclination, derivation.radius, xmlElement) return lineation.getGeometryOutputByLoop(lineation.SideLoop(teardropPath), xmlElement)
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 getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attribute dictionary." if derivation is None: derivation = SquareDerivation(elementNode) topRight = complex(derivation.topDemiwidth, derivation.demiheight) topLeft = complex(-derivation.topDemiwidth, derivation.demiheight) bottomLeft = complex(-derivation.bottomDemiwidth, -derivation.demiheight) bottomRight = complex(derivation.bottomDemiwidth, -derivation.demiheight) if derivation.interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar( math.radians(derivation.interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft lineation.setClosedAttribute(elementNode, derivation.revolutions) complexLoop = [topRight, topLeft, bottomLeft, bottomRight] originalLoop = complexLoop[:] for revolution in xrange(1, derivation.revolutions): complexLoop += originalLoop spiral = lineation.Spiral(derivation.spiral, 0.25) loop = [] loopCentroid = euclidean.getLoopCentroid(originalLoop) for point in complexLoop: unitPolar = euclidean.getNormalized(point - loopCentroid) loop.append( spiral.getSpiralPoint(unitPolar, Vector3(point.real, point.imag))) return lineation.getGeometryOutputByLoop( elementNode, lineation.SideLoop(loop, 0.5 * math.pi))
def getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." if '_arguments' in xmlElement.attributeDictionary: arguments = xmlElement.attributeDictionary['_arguments'] if len(arguments) > 0: xmlElement.attributeDictionary['sides'] = arguments[0] sides = evaluate.getEvaluatedFloatDefault(4.0, 'sides', xmlElement) sideAngle = 2.0 * math.pi / float(sides) radiusXY = evaluate.RadiusXY().getByRadius( getRadiusFromXMLElement(sideAngle, xmlElement), xmlElement) loop = [] sidesCeiling = int(math.ceil(abs(sides))) start = evaluate.getEvaluatedIntZero('start', xmlElement) start = getWrappedInteger(start, sidesCeiling) extent = evaluate.getEvaluatedIntDefault(sidesCeiling - start, 'extent', xmlElement) end = evaluate.getEvaluatedIntDefault(start + extent, 'end', xmlElement) end = getWrappedInteger(end, sidesCeiling) for side in xrange(start, min(end, sidesCeiling)): angle = float(side) * sideAngle point = euclidean.getWiddershinsUnitPolar(angle) vertex = Vector3(point.real * radiusXY.radiusX, point.imag * radiusXY.radiusY) loop.append(vertex) sideLength = sideAngle * radiusXY.radius return lineation.getGeometryOutputByLoop( None, lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
def getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = CircleDerivation(elementNode) angleTotal = math.radians(derivation.start) loop = [] sidesCeiling = int( math.ceil(abs(derivation.sides) * derivation.extent / 360.0)) sideAngle = math.radians(derivation.extent) / sidesCeiling if derivation.sides < 0.0: sideAngle = -sideAngle spiral = lineation.Spiral(derivation.spiral, 0.5 * sideAngle / math.pi) for side in xrange(sidesCeiling + 1): unitPolar = euclidean.getWiddershinsUnitPolar(angleTotal) x = unitPolar.real * derivation.radiusArealized.real y = unitPolar.imag * derivation.radiusArealized.imag vertex = spiral.getSpiralPoint(unitPolar, Vector3(x, y)) angleTotal += sideAngle loop.append(vertex) radiusMaximum = 0.000001 * max(derivation.radiusArealized.real, derivation.radiusArealized.imag) loop = euclidean.getLoopWithoutCloseEnds(radiusMaximum, loop) lineation.setClosedAttribute(elementNode, derivation.revolutions) return lineation.getGeometryOutputByLoop( elementNode, lineation.SideLoop(loop, sideAngle))
def getGeometryOutputByStep(elementNode, end, loop, steps, stepVector): "Get line geometry output by the end, loop, steps and stepVector." stepsFloor = int(math.floor(abs(steps))) for stepIndex in xrange(1, stepsFloor): loop.append(loop[stepIndex - 1] + stepVector) loop.append(end) return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(loop))
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 getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." radius = lineation.getRadiusComplex(complex(1.0, 1.0), xmlElement) sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(max(radius.real, radius.imag), xmlElement) loop = [] start = evaluate.getEvaluatedFloatZero('start', xmlElement) start = getWrappedFloat(start, 360.0) extent = evaluate.getEvaluatedFloatDefault(360.0 - start, 'extent', xmlElement) end = evaluate.getEvaluatedFloatDefault(start + extent, 'end', xmlElement) end = getWrappedFloat(end, 360.0) revolutions = evaluate.getEvaluatedFloatOne('revolutions', xmlElement) if revolutions > 1: end += 360.0 * (revolutions - 1) angleTotal = math.radians(start) extent = end - start sidesCeiling = int(math.ceil(abs(sides) * extent / 360.0)) sideAngle = math.radians(extent) / sidesCeiling spiral = lineation.Spiral(0.5 * sideAngle / math.pi, xmlElement) for side in xrange(sidesCeiling + (extent != 360.0)): unitPolar = euclidean.getWiddershinsUnitPolar(angleTotal) vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * radius.real, unitPolar.imag * radius.imag)) angleTotal += sideAngle loop.append(vertex) sideLength = sideAngle * lineation.getAverageRadius(radius) lineation.setClosedAttribute(revolutions, xmlElement) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
def getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = LineDerivation(elementNode) endMinusStart = derivation.end - derivation.start endMinusStartLength = abs(endMinusStart) if endMinusStartLength <= 0.0: print('Warning, end is the same as start in getGeometryOutput in line for:') print(derivation.start) print(derivation.end) print(elementNode) return None typeStringTwoCharacters = derivation.typeString.lower()[: 2] elementNode.attributes['closed'] = str(derivation.closed) if derivation.step == None and derivation.steps == None: return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop([derivation.start, derivation.end])) loop = [derivation.start] if derivation.step != None and derivation.steps != None: stepVector = derivation.step / endMinusStartLength * endMinusStart derivation.end = derivation.start + stepVector * derivation.steps return getGeometryOutputByStep(elementNode, derivation.end, loop, derivation.steps, stepVector) if derivation.step == None: stepVector = endMinusStart / derivation.steps return getGeometryOutputByStep(elementNode, derivation.end, loop, derivation.steps, stepVector) endMinusStartLengthOverStep = endMinusStartLength / derivation.step if typeStringTwoCharacters == 'av': derivation.steps = max(1.0, round(endMinusStartLengthOverStep)) stepVector = derivation.step / endMinusStartLength * endMinusStart derivation.end = derivation.start + stepVector * derivation.steps return getGeometryOutputByStep(elementNode, derivation.end, loop, derivation.steps, stepVector) if typeStringTwoCharacters == 'ma': derivation.steps = math.ceil(endMinusStartLengthOverStep) if derivation.steps < 1.0: return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop([derivation.start, derivation.end])) stepVector = endMinusStart / derivation.steps return getGeometryOutputByStep(elementNode, derivation.end, loop, derivation.steps, stepVector) if typeStringTwoCharacters == 'mi': derivation.steps = math.floor(endMinusStartLengthOverStep) if derivation.steps < 1.0: return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(loop)) stepVector = endMinusStart / derivation.steps return getGeometryOutputByStep(elementNode, derivation.end, loop, derivation.steps, stepVector) print('Warning, the step type was not one of (average, maximum or minimum) in getGeometryOutput in line for:') print(derivation.typeString) print(elementNode) loop.append(derivation.end) return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(loop))
def getGeometryOutput(derivation, xmlElement): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = ShaftDerivation(xmlElement) shaftPath = getShaftPath(derivation.depthBottom, derivation.depthTop, derivation.radius, derivation.sides) return lineation.getGeometryOutputByLoop(lineation.SideLoop(shaftPath), xmlElement)
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 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, elementNode): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = TeardropDerivation(elementNode) teardropPath = getTeardropPath(derivation.inclination, derivation.overhangRadians, derivation.overhangSpan, derivation.radiusArealized, derivation.sides) return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(teardropPath))
def getGeometryOutput(derivation, elementNode): 'Get triangle mesh from attribute dictionary.' if derivation == None: derivation = ConcatenateDerivation(elementNode) concatenatedList = euclidean.getConcatenatedList(derivation.target)[:] if len(concatenatedList) == 0: print('Warning, in concatenate there are no paths.') print(elementNode.attributes) return None if 'closed' not in elementNode.attributes: elementNode.attributes['closed'] = 'true' return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(concatenatedList))
def getGeometryOutput(derivation, xmlElement): 'Get triangle mesh from attribute dictionary.' if derivation == None: derivation = ConcatenateDerivation(xmlElement) concatenatedList = euclidean.getConcatenatedList(derivation.target)[:] if len(concatenatedList) == 0: print('Warning, in concatenate there are no paths.') print(xmlElement.attributeDictionary) return None if 'closed' not in xmlElement.attributeDictionary: xmlElement.attributeDictionary['closed'] = 'true' return lineation.getGeometryOutputByLoop( lineation.SideLoop(concatenatedList, None, None), xmlElement)
def getGeometryOutput(derivation, elementNode): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = PolygonDerivation(elementNode) loop = [] spiral = lineation.Spiral(derivation.spiral, 0.5 * derivation.sideAngle / math.pi) for side in xrange(derivation.start, derivation.start + derivation.extent + 1): angle = float(side) * derivation.sideAngle unitPolar = euclidean.getWiddershinsUnitPolar(angle) vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * derivation.radius.real, unitPolar.imag * derivation.radius.imag)) loop.append(vertex) loop = euclidean.getLoopWithoutCloseEnds(0.000001 * max(derivation.radius.real, derivation.radius.imag), loop) lineation.setClosedAttribute(elementNode, derivation.revolutions) return lineation.getGeometryOutputByLoop(elementNode, lineation.SideLoop(loop, derivation.sideAngle))
def getGeometryOutput(derivation, xmlElement): "Get vector3 vertexes from attribute dictionary." if derivation == None: derivation = PolygonDerivation() derivation.setToXMLElement(xmlElement) loop = [] spiral = lineation.Spiral(derivation.spiral, 0.5 * derivation.sideAngle / math.pi) for side in xrange(derivation.start, derivation.end): angle = float(side) * derivation.sideAngle unitPolar = euclidean.getWiddershinsUnitPolar(angle) vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * derivation.radius.real, unitPolar.imag * derivation.radius.imag)) loop.append(vertex) sideLength = derivation.sideAngle * lineation.getRadiusAverage(derivation.radius) lineation.setClosedAttribute(derivation.revolutions, xmlElement) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, derivation.sideAngle, sideLength), xmlElement)
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 getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." halfX = 1.0 halfX = evaluate.getEvaluatedFloatDefault(halfX, 'halfx', xmlElement) halfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, 'width', xmlElement) bottomHalfX = evaluate.getEvaluatedFloatDefault(halfX, 'bottomhalfx', xmlElement) bottomHalfX = 0.5 * evaluate.getEvaluatedFloatDefault( halfX / 0.5, 'bottomwidth', xmlElement) topHalfX = evaluate.getEvaluatedFloatDefault(halfX, 'tophalfx', xmlElement) topHalfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, 'topwidth', xmlElement) halfY = halfX if '_arguments' in xmlElement.attributeDictionary: arguments = xmlElement.attributeDictionary['_arguments'] halfX = 0.5 * euclidean.getFloatFromValue(arguments[0]) xmlElement.attributeDictionary['halfX'] = str(halfX) if len(arguments) > 1: halfY = 0.5 * euclidean.getFloatFromValue(arguments[1]) else: halfY = halfX halfY = evaluate.getEvaluatedFloatDefault(halfY, 'halfy', xmlElement) halfY = 0.5 * evaluate.getEvaluatedFloatDefault(halfY / 0.5, 'height', xmlElement) interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, 'interiorangle', xmlElement) topRight = complex(topHalfX, halfY) topLeft = complex(-topHalfX, halfY) bottomLeft = complex(-bottomHalfX, -halfY) bottomRight = complex(bottomHalfX, -halfY) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar( math.radians(interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft loop = [ Vector3(topRight.real, topRight.imag), Vector3(topLeft.real, topLeft.imag), Vector3(bottomLeft.real, bottomLeft.imag), Vector3(bottomRight.real, bottomRight.imag) ] return lineation.getGeometryOutputByLoop( None, lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." sides = evaluate.getEvaluatedFloatDefault(4.0, 'sides', xmlElement) sideAngle = 2.0 * math.pi / sides radius = complex(1.0, 1.0) radius = lineation.getComplexByMultiplierPrefixes(math.cos(0.5 * sideAngle), ['apothem', 'inradius'], radius, xmlElement) radius = lineation.getComplexByPrefixes(['demisize', 'radius'], radius, xmlElement) radius = lineation.getComplexByMultiplierPrefixes(2.0, ['diameter', 'size'], radius, xmlElement) loop = [] sidesCeiling = int(math.ceil(abs(sides))) startEnd = lineation.StartEnd(sidesCeiling, '', xmlElement) spiral = lineation.Spiral(0.5 * sideAngle / math.pi, xmlElement) for side in xrange(startEnd.start, startEnd.end): angle = float(side) * sideAngle unitPolar = euclidean.getWiddershinsUnitPolar(angle) vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * radius.real, unitPolar.imag * radius.imag)) loop.append(vertex) sideLength = sideAngle * lineation.getAverageRadius(radius) lineation.setClosedAttribute(startEnd.revolutions, xmlElement) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(1.0, 1.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) bottomDemiwidth = lineation.getFloatByPrefixBeginEnd( 'bottomdemiwidth', 'bottomwidth', demiwidth, xmlElement) topDemiwidth = lineation.getFloatByPrefixBeginEnd('topdemiwidth', 'topwidth', demiwidth, xmlElement) interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, 'interiorangle', xmlElement) topRight = complex(topDemiwidth, demiheight) topLeft = complex(-topDemiwidth, demiheight) bottomLeft = complex(-bottomDemiwidth, -demiheight) bottomRight = complex(bottomDemiwidth, -demiheight) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar( math.radians(interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft revolutions = evaluate.getEvaluatedIntOne('revolutions', xmlElement) lineation.setClosedAttribute(revolutions, xmlElement) complexLoop = [topRight, topLeft, bottomLeft, bottomRight] originalLoop = complexLoop[:] for revolution in xrange(1, revolutions): complexLoop += originalLoop spiral = lineation.Spiral(0.25, xmlElement) loop = [] loopCentroid = euclidean.getLoopCentroid(originalLoop) for point in complexLoop: unitPolar = euclidean.getNormalized(point - loopCentroid) loop.append( spiral.getSpiralPoint(unitPolar, Vector3(point.real, point.imag))) return lineation.getGeometryOutputByLoop( lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
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." start = evaluate.getVector3ByPrefix('start', Vector3(), xmlElement) end = evaluate.getVector3ByPrefix('end', Vector3(), xmlElement) endMinusStart = end - start endMinusStartLength = abs(endMinusStart) if endMinusStartLength <= 0.0: print( 'Warning, end is the same as start in getGeometryOutput in line for:' ) print(start) print(end) print(xmlElement) return None steps = evaluate.getEvaluatedFloatDefault(None, 'steps', xmlElement) step = evaluate.getEvaluatedFloatDefault(None, 'step', xmlElement) xmlElement.attributeDictionary['closed'] = str( evaluate.getEvaluatedBooleanDefault(False, 'closed', xmlElement)) if step == None and steps == None: return lineation.getGeometryOutputByLoop( lineation.SideLoop([start, end]), xmlElement) loop = [start] if step != None and steps != None: stepVector = step / endMinusStartLength * endMinusStart end = start + stepVector * steps return getGeometryOutputByStep(end, loop, steps, stepVector, xmlElement) if step == None: stepVector = endMinusStart / steps return getGeometryOutputByStep(end, loop, steps, stepVector, xmlElement) typeString = evaluate.getEvaluatedStringDefault('minimum', 'type', xmlElement) endMinusStartLengthOverStep = endMinusStartLength / step if typeString == 'average': steps = max(1.0, round(endMinusStartLengthOverStep)) stepVector = step / endMinusStartLength * endMinusStart end = start + stepVector * steps return getGeometryOutputByStep(end, loop, steps, stepVector, xmlElement) if typeString == 'maximum': steps = math.ceil(endMinusStartLengthOverStep) if steps < 1.0: return lineation.getGeometryOutputByLoop( lineation.SideLoop([start, end]), xmlElement) stepVector = endMinusStart / steps return getGeometryOutputByStep(end, loop, steps, stepVector, xmlElement) if typeString == 'minimum': steps = math.floor(endMinusStartLengthOverStep) if steps < 1.0: return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop), xmlElement) stepVector = endMinusStart / steps return getGeometryOutputByStep(end, loop, steps, stepVector, xmlElement) print( 'Warning, the step type was not one of (average, maximum or minimum) in getGeometryOutput in line for:' ) print(typeString) print(xmlElement) loop.append(end) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop), xmlElement)