Beispiel #1
0
def getLoopLayersSetCopy(elementNode, geometryOutput, importRadius, radius):
    'Get the loop layers and set the copyShallow.'
    halfLayerHeight = 0.5 * radius
    copyShallow = elementNode.getCopyShallow()
    processElementNodeByGeometry(copyShallow, geometryOutput)
    targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
    matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix)
    transformedVertexes = copyShallow.xmlObject.getTransformedVertexes()
    minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject)
    if minimumZ == None:
        copyShallow.parentNode.xmlObject.archivableObjects.remove(
            copyShallow.xmlObject)
        return []
    maximumZ = euclidean.getTopPath(transformedVertexes)
    copyShallow.attributes['visible'] = True
    copyShallowObjects = [copyShallow.xmlObject]
    bottomLoopLayer = euclidean.LoopLayer(minimumZ)
    z = minimumZ + 0.1 * radius
    zoneArrangement = triangle_mesh.ZoneArrangement(radius,
                                                    transformedVertexes)
    bottomLoopLayer.loops = boolean_geometry.getEmptyZLoops(
        copyShallowObjects, importRadius, False, z, zoneArrangement)
    loopLayers = [bottomLoopLayer]
    z = minimumZ + halfLayerHeight
    loopLayers += boolean_geometry.getLoopLayers(copyShallowObjects,
                                                 importRadius, halfLayerHeight,
                                                 maximumZ, False, z,
                                                 zoneArrangement)
    copyShallow.parentNode.xmlObject.archivableObjects.remove(
        copyShallow.xmlObject)
    return loopLayers
Beispiel #2
0
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix):
	'Get inset geometryOutput.'
	derivation = InsetDerivation(elementNode, prefix)
	if derivation.radius == 0.0:
		return geometryOutput
	copyShallow = elementNode.getCopyShallow()
	solid.processElementNodeByGeometry(copyShallow, geometryOutput)
	targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
	matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix)
	transformedVertexes = copyShallow.xmlObject.getTransformedVertexes()
	minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject)
	maximumZ = euclidean.getTopPath(transformedVertexes)
	layerThickness = setting.getLayerThickness(elementNode)
	importRadius = setting.getImportRadius(elementNode)
	zoneArrangement = triangle_mesh.ZoneArrangement(layerThickness, transformedVertexes)
	copyShallow.attributes['visible'] = True
	copyShallowObjects = [copyShallow.xmlObject]
	bottomLoopLayer = euclidean.LoopLayer(minimumZ)
	z = minimumZ + 0.1 * layerThickness
	bottomLoopLayer.loops = boolean_geometry.getEmptyZLoops(copyShallowObjects, importRadius, False, z, zoneArrangement)
	loopLayers = [bottomLoopLayer]
	z = minimumZ + layerThickness
	loopLayers += boolean_geometry.getLoopLayers(copyShallowObjects, importRadius, layerThickness, maximumZ, False, z, zoneArrangement)
	copyShallow.parentNode.xmlObject.archivableObjects.remove(copyShallow.xmlObject)
	belowLoop = []
	diagonalRadius = math.sqrt(0.5) * derivation.radius
	insetDiagonalLoops = []
	loops = []
	vertexes = []
	for loopLayer in loopLayers:
		insetDiagonalLoops.append(intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], diagonalRadius))
	for loopLayerIndex, loopLayer in enumerate(loopLayers):
		vector3Loop = []
		insetLoop = intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0], derivation.radius)
		loopLists = [[getLoopOrEmpty(loopLayerIndex - 1, insetDiagonalLoops)], [insetLoop]]
		largestLoop = euclidean.getLargestLoop(boolean_solid.getLoopsIntersection(importRadius, loopLists))
		if evaluate.getEvaluatedBoolean(True, elementNode, prefix + 'insetTop'):
			loopLists = [[getLoopOrEmpty(loopLayerIndex + 1, insetDiagonalLoops)], [largestLoop]]
			largestLoop = euclidean.getLargestLoop(boolean_solid.getLoopsIntersection(importRadius, loopLists))
		for point in largestLoop:
			vector3Index = Vector3Index(len(vertexes), point.real, point.imag, loopLayer.z)
			vector3Loop.append(vector3Index)
			vertexes.append(vector3Index)
		if len(vector3Loop) > 0:
			loops.append(vector3Loop)
	if evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'addExtraTopLayer') and len(loops) > 0:
		topLoop = loops[-1]
		vector3Loop = []
		loops.append(vector3Loop)
		z = topLoop[0].z + layerThickness
		for point in topLoop:
			vector3Index = Vector3Index(len(vertexes), point.x, point.y, z)
			vector3Loop.append(vector3Index)
			vertexes.append(vector3Index)
	geometryOutput = triangle_mesh.getMeldedPillarOutput(loops)
	return geometryOutput
Beispiel #3
0
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)
Beispiel #4
0
def getLoopLayersSetCopy(elementNode, geometryOutput, importRadius, radius):
	'Get the loop layers and set the copyShallow.'
	halfLayerHeight = 0.5 * radius
	copyShallow = elementNode.getCopyShallow()
	processElementNodeByGeometry(copyShallow, geometryOutput)
	targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
	matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix)
	transformedVertexes = copyShallow.xmlObject.getTransformedVertexes()
	minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject)
	if minimumZ == None:
		copyShallow.parentNode.xmlObject.archivableObjects.remove(copyShallow.xmlObject)
		return []
	maximumZ = euclidean.getTopPath(transformedVertexes)
	copyShallow.attributes['visible'] = True
	copyShallowObjects = [copyShallow.xmlObject]
	bottomLoopLayer = euclidean.LoopLayer(minimumZ)
	z = minimumZ + 0.1 * radius
	zoneArrangement = triangle_mesh.ZoneArrangement(radius, transformedVertexes)
	bottomLoopLayer.loops = boolean_geometry.getEmptyZLoops(copyShallowObjects, importRadius, False, z, zoneArrangement)
	loopLayers = [bottomLoopLayer]
	z = minimumZ + halfLayerHeight
	loopLayers += boolean_geometry.getLoopLayers(copyShallowObjects, importRadius, halfLayerHeight, maximumZ, False, z, zoneArrangement)
	copyShallow.parentNode.xmlObject.archivableObjects.remove(copyShallow.xmlObject)
	return loopLayers
Beispiel #5
0
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix):
    'Get inset geometryOutput.'
    derivation = InsetDerivation(elementNode, prefix)
    if derivation.radius == 0.0:
        return geometryOutput
    copyShallow = elementNode.getCopyShallow()
    solid.processElementNodeByGeometry(copyShallow, geometryOutput)
    targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
    matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix)
    transformedVertexes = copyShallow.xmlObject.getTransformedVertexes()
    minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject)
    maximumZ = euclidean.getTopPath(transformedVertexes)
    layerThickness = setting.getLayerThickness(elementNode)
    importRadius = setting.getImportRadius(elementNode)
    zoneArrangement = triangle_mesh.ZoneArrangement(layerThickness,
                                                    transformedVertexes)
    copyShallow.attributes['visible'] = True
    copyShallowObjects = [copyShallow.xmlObject]
    bottomLoopLayer = euclidean.LoopLayer(minimumZ)
    z = minimumZ + 0.1 * layerThickness
    bottomLoopLayer.loops = boolean_geometry.getEmptyZLoops(
        copyShallowObjects, importRadius, False, z, zoneArrangement)
    loopLayers = [bottomLoopLayer]
    z = minimumZ + layerThickness
    loopLayers += boolean_geometry.getLoopLayers(copyShallowObjects,
                                                 importRadius, layerThickness,
                                                 maximumZ, False, z,
                                                 zoneArrangement)
    copyShallow.parentNode.xmlObject.archivableObjects.remove(
        copyShallow.xmlObject)
    belowLoop = []
    diagonalRadius = math.sqrt(0.5) * derivation.radius
    insetDiagonalLoops = []
    loops = []
    vertexes = []
    for loopLayer in loopLayers:
        insetDiagonalLoops.append(
            intercircle.getLargestInsetLoopFromLoop(loopLayer.loops[0],
                                                    diagonalRadius))
    for loopLayerIndex, loopLayer in enumerate(loopLayers):
        vector3Loop = []
        insetLoop = intercircle.getLargestInsetLoopFromLoop(
            loopLayer.loops[0], derivation.radius)
        loopLists = [[getLoopOrEmpty(loopLayerIndex - 1, insetDiagonalLoops)],
                     [insetLoop]]
        largestLoop = euclidean.getLargestLoop(
            boolean_solid.getLoopsIntersection(importRadius, loopLists))
        if evaluate.getEvaluatedBoolean(True, elementNode,
                                        prefix + 'insetTop'):
            loopLists = [[
                getLoopOrEmpty(loopLayerIndex + 1, insetDiagonalLoops)
            ], [largestLoop]]
            largestLoop = euclidean.getLargestLoop(
                boolean_solid.getLoopsIntersection(importRadius, loopLists))
        for point in largestLoop:
            vector3Index = Vector3Index(len(vertexes), point.real, point.imag,
                                        loopLayer.z)
            vector3Loop.append(vector3Index)
            vertexes.append(vector3Index)
        if len(vector3Loop) > 0:
            loops.append(vector3Loop)
    if evaluate.getEvaluatedBoolean(False, elementNode, prefix +
                                    'addExtraTopLayer') and len(loops) > 0:
        topLoop = loops[-1]
        vector3Loop = []
        loops.append(vector3Loop)
        z = topLoop[0].z + layerThickness
        for point in topLoop:
            vector3Index = Vector3Index(len(vertexes), point.x, point.y, z)
            vector3Loop.append(vector3Index)
            vertexes.append(vector3Index)
    geometryOutput = triangle_mesh.getMeldedPillarOutput(loops)
    return geometryOutput