Example #1
0
 def __init(self, negMsgHandler):
     """called from __update
        start rwCovise and connects to COVER
        send params to GUI"""
     _infoer.function = str(self.__init)
     _infoer.write(" ")
     if self.rwCovise == None:
         self.rwCovise = RWCovise()
         theNet().add(self.rwCovise)
         VisItem.connectToCover(self, self)
         self.__connected = True
Example #2
0
    def _initOct(self):
        self._initGeo()
        if self._oct == None:
            # create or use disk-cached octtrees
            if enableCachedOctTrees == True and self._dim == 3:
                basename, extension = os.path.splitext(self._part.filename)
                self._octTreeFileName = basename + ".octtree" + extension
                print("self._octTreeFileName = ", self._octTreeFileName)
                if os.path.isfile(self._octTreeFileName) == False:
                    # create disk-cached octtree
                    self._octTreeFileExists = False
                    self._oct = MakeOctTree()
                    theNet().add(self._oct)
                    self._octIn = ConnectionPoint(self._oct, 'inGrid')
                    self._octOut = ConnectionPoint(self._oct, 'outOctTree')
                    connect(self.geoConnectionPoint(), self._octIn)

                    # connect RWCovise to MakeOctTree
                    self._octTreeWriter = RWCovise()  # writable
                    theNet().add(self._octTreeWriter)
                    self._octTreeWriter.set_grid_path(self._octTreeFileName)
                    connect(self._octOut,
                            ConnectionPoint(self._octTreeWriter, 'mesh_in'))
                else:
                    # use disk-cached octtree
                    self._octTreeFileExists = True
                    self._oct = RWCovise()
                    theNet().add(self._oct)
                    self._oct.set_grid_path(self._octTreeFileName)
                    # cached octtrees must never get an input connection (RWCovise!)
                    self._octIn = None  # ConnectionPoint(self._oct, 'mesh_in')
                    self._octOut = ConnectionPoint(self._oct, 'mesh')
            else:
                self._oct = MakeOctTree()
                theNet().add(self._oct)
                self._octIn = ConnectionPoint(self._oct, 'inGrid')
                self._octOut = ConnectionPoint(self._oct, 'outOctTree')
                connect(self.geoConnectionPoint(), self._octIn)
        else:
            if enableCachedOctTrees == True and self._octTreeFileExists == True:
                # no reconnect necessary, if using disk-cached octtree
                pass
            else:
                # reconnect OctTree
                theNet().disconnectAllFromModulePort(self._oct, 'inGrid')
                connect(self.geoConnectionPoint(), self._octIn)
Example #3
0
 def _initOct(self):
     self._initGeo()
     if self._oct==None:
         # create or use disk-cached octtrees
         if enableCachedOctTrees == True and self._dim == 3:
             basename, extension = os.path.splitext(self._part.filename)
             self._octTreeFileName = basename + ".octtree" + extension
             print("self._octTreeFileName = ", self._octTreeFileName)
             if os.path.isfile(self._octTreeFileName) == False:
                 # create disk-cached octtree
                 self._octTreeFileExists = False
                 self._oct = MakeOctTree()
                 theNet().add(self._oct)
                 self._octIn  = ConnectionPoint( self._oct, 'inGrid' )
                 self._octOut = ConnectionPoint( self._oct, 'outOctTree' )
                 connect( self.geoConnectionPoint(), self._octIn )
                 
                 # connect RWCovise to MakeOctTree
                 self._octTreeWriter = RWCovise()       # writable
                 theNet().add(self._octTreeWriter)
                 self._octTreeWriter.set_grid_path(self._octTreeFileName)
                 connect(self._octOut, ConnectionPoint(self._octTreeWriter, 'mesh_in'))
             else:
                 # use disk-cached octtree
                 self._octTreeFileExists = True
                 self._oct = RWCovise()
                 theNet().add(self._oct)
                 self._oct.set_grid_path(self._octTreeFileName)
                 # cached octtrees must never get an input connection (RWCovise!)
                 self._octIn = None # ConnectionPoint(self._oct, 'mesh_in')
                 self._octOut = ConnectionPoint(self._oct, 'mesh')
         else:
             self._oct = MakeOctTree()
             theNet().add(self._oct)
             self._octIn  = ConnectionPoint( self._oct, 'inGrid' )
             self._octOut = ConnectionPoint( self._oct, 'outOctTree' )
             connect( self.geoConnectionPoint(), self._octIn )
     else:
         if enableCachedOctTrees == True and self._octTreeFileExists == True:
             # no reconnect necessary, if using disk-cached octtree
             pass
         else:
             # reconnect OctTree
             theNet().disconnectAllFromModulePort(self._oct, 'inGrid')
             connect(self.geoConnectionPoint(), self._octIn)
Example #4
0
    def startModules(self):
        global theNet
        
        
        # Module Transform (scaling)
        #
        if (self.scale != 1.0):
            self.Transform_1 = Transform()
            theNet.add( self.Transform_1 )
            self.Transform_1.set_Transform( 5 )
            self.Transform_1.set_scaling_factor( self.scale )
            self.Transform_1.set_createSet( "FALSE" ) 

        # Module Transform (mirror)
        #
        if (self.mirror != 0):
            self.Transform_2 = Transform()
            theNet.add( self.Transform_2 )
            self.Transform_2.set_Transform( 2 )
            if (self.mirror == 1):
                self.Transform_2.set_normal_of_mirror_plane(1.0, 0.0, 0.0)
            elif (self.mirror == 2):
                self.Transform_2.set_normal_of_mirror_plane(0.0, 1.0, 0.0)
            elif (self.mirror == 3):
                self.Transform_2.set_normal_of_mirror_plane(0.0, 0.0, 1.0)
            self.Transform_2.set_MirroredAndOriginal( "FALSE" )
            self.Transform_2.set_createSet( "FALSE" )

        # Module Transform (rotation)
        #
        if (self.rotAngle != 0.0):
            self.Transform_3 = Transform()
            theNet.add( self.Transform_3 )
            self.Transform_3.set_Transform( 4 )
            self.Transform_3.set_axis_of_rotation(self.rotAxisX, self.rotAxisY, self.rotAxisZ)
            self.Transform_3.set_angle_of_rotation( self.rotAngle )
            self.Transform_3.set_createSet( "FALSE" ) 


        # Module SimplifySurface
        #
        if self.reduce:
            self.SimplifySurface_1 = SimplifySurface()
            theNet.add( self.SimplifySurface_1 )
            self.SimplifySurface_1.set_ignore_data( "TRUE" )
            self.SimplifySurface_1.set_percent( self.reductionFactor )

        #
        # MODULE: RWCovise
        #
        self.RWCovise_1 = RWCovise()
        theNet.add( self.RWCovise_1 )
        self.RWCovise_1.set_stepNo( 0 )
        self.RWCovise_1.set_rotate_output( "FALSE" )
        self.RWCovise_1.set_rotation_axis( 3 )
        self.RWCovise_1.set_rot_speed( 2.000000 )
        
        self.RWCovise_2 = RWCovise()
        theNet.add( self.RWCovise_2 )
        
        #
        # Module GetSubset
        #
        self.GetSubset_1 = GetSubset()
        theNet.add( self.GetSubset_1 )      
          
        #
        # Module FixUsg
        #                 
        self.FixUsg_1 = FixUsg()
        theNet.add( self.FixUsg_1 )      
Example #5
0
import sys, os, shutil
from coPyModules import RWCovise, GetSubset
from coviseCase import (CoviseCaseFileItem, CoviseCaseFile, GEOMETRY_2D,
                        GEOMETRY_3D, SCALARVARIABLE, VECTOR3DVARIABLE)

# params
theCoCaseFileName = "/data/Kunden/Daimler/W221_Familientag/Temperature/CoviseDaten/fahrzeug.cocase"
theOutputSubDir = "reduced"
#theFilterSelection = "1-40"
#theFilterSelection = "1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 125 129 133 137 141 145 149 153 157"
#theFilterSelection = "1-10"
#theFilterSelection = "0 40 80 120"
theFilterSelection = "1 5 9 13 17 21 25 29 33 37"

theNet = net()
theRCovise = RWCovise()
theWCovise = RWCovise()
theGetSubset = GetSubset()
theNet.add(theRCovise)
theNet.add(theWCovise)
theNet.add(theGetSubset)
theGetSubset.set_selection(theFilterSelection)
theNet.connect(theRCovise, 'mesh', theGetSubset, 'DataIn0')
theNet.connect(theGetSubset, 'DataOut0', theWCovise, 'mesh_in')

cocase = CoviseCaseFile()
inputFile = open(theCoCaseFileName, 'rb')
cocase = pickle.load(inputFile)
inputFile.close()

try:
Example #6
0
class ImportModule(object):
    def __init__(self, dimension, partcase):
        global testPath
        self._dim = dimension
        self._name = partcase.name
        self._part = partcase

        # Module Classes holding geo, oct and data
        self._geo = None
        self._data = {}
        self._oct = None

        # list of loaded files
        self._files_loaded = []
        self._oct_ready = False
        self._octTreeFileName = None
        self._octTreeFileExists = False
        self._octTreeWriter = None  # RWCovise to write out octtree

        # mapping variable name to filename and filetype
        self._dataFileNames = {}
        self._dataVariableType = {}
        self.__dataConnectionPoints = {}

        # bounding box module and content
        self._bb = None
        self._boundingBox = None
        self._numTimeSteps = None

        # bounding box module and content from unfiltered geometry
        self.__bbFromGeoRWCovise = None  # the module
        self.__boundingBoxFromGeoRWCovise = None  # the AABB

        # colors module to calculate min/max
        self._minMax = None

    def readPartcase(self):
        varNotFound = []
        for v in self._part.variables:
            if getExistingFilename(v.filename) == None:
                self._part.variables.remove(v)
                varNotFound.append(v.filename)
            else:
                self._dataFileNames[v.name] = v.filename
                self._dataVariableType[v.name] = v.variableDimension
        # check if file is transient
        self._isTransient = False
        filename = getExistingFilename(self._part.filename)
        if filename == None:
            raise CoviseFileNotFoundError(self._part.filename)
        in_file = open(
            filename, "rb"
        )  # open in binary mode (makes a difference on windows (read() may stop too early))
        # first check if we have TIMESTEP at the end
        in_file.seek(-100, os.SEEK_END)
        tail = in_file.read(100)
        if b"TIMESTEP" in tail:
            self._isTransient = True
        else:
            # if not already recognized as transient, check if we have SETELE at the beginning
            head = in_file.read(100)
            if b"SETELE" in head:
                # if we have, check the entire file since we might have nested sets
                in_file.seek(0, os.SEEK_BEGIN)
                line = in_file.readline()
                while line:
                    if b"TIMESTEP" in line:
                        self._isTransient = True
                        break
                    line = in_file.readline()
        in_file.close()
        return varNotFound

    """ ------------------------ """
    """ init by starting modules """
    """ ------------------------ """

    def _initGeo(self):
        if self._geo == None:
            self._geo = RWCoviseModule(self._part.filename)
            self._part.filename = self._geo.gridPath()

    def _initData(self, name):
        if name in self._dataFileNames:
            if not name in self._data:
                self._data[name] = RWCoviseModule(self._dataFileNames[name])
                self._dataFileNames[name] = self._data[name].gridPath()
                self.__dataConnectionPoints[name] = self._data[
                    name].connectionPoint()

    def _initOct(self):
        self._initGeo()
        if self._oct == None:
            # create or use disk-cached octtrees
            if enableCachedOctTrees == True and self._dim == 3:
                basename, extension = os.path.splitext(self._part.filename)
                self._octTreeFileName = basename + ".octtree" + extension
                print("self._octTreeFileName = ", self._octTreeFileName)
                if os.path.isfile(self._octTreeFileName) == False:
                    # create disk-cached octtree
                    self._octTreeFileExists = False
                    self._oct = MakeOctTree()
                    theNet().add(self._oct)
                    self._octIn = ConnectionPoint(self._oct, 'inGrid')
                    self._octOut = ConnectionPoint(self._oct, 'outOctTree')
                    connect(self.geoConnectionPoint(), self._octIn)

                    # connect RWCovise to MakeOctTree
                    self._octTreeWriter = RWCovise()  # writable
                    theNet().add(self._octTreeWriter)
                    self._octTreeWriter.set_grid_path(self._octTreeFileName)
                    connect(self._octOut,
                            ConnectionPoint(self._octTreeWriter, 'mesh_in'))
                else:
                    # use disk-cached octtree
                    self._octTreeFileExists = True
                    self._oct = RWCovise()
                    theNet().add(self._oct)
                    self._oct.set_grid_path(self._octTreeFileName)
                    # cached octtrees must never get an input connection (RWCovise!)
                    self._octIn = None  # ConnectionPoint(self._oct, 'mesh_in')
                    self._octOut = ConnectionPoint(self._oct, 'mesh')
            else:
                self._oct = MakeOctTree()
                theNet().add(self._oct)
                self._octIn = ConnectionPoint(self._oct, 'inGrid')
                self._octOut = ConnectionPoint(self._oct, 'outOctTree')
                connect(self.geoConnectionPoint(), self._octIn)
        else:
            if enableCachedOctTrees == True and self._octTreeFileExists == True:
                # no reconnect necessary, if using disk-cached octtree
                pass
            else:
                # reconnect OctTree
                theNet().disconnectAllFromModulePort(self._oct, 'inGrid')
                connect(self.geoConnectionPoint(), self._octIn)

    """ ------------------------ """
    """ connection points        """
    """ ------------------------ """

    def geoConnectionPoint(self):
        #        print("ImportModule::geoConnectionPoint() called")
        self._initGeo()
        return self._geo.connectionPoint()

    def dataConnectionPoint(self, name):
        if name in self._dataFileNames:
            self._initData(name)
            #return self._data[name].connectionPoint()
            return self.__dataConnectionPoints[name]
        return None

    def octTreeConnectionPoint(self):
        self._initOct()
        return self._octOut

    def boundingBoxConnectionPoint(self):
        self.getBox()
        return ConnectionPoint(self._bb, 'GridOut0')

    """ ------------------------ """
    """ execution methods        """
    """ ------------------------ """

    def execute(self):
        self.executeGeo()
        self.executeOct()
        for name in self._data:
            self.executeData(name)

    def executeGeo(self):
        self._initGeo()
        if not self._part.filename in self._files_loaded:
            _infoer.function = str(self.executeGeo)
            _infoer.write("Loading file " + self._part.filename)
            self._geo.execute()
            self._files_loaded.append(self._part.filename)
            return True
        return False

    def executeData(self, name):
        #        print("ImportModule::executeData() called")
        _infoer.function = str(self.executeGeo)
        _infoer.write("Load request for  " + name)
        if name in self._dataFileNames:
            self._initData(name)
            if not self._dataFileNames[name] in self._files_loaded:
                _infoer.write("Loading  " + self._dataFileNames[name])
                self._data[name].execute()
                self._files_loaded.append(self._dataFileNames[name])
                return True
        else:
            #            print("Import Module: no variable called %s in part %s " % ( name,  self._name ))
            assert False
        _infoer.write("Returning False")
        return False

    def executeOct(self):
        self._initOct()
        if not self._oct_ready:
            if enableCachedOctTrees == True and self._octTreeFileExists == True:
                # cached octtrees aren't connected to the geo-RWCovise
                saveExecute(self._oct)
            elif not self.executeGeo():
                saveExecute(self._oct)
            self._oct_ready = True
            return True
        return False

    def reloadGeo(self):
        if not self.executeGeo():
            self._geo.execute()

    """ ------------------------ """
    """ delete                   """
    """ ------------------------ """

    def delete(self):
        if hasattr(self, "_geo") and self._geo: self._geo.remove()
        if hasattr(self, "_data"):
            for module in self._data.values():
                module.remove()
        if hasattr(self, "_oct") and self._oct: theNet().remove(self._oct)
        if hasattr(self, "_octTreeWriter") and self._octTreeWriter:
            theNet().remove(self._octTreeWriter)
        if hasattr(self, "_bb") and self._bb: theNet().remove(self._bb)
        if hasattr(self, "_ImportModule__bbFromGeoRWCovise"
                   ) and self.__bbFromGeoRWCovise:
            theNet().remove(self.__bbFromGeoRWCovise)
        if hasattr(self, "_minMax") and self._minMax:
            theNet().remove(self._minMax)

    """ ------------------------ """
    """ read private variables   """
    """ ------------------------ """

    def getDimension(self):
        return self._dim

    def getName(self):
        return self._name

    def getParts(self):
        return [self._part]

    def getPartCase(self):
        return self._part

    def getBoxFromGeoRWCovise(self):
        """ return the bounding box from the originally unfiltered geometry """

        if self.__boundingBoxFromGeoRWCovise == None:
            self.__bbFromGeoRWCovise = BoundingBox()
            theNet().add(self.__bbFromGeoRWCovise)
            connect(self._geo.connectionPoint(),
                    ConnectionPoint(self.__bbFromGeoRWCovise, 'GridIn0'))

            # Clear info queue so we dont read a previous BB output.
            # (If something goes wrong with the queue, this could be the reason.)
            coviseStartup.globalReceiverThread.infoQueue_.clear()
            saveExecute(self.__bbFromGeoRWCovise)
            boxParser = BoundingBoxParser()
            boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_)
            self.__boundingBoxFromGeoRWCovise = boxParser.getBox()

        return self.__boundingBoxFromGeoRWCovise

    def getBox(self, execute=False):
        """ return the bounding box """
        if self._bb == None:
            self._bb = BoundingBox()
            theNet().add(self._bb)
            connect(self.geoConnectionPoint(),
                    ConnectionPoint(self._bb, 'GridIn0'))
            # Clear info queue so we dont read a previous BB output.
            # (If something goes wrong with the queue, this could be the reason.)
            coviseStartup.globalReceiverThread.infoQueue_.clear()
            if not self.executeGeo():
                saveExecute(self._bb)
            boxParser = BoundingBoxParser()
            boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_)
            self._boundingBox = boxParser.getBox()
            self._numTimeSteps = boxParser.getNumTimeSteps()
        elif execute:
            theNet().disconnectAllFromModule(self._bb)
            connect(self.geoConnectionPoint(),
                    ConnectionPoint(self._bb, 'GridIn0'))
            # Clear info queue so we dont read a previous BB output.
            # (If something goes wrong with the queue, this could be the reason.)
            coviseStartup.globalReceiverThread.infoQueue_.clear()
            if not self.executeGeo():
                saveExecute(self._bb)
            boxParser = BoundingBoxParser()
            boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_)
            try:
                oldbb = self._boundingBox
                self._boundingBox = boxParser.getBox()
                #self._numTimeSteps = boxParser.getNumTimeSteps()
            except (ValueError):
                self._boundingBox = oldbb

        if self._bb != None:
            theNet().disconnectAllFromModulePort(self._bb, 'GridIn0')
            connect(self.geoConnectionPoint(),
                    ConnectionPoint(self._bb, 'GridIn0'))

        return self._boundingBox

    def getNumTimeSteps(self):
        if not self._numTimeSteps:
            self.getBox()
        return self._numTimeSteps

    def getDataMinMax(self, variable):
        """ return min and max value of variable """
        if variable == None:
            return

        if self._minMax == None:
            self._minMax = Colors()
            theNet().add(self._minMax)
        theNet().disconnectAllFromModulePort(self._minMax, 'DataIn0')
        connect(self.dataConnectionPoint(variable),
                ConnectionPoint(self._minMax, 'DataIn0'))

        if not self.executeData(variable):
            saveExecute(self._minMax)

        return ( float(self._minMax.getParamValue('MinMax')[0]),\
                 float(self._minMax.getParamValue('MinMax')[1]) )

    def getIsTransient(self):
        return self._isTransient

    """ ------------------------ """
    """ return status string     """
    """ ------------------------ """

    def __str__(self):
        string = 'Status of ' + self._name + '\n'
        for v in self._part.variables:
            string = string + v.name + '\n'
        return string

    def getCoObjName(self):
        if not self._geo == None:
            return self._geo.getCoObjName()
Example #7
0
    import cPickle as pickle
except:
    import pickle

import sys, os, shutil
from coPyModules import RWCovise, SimplifySurface
from coviseCase import CoviseCaseFileItem, CoviseCaseFile, GEOMETRY_2D, GEOMETRY_3D, SCALARVARIABLE, VECTOR3DVARIABLE

# params
theCoCaseFileName = "/data/Kunden/Daimler/W221_Familientag/Temperature/CoviseDaten/reduced/fahrzeug.cocase"
theOutputSubDir = "simplified"
thePercent = 5.0  # lower means smaller
theMaxNormalDeviation = 5.0

theNet = net()
theGridRCovise = RWCovise()
theDataRCovise = RWCovise()
theGridWCovise = RWCovise()
theDataWCovise = RWCovise()
theSimplify = SimplifySurface()
theNet.add(theGridRCovise)
theNet.add(theDataRCovise)
theNet.add(theGridWCovise)
theNet.add(theDataWCovise)
theNet.add(theSimplify)
theSimplify.set_percent(thePercent)
theSimplify.set_max_normaldeviation(theMaxNormalDeviation)

cocase = CoviseCaseFile()
inputFile = open(theCoCaseFileName, "rb")
cocase = pickle.load(inputFile)
Example #8
0
class ImportModule(object):

    def __init__(self, dimension, partcase ):
        global testPath
        self._dim = dimension
        self._name = partcase.name
        self._part = partcase

        # Module Classes holding geo, oct and data
        self._geo = None
        self._data = {}
        self._oct = None

        # list of loaded files
        self._files_loaded = []
        self._oct_ready = False
        self._octTreeFileName = None
        self._octTreeFileExists = False
        self._octTreeWriter = None      # RWCovise to write out octtree

        # mapping variable name to filename and filetype
        self._dataFileNames = {}
        self._dataVariableType = {}
        self.__dataConnectionPoints = {}

        # bounding box module and content
        self._bb = None
        self._boundingBox = None
        self._numTimeSteps = None

        # bounding box module and content from unfiltered geometry
        self.__bbFromGeoRWCovise = None              # the module
        self.__boundingBoxFromGeoRWCovise = None     # the AABB

        # colors module to calculate min/max
        self._minMax = None

        
        
    def readPartcase(self):
        varNotFound = []
        for v in self._part.variables:
            if getExistingFilename(v.filename) == None:
                self._part.variables.remove(v)
                varNotFound.append( v.filename )
            else:
                self._dataFileNames[ v.name ] = v.filename
                self._dataVariableType[ v.name ] = v.variableDimension
        # check if file is transient
        self._isTransient = False
        filename = getExistingFilename(self._part.filename)
        if filename == None:
            raise CoviseFileNotFoundError(self._part.filename)
        in_file = open(filename, "rb") # open in binary mode (makes a difference on windows (read() may stop too early))
        # first check if we have TIMESTEP at the end
        in_file.seek(-100, os.SEEK_END)
        tail = in_file.read(100)
        if b"TIMESTEP" in tail:
            self._isTransient = True
        else:
            # if not already recognized as transient, check if we have SETELE at the beginning
            head = in_file.read(100)
            if b"SETELE" in head:
                # if we have, check the entire file since we might have nested sets
                in_file.seek(0, os.SEEK_BEGIN)
                line = in_file.readline()
                while line:
                    if b"TIMESTEP" in line:
                        self._isTransient = True
                        break
                    line = in_file.readline()
        in_file.close()
        return varNotFound
        
        
    """ ------------------------ """
    """ init by starting modules """
    """ ------------------------ """

    def _initGeo(self):
        if self._geo==None:
            self._geo = RWCoviseModule(self._part.filename)
            self._part.filename = self._geo.gridPath()

    def _initData(self, name):
        if name in self._dataFileNames:
            if not name in self._data:
                self._data[name] = RWCoviseModule( self._dataFileNames[name] )
                self._dataFileNames[name] = self._data[name].gridPath()
                self.__dataConnectionPoints[name] = self._data[name].connectionPoint()

    def _initOct(self):
        self._initGeo()
        if self._oct==None:
            # create or use disk-cached octtrees
            if enableCachedOctTrees == True and self._dim == 3:
                basename, extension = os.path.splitext(self._part.filename)
                self._octTreeFileName = basename + ".octtree" + extension
                print("self._octTreeFileName = ", self._octTreeFileName)
                if os.path.isfile(self._octTreeFileName) == False:
                    # create disk-cached octtree
                    self._octTreeFileExists = False
                    self._oct = MakeOctTree()
                    theNet().add(self._oct)
                    self._octIn  = ConnectionPoint( self._oct, 'inGrid' )
                    self._octOut = ConnectionPoint( self._oct, 'outOctTree' )
                    connect( self.geoConnectionPoint(), self._octIn )
                    
                    # connect RWCovise to MakeOctTree
                    self._octTreeWriter = RWCovise()       # writable
                    theNet().add(self._octTreeWriter)
                    self._octTreeWriter.set_grid_path(self._octTreeFileName)
                    connect(self._octOut, ConnectionPoint(self._octTreeWriter, 'mesh_in'))
                else:
                    # use disk-cached octtree
                    self._octTreeFileExists = True
                    self._oct = RWCovise()
                    theNet().add(self._oct)
                    self._oct.set_grid_path(self._octTreeFileName)
                    # cached octtrees must never get an input connection (RWCovise!)
                    self._octIn = None # ConnectionPoint(self._oct, 'mesh_in')
                    self._octOut = ConnectionPoint(self._oct, 'mesh')
            else:
                self._oct = MakeOctTree()
                theNet().add(self._oct)
                self._octIn  = ConnectionPoint( self._oct, 'inGrid' )
                self._octOut = ConnectionPoint( self._oct, 'outOctTree' )
                connect( self.geoConnectionPoint(), self._octIn )
        else:
            if enableCachedOctTrees == True and self._octTreeFileExists == True:
                # no reconnect necessary, if using disk-cached octtree
                pass
            else:
                # reconnect OctTree
                theNet().disconnectAllFromModulePort(self._oct, 'inGrid')
                connect(self.geoConnectionPoint(), self._octIn)


    """ ------------------------ """
    """ connection points        """
    """ ------------------------ """

    def geoConnectionPoint(self):
#        print("ImportModule::geoConnectionPoint() called")
        self._initGeo()
        return self._geo.connectionPoint()

    def dataConnectionPoint(self, name ):
        if name in self._dataFileNames:
            self._initData(name)
            #return self._data[name].connectionPoint()
            return self.__dataConnectionPoints[name]
        return None

    def octTreeConnectionPoint(self):
        self._initOct()
        return self._octOut

    def boundingBoxConnectionPoint(self):
        self.getBox()
        return ConnectionPoint(self._bb, 'GridOut0' )


    """ ------------------------ """
    """ execution methods        """
    """ ------------------------ """

    def execute(self):
        self.executeGeo()
        self.executeOct()
        for name in self._data:
            self.executeData(name)

    def executeGeo(self):
        self._initGeo()
        if not self._part.filename in self._files_loaded:
            _infoer.function = str(self.executeGeo)
            _infoer.write("Loading file " + self._part.filename)
            self._geo.execute()
            self._files_loaded.append(self._part.filename)
            return True
        return False

    def executeData( self, name ):
#        print("ImportModule::executeData() called")
        _infoer.function = str(self.executeGeo)
        _infoer.write("Load request for  " + name)
        if name in self._dataFileNames:
            self._initData(name)
            if not self._dataFileNames[name] in self._files_loaded:
                _infoer.write("Loading  " + self._dataFileNames[name])
                self._data[name].execute()
                self._files_loaded.append(self._dataFileNames[name])
                return True
        else :                        
#            print("Import Module: no variable called %s in part %s " % ( name,  self._name ))
            assert False
        _infoer.write("Returning False")
        return False

    def executeOct(self):
        self._initOct()
        if not self._oct_ready:
            if enableCachedOctTrees == True and self._octTreeFileExists == True:
                # cached octtrees aren't connected to the geo-RWCovise
                saveExecute(self._oct)
            elif not self.executeGeo():
                saveExecute(self._oct)
            self._oct_ready = True
            return True
        return False

    def reloadGeo(self):
        if not self.executeGeo():
            self._geo.execute()

    """ ------------------------ """
    """ delete                   """
    """ ------------------------ """

    def delete(self):
        if hasattr(self, "_geo") and self._geo: self._geo.remove()
        if hasattr(self, "_data"):
            for module in self._data.values(): module.remove()
        if hasattr(self, "_oct") and self._oct: theNet().remove(self._oct)
        if hasattr(self, "_octTreeWriter") and self._octTreeWriter: theNet().remove(self._octTreeWriter)
        if hasattr(self, "_bb") and self._bb: theNet().remove(self._bb)
        if hasattr(self, "_ImportModule__bbFromGeoRWCovise") and self.__bbFromGeoRWCovise: theNet().remove(self.__bbFromGeoRWCovise)
        if hasattr(self, "_minMax") and self._minMax: theNet().remove(self._minMax)


    """ ------------------------ """
    """ read private variables   """
    """ ------------------------ """

    def getDimension(self):
        return self._dim
    def getName(self):
        return self._name

    def getParts(self):
        return [self._part]
    def getPartCase(self):
        return self._part


    def getBoxFromGeoRWCovise(self):
        """ return the bounding box from the originally unfiltered geometry """

        if self.__boundingBoxFromGeoRWCovise == None:
            self.__bbFromGeoRWCovise = BoundingBox()
            theNet().add(self.__bbFromGeoRWCovise)
            connect( self._geo.connectionPoint(), ConnectionPoint(self.__bbFromGeoRWCovise, 'GridIn0'))

            # Clear info queue so we dont read a previous BB output.
            # (If something goes wrong with the queue, this could be the reason.)
            coviseStartup.globalReceiverThread.infoQueue_.clear()
            saveExecute(self.__bbFromGeoRWCovise)
            boxParser = BoundingBoxParser()
            boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_)
            self.__boundingBoxFromGeoRWCovise = boxParser.getBox()

        return self.__boundingBoxFromGeoRWCovise

    def getBox(self, execute = False):
        """ return the bounding box """
        if self._bb==None:
            self._bb = BoundingBox()
            theNet().add( self._bb)
            connect( self.geoConnectionPoint(), ConnectionPoint( self._bb, 'GridIn0' ) )
            # Clear info queue so we dont read a previous BB output.
            # (If something goes wrong with the queue, this could be the reason.)
            coviseStartup.globalReceiverThread.infoQueue_.clear()
            if not self.executeGeo():
                saveExecute(self._bb)
            boxParser = BoundingBoxParser()
            boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_)
            self._boundingBox = boxParser.getBox()
            self._numTimeSteps = boxParser.getNumTimeSteps()
        elif execute:
            theNet().disconnectAllFromModule(self._bb)
            connect( self.geoConnectionPoint(), ConnectionPoint( self._bb, 'GridIn0' ) )
            # Clear info queue so we dont read a previous BB output.
            # (If something goes wrong with the queue, this could be the reason.)
            coviseStartup.globalReceiverThread.infoQueue_.clear()
            if not self.executeGeo():
                saveExecute(self._bb)
            boxParser = BoundingBoxParser()
            boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_)
            try:
                oldbb = self._boundingBox
                self._boundingBox = boxParser.getBox()
                #self._numTimeSteps = boxParser.getNumTimeSteps()
            except (ValueError):
                self._boundingBox = oldbb

        if self._bb != None:
            theNet().disconnectAllFromModulePort(self._bb, 'GridIn0')
            connect( self.geoConnectionPoint(), ConnectionPoint( self._bb, 'GridIn0' ) )

        return self._boundingBox
        
    def getNumTimeSteps(self):
        if not self._numTimeSteps:
            self.getBox()
        return self._numTimeSteps
    

    def getDataMinMax( self, variable):
        """ return min and max value of variable """
        if variable==None:
            return

        if self._minMax==None:
            self._minMax = Colors()
            theNet().add(self._minMax)
        theNet().disconnectAllFromModulePort( self._minMax, 'DataIn0' )
        connect(self.dataConnectionPoint(variable), ConnectionPoint(self._minMax, 'DataIn0'))

        if not self.executeData( variable ):
            saveExecute(self._minMax)
            
        return ( float(self._minMax.getParamValue('MinMax')[0]),\
                 float(self._minMax.getParamValue('MinMax')[1]) )

    def getIsTransient(self):
        return self._isTransient

    """ ------------------------ """
    """ return status string     """
    """ ------------------------ """
    def __str__(self):
        string = 'Status of ' + self._name + '\n'
        for v in self._part.variables:
            string = string + v.name + '\n'
        return string

    def getCoObjName(self):
        if not self._geo==None:
            return self._geo.getCoObjName()
Example #9
0
    def startModules(self):
        #print "Ensight2CoviseGui.startModules"
        self.aErrorLogAction = ErrorLogAction()
        CoviseMsgLoop().register(self.aErrorLogAction)

        global theNet
        theNet = net()

        self.scalarVariables3DGetterAction = ChoiceGetterAction()
        self.vectorVariables3DGetterAction = ChoiceGetterAction()
        self.scalarVariables2DGetterAction = ChoiceGetterAction()
        self.vectorVariables2DGetterAction = ChoiceGetterAction()

        # MODULE: ReadEnsight
        self.ReadEnsight_1 = ReadEnsight()
        theNet.add(self.ReadEnsight_1)

        self.aPartsCollectorAction = PartsCollectorAction()
        CoviseMsgLoop().register(self.aPartsCollectorAction)

        # hang in variable-getters
        self.ReadEnsight_1.addNotifier('data_for_sdata1_3D',
                                       self.scalarVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_3D',
                                       self.vectorVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_sdata1_2D',
                                       self.scalarVariables2DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_2D',
                                       self.vectorVariables2DGetterAction)

        # set parameter values
        if self.isByteSwapped == True:
            self.ReadEnsight_1.set_data_byte_swap("TRUE")
        else:
            self.ReadEnsight_1.set_data_byte_swap("FALSE")
        self.ReadEnsight_1.set_case_file(self.fullEnsightCaseName)
        self.ReadEnsight_1.set_include_polyhedra("TRUE")
        self.ReadEnsight_1.set_enable_autocoloring("FALSE")

        # wait for choices to be updated
        self.scalarVariables3DGetterAction.waitForChoices()
        self.vectorVariables3DGetterAction.waitForChoices()
        self.scalarVariables2DGetterAction.waitForChoices()
        self.vectorVariables2DGetterAction.waitForChoices()

        # wait for the part info message
        self.aPartsCollectorAction.waitForPartsinfoFinished()

        # get variables
        self.scalarVariables3D = self.scalarVariables3DGetterAction.getChoices(
        )
        self.vectorVariables3D = self.vectorVariables3DGetterAction.getChoices(
        )
        self.scalarVariables2D = self.scalarVariables2DGetterAction.getChoices(
        )
        self.vectorVariables2D = self.vectorVariables2DGetterAction.getChoices(
        )

        text = "Ensight Case File: %s" % (self.fullEnsightCaseName)
        self.statusText.append(text)

        self.statusText.append("\n3D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict3dParts().keys(
        ):
            partname = self.aPartsCollectorAction.getRefNameDict3dParts(
            )[partid]
            text = "\tPart %d = %s" % (partid, partname)
            self.statusText.append(text)

        self.statusText.append("3D Part Variables:")
        for svar in self.scalarVariables3D:
            text = "\t%s(scalar)" % (svar)
            self.statusText.append(text)
        for vvar in self.vectorVariables3D:
            text = "\t%s(vector)" % (vvar)
            self.statusText.append(text)

        self.statusText.append("\n2D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict2dParts().keys(
        ):
            partname = self.aPartsCollectorAction.getRefNameDict2dParts(
            )[partid]
            text = "\tPart %d = %s" % (partid, partname)
            self.statusText.append(text)

        self.statusText.append("2D Part Variables:")
        for svar in self.scalarVariables2D:
            text = "\t%s(scalar)" % (svar)
            self.statusText.append(text)
        for vvar in self.vectorVariables2D:
            text = "\t%s(vector)" % (vvar)
            self.statusText.append(text)

        QtWidgets.QApplication.processEvents()

        # MODULE: RWCovise
        self.RWCovise_1 = RWCovise()
        theNet.add(self.RWCovise_1)
        self.RWCovise_1.set_stepNo(0)
        self.RWCovise_1.set_rotate_output("FALSE")
        self.RWCovise_1.set_rotation_axis(3)
        self.RWCovise_1.set_rot_speed(2.000000)

        self.cocase = CoviseCaseFile()
        cn = os.path.basename(str(self.fullEnsightCaseName))
        self.cocasename = cn[0:cn.rfind('.')]
Example #10
0
 def __init__(self, filename, doWrite = False):
     CoviseNetAccessModule.__init__(self, RWCovise())
     self.setGridPath(filename, doWrite)
Example #11
0
    GEOMETRY_2D,
    GEOMETRY_3D,
    SCALARVARIABLE,
    VECTOR3DVARIABLE)

# params
theCoCaseFileName = "/data/Kunden/Daimler/W221_Familientag/Temperature/CoviseDaten/fahrzeug.cocase"
theOutputSubDir = "reduced"
#theFilterSelection = "1-40"
#theFilterSelection = "1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 101 105 109 113 117 121 125 129 133 137 141 145 149 153 157"
#theFilterSelection = "1-10"
#theFilterSelection = "0 40 80 120"
theFilterSelection = "1 5 9 13 17 21 25 29 33 37"

theNet = net()
theRCovise = RWCovise()
theWCovise = RWCovise()
theGetSubset = GetSubset()
theNet.add(theRCovise)
theNet.add(theWCovise)
theNet.add(theGetSubset)
theGetSubset.set_selection(theFilterSelection)
theNet.connect(theRCovise, 'mesh', theGetSubset, 'DataIn0')
theNet.connect(theGetSubset, 'DataOut0', theWCovise, 'mesh_in')

cocase = CoviseCaseFile()
inputFile = open(theCoCaseFileName, 'rb')
cocase = pickle.load(inputFile)
inputFile.close()

try:
Example #12
0
class CoviseVis(VisItem):
    """ VisItem to show an covise object """
    def __init__(self):
        VisItem.__init__(self, VIS_COVISE, self.__class__.__name__)
        self.params = CoviseVisParams()
        self.params.isVisible = True
        self.__initBase()

    def __initBase(self):
        _infoer.function = str(self.__initBase)
        _infoer.write(" ")
        self.rwCovise = None
        self.__connected = False
        self.__registered = False
        self.__loaded = None

    def __init(self, negMsgHandler):
        """called from __update
           start rwCovise and connects to COVER
           send params to GUI"""
        _infoer.function = str(self.__init)
        _infoer.write(" ")
        if self.rwCovise == None:
            self.rwCovise = RWCovise()
            theNet().add(self.rwCovise)
            VisItem.connectToCover(self, self)
            self.__connected = True

    def __update(self, negMsgHandler):
        """ __update is called from the run method to update the module parameter before execution
            + update module parameters """
        _infoer.function = str(self.__update)
        _infoer.write(" ")
        self.__init(negMsgHandler)
        #update params
        # check if filename exists
        if getExistingFilename(self.params.filename) == None:
            raise IOError(self.params.filename)
            """
            fn = os.path.basename(filename)
            # if a path allready was selected
            if not _newPath == None:
                fname = VRPCoviseNetAccess._newPath + fn
                # test new path
                if not os.access(fname, os.R_OK):
                    filename = VRPCoviseNetAccess.changePath(filename, fn)
                else:
                    filename = fname
            else:
                filename = VRPCoviseNetAccess.changePath(filename , fn)
            """

        self.rwCovise.set_grid_path(self.params.filename)
        self.rwCovise.set_stepNo(self.params.stepNo)
        if (self.params.rotate_output == True):
            self.rwCovise.set_rotate_output('TRUE')
        else:
            self.rwCovise.set_rotate_output('FALSE')
        self.rwCovise.set_rotation_axis(self.params.rotation_axis)
        self.rwCovise.set_rot_speed(self.params.rot_speed)

    def createdKey(self, key):
        """ called during registration if key received from COVER """
        _infoer.function = str(self.createdKey)
        _infoer.write("%s, %s" % (key, self.rwCovise.getCoObjName('mesh')))
        importKey = self.rwCovise.getCoObjName('mesh')
        posCover = key.find("(")
        posImport = importKey.find("OUT")
        return (importKey[0:posImport - 1] == key[0:posCover])

    def connectionPoint(self):
        """ return the object to be displayed
            called by the class VisItem """
        if self.rwCovise:
            return ConnectionPoint(self.rwCovise, 'mesh')

    def recreate(self, negMsgHandler, parentKey, offset):
        self.__initBase()
        VisItem.recreate(self, negMsgHandler, parentKey, offset)

    def run(self, runmode, negMsgHandler=None):
        if runmode == RUN_ALL:
            _infoer.function = str(self.run)
            _infoer.write("go")
            self.__update(negMsgHandler)
            if not self.__connected:
                VisItem.connectToCover(self, self)
                self.__connected = True
            if self.__loaded == None or self.__loaded != self.params.filename:
                saveExecute(self.rwCovise)
                self.__loaded = self.params.filename

    def __register(self, negMsgHandler):
        """ register to receive events from covise """
        if negMsgHandler and self.rwCovise:
            if not self.__registered:
                mL = []
                mL.append(self.rwCovise)
                negMsgHandler.registerCopyModules(mL, self)
                paramList = [
                    'grid_path', 'stepNo', 'rotate_output', 'rot_speed'
                ]
                negMsgHandler.registerParamsNotfier(self.rwCovise, self.key,
                                                    paramList)
                self.__registered = True

    def setParams(self, params, negMsgHandler=None, sendToCover=True):
        """ set parameters from outside """
        _infoer.function = str(self.setParams)
        _infoer.write("setParams")

        VisItem.setParams(self, params)

    def delete(self, isInitialized, negMsgHandler=None):
        ''' delete this CoviseVis: remove the module '''
        _infoer.function = str(self.delete)
        _infoer.write(" ")
        if isInitialized:
            theNet().remove(self.rwCovise)
        VisItem.delete(self, isInitialized, negMsgHandler)
Example #13
0
    def startModules(self):
        #print "Ensight2CoviseGui.startModules"
        self.aErrorLogAction = ErrorLogAction()
        CoviseMsgLoop().register(self.aErrorLogAction)

        global theNet
        theNet = net()
        
        self.scalarVariables3DGetterAction = ChoiceGetterAction()
        self.vectorVariables3DGetterAction = ChoiceGetterAction()
        self.scalarVariables2DGetterAction = ChoiceGetterAction()
        self.vectorVariables2DGetterAction = ChoiceGetterAction()

 

        # MODULE: ReadEnsight
        self.ReadEnsight_1 = ReadEnsight()
        theNet.add( self.ReadEnsight_1 )

        self.aPartsCollectorAction = PartsCollectorAction()
        CoviseMsgLoop().register(self.aPartsCollectorAction)


        # hang in variable-getters
        self.ReadEnsight_1.addNotifier('data_for_sdata1_3D', self.scalarVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_3D', self.vectorVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_sdata1_2D', self.scalarVariables2DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_2D', self.vectorVariables2DGetterAction)


        # set parameter values
        if self.isByteSwapped == True:
            self.ReadEnsight_1.set_data_byte_swap( "TRUE" )
        else:
            self.ReadEnsight_1.set_data_byte_swap( "FALSE" )
        self.ReadEnsight_1.set_case_file( self.fullEnsightCaseName )
        self.ReadEnsight_1.set_include_polyhedra( "TRUE")
        self.ReadEnsight_1.set_enable_autocoloring( "FALSE" )
       
        # wait for choices to be updated
        self.scalarVariables3DGetterAction.waitForChoices()
        self.vectorVariables3DGetterAction.waitForChoices()
        self.scalarVariables2DGetterAction.waitForChoices()
        self.vectorVariables2DGetterAction.waitForChoices()

        # wait for the part info message
        self.aPartsCollectorAction.waitForPartsinfoFinished()

                
        # get variables
        self.scalarVariables3D=self.scalarVariables3DGetterAction.getChoices()
        self.vectorVariables3D=self.vectorVariables3DGetterAction.getChoices()
        self.scalarVariables2D=self.scalarVariables2DGetterAction.getChoices()
        self.vectorVariables2D=self.vectorVariables2DGetterAction.getChoices()


        text = "Ensight Case File: %s"%(self.fullEnsightCaseName)
        self.statusText.append(text)

        self.statusText.append("\n3D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict3dParts().keys():
            partname = self.aPartsCollectorAction.getRefNameDict3dParts()[partid]
            text = "\tPart %d = %s"%(partid, partname)
            self.statusText.append(text)

        self.statusText.append("3D Part Variables:")
        for svar in self.scalarVariables3D:
           text= "\t%s(scalar)"%(svar)   
           self.statusText.append(text)
        for vvar in self.vectorVariables3D:
           text= "\t%s(vector)"%(vvar)   
           self.statusText.append(text)              
                                  
        self.statusText.append("\n2D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict2dParts().keys():
            partname = self.aPartsCollectorAction.getRefNameDict2dParts()[partid]
            text = "\tPart %d = %s"%(partid, partname)
            self.statusText.append(text)

        self.statusText.append("2D Part Variables:")
        for svar in self.scalarVariables2D:
           text= "\t%s(scalar)"%(svar)   
           self.statusText.append(text)
        for vvar in self.vectorVariables2D:
           text= "\t%s(vector)"%(vvar)   
           self.statusText.append(text) 
           
        QtWidgets.QApplication.processEvents()
       
         

        # MODULE: RWCovise
        self.RWCovise_1 = RWCovise()
        theNet.add( self.RWCovise_1 )
        self.RWCovise_1.set_stepNo( 0 )
        self.RWCovise_1.set_rotate_output( "FALSE" )
        self.RWCovise_1.set_rotation_axis( 3 )
        self.RWCovise_1.set_rot_speed( 2.000000 )

        self.cocase = CoviseCaseFile()
        cn = os.path.basename(str(self.fullEnsightCaseName))
        self.cocasename = cn[0: cn.rfind('.')]
Example #14
0
class Ensight2CoviseGui(Ensight2CoviseGuiBase):

    def __init__(self):
        #print "Ensight2CoviseGui.__init__"
        
        # init base class
        Ensight2CoviseGuiBase.__init__(self, None)

        # connect buttons
        self.outputDirLineEdit.returnPressed.connect(self.setOutputDir)
        self.byteswapped.stateChanged.connect(self.setByteswap)
        self.startConversionPushButton.clicked.connect(self.startConversion)
        
        # initialize output directory
        InitialDatasetSearchPath = covise.getCoConfigEntry("vr-prepare.InitialDatasetSearchPath")
        if not InitialDatasetSearchPath:
            InitialDatasetSearchPath = os.getcwd()
        self.currentFilePath = InitialDatasetSearchPath

        self.scale = 1.0

        # disable all buttons at beginning
        self.settingsFrame.setEnabled(False)
        self.startConversionFrame.setEnabled(False)
        self.outputDirFrame.setEnabled(False)
        self.isByteSwapped = True

    def closeEvent(self, event):
        covise.clean()
        covise.quit()

    def fileOpen(self):
        #print "Ensight2CoviseGui.fileOpen"
        fd = QtWidgets.QFileDialog(self)
        fd.setMinimumWidth(1050)
        fd.setMinimumHeight(700)
        fd.setNameFilter('Ensight case File (*.case *.encas *.CASE *.ENCAS)')
        fd.setWindowTitle('Open Ensight Case File')
        fd.setDirectory(self.currentFilePath)

        acceptedOrRejected = fd.exec_()
        if acceptedOrRejected != QtWidgets.QDialog.Accepted :
            return
        filenamesQt = fd.selectedFiles()
        if filenamesQt.isEmpty():
            return
        self.currentFilePath = os.path.dirname(str(filenamesQt[0]))
        self.fullEnsightCaseName = str(filenamesQt[0])
        
        
        # try to open file
        if not os.access(self.fullEnsightCaseName, os.R_OK):
            self.statusText.append("ERROR: Could not open file "+self.fullEnsightCaseName+ " - not readable")  
        else:

            # start modules
            self.startModules()
       
            # disable file open
            self.fileOpenAction.setEnabled(False) 
        
            # set output File path
            self.outputFilePath = self.currentFilePath + "/CoviseDaten/"
            if os.path.isdir(self.outputFilePath):
                pass
            else:
                try:
                    os.mkdir(self.outputFilePath)
                except(OSError):
                    self.statusText.append("ERROR: Could not create directory "+str(self.outputFilePath)+" check permissions and enter again or select another directory")
                    self.outputFilePath = None
                
            if (self.outputFilePath):
                self.outputDirLineEdit.setText(self.outputFilePath)
                # enable all buttons           
                self.outputDirFrame.setEnabled(True)
                self.startConversionFrame.setEnabled(True)
                self.settingsFrame.setEnabled(True)


    def fileExit(self):
        #print "Ensight2CoviseGui.fileExit"
        self.close()
        sys.exit()

    def setByteswap(self, i):
        self.isByteSwapped = self.byteswapped.isChecked()       

    def setOutputDir(self):
        #print "Ensight2CoviseGui.setOutputDir"
        self.outputFilePath=str(self.outputDirLineEdit.text())
        if not os.path.isdir(self.outputFilePath):
            try:
                os.mkdir(self.outputFilePath)
                self.statusText.append("\nINFO: created directory "+self.outputFilePath)
            except(OSError):
                self.statusText.append("\nERROR: Could not create directory "+self.outputFilePath+" check permissions and enter again or select another directory")
                self.outputFilePath = None
        else:
            self.statusText.append("\nINFO: directory "+self.outputFilePath+" exists already")        
         
        
                    
    def customEvent(self,e):
        pass

   
    
    def startModules(self):
        #print "Ensight2CoviseGui.startModules"
        self.aErrorLogAction = ErrorLogAction()
        CoviseMsgLoop().register(self.aErrorLogAction)

        global theNet
        theNet = net()
        
        self.scalarVariables3DGetterAction = ChoiceGetterAction()
        self.vectorVariables3DGetterAction = ChoiceGetterAction()
        self.scalarVariables2DGetterAction = ChoiceGetterAction()
        self.vectorVariables2DGetterAction = ChoiceGetterAction()

 

        # MODULE: ReadEnsight
        self.ReadEnsight_1 = ReadEnsight()
        theNet.add( self.ReadEnsight_1 )

        self.aPartsCollectorAction = PartsCollectorAction()
        CoviseMsgLoop().register(self.aPartsCollectorAction)


        # hang in variable-getters
        self.ReadEnsight_1.addNotifier('data_for_sdata1_3D', self.scalarVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_3D', self.vectorVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_sdata1_2D', self.scalarVariables2DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_2D', self.vectorVariables2DGetterAction)


        # set parameter values
        if self.isByteSwapped == True:
            self.ReadEnsight_1.set_data_byte_swap( "TRUE" )
        else:
            self.ReadEnsight_1.set_data_byte_swap( "FALSE" )
        self.ReadEnsight_1.set_case_file( self.fullEnsightCaseName )
        self.ReadEnsight_1.set_include_polyhedra( "TRUE")
        self.ReadEnsight_1.set_enable_autocoloring( "FALSE" )
       
        # wait for choices to be updated
        self.scalarVariables3DGetterAction.waitForChoices()
        self.vectorVariables3DGetterAction.waitForChoices()
        self.scalarVariables2DGetterAction.waitForChoices()
        self.vectorVariables2DGetterAction.waitForChoices()

        # wait for the part info message
        self.aPartsCollectorAction.waitForPartsinfoFinished()

                
        # get variables
        self.scalarVariables3D=self.scalarVariables3DGetterAction.getChoices()
        self.vectorVariables3D=self.vectorVariables3DGetterAction.getChoices()
        self.scalarVariables2D=self.scalarVariables2DGetterAction.getChoices()
        self.vectorVariables2D=self.vectorVariables2DGetterAction.getChoices()


        text = "Ensight Case File: %s"%(self.fullEnsightCaseName)
        self.statusText.append(text)

        self.statusText.append("\n3D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict3dParts().keys():
            partname = self.aPartsCollectorAction.getRefNameDict3dParts()[partid]
            text = "\tPart %d = %s"%(partid, partname)
            self.statusText.append(text)

        self.statusText.append("3D Part Variables:")
        for svar in self.scalarVariables3D:
           text= "\t%s(scalar)"%(svar)   
           self.statusText.append(text)
        for vvar in self.vectorVariables3D:
           text= "\t%s(vector)"%(vvar)   
           self.statusText.append(text)              
                                  
        self.statusText.append("\n2D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict2dParts().keys():
            partname = self.aPartsCollectorAction.getRefNameDict2dParts()[partid]
            text = "\tPart %d = %s"%(partid, partname)
            self.statusText.append(text)

        self.statusText.append("2D Part Variables:")
        for svar in self.scalarVariables2D:
           text= "\t%s(scalar)"%(svar)   
           self.statusText.append(text)
        for vvar in self.vectorVariables2D:
           text= "\t%s(vector)"%(vvar)   
           self.statusText.append(text) 
           
        QtWidgets.QApplication.processEvents()
       
         

        # MODULE: RWCovise
        self.RWCovise_1 = RWCovise()
        theNet.add( self.RWCovise_1 )
        self.RWCovise_1.set_stepNo( 0 )
        self.RWCovise_1.set_rotate_output( "FALSE" )
        self.RWCovise_1.set_rotation_axis( 3 )
        self.RWCovise_1.set_rot_speed( 2.000000 )

        self.cocase = CoviseCaseFile()
        cn = os.path.basename(str(self.fullEnsightCaseName))
        self.cocasename = cn[0: cn.rfind('.')]
        
        
    def startConversion(self):
        #print "Ensight2CoviseGui.startConversion"

        # Module Transform
        self.scale = float(str(self.leScale.text()))
        if self.scale != 1:
            if not hasattr(self, "Transform_1"):
                self.Transform_1 = Transform()
                theNet.add( self.Transform_1 )
                self.Transform_1.set_Transform( 5 )
                self.Transform_1.set_createSet( "FALSE" )
            self.Transform_1.set_scaling_factor( self.scale )

        self.outputDirFrame.setEnabled(False)
        self.startConversionFrame.setEnabled(False)
        self.settingsFrame.setEnabled(False)
        #self.statusText.clear()
        text="\nStarting Conversion in %s..."%(self.outputFilePath)
        self.statusText.append(text)
        QtWidgets.QApplication.processEvents()
        self.startConversionOf3DParts()
        self.startConversionOf2DParts()

        QtWidgets.QApplication.processEvents()
        CoviseMsgLoop().unregister(self.aPartsCollectorAction)
        CoviseMsgLoop().unregister(self.aErrorLogAction)

        theNet.remove( self.ReadEnsight_1 )

        text="\nWriting cocase to file..."
        self.statusText.append(text)
        pickleFile = self.outputFilePath + self.cocasename + '.cocase'
        counter=0
        while os.path.isfile(pickleFile):
            text= "! A file named %s is already available ... trying a new name"%(pickleFile)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents()            
            counter=counter+1
            pickleFile = self.outputFilePath + self.cocasename + "_"+str(counter)     
        output = open(pickleFile, 'wb')
        pickle.dump(self.cocase,output)
        output.close()

        text="cocasefile written to %s\n"%(pickleFile,)
        self.statusText.append(text)
        QtWidgets.QApplication.processEvents()


        text="\nConversion finished!"
        self.statusText.append(text)


    def startConversionOf3DParts(self):     
        for partid in self.aPartsCollectorAction.getRefNameDict3dParts().keys():
            #if int(partid) >= int(self.comboStartId.getCurrentIndex()):
            # get partname
            partname = self.aPartsCollectorAction.getRefNameDict3dParts()[partid]
            text = "\nConverting grid of part %s please be patient..."%(partname)
            self.statusText.append(text)            
            QtWidgets.QApplication.processEvents() 
            # connect modules
            if self.scale != 1:
                theNet.connect( self.ReadEnsight_1, "geoOut_3D", self.Transform_1, "geo_in" )
                theNet.connect( self.Transform_1, "geo_out", self.RWCovise_1, "mesh_in" )
            else:
                theNet.connect( self.ReadEnsight_1, "geoOut_3D", self.RWCovise_1, "mesh_in" )
                
            # select part
            self.ReadEnsight_1.set_choose_parts( str(partid) )
            
            # clean partname
            if "/" in partname:
                text="! Removing the / in partname = %s\n"%(partname)
                self.statusText.append(text) 
                QtWidgets.QApplication.processEvents()            
                partname=partname.replace("/","")
                
            # create RW Covise name
            covisename = self.outputFilePath +partname + "-3D.covise"
            # check if file is already available
            #print "rwcovisename=", covisename
            counter=0
            while os.path.isfile(covisename):
                text= "! A file named %s is already available ... trying a new name"%(covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()            
                counter=counter+1
                covisename = self.outputFilePath + partname + str(counter) + "-3D.covise"            

            QtWidgets.QApplication.processEvents()
                                     
            self.RWCovise_1.set_grid_path( covisename )
            QtWidgets.QApplication.processEvents() 
            # execute
            self.ReadEnsight_1.execute()
            theNet.finishedBarrier()
        
            #theNet.save( "grid.net" )

            # write logfile
            text="Converted grid of part %s to covise file %s"%(partname, covisename)
            self.statusText.append(text)            
            QtWidgets.QApplication.processEvents() 
            # create cocase item
            item3D = CoviseCaseFileItem(partname, GEOMETRY_3D, os.path.basename(covisename))
           
            # disconnect modules
            if self.scale !=1:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_3D", self.Transform_1, "geo_in" )
                theNet.disconnect( self.Transform_1, "geo_out", self.RWCovise_1, "mesh_in" )
            else:
                theNet.disconnect(self. ReadEnsight_1, "geoOut_3D", self.RWCovise_1, "mesh_in" )
                
        
            QtWidgets.QApplication.processEvents() 

            # scalar variables
        
            # connect modules
            if self.scale!=1:
                theNet.connect( self.ReadEnsight_1, "geoOut_3D", self.Transform_1, "geo_in" )
                theNet.connect( self.ReadEnsight_1, "sdata1_3D", self.Transform_1, "data_in0" )
                theNet.connect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.connect( self.ReadEnsight_1, "sdata1_3D", self.RWCovise_1, "mesh_in" )
       
            # loop over scalar variables
            choice=1
            for svar in self.scalarVariables3D:
                text= "\nConverting scalar variable %s of part %s, please be patient..."%(svar, partname)   
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                    
                # select variable
                choice+=1
                self.ReadEnsight_1.set_data_for_sdata1_3D( choice )
                # clean variablename
                if "/" in svar:
                    text="! Removing the / in svar = %s\n"%(svar,)
                    statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    svar=svar.replace("/","")
                # create RWCovise name
                covisename = self.outputFilePath + partname + "-" + svar + "-3D.covise"
                # check if file is already available
                counter=0
                while os.path.isfile(covisename):
                    text="! A file named %s is already available ... trying a new name"%(covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    counter=counter+1
                    covisename = self.outputFilePath + partname + str(counter) + "-" + svar + "-3D.covise"
                    
                
                
                self.RWCovise_1.set_grid_path( covisename )
                QtWidgets.QApplication.processEvents()     
                
                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text="Converted scalar variable %s of part %s to file %s"%(svar, partname, covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                
                # add variable to cacase item
                item3D.addVariableAndFilename(svar, covisename, SCALARVARIABLE)
                
                #theNet.save( "scalar.net" )

            # disconnect modules
            if self.scale!=1:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_3D", self.Transform_1, "geo_in" )
                theNet.disconnect( self.ReadEnsight_1, "sdata1_3D", self.Transform_1, "data_in0" )
                theNet.disconnect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.disconnect( self.ReadEnsight_1, "sdata1_3D", self.RWCovise_1, "mesh_in" )
 
            QtWidgets.QApplication.processEvents() 
            
            

            # vector variables

            # connect modules
            if self.scale!=1:
                theNet.connect( self.ReadEnsight_1, "geoOut_3D", self.Transform_1, "geo_in" )
                theNet.connect( self.ReadEnsight_1, "vdata1_3D", self.Transform_1, "data_in0" )
                theNet.connect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.connect( self.ReadEnsight_1, "vdata1_3D", self.RWCovise_1, "mesh_in" )

            # loop over variables
            choice=1
            for vvar in self.vectorVariables3D:
                text= "\nConverting vector variable %s of part %s, please be patient..."%(vvar, partname)   
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 

                # select variable
                choice+=1
                self.ReadEnsight_1.set_data_for_vdata1_3D( choice )
                # clean variablename
                if "/" in vvar:
                    text="! Removing the / in vvar = %s\n"%(vvar,)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    partname=partname.replace("/","")
                # create covisename
                covisename = self.outputFilePath + partname + "-" + vvar + "-3D.covise"
                # check if file is already available
                counter=0
                while os.path.isfile(covisename):
                    text="! A file named %s is already available trying a new name"%(covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    counter=counter+1
                    covisename = self.outputFilePath + partname + str(counter) + "-" + vvar + "-3D.covise"
                self.RWCovise_1.set_grid_path( covisename )
                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text="Converted vector variable%s of part %s to file %s"%(vvar,partname, covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                # add variable to cocase item
                item3D.addVariableAndFilename(vvar, covisename, VECTOR3DVARIABLE)
                 

            # disconnect modules
            if self.scale!=1:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_3D", self.Transform_1, "geo_in" )
                theNet.disconnect( self.ReadEnsight_1, "vdata1_3D", self.Transform_1, "data_in0" )
                theNet.disconnect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.disconnect( self.ReadEnsight_1, "vdata1_3D",self. RWCovise_1, "mesh_in" )

            # add the cocase item to the case file
            self.cocase.add(item3D)
            QtWidgets.QApplication.processEvents()    

    def startConversionOf2DParts(self):
        #print "__________START 2D---------" 
        for partid in self.aPartsCollectorAction.getRefNameDict2dParts().keys():
            partname = self.aPartsCollectorAction.getRefNameDict2dParts()[partid]
             # write logfile
            text="\nConverting surface of part %s, please be patient..."%(partname)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents() 
            # connect modules
            if self.scale!=1:
                theNet.connect( self.ReadEnsight_1, "geoOut_2D", self.Transform_1, "geo_in" )
                theNet.connect( self.Transform_1, "geo_out", self.RWCovise_1, "mesh_in" )
            else:
                theNet.connect( self.ReadEnsight_1, "geoOut_2D", self.RWCovise_1, "mesh_in" )
            # select part
            self.ReadEnsight_1.set_choose_parts( str(partid) )
            # clean partname
            if "/" in partname:
                text="! Removing the / in partname = %s\n"%(partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                partname=partname.replace("/","")
            # create RWCovise name
            covisename = self.outputFilePath + partname + "-2D.covise"
            counter=0
            while os.path.isfile(covisename):
                text="! A file named %s is already available trying a new name"%(covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                counter=counter+1
                covisename = self.outputFilePath + partname + str(counter) + "-2D.covise"
            self.RWCovise_1.set_grid_path( covisename )
            
            # execute
            self.ReadEnsight_1.execute()
            theNet.finishedBarrier()
            
            # write logfile
            text="Converted surface of part %s to file %s"%(partname, covisename)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents() 
            # create cocase item
            item2D = CoviseCaseFileItem(partname, GEOMETRY_2D, os.path.basename(covisename))
            

            # disconnect the modules
            if self.scale !=1:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_2D", self.Transform_1, "geo_in" )
                theNet.disconnect( self.Transform_1, "geo_out", self.RWCovise_1, "mesh_in" )
            else:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_2D", self.RWCovise_1, "mesh_in" )

            #
            # scalar variables
            #

            # connect modules
            if self.scale!=1:
                theNet.connect( self.ReadEnsight_1, "geoOut_2D", self.Transform_1, "geo_in" )
                theNet.connect( self.ReadEnsight_1, "sdata1_2D", self.Transform_1, "data_in0" )
                theNet.connect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.connect( self.ReadEnsight_1, "sdata1_2D", self.RWCovise_1, "mesh_in" )

            choice=1
            for svar in self.scalarVariables2D:
                # select variable
                choice+=1
                text="\nConverting scalar variable %s of part %s, please be patient..."%(svar, partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                self.ReadEnsight_1.set_data_for_sdata1_2D( choice )
                # clean variablename
                if "/" in partname:
                    text="! Removing the / in partname = %s\n"%(partname)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    partname=partname.replace("/","")
                # create RWCovise name
                covisename = self.outputFilePath + partname + "-" + svar + "-2D.covise"
                counter=0
                while os.path.isfile(covisename):
                    text="! A file named %s is already available ... trying a new name"%(covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    counter=counter+1
                    covisename = self.outputFilePath + partname + str(counter) + "-" + svar + "-2D.covise"
                self.RWCovise_1.set_grid_path( covisename )
                
                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text="Converted scalar variable %s of part %s to file %s"%(svar, partname, covisename,)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                # add variable to cicase item
                item2D.addVariableAndFilename(svar, covisename, SCALARVARIABLE)
                # print memory usage of module
                #os.system('ps aux | grep ReadEnsight_1')

            # disconnect modules
            if self.scale!=1:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_2D", self.Transform_1, "geo_in" )
                theNet.disconnect( self.ReadEnsight_1, "sdata1_2D", self.Transform_1, "data_in0" )
                theNet.disconnect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.disconnect( self.ReadEnsight_1, "sdata1_2D", self.RWCovise_1, "mesh_in" )

            
            #  vector variables

            # connect modules
            if self.scale!=1:
                theNet.connect( self.ReadEnsight_1, "geoOut_2D", self.Transform_1, "geo_in" )
                theNet.connect( self.ReadEnsight_1, "vdata1_2D", self.Transform_1, "data_in0" )
                theNet.connect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.connect( self.ReadEnsight_1, "vdata1_2D", self.RWCovise_1, "mesh_in" )
            choice=1
            for vvar in self.vectorVariables2D:
                # select variable
                choice+=1
                text="\nConverting vector variable %s of part %s, please be patient..."%(vvar, partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                self.ReadEnsight_1.set_data_for_vdata1_2D( choice )
                # clean partname
                if "/" in partname:
                    text="! Removing the / in partname = %s\n"%(partname,)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    partname=partname.replace("/","")
                # create RWCovise name
                covisename = self.outputFilePath + partname + "-" + vvar + "-2D.covise"
                counter=0
                while os.path.isfile(covisename):
                    text="! A file named %s is already available ... trying a new name"%(covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents() 
                    counter=counter+1
                    covisename = self.outputFilePath + partname + str(counter) + "-" + vvar + "-2D.covise"
                self.RWCovise_1.set_grid_path( covisename )
                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text="Converted vector variable%s of part %s to file %s"%(vvar, partname, covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents() 
                # add varibale to coscase item
                item2D.addVariableAndFilename(vvar, covisename, VECTOR3DVARIABLE)
                

            # disconnect modules
            if self.scale!=1:
                theNet.disconnect( self.ReadEnsight_1, "geoOut_2D", self.Transform_1, "geo_in" )
                theNet.disconnect( self.ReadEnsight_1, "vdata1_2D", self.Transform_1, "data_in0" )
                theNet.disconnect( self.Transform_1, "data_out0", self.RWCovise_1, "mesh_in" )
            else:
                theNet.disconnect( self.ReadEnsight_1, "vdata1_2D", self.RWCovise_1, "mesh_in" )

            # add the cocase item to the case file
            self.cocase.add(item2D)
Example #15
0
class Cfx2CoviseGui(Cfx2CoviseGuiBase):

    def __init__(self):
        
        InitialDatasetSearchPath = covise.getCoConfigEntry("vr-prepare.InitialDatasetSearchPath")
        if not InitialDatasetSearchPath:
            InitialDatasetSearchPath = os.getcwd()
        self.currentFilePath = InitialDatasetSearchPath
        self.ReadCfx_1 = 'None'
        self.scale=1.0
        self.mirror=0 # 0=none, 1=X, 2=Y, 3=Z
        self.rotAxisX=1.0
        self.rotAxisY=1.0
        self.rotAxisZ=1.0
        self.rotAngle=0.0
        self.composedGrid = False
        self.noGrid = False
        self.processBoundaries = True
        self.numVariables = 0
        self.fixdomain = "None"
        self.calculatePDYNFlag = False
        self.domains=[]
        self.coCaseFile = "None"
        self.reduce = False
        self.reductionFactor = 40.0

        
        #
        # init base class
        #
        Cfx2CoviseGuiBase.__init__(self, None)

        #
        # remove unused menubar items 
        #
        self.fileNewAction.setVisible(False)
        #
        # disable all buttons
        #
        self.gridFrame.setEnabled(False)
        self.reduceFrame.setEnabled(False)
        self.variableFrame.setEnabled(False)
        self.settingsFrame.setEnabled(False)
        self.startConversionFrame.setEnabled(False)
        self.outputDirFrame.setEnabled(False)
             
         
        #
        # register error log action
        #
        self.aErrorLogAction = ErrorLogAction()
        CoviseMsgLoop().register(self.aErrorLogAction)
        self.aErrorLogAction.register(self)
        
        # 
        # register action to read message and boundaries
        self.aBoundaryCollectorAction = BoundariesCollectorAction()
        CoviseMsgLoop().register(self.aBoundaryCollectorAction)
        
        
        #
        # register choice action
        #
        self.domainsGetterAction = ChoiceGetterAction()
        self.RegionsSelectionGetterAction = ChoiceGetterAction()        
        self.BoundarySelectionGetterAction = ChoiceGetterAction()        
        self.scalar_dataGetterAction = ChoiceGetterAction()
        self.vector_dataGetterAction = ChoiceGetterAction()
        self.timestepsGetterAction = IntGetterAction()
        #self.first_timestepGetterAction = ChoiceGetterAction()
        #self.readGridGetterAction = ChoiceGetterAction()
        #self.readRegionsGetterAction = ChoiceGetterAction()
        #self.readBoundariesGetterAction = ChoiceGetterAction()
        self.boundary_scalar_dataGetterAction = ChoiceGetterAction()
        self.boundary_vector_dataGetterAction = ChoiceGetterAction()
        #self.grid_is_time_dependentGetterAction = ChoiceGetterAction()
        #self.zone_with_time_dependent_gridGetterAction = ChoiceGetterAction()
        #self.rotAxisGetterAction = ChoiceGetterAction()
        #self.point_on_rotAxisGetterAction = ChoiceGetterAction()
        #self.rot_Angle_pre_timestepGetterAction = ChoiceGetterAction()
        #self.transform_velocityGetterAction = ChoiceGetterAction()
        #self.transform_directionGetterAction = ChoiceGetterAction()
        #self.rotation_axisGetterAction = ChoiceGetterAction()
        #self.zone_to_transform_velocityGetterAction = ChoiceGetterAction()
        #self.angular_velocityGetterAction = ChoiceGetterAction()
        #self.rotate_velocityGetterAction = ChoiceGetterAction()
        
        self.domainsGetterAction.register(self)
        self.RegionsSelectionGetterAction.register(self)
        self.BoundarySelectionGetterAction.register(self)
        self.scalar_dataGetterAction.register(self)
        self.vector_dataGetterAction.register(self)
        #self.timestepsGetterAction.register(self)
        #self.first_timestepGetterAction.register(self)
        #self.readGridGetterAction.register(self)
        #self.readRegionsGetterAction.register(self)
        #self.readBoundariesGetterAction.register(self)
        self.boundary_scalar_dataGetterAction.register(self)
        self.boundary_vector_dataGetterAction.register(self)
        #self.grid_is_time_dependentGetterAction.register(self)
        #self.zone_with_time_dependent_gridGetterAction.register(self)
        #self.rotAxisGetterAction.register(self)
        #self.point_on_rotAxisGetterAction.register(self)
        #self.rot_Angle_pre_timestepGetterAction.register(self)
        #self.transform_velocityGetterAction.register(self)
        #self.transform_directionGetterAction.register(self)
        #self.rotation_axisGetterAction.register(self)
        #self.zone_to_transform_velocityGetterAction.register(self)
        #self.angular_velocityGetterAction.register(self)
        #self.rotate_velocityGetterAction.register(self)
        
        global theNet
        theNet = net() 
        #
        # MODULE: ReadCfx
        #
        self.ReadCfx_1 = ReadCFX()
        theNet.add( self.ReadCfx_1 )
        #
        # hang in variable-getters
        #
        self.ReadCfx_1.addNotifier('domains',self.domainsGetterAction)
        self.ReadCfx_1.addNotifier('RegionsSelection',self.RegionsSelectionGetterAction)
        self.ReadCfx_1.addNotifier('BoundarySelection',self.BoundarySelectionGetterAction)
        self.ReadCfx_1.addNotifier('scalar_data',self.scalar_dataGetterAction)
        self.ReadCfx_1.addNotifier('vector_data',self.vector_dataGetterAction)
        self.ReadCfx_1.addNotifier('timesteps',self.timestepsGetterAction)
        #self.ReadCfx_1.addNotifier('first_timestep',self.first_timestepGetterAction)
        #self.ReadCfx_1.addNotifier('readGrid',self.readGridGetterAction)
        #self.ReadCfx_1.addNotifier('readRegions',self.readRegionsGetterAction)
        #self.ReadCfx_1.addNotifier('readBoundaries',self.readBoundariesGetterAction)
        self.ReadCfx_1.addNotifier('boundary_scalar_data',self.boundary_scalar_dataGetterAction)
        self.ReadCfx_1.addNotifier('boundary_vector_data',self.boundary_vector_dataGetterAction)
        #self.ReadCfx_1.addNotifier('grid_is_time_dependent',self.grid_is_time_dependentGetterAction)
        #self.ReadCfx_1.addNotifier('zone_with_time_dependent_grid',self.zone_with_time_dependent_gridGetterAction)
        #self.ReadCfx_1.addNotifier('rotAxis',self.rotAxisGetterAction)
        #self.ReadCfx_1.addNotifier('point_on_rotAxis',self.point_on_rotAxisGetterAction)
        #self.ReadCfx_1.addNotifier('rot_Angle_pre_timestep',self.rot_Angle_pre_timestepGetterAction)
        #self.ReadCfx_1.addNotifier('transform_velocity',self.transform_velocityGetterAction)
        #self.ReadCfx_1.addNotifier('transform_direction',self.transform_directionGetterAction)
        #self.ReadCfx_1.addNotifier('rotation_axis',self.rotation_axisGetterAction)
        #self.ReadCfx_1.addNotifier('zone_to_transform_velocity',self.zone_to_transform_velocityGetterAction)
        #self.ReadCfx_1.addNotifier('angular_velocity',self.angular_velocityGetterAction)
        #self.ReadCfx_1.addNotifier('rotate_velocity',self.rotate_velocityGetterAction)

        #
        # connect buttons
        #
        
        self.cbNoGrid.stateChanged.connect(self.setNoGrid)
        self.cbNoGrid.stateChanged.connect(self.setComposedGrid)
        self.cbNoGrid.stateChanged.connect(self.setTransientGrid)
        self.cbNoGrid.currentIndexChanged.connect(self.setNumVar)
        self.cbNoGrid.stateChanged.connect(self.setPdyn)
        self.cbNoGrid.stateChanged.connect(self.setNoBound)
        self.cbNoGrid.currentIndexChanged.connect(self.setDomain)
        self.cbNoGrid.returnPressed.connect(self.setOutputDir)
        self.cbNoGrid.clicked.connect(self.addToCoCase)
        self.cbNoGrid.clicked.connect(self.startConversion)


    def closeEvent(self, event):
        covise.clean()
        covise.quit()


    def addToCoCase(self ):
        fd = QtWidgets.QFileDialog(self)#, 'Open Cfx File',self.currentFilePath,'cfx file (*.plt *.dat)')
        fd.setMinimumWidth(1050)
        fd.setMinimumHeight(700)
        fd.setNameFilter('cocase file (*.cocase)')
        fd.setWindowTitle('Open coCase File')
        fd.setDirectory(self.currentFilePath)

        acceptedOrRejected = fd.exec_()
        if acceptedOrRejected != QtWidgets.QDialog.Accepted :
            return
        filenamesQt = fd.selectedFiles()
        if filenamesQt.isEmpty():
            return
        self.coCaseFile = str(filenamesQt[0])
        self.coCaseLabel.setText(self.coCaseFile)
        
        
    def setNoGrid(self, i):
        self.noGrid = self.cbNoGrid.isChecked()       
        
    def setComposedGrid(self, i):
        self.composedGrid = self.cbComposedGrid.isChecked()       
                
    def setTransientGrid(self, i):
        if self.cbTransientGrid.isChecked():
            self.ReadCfx_1.set_grid_is_time_dependent("True")
        else:
            self.ReadCfx_1.set_grid_is_time_dependent("False")
        
    def setNumVar(self, i):
        self.numVariables = i+1

    def setPdyn(self, i):
        self.calculatePDYNFlag = self.cbPdyn.isChecked()

    def setNoBound(self, i):
        # set the boundaries to all
        # choice param is "None", "All", "Affenfelsen",....
        self.processBoundaries = not self.cbNoBound.isChecked()

    def setDomain(self, i):
        if i!=0:
            self.fixdomain = str(self.comboDomain.currentText ())
        self.domains=self.domainsGetterAction.getChoices()

    def setOutputDir(self):
        self.outputFilePath=str(self.outputDirLineEdit.text())
        

    def customEvent(self,e):
        if e.type() == NOTIFIER_EVENT:
            self.variables=e.value[1:]
            
            if e.param == "domains":
                self.comboDomain.clear()
                for v in self.variables:
                    self.comboDomain.addItem(v)  
                self.domains=self.domainsGetterAction.getChoices()              
                        
            if e.param == "scalar_data":
                    # first is none
                numVar = len(self.variables)-1
                if self.comboNumVar.count()==0 or numVar >= self.comboNumVar.count():
                    self.comboNumVar.clear()
                    for i in range(numVar):
                        self.comboNumVar.addItem(str(i+1))
                    self.numVariables = self.comboNumVar.count()-1
                    self.comboNumVar.setCurrentIndex (self.numVariables)
            if e.param == "vector_data":
                    # first is none
                numVar = len(self.variables)-1
                if self.comboNumVar.count()==0 or numVar >= self.comboNumVar.count():
                    self.comboNumVar.clear()
                    for i in range(numVar):
                        self.comboNumVar.addItem(str(i+1))
                    self.numVariables = self.comboNumVar.count()-1
                    self.comboNumVar.setCurrentIndex (self.numVariables)
            if e.param == "boundary_scalar_data":
                    # first is none
                numVar = len(self.variables)-1
                if self.comboNumVar.count()==0 or numVar >= self.comboNumVar.count():
                    self.comboNumVar.clear()
                    for i in range(numVar):
                        self.comboNumVar.addItem(str(i+1))
                    self.numVariables = self.comboNumVar.count()-1
                    self.comboNumVar.setCurrentIndex (self.numVariables)
            if e.param == "boundary_vector_data":
            # first is none
                numVar = len(self.variables)-1
                if self.comboNumVar.count()==0 or numVar >= self.comboNumVar.count():
                    self.comboNumVar.clear()
                    for i in range(numVar):
                        self.comboNumVar.addItem(str(i+1))
                    self.numVariables = self.comboNumVar.count()-1
                    self.comboNumVar.setCurrentIndex (self.numVariables)
                   
  
        if e.type() == ERROR_EVENT:
            if self.outputFilePath:           
                text="ERROR: "+e.error+"\n"            
                self.statusText.append(text)  
                  
    def fileOpen(self):
    
    
        fd = QtWidgets.QFileDialog(self)#, 'Open Cfx File',self.currentFilePath,'cfx file (*.plt *.dat)')
        fd.setMinimumWidth(1050)
        fd.setMinimumHeight(700)
        fd.setNameFilter('cfx file (*.res)')
        fd.setWindowTitle('Open Cfx File')
        fd.setDirectory(self.currentFilePath)

        acceptedOrRejected = fd.exec_()
        if acceptedOrRejected != QtWidgets.QDialog.Accepted :
            return
        filenamesQt = fd.selectedFiles()
        if filenamesQt.isEmpty():
            return
        self.currentFilePath = os.path.dirname(str(filenamesQt[0]))
        self.fileName = (os.path.basename(str(filenamesQt[0])))[0:-4]
        fullCfxCaseName = str(filenamesQt[0])
        
        
        #
        # try to open file
        #
        if not os.access(fullCfxCaseName, os.R_OK):
            self.statusText.append("ERROR: Could not open file "+fullCfxCaseName+ " - not readable")  
        else:
            #self.setCaption(os.path.basename(fullCfxCaseName))

            #
            # set filename
            #
            self.ReadCfx_1.set_result( fullCfxCaseName )
            #self.ReadCFX_1.set_read_grid("false")
       
            #
            # disable file open
            #
            self.fileOpenAction.setEnabled(False) 
        
            #
            # set output File path
            #
            self.outputDirFrame.setEnabled(True)
            self.outputFilePath = self.currentFilePath + "/CoviseDaten"
            self.outputDirLineEdit.setText(self.outputFilePath)           
                #
                # enable format
                #
                
            #enable all frames
            self.gridFrame.setEnabled(True)
            self.reduceFrame.setEnabled(True)
            self.variableFrame.setEnabled(True)
            self.settingsFrame.setEnabled(True)
            self.startConversionFrame.setEnabled(True)
            self.outputDirFrame.setEnabled(True)  
        
        self.aBoundaryCollectorAction.waitForBoundaryInfoFinished()
        

       

    def fileExit(self):
        sys.exit()

    def calculatePDYN(self, caseFileItem):
        if not self.calculatePDYNFlag:
            return
        ptot_filename = ""
        pres_filename = ""
        for (varName, varFile, varDimension) in caseFileItem.variables_:
            if (varName == "PTOT") and (varDimension == SCALARVARIABLE):
                ptot_filename = varFile
            if (varName == "PRES") and (varDimension == SCALARVARIABLE):
                pres_filename = varFile
        if (ptot_filename != "") and (pres_filename != ""):
            pdyn_filename = ptot_filename.replace("-PTOT-", "-PDYN-")
            # calculate
            os.spawnlp(os.P_WAIT, "calcCovise", "calcCovise", pdyn_filename, "s1-s2", ptot_filename, pres_filename)
            # add
            caseFileItem.addVariableAndFilename("PDYN", pdyn_filename, SCALARVARIABLE)
            
    def convertBegin(self):
        self.cocase = CoviseCaseFile()
        if self.coCaseFile != "None":
            inputFile = open(self.coCaseFile, 'rb')
            self.cocase = pickle.load(inputFile)
            inputFile.close()
            self.cocasename = (os.path.basename(self.coCaseFile))[0:-7]
        else:
            self.cocasename=self.fileName
        logFileName = self.outputFilePath + '/' + self.cocasename + '.log'
        self.logFile = open(logFileName, 'w')
        self.logFile.write("Options:\n")
        self.logFile.write("Covise Case Name = %s\n"%(self.cocasename,))
        self.logFile.write("Covise Data Directory = %s\n"%(self.outputFilePath,))
        self.logFile.write("scale = %s\n"%(self.scale))
        self.logFile.write("\n")
        self.logFile.flush()



    def convertEnd(self):
        self.pickleFile = self.outputFilePath + '/' + self.cocasename + '.cocase'
        output = open(self.pickleFile, 'wb')
        pickle.dump(self.cocase,output)
        output.close()

        self.logFile.write("\ncocasefile = %s\n"%(self.pickleFile,))
        self.logFile.flush()

        self.logFile.write("\nConversion finished\n")
        self.logFile.flush()
        self.logFile.close()    


    def convert(self, domainname, domainchoice, processGrid, processBoundaries):
        # write logfile
        self.logFile.write("\nprocessing %s\n"%(domainname))
        self.logFile.flush()
        text = "\nprocessing %s"%(domainname)
        self.statusText.append(text)

        # reset wait variable    
        self.scalar_dataGetterAction.resetWait()
        self.vector_dataGetterAction.resetWait()
        self.boundary_scalar_dataGetterAction.resetWait()
        
        # select the domain
        self.ReadCfx_1.set_domains( domainchoice )

        # wait for choices to be updated by the module
        self.scalar_dataGetterAction.waitForChoices()
        self.vector_dataGetterAction.waitForChoices()
        self.boundary_scalar_dataGetterAction.waitForChoices()

        # read chocies
        scalarVariablesTuple = self.scalar_dataGetterAction.getChoices()
        vectorVariablesTuple = self.vector_dataGetterAction.getChoices()
        scalarVariables = {}
        vectorVariables = {}
        
        #first choice is none
        varChoice = 2
        for svar in scalarVariablesTuple:
            if  not 'boundary' in svar:
                scalarVariables[varChoice] = svar
            varChoice += 1
        varChoice = 2
        for vvar in vectorVariablesTuple:
            if not 'boundary' in vvar:
                vectorVariables[varChoice] = vvar
            varChoice += 1
       
        
        #get boundaries from message
        if processBoundaries:
            boundaries = self.aBoundaryCollectorAction.getBoundaryNames(domainname)
        else:
            boundaries = []


        #
        # CONVERT GRID
        #

        # connect grid
        gridPort = (self.ReadCfx_1, "GridOut0")
        if (self.scale != 1.0):
            theNet.connect( gridPort[0], gridPort[1], self.Transform_1, "geo_in" )
            gridPort = (self.Transform_1, "geo_out")
        if (self.mirror != 0):
            theNet.connect( gridPort[0], gridPort[1], self.Transform_2, "geo_in" )
            gridPort = (self.Transform_2, "geo_out")
        if (self.rotAngle != 0.0):
            theNet.connect( gridPort[0], gridPort[1], self.Transform_3, "geo_in" )
            gridPort = (self.Transform_3, "geo_out")
        theNet.connect( gridPort[0], gridPort[1], self.RWCovise_1, "mesh_in" )

        # set variables to None
        self.ReadCfx_1.set_scalar_data( 1 )
        self.ReadCfx_1.set_vector_data( 1 )    
        self.ReadCfx_1.set_boundary_scalar_data( 1 )

        covisename = domainname + "-3D.covise"         
        # create the cocase file item
        item3D = None
        if processGrid:
            self.ReadCfx_1.set_readGrid('True')
            item3D = CoviseCaseFileItem(domainname, GEOMETRY_3D, covisename)  
            # write logfile
            self.logFile.write("\n\tconverting grid %s ...\n"%(domainname))
            self.logFile.flush()
            text = "\n\tconverting grid "+ domainname + " ..."
            self.statusText.append( text )
            # clean the domainname
            if "/" in domainname:
                self.logFile.write("\t! Attention: Replacing the / in domainname = %s\n"%(domainname,))
                self.logFile.flush()
                text =  "\t! Attention: Replacing the / in domainname = "+ domainname
                self.statusText.append(text)
                domainname=domainname.replace("/","per")
            if "\x7f" in domainname:
                self.logFile.write("\t! Attention: Replacing a special character in domainname = %s\n"%(domainname,))
                self.logFile.flush()
                text =  "\t! Attention: Removing a special character in domainname = "+ domainname
                self.statusText.append(text)
                domainname=domainname.replace("\x7f","_")
            # create the RWCovise name
            self.RWCovise_1.set_grid_path( self.outputFilePath + '/' +covisename )
            # execute
            self.ReadCfx_1.execute()     
            theNet.finishedBarrier()
            # write logfile
            self.logFile.write("\t... conversion successful! File: %s\n"%(covisename,))
            self.logFile.flush()
            text =  "\t... conversion successful! File: "+covisename
            self.statusText.append(text)
        
            # disconnect grid
            theNet.disconnectAllFromModule(self.ReadCfx_1)
            theNet.disconnectAllFromModule(self.RWCovise_1)
            if (self.scale != 1.0):
                theNet.disconnectAllFromModule(self.Transform_1)
            if (self.mirror != 0):
                theNet.disconnectAllFromModule(self.Transform_2)
            if (self.rotAngle != 0.0):
                theNet.disconnectAllFromModule(self.Transform_3)

            self.ReadCfx_1.set_readGrid("False")

        else:
            self.ReadCfx_1.set_readGrid('False')
            item3D = CoviseCaseFileItem(domainname, GEOMETRY_3D, covisename)  
            for item in self.cocase.items_:
                text = "name "+item.name_
                self.statusText.append( text)
                text = "covisename "+domainname
                self.statusText.append( text)
                if item.name_ == domainname:
                    item3D = item
                    break             
            self.ReadCfx_1.execute()
            theNet.finishedBarrier()            

        timesteps = self.timestepsGetterAction.getInt()
        if timesteps == 0:
            timesteps = None
             

        #
        # CONVERT BOUNDARIES
        #

        # workaround for bug in readCFX, some parts are not convertes correctly,
        # but "all" parts are allways correct, therefore we use all parts
        # and extract the parts with GetSubset
        item2D={}
        if processBoundaries:
            self.ReadCfx_1.set_readBoundaries("True")
            # 
            # RWCovise
            #
            self.RWCovise_2.set_stepNo( 0 )
            self.RWCovise_2.set_rotate_output( "FALSE" )
            self.RWCovise_2.set_rotation_axis( 3 )
            self.RWCovise_2.set_rot_speed( 2.000000 )
    
           
            # connect boundaries
            outPort = (self.ReadCfx_1, "GridOut2")
            if timesteps==None:
                theNet.connect( outPort[0], outPort[1], self.GetSubset_1, "DataIn0" )      
                theNet.connect( self.GetSubset_1, "DataOut0", self.FixUsg_1, "GridIn0" )
                outPort = (self.FixUsg_1, "GridIn0")
            if self.reduce:
                theNet.connect( outPort[0], outPort[1], self.SimplifySurface_1, "meshIn" )
                outPort = (self.SimplifySurface_1, "meshOut")
            if (self.scale != 1.0):
                theNet.connect( outPort[0], outPort[1], self.Transform_1, "geo_in" )
                outPort = (self.Transform_1, "geo_out")
            if (self.mirror != 0):
                theNet.connect( outPort[0], outPort[1], self.Transform_2, "geo_in" )
                outPort = (self.Transform_2, "geo_out")
            if (self.rotAngle != 0.0):
                theNet.connect( outPort[0], outPort[1], self.Transform_3, "geo_in" )
                outPort = (self.Transform_3, "geo_out")
            theNet.connect( outPort[0], outPort[1], self.RWCovise_2, "mesh_in" )

            subset=0
            boundchoice=1
            for boundname in boundaries:
                boundchoice = int(boundaries[boundname])
                self.ReadCfx_1.set_BoundarySelection(str(boundchoice))
                # ommit names "None" "all"
                #boundchoice+=1            
                if int(boundchoice) > 0 :
                    # write logfile
                    self.logFile.write("\n\tconverting surface %s ...\n"%(boundname,))
                    self.logFile.flush()
                    text =  "\n\tconverting surface %s ..."%(boundname,)
                    self.statusText.append( text)
                    bname=boundname
                    # clean boundname
                    if "/" in boundname:
                        self.logFile.write("\t! Attention: Replacing the / in boundname = %s\n"%(boundname,))
                        self.logFile.flush()
                        text =  "\t! Attention: Replacing the / in boundname = "+ boundname
                        self.statusText.append( text)
                        bname=boundname.replace("/","per")
                    if "\x7f" in boundname:
                        self.logFile.write("\t! Attention: Replacing a special character in boundname = %s\n"%(boundname,))
                        self.logFile.flush()
                        text =  "\t! Attention: Replacing a special character in boundname = ", boundname
                        self.statusText.append( text)
                        bname=boundname.replace("\x7f","_")
                    # set the subset
                    self.GetSubset_1.set_selection( str(0) )
                    # create RWCovise name
                    bname = bname.replace(' ','_')
                    covisename = domainname + "-boundary-" + bname + "-2D.covise"
                    self.RWCovise_2.set_grid_path( self.outputFilePath + '/' +covisename )
                    # execute
                    self.ReadCfx_1.execute()
                    #if timesteps==None:
                    #    GetSubset_1.execute()
                    #else :
                    #    GetSetelem_1.set_stepNo(1)
                    #    GetSetelem_1.execute()    
                    theNet.finishedBarrier()
                    # write logfile
                    self.logFile.write("\t... conversion successful! Filen: %s\n"%(covisename,))
                    self.logFile.flush()
                    text =  "\t... conversion successful! File: "+covisename
                    self.statusText.append( text)
                    # create cocase item
                    item2D[boundname] = CoviseCaseFileItem(domainname + "-" + bname, GEOMETRY_2D, covisename)
                    subset+=1
            
            # disconnect boundaries
            theNet.disconnectAllFromModule(self.ReadCfx_1)
            theNet.disconnectAllFromModule(self.RWCovise_2)
            if self.reduce:
                theNet.disconnectAllFromModule(self.SimplifySurface_1)
            if timesteps==None:
                theNet.disconnectAllFromModule(self.GetSubset_1)
                theNet.disconnectAllFromModule(self.FixUsg_1)
            if (self.scale != 1.0):
                theNet.disconnectAllFromModule(self.Transform_1)
            if (self.mirror != 0):
                theNet.disconnectAllFromModule(self.Transform_2)
            if (self.rotAngle != 0.0):
                theNet.disconnectAllFromModule(self.Transform_3)
    
            #theNet.remove( RWCovise_2 )
            #theNet.remove( GetSubset_1 )
            #theNet.remove( FixUsg_1 )
    
            #if not timesteps==None:
            #    theNet.remove( GetSetelem_1 )
            #    theNet.remove( self.PipelineCollect_1 )
            

        #
        # CONVERT SCALAR VARIABLES
        #

        # connect the 3D scalar data
        theNet.connect( self.ReadCfx_1, "DataOut0", self.RWCovise_1, "mesh_in" )


       # loop through the scalar variables
        # select the variable, ommit variable "none"
        countVar = 0
        for varchoice in scalarVariables:
            svar = scalarVariables[varchoice]
            #bsvar = boundScalarVariables[varchoice]
            # convert only the first numVariables variables
            countVar += 1
            #if ( fixresult=="None" and int(varchoice) < (int(self.numVariables)+2) ) or svar==fixresult :
            if countVar <= self.numVariables :
        
                #
                # CONVERT SCALAR VARIABLES OF GRID
                #

                self.logFile.write("\n\tconverting scalar variable %s on grid %s...\n"%(svar,domainname))
                self.logFile.flush()
                text = "\n\tconverting scalar variable "+ svar + " on grid " + domainname + "..."
                self.statusText.append( text)
                # clean variablename
                if "/" in svar:
                    self.logFile.write("\t! Attention: Replacing the / in svar = %s\n"%(svar,))
                    self.logFile.flush()
                    text = "\t! Attention: Replacing the / in svar = "+ svar
                    self.statusText.append( text)
                    svar=svar.replace("/","per")
                if "\x7f" in svar:
                    self.logFile.write("\t! Attention: Replacing a special character in svar = %s\n"%(svar,))
                    self.logFile.flush()
                    text = "\t! Attention: Replacing a special character in svar = "+ svar
                    self.statusText.append( text)
                    svar=svar.replace("\x7f","_")
                # select variable
                self.ReadCfx_1.set_scalar_data( varchoice )
                self.ReadCfx_1.set_boundary_scalar_data( varchoice )
                self.ReadCfx_1.set_readGrid("false")
                covisename = domainname + "-" + svar + "-3D.covise"
                #create RWCovise name
                self.RWCovise_1.set_grid_path( self.outputFilePath + '/' +covisename )
                # execute
                self.ReadCfx_1.execute()
                theNet.finishedBarrier()
                # write logile
                self.logFile.write("\t... conversion successful! Filename: %s\n"%(covisename,))
                self.logFile.flush()
                text = "\t... conversion successful! Filename: "+covisename
                self.statusText.append( text)
                # add variable to cocase item
                item3D.addVariableAndFilename(svar, covisename, SCALARVARIABLE)
            

                #
                # CONVERT SCALAR VARIABLES OF BOUNDARIES
                #

                if processBoundaries:
                    # 
                    # RWCovise
                    #
                    self.RWCovise_2.set_stepNo( 0 )
                    self.RWCovise_2.set_rotate_output( "FALSE" )
                    self.RWCovise_2.set_rotation_axis( 3 )
                    self.RWCovise_2.set_rot_speed( 2.000000 )

                    
                    # connect the boundary scalar data
                    gridPort = (self.ReadCfx_1, "GridOut2")
                    dataPort = (self.ReadCfx_1, "DataOut3")
                    if timesteps==None:
                        theNet.connect( gridPort[0], gridPort[1], self.GetSubset_1, "DataIn0" )      
                        theNet.connect( dataPort[0], dataPort[1], self.GetSubset_1, "DataIn1" )
                        theNet.connect( self.GetSubset_1, "DataOut0", self.FixUsg_1, "GridIn0" )      
                        theNet.connect( self.GetSubset_1, "DataOut1", self.FixUsg_1, "DataIn0" )  
                        gridPort = (self.FixUsg_1, "GridOut0")
                        dataPort = (self.FixUsg_1, "DataOut0")
                    if self.reduce:
                        theNet.connect( gridPort[0], gridPort[1], self.SimplifySurface_1, "meshIn")
                        theNet.connect( dataPort[0], dataPort[1], self.SimplifySurface_1, "dataIn_0")
                        gridPort = (self.SimplifySurface_1, "meshOut")
                        dataPort = (self.SimplifySurface_1, "dataOut_0")
                    theNet.connect( dataPort[0], dataPort[1], self.RWCovise_2, "mesh_in" )
                       
   
                    subset=0
                    boundchoice=1
                    for boundname in boundaries:
                        boundchoice = int(boundaries[boundname])
                        self.ReadCfx_1.set_BoundarySelection(str(boundchoice))
                        # ommit names "None" "all"
                        #boundchoice+=1            
                        if int(boundchoice) > 0 :
                            self.logFile.write("\n\tconverting scalar variable %s on surface %s %d...\n"%(svar,boundname, boundchoice))
                            self.logFile.flush()
                            text =  "\n\tconverting scalar variable "+ svar + " on surface " + boundname + "..."
                            self.statusText.append( text)
                            bname=boundname
                            # clean boundname
                            if "/" in boundname:
                                self.logFile.write("\t! Attention: Replacing the / in boundname = %s\n"%(boundname,))
                                self.logFile.flush()
                                text =  "\t! Attention: Replacing the / in boundname = "+ boundname
                                self.statusText.append( text)
                                bname=boundname.replace("/","per")
                            if "\x7f" in boundname:
                                self.logFile.write("\t! Attention: Replacing a special character in boundname = %s\n"%(boundname,))
                                self.logFile.flush()
                                text = "\t! Attention: Replacing a special character in boundname = "+ boundname
                                self.statusText.append( text)
                                bname=boundname.replace("\x7f","_")
                            # clean variablename
                            if "/" in svar:
                                self.logFile.write("\t! Attention: Replacing the / in svar = %s\n"%(svar,))
                                self.logFile.flush()
                                text = "\t! Attention: Replacing the / in svar = "+ svar
                                self.statusText.append( text)
                                svar=svar.replace("/","per")
                            if "\x7f" in svar:
                                self.logFile.write("\t! Attention: Replacing a special character in svar = %s\n"%(svar,))
                                self.logFile.flush()
                                text = "\t! Attention: Replacing a special character in svar = "+ svar
                                self.statusText.append( text)
                                svar=svar.replace("\x7f","_")
                                text = "\t! new svar = ", svar
                                self.statusText.append( text)
                            # set the subset
                            self.GetSubset_1.set_selection( str(0) )
                            # create RWCovise name
                            bname = bname.replace(' ', '_')
                            svar = svar.replace(' ', '_')
                            covisename = domainname + "-boundary-" + bname + "-" + svar + "-2D.covise"
                            self.RWCovise_2.set_grid_path( self.outputFilePath + '/' +covisename )                         
                            # execute  
                            self.ReadCfx_1.execute()
                            #if timesteps==None:
                            #    self.ReadCfx_1.execute()
                            #else :
                            #    self.GetSetelem_1.set_stepNo(1)
                            #    self.GetSetelem_1.execute()                    
                            theNet.finishedBarrier()
                            # write logfile
                            self.logFile.write("\t... conversion successful: Filename %s\n"%(covisename,))
                            self.logFile.flush()
                            text =  "\t... conversion successful: "+covisename
                            self.statusText.append( text)
                            # append variable to cocase item
                            if boundname in item2D:
                                item2D[boundname].addVariableAndFilename(svar, covisename, SCALARVARIABLE)
                            subset+=1
                                           

                    # disconnect the boundaries
                    gridPort = (self.ReadCfx_1, "GridOut2")
                    dataPort = (self.ReadCfx_1, "DataOut3")
                    if timesteps==None:
                        theNet.disconnect( gridPort[0], gridPort[1], self.GetSubset_1, "DataIn0" )      
                        theNet.disconnect( dataPort[0], dataPort[1], self.GetSubset_1, "DataIn1" )
                        theNet.disconnect( self.GetSubset_1, "DataOut0", self.FixUsg_1, "GridIn0" )      
                        theNet.disconnect( self.GetSubset_1, "DataOut1", self.FixUsg_1, "DataIn0" )  
                        gridPort = (self.FixUsg_1, "GridOut0")
                        dataPort = (self.FixUsg_1, "DataOut0")
                    if self.reduce:
                        theNet.disconnect( gridPort[0], gridPort[1], self.SimplifySurface_1, "meshIn")
                        theNet.disconnect( dataPort[0], dataPort[1], self.SimplifySurface_1, "dataIn_0")
                        gridPort = (self.SimplifySurface_1, "meshOut")
                        dataPort = (self.SimplifySurface_1, "dataOut_0")
                    theNet.disconnect( dataPort[0], dataPort[1], self.RWCovise_2, "mesh_in" )
                          
                        
                    #theNet.remove( RWCovise_2 )
                    #theNet.remove( GetSubset_1 )            
                    #theNet.remove( FixUsg_1 )            
                    #if not timesteps==None:
                    #    theNet.remove( GetSetelem_1 )
                    #    theNet.remove( self.PipelineCollect_1 ) 
    
                
        # disconnect the grid
        theNet.disconnect( self.ReadCfx_1, "DataOut0", self.RWCovise_1, "mesh_in" )            



        #
        # convert the vector variables
        #

        # read no boundaries
        self.ReadCfx_1.set_readBoundaries( "False" )  

        if (self.scale == 1.0) and (self.mirror == 0) and (self.rotAngle == 0.0):
            self.ReadCfx_1.set_readGrid("false")
        else:
            self.ReadCfx_1.set_readGrid("true")

        # connect the modules
        gridPort = (self.ReadCfx_1, "GridOut0")
        dataPort = (self.ReadCfx_1, "DataOut1")
        if (self.scale != 1.0):
            theNet.connect( gridPort[0], gridPort[1], self.Transform_1, "geo_in" )
            theNet.connect( dataPort[0], dataPort[1], self.Transform_1, "data_in0" )
            gridPort = (self.Transform_1, "geo_out")
            dataPort = (self.Transform_1, "data_out0")
        if (self.mirror != 0):
            theNet.connect( gridPort[0], gridPort[1], self.Transform_2, "geo_in" )
            theNet.connect( dataPort[0], dataPort[1], self.Transform_2, "data_in0" )
            gridPort = (self.Transform_2, "geo_out")
            dataPort = (self.Transform_2, "data_out0")
        if (self.rotAngle != 0.0):
            theNet.connect( gridPort[0], gridPort[1], self.Transform_3, "geo_in" )
            theNet.connect( dataPort[0], dataPort[1], self.Transform_3, "data_in0" )
            gridPort = (self.Transform_3, "geo_out")
            dataPort = (self.Transform_3, "data_out0")
        theNet.connect( dataPort[0], dataPort[1], self.RWCovise_1, "mesh_in" )

        # loop though the variables
        # ommit variable "none"
        countVar = 0
        for varchoice in vectorVariables:
            vvar = vectorVariables[varchoice]
            # select only the first numVariables variables
            #if ( fixresult=="None" and int(varchoice) < (int(numVariables)+2) ) or vvar==fixresult :
            countVar +=1
            if countVar <= self.numVariables :
                self.logFile.write("\n\tconverting vector variable %s ...\n"%(vvar,))
                self.logFile.flush()
                text = "\n\tconverting vector variable "+ vvar + " ..."
                self.statusText.append( text)
                # clean variablename
                if "/" in vvar:
                    self.logFile.write("\t! Attention: Replacing the / in vvar = %s\n"%(vvar,))
                    self.logFile.flush()
                    text =  "\t! Attention: Replacing the / in vvar = "+ vvar
                    self.statusText.append( text)
                    vvar=vvar.replace("/","per")
                if "\x7f" in vvar:
                    self.logFile.write("\t! Attention: Replacing a special character in vvar = %s\n"%(vvar,))
                    self.logFile.flush()
                    text = "\t! Attention: Replacing a special character in vvar = "+ vvar
                    self.statusText.append( text)
                    vvar=vvar.replace("\x7f","_")
                    text = "\t! new vvar = ", vvar
                    self.statusText.append( text)
                # select variable
                self.ReadCfx_1.set_vector_data( varchoice )
                # create RWCovise name
                covisename = domainname + "-" + vvar + "-3D.covise"
                self.RWCovise_1.set_grid_path(self.outputFilePath + '/' + covisename )
                # execute
                self.ReadCfx_1.execute()
                theNet.finishedBarrier()
                # write logfile
                self.logFile.write("\t... conversion successful! Filename: %s\n"%(covisename,))
                self.logFile.flush()
                text = "\t... conversion successful! Filename: "+covisename
                self.statusText.append( text)
                # append variable to cocase item
                item3D.addVariableAndFilename(vvar, covisename, VECTOR3DVARIABLE)
        # disconnect the modules
        theNet.disconnectAllFromModule(self.ReadCfx_1)
        theNet.disconnectAllFromModule(self.RWCovise_1)
        if (self.scale != 1.0):
            theNet.disconnectAllFromModule(self.Transform_1)
        if (self.mirror != 0):
            theNet.disconnectAllFromModule(self.Transform_2)
        if (self.rotAngle != 0.0):
            theNet.disconnectAllFromModule(self.Transform_3)

        #
        # add Grid to coCase
        #
        if processGrid:
            # add to cocase
            self.cocase.add(item3D)
        # add the boundary item do the case file
        if processBoundaries:
            for boundname in boundaries:
                # ommit names "None" "all"
                boundchoice = int(boundaries[boundname])            
                if int(boundchoice) > 0 :
                    self.calculatePDYN(item2D[boundname])
                    self.cocase.add(item2D[boundname])
            


    def startModules(self):
        global theNet
        
        
        # Module Transform (scaling)
        #
        if (self.scale != 1.0):
            self.Transform_1 = Transform()
            theNet.add( self.Transform_1 )
            self.Transform_1.set_Transform( 5 )
            self.Transform_1.set_scaling_factor( self.scale )
            self.Transform_1.set_createSet( "FALSE" ) 

        # Module Transform (mirror)
        #
        if (self.mirror != 0):
            self.Transform_2 = Transform()
            theNet.add( self.Transform_2 )
            self.Transform_2.set_Transform( 2 )
            if (self.mirror == 1):
                self.Transform_2.set_normal_of_mirror_plane(1.0, 0.0, 0.0)
            elif (self.mirror == 2):
                self.Transform_2.set_normal_of_mirror_plane(0.0, 1.0, 0.0)
            elif (self.mirror == 3):
                self.Transform_2.set_normal_of_mirror_plane(0.0, 0.0, 1.0)
            self.Transform_2.set_MirroredAndOriginal( "FALSE" )
            self.Transform_2.set_createSet( "FALSE" )

        # Module Transform (rotation)
        #
        if (self.rotAngle != 0.0):
            self.Transform_3 = Transform()
            theNet.add( self.Transform_3 )
            self.Transform_3.set_Transform( 4 )
            self.Transform_3.set_axis_of_rotation(self.rotAxisX, self.rotAxisY, self.rotAxisZ)
            self.Transform_3.set_angle_of_rotation( self.rotAngle )
            self.Transform_3.set_createSet( "FALSE" ) 


        # Module SimplifySurface
        #
        if self.reduce:
            self.SimplifySurface_1 = SimplifySurface()
            theNet.add( self.SimplifySurface_1 )
            self.SimplifySurface_1.set_ignore_data( "TRUE" )
            self.SimplifySurface_1.set_percent( self.reductionFactor )

        #
        # MODULE: RWCovise
        #
        self.RWCovise_1 = RWCovise()
        theNet.add( self.RWCovise_1 )
        self.RWCovise_1.set_stepNo( 0 )
        self.RWCovise_1.set_rotate_output( "FALSE" )
        self.RWCovise_1.set_rotation_axis( 3 )
        self.RWCovise_1.set_rot_speed( 2.000000 )
        
        self.RWCovise_2 = RWCovise()
        theNet.add( self.RWCovise_2 )
        
        #
        # Module GetSubset
        #
        self.GetSubset_1 = GetSubset()
        theNet.add( self.GetSubset_1 )      
          
        #
        # Module FixUsg
        #                 
        self.FixUsg_1 = FixUsg()
        theNet.add( self.FixUsg_1 )      


#        self.GetSetelem_1 = GetSetelem()
#        theNet.add( self.GetSetelem_1 )
#        self.PipelineCollect_1 = PipelineCollect()
#        theNet.add( self.PipelineCollect_1 )


    def startConversion(self):
       
        global theNet
        
        if os.path.isdir(self.outputFilePath):
            pass
        else:
            try:
                os.mkdir(self.outputFilePath)
            except(OSError):
                self.statusText.append("ERROR: Could not create directory "+str(self.outputFilePath)+" check permissions and enter again or select another directory")
                return


        # reduction
        self.reduce = self.reduceCheckBox.isChecked()
        self.reductionFactor=float(str(self.leReductionFactor.text()))
        # scale
        self.scale=float(str(self.leScaleX.text()))
        # mirror
        self.mirror=self.comboMirror.currentIndex()
        # rotation
        self.rotAxisX=float(str(self.leRotAxisX.text()))
        self.rotAxisY=float(str(self.leRotAxisY.text()))
        self.rotAxisZ=float(str(self.leRotAxisZ.text()))
        self.rotAngle=float(str(self.leRotAngle.text()))


        self.statusText.append("Starting conversion...")
        self.startModules()
        self.convertBegin()

        #
        # loop through the domains parts
        # ('all', 'Domain\x7f1', '')
        #
        domainchoice=1
        #
        # read the domain values
        #
        for domainname in self.domains:
            domainchoice+=1
            if self.fixdomain=="None" or self.fixdomain==domainname:            
                self.convert(domainname, domainchoice, (not self.noGrid), self.processBoundaries)

        #
        # create composed grid
        #
        if (not self.noGrid) and (self.composedGrid):
            self.convert("all", 1, True, False)



        self.convertEnd()
        self.repaint()
        

        
        text="\n\n...conversion finished!\n"
        self.statusText.append(text)
Example #16
0
except:
    import pickle

import sys, os, shutil
from coPyModules import RWCovise, SimplifySurface
from coviseCase import (CoviseCaseFileItem, CoviseCaseFile, GEOMETRY_2D,
                        GEOMETRY_3D, SCALARVARIABLE, VECTOR3DVARIABLE)

# params
theCoCaseFileName = "/data/Kunden/Daimler/W221_Familientag/Temperature/CoviseDaten/reduced/fahrzeug.cocase"
theOutputSubDir = "simplified"
thePercent = 5.0  # lower means smaller
theMaxNormalDeviation = 5.0

theNet = net()
theGridRCovise = RWCovise()
theDataRCovise = RWCovise()
theGridWCovise = RWCovise()
theDataWCovise = RWCovise()
theSimplify = SimplifySurface()
theNet.add(theGridRCovise)
theNet.add(theDataRCovise)
theNet.add(theGridWCovise)
theNet.add(theDataWCovise)
theNet.add(theSimplify)
theSimplify.set_percent(thePercent)
theSimplify.set_max_normaldeviation(theMaxNormalDeviation)

cocase = CoviseCaseFile()
inputFile = open(theCoCaseFileName, 'rb')
cocase = pickle.load(inputFile)
Example #17
0
class Ensight2CoviseGui(Ensight2CoviseGuiBase):
    def __init__(self):
        #print "Ensight2CoviseGui.__init__"

        # init base class
        Ensight2CoviseGuiBase.__init__(self, None)

        # connect buttons
        self.outputDirLineEdit.returnPressed.connect(self.setOutputDir)
        self.byteswapped.stateChanged.connect(self.setByteswap)
        self.startConversionPushButton.clicked.connect(self.startConversion)

        # initialize output directory
        InitialDatasetSearchPath = covise.getCoConfigEntry(
            "vr-prepare.InitialDatasetSearchPath")
        if not InitialDatasetSearchPath:
            InitialDatasetSearchPath = os.getcwd()
        self.currentFilePath = InitialDatasetSearchPath

        self.scale = 1.0

        # disable all buttons at beginning
        self.settingsFrame.setEnabled(False)
        self.startConversionFrame.setEnabled(False)
        self.outputDirFrame.setEnabled(False)
        self.isByteSwapped = True

    def closeEvent(self, event):
        covise.clean()
        covise.quit()

    def fileOpen(self):
        #print "Ensight2CoviseGui.fileOpen"
        fd = QtWidgets.QFileDialog(self)
        fd.setMinimumWidth(1050)
        fd.setMinimumHeight(700)
        fd.setNameFilter('Ensight case File (*.case *.encas *.CASE *.ENCAS)')
        fd.setWindowTitle('Open Ensight Case File')
        fd.setDirectory(self.currentFilePath)

        acceptedOrRejected = fd.exec_()
        if acceptedOrRejected != QtWidgets.QDialog.Accepted:
            return
        filenamesQt = fd.selectedFiles()
        if filenamesQt.isEmpty():
            return
        self.currentFilePath = os.path.dirname(str(filenamesQt[0]))
        self.fullEnsightCaseName = str(filenamesQt[0])

        # try to open file
        if not os.access(self.fullEnsightCaseName, os.R_OK):
            self.statusText.append("ERROR: Could not open file " +
                                   self.fullEnsightCaseName +
                                   " - not readable")
        else:

            # start modules
            self.startModules()

            # disable file open
            self.fileOpenAction.setEnabled(False)

            # set output File path
            self.outputFilePath = self.currentFilePath + "/CoviseDaten/"
            if os.path.isdir(self.outputFilePath):
                pass
            else:
                try:
                    os.mkdir(self.outputFilePath)
                except (OSError):
                    self.statusText.append(
                        "ERROR: Could not create directory " +
                        str(self.outputFilePath) +
                        " check permissions and enter again or select another directory"
                    )
                    self.outputFilePath = None

            if (self.outputFilePath):
                self.outputDirLineEdit.setText(self.outputFilePath)
                # enable all buttons
                self.outputDirFrame.setEnabled(True)
                self.startConversionFrame.setEnabled(True)
                self.settingsFrame.setEnabled(True)

    def fileExit(self):
        #print "Ensight2CoviseGui.fileExit"
        self.close()
        sys.exit()

    def setByteswap(self, i):
        self.isByteSwapped = self.byteswapped.isChecked()

    def setOutputDir(self):
        #print "Ensight2CoviseGui.setOutputDir"
        self.outputFilePath = str(self.outputDirLineEdit.text())
        if not os.path.isdir(self.outputFilePath):
            try:
                os.mkdir(self.outputFilePath)
                self.statusText.append("\nINFO: created directory " +
                                       self.outputFilePath)
            except (OSError):
                self.statusText.append(
                    "\nERROR: Could not create directory " +
                    self.outputFilePath +
                    " check permissions and enter again or select another directory"
                )
                self.outputFilePath = None
        else:
            self.statusText.append("\nINFO: directory " + self.outputFilePath +
                                   " exists already")

    def customEvent(self, e):
        pass

    def startModules(self):
        #print "Ensight2CoviseGui.startModules"
        self.aErrorLogAction = ErrorLogAction()
        CoviseMsgLoop().register(self.aErrorLogAction)

        global theNet
        theNet = net()

        self.scalarVariables3DGetterAction = ChoiceGetterAction()
        self.vectorVariables3DGetterAction = ChoiceGetterAction()
        self.scalarVariables2DGetterAction = ChoiceGetterAction()
        self.vectorVariables2DGetterAction = ChoiceGetterAction()

        # MODULE: ReadEnsight
        self.ReadEnsight_1 = ReadEnsight()
        theNet.add(self.ReadEnsight_1)

        self.aPartsCollectorAction = PartsCollectorAction()
        CoviseMsgLoop().register(self.aPartsCollectorAction)

        # hang in variable-getters
        self.ReadEnsight_1.addNotifier('data_for_sdata1_3D',
                                       self.scalarVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_3D',
                                       self.vectorVariables3DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_sdata1_2D',
                                       self.scalarVariables2DGetterAction)
        self.ReadEnsight_1.addNotifier('data_for_vdata1_2D',
                                       self.vectorVariables2DGetterAction)

        # set parameter values
        if self.isByteSwapped == True:
            self.ReadEnsight_1.set_data_byte_swap("TRUE")
        else:
            self.ReadEnsight_1.set_data_byte_swap("FALSE")
        self.ReadEnsight_1.set_case_file(self.fullEnsightCaseName)
        self.ReadEnsight_1.set_include_polyhedra("TRUE")
        self.ReadEnsight_1.set_enable_autocoloring("FALSE")

        # wait for choices to be updated
        self.scalarVariables3DGetterAction.waitForChoices()
        self.vectorVariables3DGetterAction.waitForChoices()
        self.scalarVariables2DGetterAction.waitForChoices()
        self.vectorVariables2DGetterAction.waitForChoices()

        # wait for the part info message
        self.aPartsCollectorAction.waitForPartsinfoFinished()

        # get variables
        self.scalarVariables3D = self.scalarVariables3DGetterAction.getChoices(
        )
        self.vectorVariables3D = self.vectorVariables3DGetterAction.getChoices(
        )
        self.scalarVariables2D = self.scalarVariables2DGetterAction.getChoices(
        )
        self.vectorVariables2D = self.vectorVariables2DGetterAction.getChoices(
        )

        text = "Ensight Case File: %s" % (self.fullEnsightCaseName)
        self.statusText.append(text)

        self.statusText.append("\n3D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict3dParts().keys(
        ):
            partname = self.aPartsCollectorAction.getRefNameDict3dParts(
            )[partid]
            text = "\tPart %d = %s" % (partid, partname)
            self.statusText.append(text)

        self.statusText.append("3D Part Variables:")
        for svar in self.scalarVariables3D:
            text = "\t%s(scalar)" % (svar)
            self.statusText.append(text)
        for vvar in self.vectorVariables3D:
            text = "\t%s(vector)" % (vvar)
            self.statusText.append(text)

        self.statusText.append("\n2D parts:")
        for partid in self.aPartsCollectorAction.getRefNameDict2dParts().keys(
        ):
            partname = self.aPartsCollectorAction.getRefNameDict2dParts(
            )[partid]
            text = "\tPart %d = %s" % (partid, partname)
            self.statusText.append(text)

        self.statusText.append("2D Part Variables:")
        for svar in self.scalarVariables2D:
            text = "\t%s(scalar)" % (svar)
            self.statusText.append(text)
        for vvar in self.vectorVariables2D:
            text = "\t%s(vector)" % (vvar)
            self.statusText.append(text)

        QtWidgets.QApplication.processEvents()

        # MODULE: RWCovise
        self.RWCovise_1 = RWCovise()
        theNet.add(self.RWCovise_1)
        self.RWCovise_1.set_stepNo(0)
        self.RWCovise_1.set_rotate_output("FALSE")
        self.RWCovise_1.set_rotation_axis(3)
        self.RWCovise_1.set_rot_speed(2.000000)

        self.cocase = CoviseCaseFile()
        cn = os.path.basename(str(self.fullEnsightCaseName))
        self.cocasename = cn[0:cn.rfind('.')]

    def startConversion(self):
        #print "Ensight2CoviseGui.startConversion"

        # Module Transform
        self.scale = float(str(self.leScale.text()))
        if self.scale != 1:
            if not hasattr(self, "Transform_1"):
                self.Transform_1 = Transform()
                theNet.add(self.Transform_1)
                self.Transform_1.set_Transform(5)
                self.Transform_1.set_createSet("FALSE")
            self.Transform_1.set_scaling_factor(self.scale)

        self.outputDirFrame.setEnabled(False)
        self.startConversionFrame.setEnabled(False)
        self.settingsFrame.setEnabled(False)
        #self.statusText.clear()
        text = "\nStarting Conversion in %s..." % (self.outputFilePath)
        self.statusText.append(text)
        QtWidgets.QApplication.processEvents()
        self.startConversionOf3DParts()
        self.startConversionOf2DParts()

        QtWidgets.QApplication.processEvents()
        CoviseMsgLoop().unregister(self.aPartsCollectorAction)
        CoviseMsgLoop().unregister(self.aErrorLogAction)

        theNet.remove(self.ReadEnsight_1)

        text = "\nWriting cocase to file..."
        self.statusText.append(text)
        pickleFile = self.outputFilePath + self.cocasename + '.cocase'
        counter = 0
        while os.path.isfile(pickleFile):
            text = "! A file named %s is already available ... trying a new name" % (
                pickleFile)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents()
            counter = counter + 1
            pickleFile = self.outputFilePath + self.cocasename + "_" + str(
                counter)
        output = open(pickleFile, 'wb')
        pickle.dump(self.cocase, output)
        output.close()

        text = "cocasefile written to %s\n" % (pickleFile, )
        self.statusText.append(text)
        QtWidgets.QApplication.processEvents()

        text = "\nConversion finished!"
        self.statusText.append(text)

    def startConversionOf3DParts(self):
        for partid in self.aPartsCollectorAction.getRefNameDict3dParts().keys(
        ):
            #if int(partid) >= int(self.comboStartId.getCurrentIndex()):
            # get partname
            partname = self.aPartsCollectorAction.getRefNameDict3dParts(
            )[partid]
            text = "\nConverting grid of part %s please be patient..." % (
                partname)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents()
            # connect modules
            if self.scale != 1:
                theNet.connect(self.ReadEnsight_1, "geoOut_3D",
                               self.Transform_1, "geo_in")
                theNet.connect(self.Transform_1, "geo_out", self.RWCovise_1,
                               "mesh_in")
            else:
                theNet.connect(self.ReadEnsight_1, "geoOut_3D",
                               self.RWCovise_1, "mesh_in")

            # select part
            self.ReadEnsight_1.set_choose_parts(str(partid))

            # clean partname
            if "/" in partname:
                text = "! Removing the / in partname = %s\n" % (partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                partname = partname.replace("/", "")

            # create RW Covise name
            covisename = self.outputFilePath + partname + "-3D.covise"
            # check if file is already available
            #print "rwcovisename=", covisename
            counter = 0
            while os.path.isfile(covisename):
                text = "! A file named %s is already available ... trying a new name" % (
                    covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                counter = counter + 1
                covisename = self.outputFilePath + partname + str(
                    counter) + "-3D.covise"

            QtWidgets.QApplication.processEvents()

            self.RWCovise_1.set_grid_path(covisename)
            QtWidgets.QApplication.processEvents()
            # execute
            self.ReadEnsight_1.execute()
            theNet.finishedBarrier()

            #theNet.save( "grid.net" )

            # write logfile
            text = "Converted grid of part %s to covise file %s" % (partname,
                                                                    covisename)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents()
            # create cocase item
            item3D = CoviseCaseFileItem(partname, GEOMETRY_3D,
                                        os.path.basename(covisename))

            # disconnect modules
            if self.scale != 1:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_3D",
                                  self.Transform_1, "geo_in")
                theNet.disconnect(self.Transform_1, "geo_out", self.RWCovise_1,
                                  "mesh_in")
            else:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_3D",
                                  self.RWCovise_1, "mesh_in")

            QtWidgets.QApplication.processEvents()

            # scalar variables

            # connect modules
            if self.scale != 1:
                theNet.connect(self.ReadEnsight_1, "geoOut_3D",
                               self.Transform_1, "geo_in")
                theNet.connect(self.ReadEnsight_1, "sdata1_3D",
                               self.Transform_1, "data_in0")
                theNet.connect(self.Transform_1, "data_out0", self.RWCovise_1,
                               "mesh_in")
            else:
                theNet.connect(self.ReadEnsight_1, "sdata1_3D",
                               self.RWCovise_1, "mesh_in")

            # loop over scalar variables
            choice = 1
            for svar in self.scalarVariables3D:
                text = "\nConverting scalar variable %s of part %s, please be patient..." % (
                    svar, partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()

                # select variable
                choice += 1
                self.ReadEnsight_1.set_data_for_sdata1_3D(choice)
                # clean variablename
                if "/" in svar:
                    text = "! Removing the / in svar = %s\n" % (svar, )
                    statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    svar = svar.replace("/", "")
                # create RWCovise name
                covisename = self.outputFilePath + partname + "-" + svar + "-3D.covise"
                # check if file is already available
                counter = 0
                while os.path.isfile(covisename):
                    text = "! A file named %s is already available ... trying a new name" % (
                        covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    counter = counter + 1
                    covisename = self.outputFilePath + partname + str(
                        counter) + "-" + svar + "-3D.covise"

                self.RWCovise_1.set_grid_path(covisename)
                QtWidgets.QApplication.processEvents()

                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text = "Converted scalar variable %s of part %s to file %s" % (
                    svar, partname, covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()

                # add variable to cacase item
                item3D.addVariableAndFilename(svar, covisename, SCALARVARIABLE)

                #theNet.save( "scalar.net" )

            # disconnect modules
            if self.scale != 1:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_3D",
                                  self.Transform_1, "geo_in")
                theNet.disconnect(self.ReadEnsight_1, "sdata1_3D",
                                  self.Transform_1, "data_in0")
                theNet.disconnect(self.Transform_1, "data_out0",
                                  self.RWCovise_1, "mesh_in")
            else:
                theNet.disconnect(self.ReadEnsight_1, "sdata1_3D",
                                  self.RWCovise_1, "mesh_in")

            QtWidgets.QApplication.processEvents()

            # vector variables

            # connect modules
            if self.scale != 1:
                theNet.connect(self.ReadEnsight_1, "geoOut_3D",
                               self.Transform_1, "geo_in")
                theNet.connect(self.ReadEnsight_1, "vdata1_3D",
                               self.Transform_1, "data_in0")
                theNet.connect(self.Transform_1, "data_out0", self.RWCovise_1,
                               "mesh_in")
            else:
                theNet.connect(self.ReadEnsight_1, "vdata1_3D",
                               self.RWCovise_1, "mesh_in")

            # loop over variables
            choice = 1
            for vvar in self.vectorVariables3D:
                text = "\nConverting vector variable %s of part %s, please be patient..." % (
                    vvar, partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()

                # select variable
                choice += 1
                self.ReadEnsight_1.set_data_for_vdata1_3D(choice)
                # clean variablename
                if "/" in vvar:
                    text = "! Removing the / in vvar = %s\n" % (vvar, )
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    partname = partname.replace("/", "")
                # create covisename
                covisename = self.outputFilePath + partname + "-" + vvar + "-3D.covise"
                # check if file is already available
                counter = 0
                while os.path.isfile(covisename):
                    text = "! A file named %s is already available trying a new name" % (
                        covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    counter = counter + 1
                    covisename = self.outputFilePath + partname + str(
                        counter) + "-" + vvar + "-3D.covise"
                self.RWCovise_1.set_grid_path(covisename)
                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text = "Converted vector variable%s of part %s to file %s" % (
                    vvar, partname, covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                # add variable to cocase item
                item3D.addVariableAndFilename(vvar, covisename,
                                              VECTOR3DVARIABLE)

            # disconnect modules
            if self.scale != 1:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_3D",
                                  self.Transform_1, "geo_in")
                theNet.disconnect(self.ReadEnsight_1, "vdata1_3D",
                                  self.Transform_1, "data_in0")
                theNet.disconnect(self.Transform_1, "data_out0",
                                  self.RWCovise_1, "mesh_in")
            else:
                theNet.disconnect(self.ReadEnsight_1, "vdata1_3D",
                                  self.RWCovise_1, "mesh_in")

            # add the cocase item to the case file
            self.cocase.add(item3D)
            QtWidgets.QApplication.processEvents()

    def startConversionOf2DParts(self):
        #print "__________START 2D---------"
        for partid in self.aPartsCollectorAction.getRefNameDict2dParts().keys(
        ):
            partname = self.aPartsCollectorAction.getRefNameDict2dParts(
            )[partid]
            # write logfile
            text = "\nConverting surface of part %s, please be patient..." % (
                partname)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents()
            # connect modules
            if self.scale != 1:
                theNet.connect(self.ReadEnsight_1, "geoOut_2D",
                               self.Transform_1, "geo_in")
                theNet.connect(self.Transform_1, "geo_out", self.RWCovise_1,
                               "mesh_in")
            else:
                theNet.connect(self.ReadEnsight_1, "geoOut_2D",
                               self.RWCovise_1, "mesh_in")
            # select part
            self.ReadEnsight_1.set_choose_parts(str(partid))
            # clean partname
            if "/" in partname:
                text = "! Removing the / in partname = %s\n" % (partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                partname = partname.replace("/", "")
            # create RWCovise name
            covisename = self.outputFilePath + partname + "-2D.covise"
            counter = 0
            while os.path.isfile(covisename):
                text = "! A file named %s is already available trying a new name" % (
                    covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                counter = counter + 1
                covisename = self.outputFilePath + partname + str(
                    counter) + "-2D.covise"
            self.RWCovise_1.set_grid_path(covisename)

            # execute
            self.ReadEnsight_1.execute()
            theNet.finishedBarrier()

            # write logfile
            text = "Converted surface of part %s to file %s" % (partname,
                                                                covisename)
            self.statusText.append(text)
            QtWidgets.QApplication.processEvents()
            # create cocase item
            item2D = CoviseCaseFileItem(partname, GEOMETRY_2D,
                                        os.path.basename(covisename))

            # disconnect the modules
            if self.scale != 1:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_2D",
                                  self.Transform_1, "geo_in")
                theNet.disconnect(self.Transform_1, "geo_out", self.RWCovise_1,
                                  "mesh_in")
            else:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_2D",
                                  self.RWCovise_1, "mesh_in")

            #
            # scalar variables
            #

            # connect modules
            if self.scale != 1:
                theNet.connect(self.ReadEnsight_1, "geoOut_2D",
                               self.Transform_1, "geo_in")
                theNet.connect(self.ReadEnsight_1, "sdata1_2D",
                               self.Transform_1, "data_in0")
                theNet.connect(self.Transform_1, "data_out0", self.RWCovise_1,
                               "mesh_in")
            else:
                theNet.connect(self.ReadEnsight_1, "sdata1_2D",
                               self.RWCovise_1, "mesh_in")

            choice = 1
            for svar in self.scalarVariables2D:
                # select variable
                choice += 1
                text = "\nConverting scalar variable %s of part %s, please be patient..." % (
                    svar, partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                self.ReadEnsight_1.set_data_for_sdata1_2D(choice)
                # clean variablename
                if "/" in partname:
                    text = "! Removing the / in partname = %s\n" % (partname)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    partname = partname.replace("/", "")
                # create RWCovise name
                covisename = self.outputFilePath + partname + "-" + svar + "-2D.covise"
                counter = 0
                while os.path.isfile(covisename):
                    text = "! A file named %s is already available ... trying a new name" % (
                        covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    counter = counter + 1
                    covisename = self.outputFilePath + partname + str(
                        counter) + "-" + svar + "-2D.covise"
                self.RWCovise_1.set_grid_path(covisename)

                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text = "Converted scalar variable %s of part %s to file %s" % (
                    svar,
                    partname,
                    covisename,
                )
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                # add variable to cicase item
                item2D.addVariableAndFilename(svar, covisename, SCALARVARIABLE)
                # print memory usage of module
                #os.system('ps aux | grep ReadEnsight_1')

            # disconnect modules
            if self.scale != 1:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_2D",
                                  self.Transform_1, "geo_in")
                theNet.disconnect(self.ReadEnsight_1, "sdata1_2D",
                                  self.Transform_1, "data_in0")
                theNet.disconnect(self.Transform_1, "data_out0",
                                  self.RWCovise_1, "mesh_in")
            else:
                theNet.disconnect(self.ReadEnsight_1, "sdata1_2D",
                                  self.RWCovise_1, "mesh_in")

            #  vector variables

            # connect modules
            if self.scale != 1:
                theNet.connect(self.ReadEnsight_1, "geoOut_2D",
                               self.Transform_1, "geo_in")
                theNet.connect(self.ReadEnsight_1, "vdata1_2D",
                               self.Transform_1, "data_in0")
                theNet.connect(self.Transform_1, "data_out0", self.RWCovise_1,
                               "mesh_in")
            else:
                theNet.connect(self.ReadEnsight_1, "vdata1_2D",
                               self.RWCovise_1, "mesh_in")
            choice = 1
            for vvar in self.vectorVariables2D:
                # select variable
                choice += 1
                text = "\nConverting vector variable %s of part %s, please be patient..." % (
                    vvar, partname)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                self.ReadEnsight_1.set_data_for_vdata1_2D(choice)
                # clean partname
                if "/" in partname:
                    text = "! Removing the / in partname = %s\n" % (partname, )
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    partname = partname.replace("/", "")
                # create RWCovise name
                covisename = self.outputFilePath + partname + "-" + vvar + "-2D.covise"
                counter = 0
                while os.path.isfile(covisename):
                    text = "! A file named %s is already available ... trying a new name" % (
                        covisename)
                    self.statusText.append(text)
                    QtWidgets.QApplication.processEvents()
                    counter = counter + 1
                    covisename = self.outputFilePath + partname + str(
                        counter) + "-" + vvar + "-2D.covise"
                self.RWCovise_1.set_grid_path(covisename)
                # execute
                self.ReadEnsight_1.execute()
                theNet.finishedBarrier()
                # write logfile
                text = "Converted vector variable%s of part %s to file %s" % (
                    vvar, partname, covisename)
                self.statusText.append(text)
                QtWidgets.QApplication.processEvents()
                # add varibale to coscase item
                item2D.addVariableAndFilename(vvar, covisename,
                                              VECTOR3DVARIABLE)

            # disconnect modules
            if self.scale != 1:
                theNet.disconnect(self.ReadEnsight_1, "geoOut_2D",
                                  self.Transform_1, "geo_in")
                theNet.disconnect(self.ReadEnsight_1, "vdata1_2D",
                                  self.Transform_1, "data_in0")
                theNet.disconnect(self.Transform_1, "data_out0",
                                  self.RWCovise_1, "mesh_in")
            else:
                theNet.disconnect(self.ReadEnsight_1, "vdata1_2D",
                                  self.RWCovise_1, "mesh_in")

            # add the cocase item to the case file
            self.cocase.add(item2D)