Example #1
0
def processTargetByFunction(manipulationFunction, target):
    'Process the target by the manipulationFunction.'
    if target.xmlObject == None:
        print(
            'Warning, there is no object in processTargetByFunction in lineation for:'
        )
        print(target)
        return
    geometryOutput = []
    transformedPaths = target.xmlObject.getTransformedPaths()
    for transformedPath in transformedPaths:
        sideLoop = SideLoop(transformedPath)
        sideLoop.rotate(target)
        sideLoop.loop = euclidean.getLoopWithoutCloseSequentialPoints(
            sideLoop.close, sideLoop.loop)
        geometryOutput += manipulationFunction(sideLoop.close, target,
                                               sideLoop.loop, '',
                                               sideLoop.sideLength)
    if len(geometryOutput) < 1:
        print(
            'Warning, there is no geometryOutput in processTargetByFunction in lineation for:'
        )
        print(target)
        return
    removeChildNodesFromElementObject(target)
    path.convertElementNode(target, geometryOutput)
Example #2
0
def processElementNodeByDerivation(derivation, elementNode):
	'Process the xml element by derivation.'
	if derivation == None:
		derivation = DisjoinDerivation(elementNode)
	targetElementNode = derivation.targetElementNode
	if targetElementNode == None:
		print('Warning, disjoin could not get target for:')
		print(elementNode)
		return
	xmlObject = targetElementNode.xmlObject
	if xmlObject == None:
		print('Warning, processElementNodeByDerivation in disjoin could not get xmlObject for:')
		print(targetElementNode)
		print(derivation.elementNode)
		return
	matrix.getBranchMatrixSetElementNode(targetElementNode)
	transformedVertexes = xmlObject.getTransformedVertexes()
	if len(transformedVertexes) < 1:
		print('Warning, transformedVertexes is zero in processElementNodeByDerivation in disjoin for:')
		print(xmlObject)
		print(targetElementNode)
		print(derivation.elementNode)
		return
	elementNode.localName = 'group'
	elementNode.getXMLProcessor().processElementNode(elementNode)
	targetChainMatrix = matrix.Matrix(xmlObject.getMatrixChainTetragrid())
	minimumZ = boolean_geometry.getMinimumZ(xmlObject)
	z = minimumZ + 0.5 * derivation.sheetThickness
	zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerThickness, transformedVertexes)
	oldVisibleString = targetElementNode.attributes['visible']
	targetElementNode.attributes['visible'] = True
	loops = boolean_geometry.getEmptyZLoops([xmlObject], derivation.importRadius, False, z, zoneArrangement)
	targetElementNode.attributes['visible'] = oldVisibleString
	vector3Loops = euclidean.getVector3Paths(loops, z)
	pathElement = getLinkedElementNode('_sheet', elementNode, targetElementNode)
	path.convertElementNode(pathElement, vector3Loops)
	targetOutput = xmlObject.getGeometryOutput()
	differenceElement = getLinkedElementNode('_solid', elementNode, targetElementNode)
	targetElementCopy = targetElementNode.getCopy('_positive', differenceElement)
	targetElementCopy.attributes['visible'] = True
	targetElementCopy.attributes.update(targetChainMatrix.getAttributes('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.ElementNode()
	cubeElement.attributes['inradius'] = str(inradius)
	if not centerVector3.getIsDefault():
		cubeElement.attributes['translate.'] = str(centerVector3)
	cubeElement.localName = 'cube'
	cubeElement.setParentAddToChildNodes(differenceElement)
	difference.processElementNode(differenceElement)
Example #3
0
def processElementNodeByDerivation(derivation, elementNode):
	'Process the xml element by derivation.'
	if derivation is None:
		derivation = DisjoinDerivation(elementNode)
	targetElementNode = derivation.targetElementNode
	if targetElementNode is None:
		print('Warning, disjoin could not get target for:')
		print(elementNode)
		return
	xmlObject = targetElementNode.xmlObject
	if xmlObject is None:
		print('Warning, processElementNodeByDerivation in disjoin could not get xmlObject for:')
		print(targetElementNode)
		print(derivation.elementNode)
		return
	matrix.getBranchMatrixSetElementNode(targetElementNode)
	transformedVertexes = xmlObject.getTransformedVertexes()
	if len(transformedVertexes) < 1:
		print('Warning, transformedVertexes is zero in processElementNodeByDerivation in disjoin for:')
		print(xmlObject)
		print(targetElementNode)
		print(derivation.elementNode)
		return
	elementNode.localName = 'group'
	elementNode.getXMLProcessor().processElementNode(elementNode)
	targetChainMatrix = matrix.Matrix(xmlObject.getMatrixChainTetragrid())
	minimumZ = boolean_geometry.getMinimumZ(xmlObject)
	z = minimumZ + 0.5 * derivation.sheetThickness
	zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerThickness, transformedVertexes)
	oldVisibleString = targetElementNode.attributes['visible']
	targetElementNode.attributes['visible'] = True
	loops = boolean_geometry.getEmptyZLoops([xmlObject], derivation.importRadius, False, z, zoneArrangement)
	targetElementNode.attributes['visible'] = oldVisibleString
	vector3Loops = euclidean.getVector3Paths(loops, z)
	pathElement = getLinkedElementNode('_sheet', elementNode, targetElementNode)
	path.convertElementNode(pathElement, vector3Loops)
	targetOutput = xmlObject.getGeometryOutput()
	differenceElement = getLinkedElementNode('_solid', elementNode, targetElementNode)
	targetElementCopy = targetElementNode.getCopy('_positive', differenceElement)
	targetElementCopy.attributes['visible'] = True
	targetElementCopy.attributes.update(targetChainMatrix.getAttributes('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.ElementNode()
	cubeElement.attributes['inradius'] = str(inradius)
	if not centerVector3.getIsDefault():
		cubeElement.attributes['translate.'] = str(centerVector3)
	cubeElement.localName = 'cube'
	cubeElement.setParentAddToChildNodes(differenceElement)
	difference.processElementNode(differenceElement)
Example #4
0
def processElementNodeByFunction(elementNode, manipulationFunction):
	'Process the xml element.'
	if 'target' not in elementNode.attributes:
		print('Warning, there was no target in processElementNodeByFunction in solid for:')
		print(elementNode)
		return
	target = evaluate.getEvaluatedLinkValue(elementNode, str(elementNode.attributes['target']).strip())
	if target.__class__.__name__ == 'ElementNode':
		manipulationFunction(elementNode, target)
		return
	path.convertElementNode(elementNode, target)
	manipulationFunction(elementNode, elementNode)
Example #5
0
def processElementNodeByDerivation(derivation, elementNode):
    'Process the xml element by derivation.'
    if derivation == None:
        derivation = CarveDerivation(elementNode)
    targetElementNode = derivation.targetElementNode
    if targetElementNode == None:
        print('Warning, carve could not get target for:')
        print(elementNode)
        return
    xmlObject = targetElementNode.xmlObject
    if xmlObject == None:
        print(
            'Warning, processElementNodeByDerivation in carve could not get xmlObject for:'
        )
        print(targetElementNode)
        print(derivation.elementNode)
        return
    matrix.getBranchMatrixSetElementNode(targetElementNode)
    transformedVertexes = xmlObject.getTransformedVertexes()
    if len(transformedVertexes) < 1:
        print(
            'Warning, transformedVertexes is zero in processElementNodeByDerivation in carve for:'
        )
        print(xmlObject)
        print(targetElementNode)
        print(derivation.elementNode)
        return
    elementNode.localName = 'group'
    elementNode.getXMLProcessor().processElementNode(elementNode)
    minimumZ = boolean_geometry.getMinimumZ(xmlObject)
    maximumZ = euclidean.getTopPath(transformedVertexes)
    zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerThickness,
                                                    transformedVertexes)
    oldVisibleString = targetElementNode.attributes['visible']
    targetElementNode.attributes['visible'] = True
    z = minimumZ + 0.5 * derivation.layerThickness
    loopLayers = boolean_geometry.getLoopLayers([xmlObject],
                                                derivation.importRadius,
                                                derivation.layerThickness,
                                                maximumZ, False, z,
                                                zoneArrangement)
    targetElementNode.attributes['visible'] = oldVisibleString
    for loopLayerIndex, loopLayer in enumerate(loopLayers):
        if len(loopLayer.loops) > 0:
            pathElement = getLinkedElementNode('_carve_%s' % loopLayerIndex,
                                               elementNode, targetElementNode)
            vector3Loops = euclidean.getVector3Paths(loopLayer.loops,
                                                     loopLayer.z)
            path.convertElementNode(pathElement, vector3Loops)
Example #6
0
def processElementNodeByDerivation(derivation, elementNode):
    'Process the xml element by derivation.'
    if derivation == None:
        derivation = CarveDerivation(elementNode)
    targetElementNode = derivation.targetElementNode
    if targetElementNode == None:
        print('Warning, carve could not get target for:')
        print(elementNode)
        return
    xmlObject = targetElementNode.xmlObject
    if xmlObject == None:
        print(
            'Warning, processElementNodeByDerivation in carve could not get xmlObject for:'
        )
        print(targetElementNode)
        print(derivation.elementNode)
        return
    matrix.getBranchMatrixSetElementNode(targetElementNode)
    transformedVertexes = xmlObject.getTransformedVertexes()
    if len(transformedVertexes) < 1:
        print(
            'Warning, transformedVertexes is zero in processElementNodeByDerivation in carve for:'
        )
        print(xmlObject)
        print(targetElementNode)
        print(derivation.elementNode)
        return
    elementNode.localName = 'group'
    elementNode.getXMLProcessor().processElementNode(elementNode)
    minimumZ = boolean_geometry.getMinimumZ(xmlObject)
    maximumZ = euclidean.getTopPath(transformedVertexes)
    zoneArrangement = triangle_mesh.ZoneArrangement(derivation.layerHeight,
                                                    transformedVertexes)
    oldVisibleString = targetElementNode.attributes['visible']
    targetElementNode.attributes['visible'] = True
    z = minimumZ + 0.5 * derivation.layerHeight
    loopLayers = boolean_geometry.getLoopLayers(
        [xmlObject], derivation.importRadius, derivation.layerHeight, maximumZ,
        False, z, zoneArrangement)
    targetElementNode.attributes['visible'] = oldVisibleString
    for loopLayerIndex, loopLayer in enumerate(loopLayers):
        if len(loopLayer.loops) > 0:
            pathElement = getLinkedElementNode('_carve_%s' % loopLayerIndex,
                                               elementNode, targetElementNode)
            vector3Loops = euclidean.getVector3Paths(loopLayer.loops,
                                                     loopLayer.z)
            path.convertElementNode(pathElement, vector3Loops)
Example #7
0
def processTargetByFunction(manipulationFunction, target):
	'Process the target by the manipulationFunction.'
	if target.xmlObject == None:
		print('Warning, there is no object in processTargetByFunction in lineation for:')
		print(target)
		return
	geometryOutput = []
	transformedPaths = target.xmlObject.getTransformedPaths()
	for transformedPath in transformedPaths:
		sideLoop = SideLoop(transformedPath)
		sideLoop.rotate(target)
		sideLoop.loop = euclidean.getLoopWithoutCloseSequentialPoints( sideLoop.close, sideLoop.loop )
		geometryOutput += manipulationFunction(sideLoop.close, target, sideLoop.loop, '', sideLoop.sideLength)
	if len(geometryOutput) < 1:
		print('Warning, there is no geometryOutput in processTargetByFunction in lineation for:')
		print(target)
		return
	removeChildNodesFromElementObject(target)
	path.convertElementNode(target, geometryOutput)
def processElementNode(elementNode):
	"Process the xml element."
	path.convertElementNode(elementNode, getGeometryOutput(None, elementNode))
Example #9
0
def processElementNode(elementNode):
	'Process the xml element.'
	path.convertElementNode(elementNode, getGeometryOutput(elementNode))
Example #10
0
def processElementNode(elementNode):
	"Process the xml element."
	path.convertElementNode(elementNode, getGeometryOutput(None, elementNode))
Example #11
0
def processElementNode(elementNode):
    'Process the xml element.'
    path.convertElementNode(elementNode, getGeometryOutput(elementNode))