Exemple #1
0
    def __init__(self, _mapStrStrElementPy):
        self.map = _mapStrStrElementPy.map
        #         self.invItr=CC3DXML.STLPyIteratorCC3DXMLElementList()
        self.invItr = CC3DXML.MapStrStrIterator()

        self.invItr.initialize(self.map)
        self.invItr.setToBegin()
 def extract_cell_type_cpp_info_from_file_name(_lds_file: str) -> CC3DXML.MapIntStr:
     _lds_file = LatticeDataSummaryReader.lds_file_check(_lds_file)
     type_id_type_name_dict = LatticeDataSummaryReader.extract_cell_type_info_from_file_name(_lds_file)
     type_id_type_name_cpp_map = CC3DXML.MapIntStr()
     for type_id in list(type_id_type_name_dict.keys()):
         type_id_type_name_cpp_map[int(type_id)] = type_id_type_name_dict[type_id]
     return type_id_type_name_cpp_map
Exemple #3
0
    def __init__(self, _cc3dXMLElementListPy):
        self.elementList = _cc3dXMLElementListPy.elementList

        self.invItr = CC3DXML.CC3DXMLElementListIterator()

        self.invItr.initialize(self.elementList)
        self.invItr.setToBegin()
Exemple #4
0
    def __init__(self, _xmlAttributeList):
        self.xmlElement = _xmlAttributeList.xmlElement

        # have to store attributes in a local variable so that it does not get garbage collected
        self.attributes = self.xmlElement.getAttributes()
        self.itr = CC3DXML.MapStrStrIterator()

        self.itr.initialize(self.attributes)
        self.itr.setToBegin()
Exemple #5
0
def dictionaryToMapStrStr(_dictionary: dict) -> object:
    """
    converts python dictionaty to c++ map (std::map<std:string, std:string>)
    :param _dictionary:
    :return:
    """
    mapStrStr = CC3DXML.MapStrStr()
    for key in _dictionary.keys():
        # mapStrStr[key.encode()]=str(_dictionary[key])
        mapStrStr[key] = str(_dictionary[key])
    return mapStrStr
Exemple #6
0
    def StartElement(self, name, attributes):
        'Expat start element event handler'
        element = CC3DXML.CC3DXMLElement(str(name),
                                         dictionaryToMapStrStr(attributes))

        # Push element onto the stack and make it a child of parent
        if self.nodeStack:
            parent = self.nodeStack[-1]
            parent.addChild(element)
        else:
            self.root = element
        self.nodeStack.append(element)
        self.elementInventory.append(element)
Exemple #7
0
    def extract_lattice_description_info(self, file_name: str) -> None:
        """
        Reads the xml that summarizes serialized simulation files
        :param file_name:{str} xml metadata file name
        :return: None
        """

        # lattice data simulation file
        lds_file = os.path.abspath(file_name)
        self.ldsDir = os.path.dirname(lds_file)

        xml2_obj_converter = XMLUtils.Xml2Obj()
        root_element = xml2_obj_converter.Parse(lds_file)
        dim_element = root_element.getFirstElement("Dimensions")
        self.fieldDim = CompuCell.Dim3D()
        self.fieldDim.x = int(dim_element.getAttribute("x"))
        self.fieldDim.y = int(dim_element.getAttribute("y"))
        self.fieldDim.z = int(dim_element.getAttribute("z"))
        output_element = root_element.getFirstElement("Output")
        self.ldsCoreFileName = output_element.getAttribute("CoreFileName")
        self.frequency = int(output_element.getAttribute("Frequency"))
        self.numberOfSteps = int(output_element.getAttribute("NumberOfSteps"))

        # obtaining list of files in the ldsDir
        lattice_element = root_element.getFirstElement("Lattice")
        self.latticeType = lattice_element.getAttribute("Type")

        # getting information about cell type names and cell ids.
        # It is necessary during generation of the PIF files from VTK output
        cell_types_elements = root_element.getElements("CellType")
        list_cell_type_elements = CC3DXMLListPy(cell_types_elements)
        for cell_type_element in list_cell_type_elements:
            type_name = cell_type_element.getAttribute("TypeName")
            type_id = cell_type_element.getAttributeAsInt("TypeId")
            self.typeIdTypeNameDict[type_id] = type_name

        # now will convert python dictionary into C++ map<int, string>

        self.typeIdTypeNameCppMap = CC3DXML.MapIntStr()
        for type_id in list(self.typeIdTypeNameDict.keys()):
            self.typeIdTypeNameCppMap[int(
                type_id)] = self.typeIdTypeNameDict[type_id]

        lds_file_list = os.listdir(self.ldsDir)

        for fName in lds_file_list:
            if re.match(".*\.vtk$", fName):
                self.ldsFileList.append(fName)

        self.ldsFileList.sort()

        # extracting information about fields in the lds file
        fields_element = root_element.getFirstElement("Fields")
        if fields_element:
            field_list = XMLUtils.CC3DXMLListPy(
                fields_element.getElements("Field"))

            for field_elem in field_list:

                field_name = field_elem.getAttribute("Name")
                self.fieldsUsed[field_elem.getAttribute(
                    "Name")] = field_elem.getAttribute("Type")
                if field_elem.findAttribute(
                        "Script"):  # True or False if present
                    # ToDo:  if a "CustomVis" Type was provided,
                    #  require that a "Script" was also provided; else warn user
                    custom_vis_script = field_elem.getAttribute("Script")

                    self.customVis = CompuCellSetup.createCustomVisPy(
                        field_name)
                    self.customVis.registerVisCallbackFunction(
                        CompuCellSetup.vtkScriptCallback)

                    self.customVis.addActor(field_name, "vtkActor")
                    # we'll piggyback off the actorsDict
                    self.customVis.addActor("customVTKScript",
                                            custom_vis_script)
Exemple #8
0
 def __init__(self, _name, _attributes={}, _cdata=""):
     self.CC3DXMLElement = CC3DXML.CC3DXMLElement(
         str(_name), dictionaryToMapStrStr(_attributes), str(_cdata))
     self.childrenList = []