Пример #1
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)
Пример #2
0
def processXMLElementByFunction(manipulationFunction, xmlElement):
	'Process the xml element.'
	if 'target' not in xmlElement.attributeDictionary:
		print('Warning, there was no target in processXMLElementByFunction in solid for:')
		print(xmlElement)
		return
	target = evaluate.getEvaluatedLinkValue(str(xmlElement.attributeDictionary['target']).strip(), xmlElement)
	if target.__class__.__name__ == 'XMLElement':
		manipulationFunction(target, xmlElement)
		return
	path.convertXMLElement(target, xmlElement)
	manipulationFunction(xmlElement, xmlElement)
Пример #3
0
def processTargetByFunction(manipulationFunction, target):
	'Process the target by the manipulationFunction.'
	if target.object == None:
		print('Warning, there is no object in processTargetByFunction in lineation for:')
		print(target)
		return
	geometryOutput = []
	transformedPaths = target.object.getTransformedPaths()
	for transformedPath in transformedPaths:
		sideLoop = SideLoop(transformedPath)
		sideLoop.rotate(target)
		sideLoop.loop = euclidean.getLoopWithoutCloseSequentialPoints( sideLoop.close, sideLoop.loop )
		geometryOutput += manipulationFunction( sideLoop.close, sideLoop.loop, '', sideLoop.sideLength, target )
	if len(geometryOutput) < 1:
		print('Warning, there is no geometryOutput in processTargetByFunction in lineation for:')
		print(target)
		return
	removeChildrenFromElementObject(target)
	path.convertXMLElement(geometryOutput, target)
Пример #4
0
def processXMLElement(xmlElement):
	'Process the xml element.'
	path.convertXMLElement(getGeometryOutput(xmlElement), xmlElement)
Пример #5
0
def processXMLElement(xmlElement):
	"Process the xml element."
	path.convertXMLElement(getGeometryOutput(None, xmlElement), xmlElement)
Пример #6
0
def processXMLElement(xmlElement):
    "Process the xml element."
    path.convertXMLElement(getGeometryOutput(None, xmlElement), xmlElement)
Пример #7
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.className = '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.className = 'cube'
    cubeElement.importName = differenceElement.importName
    cubeElement.setParentAddToChildren(differenceElement)
    difference.processXMLElement(differenceElement)