def convertElementNodeRenameByPaths(elementNode, geometryOutput): 'Convert the xml element to a path xml element and add paths.' createLinkPath(elementNode) for geometryOutputChild in geometryOutput: pathElement = xml_simple_reader.ElementNode() pathElement.setParentAddToChildNodes(elementNode) convertElementNodeByPath(pathElement, geometryOutputChild)
def addGeometryList(elementNode, faces): "Add vertex elements to an xml element." for face in faces: faceElement = xml_simple_reader.ElementNode() face.addToAttributes(faceElement.attributes) faceElement.localName = 'face' faceElement.parentNode = elementNode elementNode.childNodes.append(faceElement)
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)
def getLinkedElementNode(idSuffix, parentNode, target): 'Get elementNode with identifiers and parentNode.' linkedElementNode = xml_simple_reader.ElementNode() euclidean.overwriteDictionary(target.attributes, ['id', 'name', 'quantity'], linkedElementNode.attributes) linkedElementNode.addSuffixToID(idSuffix) tagKeys = target.getTagKeys() tagKeys.append('carve') tagKeys.sort() tags = ', '.join(tagKeys) linkedElementNode.attributes['tags'] = tags linkedElementNode.setParentAddToChildNodes(parentNode) linkedElementNode.addToIdentifierDictionaries() return linkedElementNode
def getUnboundVertexElement(vertex): "Add vertex element to an xml element." vertexElement = xml_simple_reader.ElementNode() addVertexToAttributes(vertexElement.attributes, vertex) vertexElement.localName = 'vertex' return vertexElement
def createChildNodes(self, geometryOutput, parentNode): "Create childNodes for the parentNode." for geometryOutputChild in geometryOutput: childNode = xml_simple_reader.ElementNode() childNode.setParentAddToChildNodes(parentNode) self.convertElementNode(childNode, geometryOutputChild)