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 __init__(self, modulo, prefix, xmlElement): "Initialize." self.start = evaluate.getEvaluatedIntZero(prefix + 'start', xmlElement) self.start = getWrappedInteger(self.start, modulo) self.extent = evaluate.getEvaluatedIntDefault(modulo - self.start, prefix + 'extent', xmlElement) self.end = evaluate.getEvaluatedIntDefault(self.start + self.extent, prefix + 'end', xmlElement) self.end = getWrappedInteger(self.end, modulo) self.revolutions = evaluate.getEvaluatedIntOne(prefix + 'revolutions', xmlElement) if self.revolutions > 1: self.end += modulo * (self.revolutions - 1)
def getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." paths = evaluate.getPathsByKeys(['crosssection', 'section', 'target'], xmlElement) if len(euclidean.getConcatenatedList(paths)) == 0: print('Warning, in extrude there are no paths.') print(xmlElement.attributeDictionary) return None offsetPathDefault = [Vector3(), Vector3(0.0, 0.0, 1.0)] extrude = Extrude() extrude.tiltFollow = evaluate.getEvaluatedBooleanDefault( extrude.tiltFollow, 'tiltfollow', xmlElement) extrude.tiltTop = evaluate.getVector3ByPrefix('tilttop', extrude.tiltTop, xmlElement) extrude.maximumUnbuckling = evaluate.getEvaluatedFloatDefault( 5.0, 'maximumunbuckling', xmlElement) scalePathDefault = [Vector3(1.0, 1.0, 0.0), Vector3(1.0, 1.0, 1.0)] extrude.interpolationDictionary['scale'] = evaluate.Interpolation( ).getByPrefixZ(scalePathDefault, 'scale', xmlElement) if extrude.tiltTop == None: extrude.interpolationDictionary['offset'] = evaluate.Interpolation( ).getByPrefixZ(offsetPathDefault, '', xmlElement) tiltPathDefault = [Vector3(), Vector3(0.0, 0.0, 1.0)] interpolationTilt = evaluate.Interpolation().getByPrefixZ( tiltPathDefault, 'tilt', xmlElement) extrude.interpolationDictionary['tilt'] = interpolationTilt for point in interpolationTilt.path: point.x = math.radians(point.x) point.y = math.radians(point.y) else: offsetAlongDefault = [Vector3(), Vector3(1.0, 0.0, 0.0)] extrude.interpolationDictionary['offset'] = evaluate.Interpolation( ).getByPrefixAlong(offsetAlongDefault, '', xmlElement) insertTwistPortions(extrude.interpolationDictionary, xmlElement) segments = evaluate.getEvaluatedIntOne('segments', xmlElement) negatives = [] positives = [] portionDirections = evaluate.getSpacedPortionDirections( extrude.interpolationDictionary) for path in paths: endMultiplier = None if not euclidean.getIsWiddershinsByVector3(path): endMultiplier = 1.000001 geometryOutput = getGeometryOutputByPath(endMultiplier, extrude, path, portionDirections) if endMultiplier == None: positives.append(geometryOutput) else: negatives.append(geometryOutput) positiveOutput = trianglemesh.getUnifiedOutput(positives) if len(negatives) < 1: return positiveOutput return {'difference': [positiveOutput] + negatives}
def __init__(self, modulo, prefix, xmlElement): "Initialize." self.start = evaluate.getEvaluatedIntZero(prefix + 'start', xmlElement) self.start = getWrappedInteger(self.start, modulo) self.extent = evaluate.getEvaluatedIntDefault(modulo - self.start, prefix + 'extent', xmlElement) self.end = evaluate.getEvaluatedIntDefault(self.start + self.extent, prefix + 'end', xmlElement) self.end = getWrappedInteger(self.end, modulo) self.revolutions = evaluate.getEvaluatedIntOne(prefix + 'revolutions', xmlElement) if self.revolutions > 1: self.end += modulo * (self.revolutions - 1)
def getGeometryOutput(xmlElement): "Get triangle mesh from attribute dictionary." paths = evaluate.getPathsByKeys( ['crosssection', 'section', 'target'], xmlElement ) if len( euclidean.getConcatenatedList( paths ) ) == 0: print('Warning, in extrude there are no paths.') print( xmlElement.attributeDictionary ) return None offsetPathDefault = [ Vector3(), Vector3( 0.0, 0.0, 1.0 ) ] extrude = Extrude() extrude.tiltFollow = evaluate.getEvaluatedBooleanDefault( extrude.tiltFollow, 'tiltfollow', xmlElement ) extrude.tiltTop = evaluate.getVector3ByPrefix('tilttop', extrude.tiltTop, xmlElement ) extrude.maximumUnbuckling = evaluate.getEvaluatedFloatDefault( 5.0, 'maximumunbuckling', xmlElement ) scalePathDefault = [ Vector3( 1.0, 1.0, 0.0 ), Vector3( 1.0, 1.0, 1.0 ) ] extrude.interpolationDictionary['scale'] = Interpolation().getByPrefixZ( scalePathDefault, 'scale', xmlElement ) if extrude.tiltTop == None: extrude.interpolationDictionary['offset'] = Interpolation().getByPrefixZ( offsetPathDefault, '', xmlElement ) tiltPathDefault = [ Vector3(), Vector3( 0.0, 0.0, 1.0 ) ] interpolationTilt = Interpolation().getByPrefixZ( tiltPathDefault, 'tilt', xmlElement ) extrude.interpolationDictionary['tilt'] = interpolationTilt for point in interpolationTilt.path: point.x = math.radians( point.x ) point.y = math.radians( point.y ) else: offsetAlongDefault = [ Vector3(), Vector3( 1.0, 0.0, 0.0 ) ] extrude.interpolationDictionary['offset'] = Interpolation().getByPrefixAlong( offsetAlongDefault, '', xmlElement ) insertTwistPortions( extrude.interpolationDictionary, xmlElement ) segments = evaluate.getEvaluatedIntOne('segments', xmlElement ) negatives = [] positives = [] portionDirections = getSpacedPortionDirections( extrude.interpolationDictionary ) for path in paths: endMultiplier = None if not euclidean.getIsWiddershinsByVector3( path ): endMultiplier = 1.000001 geometryOutput = getGeometryOutputByPath( endMultiplier, extrude, path, portionDirections ) if endMultiplier == None: positives.append( geometryOutput ) else: negatives.append( geometryOutput ) positiveOutput = trianglemesh.getUnifiedOutput( positives ) interpolationOffset = extrude.interpolationDictionary['offset'] if len( negatives ) < 1: return getGeometryOutputWithConnection( positiveOutput, interpolationOffset, xmlElement ) return getGeometryOutputWithConnection( { 'difference' : [ positiveOutput ] + negatives }, interpolationOffset, 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)