def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = CopyDerivation(elementNode) if derivation.target == None: print('Warning, copy could not get target for:') print(elementNode) return del elementNode.attributes['target'] copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode) targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target) targetDictionaryCopy = evaluate.removeIdentifiersFromDictionary(derivation.target.attributes.copy()) targetDictionaryCopy.update(elementNode.attributes) elementNode.attributes = targetDictionaryCopy euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible') elementNode.localName = derivation.target.localName derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode) elementNode.getXMLProcessor().processElementNode(elementNode) if copyMatrix != None and targetMatrix != None: elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid) if elementNode.xmlObject == None: return if len(elementNode.xmlObject.getPaths()) > 0: lineation.processElementNode(elementNode) return geometryOutput = elementNode.xmlObject.getGeometryOutput() if geometryOutput == None: return solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode) if len(solidMatchingPlugins) == 0: return geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput) elementNode.xmlObject.transformGeometryOutput(geometryOutput) lineation.removeChildNodesFromElementObject(elementNode) elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
def convertElementNode(elementNode, geometryOutput): 'Convert the xml element to a TriangleMesh xml element.' elementNode.linkObject(TriangleMesh()) matrix.getBranchMatrixSetElementNode(elementNode) vertex.addGeometryList(elementNode, geometryOutput['vertex']) face.addGeometryList(elementNode, geometryOutput['face']) elementNode.getXMLProcessor().processChildNodes(elementNode)
def convertElementNode(elementNode, geometryOutput): 'Convert the xml element to a TriangleMesh xml element.' elementNode.linkObject(TriangleMesh()) matrix.getBranchMatrixSetElementNode(elementNode) vertex.addGeometryList(elementNode, geometryOutput['vertex']) face.addGeometryList(elementNode, geometryOutput['face']) elementNode.getXMLProcessor().processChildNodes(elementNode)
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = CopyDerivation(elementNode) if derivation.target == None: print('Warning, copy could not get target for:') print(elementNode) return del elementNode.attributes['target'] copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode) targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target) targetDictionaryCopy = evaluate.removeIdentifiersFromDictionary(derivation.target.attributes.copy()) targetDictionaryCopy.update(elementNode.attributes) elementNode.attributes = targetDictionaryCopy euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible') elementNode.localName = derivation.target.localName derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode) elementNode.getXMLProcessor().processElementNode(elementNode) if copyMatrix != None and targetMatrix != None: elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid) if elementNode.xmlObject == None: return if len(elementNode.xmlObject.getPaths()) > 0: lineation.processElementNode(elementNode) return geometryOutput = elementNode.xmlObject.getGeometryOutput() if geometryOutput == None: return solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode) if len(solidMatchingPlugins) == 0: return geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput) elementNode.xmlObject.transformGeometryOutput(geometryOutput) lineation.removeChildNodesFromElementObject(elementNode) elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
def processArchiveRemoveSolid(elementNode, geometryOutput): 'Process the target by the manipulationFunction.' solidMatchingPlugins = getSolidMatchingPlugins(elementNode) if len(solidMatchingPlugins) == 0: elementNode.parentNode.xmlObject.archivableObjects.append(elementNode.xmlObject) matrix.getBranchMatrixSetElementNode(elementNode) return processElementNodeByGeometry(elementNode, getGeometryOutputByManipulation(elementNode, geometryOutput))
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 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)
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)
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
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)
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
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): 'Get flipped paths.' if len(loop) < 1: return [[]] derivation = BottomDerivation(elementNode, prefix) targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode) transformedLoop = matrix.getTransformedVector3s(matrix.getIdentityTetragrid(targetMatrix.tetragrid), loop) lift = derivation.altitude + derivation.getAdditionalPathLift() - euclidean.getBottomByPath(transformedLoop) for point in loop: point.z += lift return [loop]
def getCopy(self, idSuffix, parentNode): 'Copy the xml element, set its dictionary and add it to the parentNode.' matrix4X4 = matrix.getBranchMatrixSetElementNode(self) attributesCopy = self.attributes.copy() attributesCopy.update(matrix4X4.getAttributes('matrix.')) copy = self.getCopyShallow(attributesCopy) copy.setParentAddToChildNodes(parentNode) copy.addSuffixToID(idSuffix) copy.addToIdentifierDictionaries() self.copyXMLChildNodes(idSuffix, copy) return copy
def getCopy(self, idSuffix, parentNode): 'Copy the xml element, set its dictionary and add it to the parentNode.' matrix4X4 = matrix.getBranchMatrixSetElementNode(self) attributesCopy = self.attributes.copy() attributesCopy.update(matrix4X4.getAttributes('matrix.')) copy = self.getCopyShallow(attributesCopy) copy.setParentAddToChildNodes(parentNode) copy.addSuffixToID(idSuffix) copy.addToIdentifierDictionaries() self.copyXMLChildNodes(idSuffix, copy) return copy
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get flipped paths." if len(loop) < 1: return [[]] derivation = BottomDerivation(elementNode, prefix) targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode) transformedLoop = matrix.getTransformedVector3s(matrix.getIdentityTetragrid(targetMatrix.tetragrid), loop) lift = derivation.altitude + derivation.getAdditionalPathLift() - euclidean.getBottomByPath(transformedLoop) for point in loop: point.z += lift return [loop]
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = CopyDerivation(elementNode) if derivation.target == None: print('Warning, copy could not get target for:') print(elementNode) return del elementNode.attributes['target'] copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode) targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target) targetDictionaryCopy = derivation.target.attributes.copy() evaluate.removeIdentifiersFromDictionary(targetDictionaryCopy) targetDictionaryCopy.update(elementNode.attributes) elementNode.attributes = targetDictionaryCopy euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible') elementNode.localName = derivation.target.localName derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode) elementNode.getXMLProcessor().processElementNode(elementNode) if copyMatrix != None and targetMatrix != None: elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = CopyDerivation(elementNode) if derivation.target == None: print('Warning, copy could not get target for:') print(elementNode) return del elementNode.attributes['target'] copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode) targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target) targetDictionaryCopy = derivation.target.attributes.copy() evaluate.removeIdentifiersFromDictionary(targetDictionaryCopy) targetDictionaryCopy.update(elementNode.attributes) elementNode.attributes = targetDictionaryCopy euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible') elementNode.localName = derivation.target.localName derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode) elementNode.getXMLProcessor().processElementNode(elementNode) if copyMatrix != None and targetMatrix != None: elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther( targetMatrix.tetragrid)
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): "Get bottomed geometryOutput." derivation = BottomDerivation(elementNode, prefix) copyShallow = elementNode.getCopyShallow() solid.processElementNodeByGeometry(copyShallow, geometryOutput) targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode) matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix) minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject) copyShallow.parentNode.xmlObject.archivableObjects.remove(copyShallow.xmlObject) lift = derivation.altitude - minimumZ vertexes = matrix.getVertexes(geometryOutput) for vertex in vertexes: vertex.z += lift return geometryOutput
def getManipulatedGeometryOutput(elementNode, geometryOutput, prefix): 'Get bottomed geometryOutput.' derivation = BottomDerivation(elementNode, prefix) copyShallow = elementNode.getCopyShallow() solid.processElementNodeByGeometry(copyShallow, geometryOutput) targetMatrix = matrix.getBranchMatrixSetElementNode(elementNode) matrix.setElementNodeDictionaryMatrix(copyShallow, targetMatrix) minimumZ = boolean_geometry.getMinimumZ(copyShallow.xmlObject) copyShallow.parentNode.xmlObject.archivableObjects.remove(copyShallow.xmlObject) lift = derivation.altitude - minimumZ vertexes = matrix.getVertexes(geometryOutput) for vertex in vertexes: vertex.z += lift return geometryOutput
def bottomElementNode(derivation, target): "Bottom target." xmlObject = target.xmlObject if xmlObject == None: print("Warning, bottomTarget in bottom could not get xmlObject for:") print(target) print(derivation.elementNode) return targetMatrix = matrix.getBranchMatrixSetElementNode(target) lift = derivation.altitude transformedPaths = xmlObject.getTransformedPaths() if len(transformedPaths) > 0: lift += derivation.getAdditionalPathLift() - euclidean.getBottomByPaths(transformedPaths) else: lift -= boolean_geometry.getMinimumZ(xmlObject) targetMatrix.tetragrid = matrix.getIdentityTetragrid(targetMatrix.tetragrid) targetMatrix.tetragrid[2][3] += lift matrix.setElementNodeDictionaryMatrix(target, targetMatrix)
def bottomElementNode(derivation, target): "Bottom target." xmlObject = target.xmlObject if xmlObject == None: print('Warning, bottomTarget in bottom could not get xmlObject for:') print(target) print(derivation.elementNode) return targetMatrix = matrix.getBranchMatrixSetElementNode(target) lift = derivation.altitude transformedPaths = xmlObject.getTransformedPaths() if len(transformedPaths) > 0: lift += derivation.getAdditionalPathLift() - euclidean.getBottomByPaths(transformedPaths) else: lift -= boolean_geometry.getMinimumZ(xmlObject) targetMatrix.tetragrid = matrix.getIdentityTetragrid(targetMatrix.tetragrid) targetMatrix.tetragrid[2][3] += lift matrix.setElementNodeDictionaryMatrix(target, targetMatrix)
def processElementNodeByDerivation(derivation, elementNode): 'Process the xml element by derivation.' if derivation == None: derivation = ArrayDerivation(elementNode) if derivation.target == None: print('Warning, array could not get target for:') print(elementNode) return if len(derivation.paths) < 1: print('Warning, array could not get paths for:') print(elementNode) return groupDictionaryCopy = elementNode.attributes.copy() euclidean.removeElementsFromDictionary(groupDictionaryCopy, ['closed', 'paths', 'target', 'track', 'vertexes']) evaluate.removeIdentifiersFromDictionary(groupDictionaryCopy) targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target) elementNode.localName = 'group' totalIndex = 0 for path in derivation.paths: addPathToGroup(derivation, groupDictionaryCopy, path, targetMatrix, totalIndex) elementNode.getXMLProcessor().processElementNode(elementNode)
def processElementNodeByDerivation(derivation, elementNode): "Process the xml element by derivation." if derivation == None: derivation = ArrayDerivation(elementNode) if derivation.target == None: print("Warning, array could not get target for:") print(elementNode) return if len(derivation.paths) < 1: print("Warning, array could not get paths for:") print(elementNode) return groupDictionaryCopy = elementNode.attributes.copy() euclidean.removeElementsFromDictionary(groupDictionaryCopy, ["closed", "paths", "target", "track", "vertexes"]) evaluate.removeIdentifiersFromDictionary(groupDictionaryCopy) targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target) elementNode.localName = "group" totalIndex = 0 for path in derivation.paths: addPathToGroup(derivation, groupDictionaryCopy, path, targetMatrix, totalIndex) elementNode.getXMLProcessor().processElementNode(elementNode)
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
def setToElementNode(self, elementNode): 'Set to elementNode.' self.elementNode = elementNode elementNode.parentNode.xmlObject.archivableObjects.append(self) matrix.getBranchMatrixSetElementNode(elementNode)
def convertContainerElementNode(elementNode, geometryOutput, xmlObject): "Convert the xml element to a group xml element." elementNode.linkObject(xmlObject) matrix.getBranchMatrixSetElementNode(elementNode) elementNode.getXMLProcessor().createChildNodes(geometryOutput['shapes'], elementNode)
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