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, xmlElement): "Get triangle mesh from attribute dictionary." if derivation == None: derivation = ExtrudeDerivation() derivation.setToXMLElement(xmlElement) if derivation.radius != complex(): maximumRadius = max(derivation.radius.real, derivation.radius.imag) sides = int( math.ceil( evaluate.getSidesMinimumThreeBasedOnPrecisionSides( maximumRadius, xmlElement))) loop = [] sideAngle = 2.0 * math.pi / sides angleTotal = 0.0 for side in xrange(sides): point = euclidean.getWiddershinsUnitPolar(angleTotal) loop.append( Vector3(point.real * derivation.radius.real, point.imag * derivation.radius.imag)) angleTotal += sideAngle derivation.target = [loop] + derivation.target if len(euclidean.getConcatenatedList(derivation.target)) == 0: print('Warning, in extrude there are no paths.') print(xmlElement.attributeDictionary) return None negatives = [] positives = [] addNegativesPositives(derivation, negatives, derivation.target, positives) return getGeometryOutputByNegativesPositives(derivation, negatives, positives, xmlElement)
def getTeardropPathByEndStart(elementNode, end, radius, start): "Get vector3 teardrop path by end and start." inclination = getInclination(end, start) sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides( elementNode, radius) radiusArealized = evaluate.getRadiusArealizedBasedOnAreaRadius( elementNoderadius, sides) return getTeardropPath( inclination, setting.getOverhangRadians(elementNode), setting.getOverhangSpan(elementNode), radiusArealized, sides)
def getTeardropPathByEndStart(elementNode, end, radius, start): "Get vector3 teardrop path by end and start." inclination = getInclination(end, start) sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides( elementNode, radius) radiusArealized = evaluate.getRadiusArealizedBasedOnAreaRadius( elementNoderadius, sides) return getTeardropPath(inclination, setting.getOverhangRadians(elementNode), setting.getOverhangSpan(elementNode), radiusArealized, sides)
def __init__(self, xmlElement): 'Set defaults.' self.radius = lineation.getRadiusComplex(complex(1.0, 1.0), xmlElement) self.sides = evaluate.getEvaluatedFloatDefault(None, 'sides', xmlElement) if self.sides == None: radiusMaximum = max(self.radius.real, self.radius.imag) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(radiusMaximum, xmlElement) self.start = evaluate.getEvaluatedFloatDefault(0.0, 'start', xmlElement) end = evaluate.getEvaluatedFloatDefault(360.0, 'end', xmlElement) self.revolutions = evaluate.getEvaluatedFloatDefault(1.0, 'revolutions', xmlElement) self.extent = evaluate.getEvaluatedFloatDefault(end - self.start, 'extent', xmlElement) self.extent += 360.0 * (self.revolutions - 1.0) self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
def __init__(self, elementNode): 'Set defaults.' self.axisEnd = evaluate.getVector3ByPrefix(None, elementNode, 'axisEnd') self.axisStart = evaluate.getVector3ByPrefix(None, elementNode, 'axisStart') self.end = evaluate.getEvaluatedFloat(360.0, elementNode, 'end') self.loop = evaluate.getTransformedPathByKey([], elementNode, 'loop') self.sides = evaluate.getEvaluatedInt(None, elementNode, 'sides') self.start = evaluate.getEvaluatedFloat(0.0, elementNode, 'start') self.target = evaluate.getTransformedPathsByKey([], elementNode, 'target') if len(self.target) < 1: print('Warning, no target in derive in lathe for:') print(elementNode) return firstPath = self.target[0] if len(firstPath) < 3: print('Warning, firstPath length is less than three in derive in lathe for:') print(elementNode) self.target = [] return if self.axisStart == None: if self.axisEnd == None: self.axisStart = firstPath[0] self.axisEnd = firstPath[-1] else: self.axisStart = Vector3() self.axis = self.axisEnd - self.axisStart axisLength = abs(self.axis) if axisLength <= 0.0: print('Warning, axisLength is zero in derive in lathe for:') print(elementNode) self.target = [] return self.axis /= axisLength firstVector3 = firstPath[1] - self.axisStart firstVector3Length = abs(firstVector3) if firstVector3Length <= 0.0: print('Warning, firstVector3Length is zero in derive in lathe for:') print(elementNode) self.target = [] return firstVector3 /= firstVector3Length self.axisProjectiveSpace = euclidean.ProjectiveSpace().getByBasisZFirst(self.axis, firstVector3) if self.sides == None: distanceToLine = euclidean.getDistanceToLineByPaths(self.axisStart, self.axisEnd, self.target) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(elementNode, distanceToLine) endRadian = math.radians(self.end) startRadian = math.radians(self.start) self.isEndCloseToStart = euclidean.getIsRadianClose(endRadian, startRadian) if len(self.loop) < 1: self.loop = euclidean.getComplexPolygonByStartEnd(endRadian, 1.0, self.sides, startRadian) self.normal = euclidean.getNormalByPath(firstPath)
def __init__(self, elementNode): 'Set defaults.' self.radius = lineation.getRadiusComplex(elementNode, complex(1.0, 1.0)) self.sides = evaluate.getEvaluatedFloat(None, elementNode, 'sides') if self.sides == None: radiusMaximum = max(self.radius.real, self.radius.imag) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(elementNode, radiusMaximum) self.radiusArealized = evaluate.getRadiusArealizedBasedOnAreaRadius(elementNode, self.radius, self.sides) self.start = evaluate.getEvaluatedFloat(0.0, elementNode, 'start') end = evaluate.getEvaluatedFloat(360.0, elementNode, 'end') self.revolutions = evaluate.getEvaluatedFloat(1.0, elementNode, 'revolutions') self.extent = evaluate.getEvaluatedFloat(end - self.start, elementNode, 'extent') self.extent += 360.0 * (self.revolutions - 1.0) self.spiral = evaluate.getVector3ByPrefix(None, elementNode, 'spiral')
def setToXMLElement(self, xmlElement): "Set to the xmlElement." self.radius = lineation.getRadiusComplex(self.radius, xmlElement) if self.sides == None: self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(max(self.radius.real, self.radius.imag), xmlElement) self.start = evaluate.getEvaluatedFloatDefault(self.start, 'start', xmlElement) self.start = getWrappedFloat(self.start, 360.0) self.extent = evaluate.getEvaluatedFloatDefault(360.0 - self.start, 'extent', xmlElement) self.end = evaluate.getEvaluatedFloatDefault(self.start + self.extent, 'end', xmlElement) self.end = getWrappedFloat(self.end, 360.0) self.revolutions = evaluate.getEvaluatedFloatDefault(self.revolutions, 'revolutions', xmlElement) if self.revolutions > 1: self.end += 360.0 * (self.revolutions - 1) self.extent = self.end - self.start self.spiral = evaluate.getVector3ByPrefix('spiral', self.spiral, xmlElement)
def __init__(self, xmlElement): 'Set defaults.' self.radius = lineation.getRadiusComplex(complex(1.0, 1.0), xmlElement) self.sides = evaluate.getEvaluatedFloat(None, 'sides', xmlElement) if self.sides == None: radiusMaximum = max(self.radius.real, self.radius.imag) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(radiusMaximum, xmlElement) self.circularizedRadius = self.radius if evaluate.getEvaluatedBoolean(False, 'areaRadius', xmlElement): self.circularizedRadius *= euclidean.getAreaRadiusMultiplier(self.sides) self.start = evaluate.getEvaluatedFloat(0.0, 'start', xmlElement) end = evaluate.getEvaluatedFloat(360.0, 'end', xmlElement) self.revolutions = evaluate.getEvaluatedFloat(1.0, 'revolutions', xmlElement) self.extent = evaluate.getEvaluatedFloat(end - self.start, 'extent', xmlElement) self.extent += 360.0 * (self.revolutions - 1.0) self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
def __init__(self, elementNode): 'Set defaults.' end = evaluate.getVector3ByPrefix(None, elementNode, 'end') start = evaluate.getVector3ByPrefix(Vector3(), elementNode, 'start') inclinationDegree = math.degrees(getInclination(end, start)) self.elementNode = elementNode self.inclination = math.radians(evaluate.getEvaluatedFloat(inclinationDegree, elementNode, 'inclination')) self.overhangRadians = setting.getOverhangRadians(elementNode) self.overhangSpan = setting.getOverhangSpan(elementNode) self.radius = lineation.getFloatByPrefixBeginEnd(elementNode, 'radius', 'diameter', 1.0) size = evaluate.getEvaluatedFloat(None, elementNode, 'size') if size != None: self.radius = 0.5 * size self.sides = evaluate.getEvaluatedFloat(None, elementNode, 'sides') if self.sides == None: self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(elementNode, self.radius) self.radiusArealized = evaluate.getRadiusArealizedBasedOnAreaRadius(elementNode, self.radius, self.sides)
def __init__(self, elementNode): 'Set defaults.' self.radius = lineation.getRadiusComplex(elementNode, complex(1.0, 1.0)) self.sides = evaluate.getEvaluatedFloat(None, elementNode, 'sides') if self.sides == None: radiusMaximum = max(self.radius.real, self.radius.imag) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides( elementNode, radiusMaximum) self.radiusArealized = evaluate.getRadiusArealizedBasedOnAreaRadius( elementNode, self.radius, self.sides) self.start = evaluate.getEvaluatedFloat(0.0, elementNode, 'start') end = evaluate.getEvaluatedFloat(360.0, elementNode, 'end') self.revolutions = evaluate.getEvaluatedFloat(1.0, elementNode, 'revolutions') self.extent = evaluate.getEvaluatedFloat(end - self.start, elementNode, 'extent') self.extent += 360.0 * (self.revolutions - 1.0) self.spiral = evaluate.getVector3ByPrefix(None, elementNode, 'spiral')
def getGeometryOutput(derivation, xmlElement): 'Get triangle mesh from attribute dictionary.' if derivation == None: derivation = ExtrudeDerivation(xmlElement) if derivation.radius != complex(): maximumRadius = max(derivation.radius.real, derivation.radius.imag) sides = int(math.ceil(evaluate.getSidesMinimumThreeBasedOnPrecisionSides(maximumRadius, xmlElement))) loop = [] sideAngle = 2.0 * math.pi / sides angleTotal = 0.0 for side in xrange(sides): point = euclidean.getWiddershinsUnitPolar(angleTotal) loop.append(Vector3(point.real * derivation.radius.real, point.imag * derivation.radius.imag)) angleTotal += sideAngle derivation.target = [loop] + derivation.target if len(euclidean.getConcatenatedList(derivation.target)) == 0: print('Warning, in extrude there are no paths.') print(xmlElement.attributeDictionary) return None return getGeometryOutputByLoops(derivation, derivation.target)
def __init__(self, xmlElement): 'Set defaults.' self.radius = lineation.getRadiusComplex(complex(1.0, 1.0), xmlElement) self.sides = evaluate.getEvaluatedFloat(None, 'sides', xmlElement) if self.sides == None: radiusMaximum = max(self.radius.real, self.radius.imag) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides( radiusMaximum, xmlElement) self.circularizedRadius = self.radius if evaluate.getEvaluatedBoolean(False, 'areaRadius', xmlElement): self.circularizedRadius *= euclidean.getAreaRadiusMultiplier( self.sides) self.start = evaluate.getEvaluatedFloat(0.0, 'start', xmlElement) end = evaluate.getEvaluatedFloat(360.0, 'end', xmlElement) self.revolutions = evaluate.getEvaluatedFloat(1.0, 'revolutions', xmlElement) self.extent = evaluate.getEvaluatedFloat(end - self.start, 'extent', xmlElement) self.extent += 360.0 * (self.revolutions - 1.0) self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
def derive(self, xmlElement): "Derive using the xmlElement." if len(self.target) < 1: print('Warning, no target in derive in lathe for:') print(xmlElement) return firstPath = self.target[0] if len(firstPath) < 3: print('Warning, firstPath length is less than three in derive in lathe for:') print(xmlElement) self.target = [] return if self.axisStart == None: if self.axisEnd == None: self.axisStart = firstPath[0] self.axisEnd = firstPath[-1] else: self.axisStart = Vector3() self.axis = self.axisEnd - self.axisStart axisLength = abs(self.axis) if axisLength <= 0.0: print('Warning, axisLength is zero in derive in lathe for:') print(xmlElement) self.target = [] return self.axis /= axisLength firstVector3 = firstPath[1] - self.axisStart firstVector3Length = abs(firstVector3) if firstVector3Length <= 0.0: print('Warning, firstVector3Length is zero in derive in lathe for:') print(xmlElement) self.target = [] return firstVector3 /= firstVector3Length self.axisProjectiveSpace = euclidean.ProjectiveSpace().getByBasisZFirst(self.axis, firstVector3) if self.sides == None: distanceToLine = euclidean.getDistanceToLineByPaths(self.axisStart, self.axisEnd, self.target) self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(distanceToLine, xmlElement) if len(self.loop) < 1: self.loop = euclidean.getComplexPolygonByStartEnd(math.radians(self.end), 1.0, self.sides, math.radians(self.start)) self.normal = euclidean.getNormalByPath(firstPath)
def setToXMLElement(self, xmlElement): "Set to the xmlElement." self.radius = lineation.getRadiusComplex(self.radius, xmlElement) if self.sides == None: self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides( max(self.radius.real, self.radius.imag), xmlElement) self.start = evaluate.getEvaluatedFloatDefault(self.start, 'start', xmlElement) self.start = getWrappedFloat(self.start, 360.0) self.extent = evaluate.getEvaluatedFloatDefault( 360.0 - self.start, 'extent', xmlElement) self.end = evaluate.getEvaluatedFloatDefault(self.start + self.extent, 'end', xmlElement) self.end = getWrappedFloat(self.end, 360.0) self.revolutions = evaluate.getEvaluatedFloatDefault( self.revolutions, 'revolutions', xmlElement) if self.revolutions > 1: self.end += 360.0 * (self.revolutions - 1) self.extent = self.end - self.start self.spiral = evaluate.getVector3ByPrefix('spiral', self.spiral, xmlElement)
def getGeometryOutput(xmlElement): "Get triangle mesh from attribute dictionary." paths = evaluate.getTransformedPathsByKey('target', xmlElement) radius = lineation.getRadiusComplex(complex(), xmlElement) if radius != complex(): sides = int(math.ceil(evaluate.getSidesMinimumThreeBasedOnPrecisionSides(max(radius.real, radius.imag), xmlElement))) loop = [] sideAngle = 2.0 * math.pi / sides angleTotal = 0.0 for side in xrange(sides): point = euclidean.getWiddershinsUnitPolar(angleTotal) loop.append(Vector3(point.real * radius.real, point.imag * radius.imag)) angleTotal += sideAngle paths = [loop] + paths if len(euclidean.getConcatenatedList(paths)) == 0: print('Warning, in extrude there are no paths.') print(xmlElement.attributeDictionary) return None extrudeDerivation = ExtrudeDerivation() extrudeDerivation.setToXMLElement(xmlElement) return getGeometryOutputByExtrudePaths(extrudeDerivation, paths, xmlElement)
def __init__(self, elementNode): 'Set defaults.' end = evaluate.getVector3ByPrefix(None, elementNode, 'end') start = evaluate.getVector3ByPrefix(Vector3(), elementNode, 'start') inclinationDegree = math.degrees(getInclination(end, start)) self.elementNode = elementNode self.inclination = math.radians( evaluate.getEvaluatedFloat(inclinationDegree, elementNode, 'inclination')) self.overhangRadians = setting.getOverhangRadians(elementNode) self.overhangSpan = setting.getOverhangSpan(elementNode) self.radius = lineation.getFloatByPrefixBeginEnd( elementNode, 'radius', 'diameter', 1.0) size = evaluate.getEvaluatedFloat(None, elementNode, 'size') if size != None: self.radius = 0.5 * size self.sides = evaluate.getEvaluatedFloat(None, elementNode, 'sides') if self.sides == None: self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides( elementNode, self.radius) self.radiusArealized = evaluate.getRadiusArealizedBasedOnAreaRadius( elementNode, self.radius, self.sides)