def __init__(self, elementNode): 'Initialize.' elementNode.attributes['closed'] = 'true' self.density = evaluate.getEvaluatedFloat(1.0, elementNode, 'density') self.minimumRadiusOverThickness = evaluate.getEvaluatedFloat(1.0, elementNode, 'minimumRadiusOverThickness') self.mobile = evaluate.getEvaluatedBoolean(False, elementNode, 'mobile') self.inradius = lineation.getInradius(complex(10.0, 10.0), elementNode) self.path = None if 'path' in elementNode.attributes: self.path = evaluate.getPathByKey([], elementNode, 'path') self.searchAttempts = evaluate.getEvaluatedInt(0, elementNode, 'searchAttempts') self.searchRadiusOverRadius = evaluate.getEvaluatedFloat(1.0, elementNode, 'searchRadiusOverRadius') self.seed = evaluate.getEvaluatedInt(None, elementNode, 'seed') self.wallThickness = evaluate.getEvaluatedFloat(2.0 * setting.getPerimeterWidth(elementNode), elementNode, 'wallThickness') # Set derived variables. self.halfWallThickness = 0.5 * self.wallThickness self.inradiusMinusThickness = self.inradius - complex(self.wallThickness, self.wallThickness) self.minimumRadius = evaluate.getEvaluatedFloat(self.minimumRadiusOverThickness * self.wallThickness, elementNode, 'minimumRadius') self.inradiusMinusRadiusThickness = self.inradiusMinusThickness - complex(self.minimumRadius, self.minimumRadius) self.potentialBubbleArea = 4.0 * self.inradiusMinusThickness.real * self.inradiusMinusThickness.imag if self.path is None: radiusPlusHalfThickness = self.minimumRadius + self.halfWallThickness numberOfPoints = int(math.ceil(self.density * self.potentialBubbleArea / math.pi / radiusPlusHalfThickness / radiusPlusHalfThickness)) self.path = [] if self.seed is None: self.seed = time.time() print('Sponge slice seed used was: %s' % self.seed) random.seed(self.seed) for pointIndex in xrange(numberOfPoints): point = euclidean.getRandomComplex(-self.inradiusMinusRadiusThickness, self.inradiusMinusRadiusThickness) self.path.append(Vector3(point.real, point.imag))
def __init__(self, elementNode): 'Set defaults.' self.inradius = lineation.getInradius(complex(1.0, 1.0), elementNode) self.demiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'demiwidth', 'width', self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd(elementNode, 'demiheight', 'height', self.inradius.imag) self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'bottomdemiwidth', 'bottomwidth', self.demiwidth) self.topDemiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'topdemiwidth', 'topwidth', self.demiwidth) self.interiorAngle = evaluate.getEvaluatedFloat(90.0, elementNode, 'interiorangle') self.revolutions = evaluate.getEvaluatedInt(1, elementNode, 'revolutions') self.spiral = evaluate.getVector3ByPrefix(None, elementNode, 'spiral')
def __init__(self, elementNode): "Set defaults." self.inradius = lineation.getInradius(complex(1.0, 1.0), elementNode) self.demiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, "demiwidth", "width", self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd(elementNode, "demiheight", "height", self.inradius.imag) self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd( elementNode, "bottomdemiwidth", "bottomwidth", self.demiwidth ) self.topDemiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, "topdemiwidth", "topwidth", self.demiwidth) self.interiorAngle = evaluate.getEvaluatedFloat(90.0, elementNode, "interiorangle") self.revolutions = evaluate.getEvaluatedInt(1, elementNode, "revolutions") self.spiral = evaluate.getVector3ByPrefix(None, elementNode, "spiral")
def __init__(self, elementNode): 'Set defaults.' self.inradius = lineation.getInradius(complex(10.0, 10.0), elementNode) self.demiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'demiwidth', 'width', self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd(elementNode, 'demiheight', 'height', self.inradius.imag) self.density = evaluate.getEvaluatedFloat(0.2, elementNode, 'density') self.radius = lineation.getComplexByPrefixBeginEnd(elementNode, 'elementRadius', 'elementDiameter', complex(1.0, 1.0)) self.radius = lineation.getComplexByPrefixBeginEnd(elementNode, 'radius', 'diameter', self.radius) self.seed = evaluate.getEvaluatedInt(None, elementNode, 'seed') self.target = evaluate.getTransformedPathsByKey([], elementNode, 'target') self.typeMenuRadioStrings = 'hexagonal random rectangular'.split() self.typeString = evaluate.getEvaluatedString('rectangular', elementNode, 'type') self.zigzag = evaluate.getEvaluatedBoolean(True, elementNode, 'zigzag')
def __init__(self, elementNode): "Set defaults." self.inradius = lineation.getInradius(complex(10.0, 10.0), elementNode) self.demiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, "demiwidth", "width", self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd(elementNode, "demiheight", "height", self.inradius.imag) self.density = evaluate.getEvaluatedFloat(0.2, elementNode, "density") self.radius = lineation.getComplexByPrefixBeginEnd( elementNode, "elementRadius", "elementDiameter", complex(1.0, 1.0) ) self.radius = lineation.getComplexByPrefixBeginEnd(elementNode, "radius", "diameter", self.radius) self.seed = evaluate.getEvaluatedInt(None, elementNode, "seed") self.target = evaluate.getTransformedPathsByKey([], elementNode, "target") self.typeMenuRadioStrings = "hexagonal random rectangular".split() self.typeString = evaluate.getEvaluatedString("rectangular", elementNode, "type") self.zigzag = evaluate.getEvaluatedBoolean(True, elementNode, "zigzag")
def __init__(self, elementNode): 'Set defaults.' self.inradius = lineation.getInradius(complex(10.0, 10.0), elementNode) self.demiwidth = lineation.getFloatByPrefixBeginEnd( elementNode, 'demiwidth', 'width', self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd( elementNode, 'demiheight', 'height', self.inradius.imag) self.density = evaluate.getEvaluatedFloat(0.2, elementNode, 'density') self.radius = lineation.getComplexByPrefixBeginEnd( elementNode, 'elementRadius', 'elementDiameter', complex(1.0, 1.0)) self.radius = lineation.getComplexByPrefixBeginEnd( elementNode, 'radius', 'diameter', self.radius) self.seed = evaluate.getEvaluatedInt(None, elementNode, 'seed') self.target = evaluate.getTransformedPathsByKey([], elementNode, 'target') self.typeMenuRadioStrings = 'hexagonal random rectangular'.split() self.typeString = evaluate.getEvaluatedString('rectangular', elementNode, 'type') self.zigzag = evaluate.getEvaluatedBoolean(True, elementNode, 'zigzag')