Exemple #1
0
    def UpdateCinema(self, view, datadescription, specLevel):
        """ called from catalyst at each timestep to add to the cinema database """
        if not view.IsA("vtkSMRenderViewProxy") == True:
            return

        try:
            import paraview.cinemaIO.cinema_store as CS
            import paraview.cinemaIO.explorers as explorers
            import paraview.cinemaIO.pv_explorers as pv_explorers
            import paraview.cinemaIO.pv_introspect as pv_introspect
            import paraview.simple as simple
        except ImportError as e:
            paraview.print_error("Cannot import cinema")
            paraview.print_error(e)
            return

        #figure out where to put this store
        import os.path
        vfname = view.cpFileName
        vfname = vfname[0:vfname.rfind("_")]  #strip _num.ext
        fname = os.path.join(os.path.dirname(vfname), "cinema",
                             os.path.basename(vfname), "info.json")

        def float_limiter(x):
            #a shame, but needed to make sure python, javascript and (directory/file)name agree
            if isinstance(x, (float)):
                return '%.6e' % x  #arbitrarily chose 6 significant digits
            else:
                return x

        #what time?
        timestep = datadescription.GetTimeStep()
        time = datadescription.GetTime()
        view.ViewTime = time
        formatted_time = float_limiter(time)

        # Include camera information in the user defined parameters.
        # pv_introspect uses __CinemaTracks to customize the exploration.
        co = view.cpCinemaOptions
        camType = co["camera"]
        if "phi" in co:
            self.__CinemaTracks["phi"] = co["phi"]
        if "theta" in co:
            self.__CinemaTracks["theta"] = co["theta"]
        if "roll" in co:
            self.__CinemaTracks["roll"] = co["roll"]

        tracking_def = {}
        if "tracking" in co:
            tracking_def = co['tracking']

        #figure out what we show now
        pxystate = pv_introspect.record_visibility()
        # a conservative global bounds for consistent z scaling
        minbds, maxbds = pv_introspect.max_bounds()

        #make sure depth rasters are consistent
        view.MaxClipBounds = [minbds, maxbds, minbds, maxbds, minbds, maxbds]
        view.LockBounds = 1

        if specLevel == "B":
            p = pv_introspect.inspect(skip_invisible=True)
        else:
            p = pv_introspect.inspect(skip_invisible=False)
        fs = pv_introspect.make_cinema_store(p,
                                             fname,
                                             view,
                                             forcetime=formatted_time,
                                             userDefined=self.__CinemaTracks,
                                             specLevel=specLevel,
                                             camType=camType)

        #all nodes participate, but only root can writes out the files
        pm = servermanager.vtkProcessModule.GetProcessModule()
        pid = pm.GetPartitionId()

        enableFloatVal = False if 'floatValues' not in co else co['floatValues']

        pv_introspect.explore(fs,
                              p,
                              iSave=(pid == 0),
                              currentTime={'time': formatted_time},
                              userDefined=self.__CinemaTracks,
                              specLevel=specLevel,
                              camType=camType,
                              tracking=tracking_def,
                              floatValues=enableFloatVal)
        if pid == 0:
            fs.save()

        view.LockBounds = 0

        #restore what we showed
        pv_introspect.restore_visibility(pxystate)
        return os.path.basename(vfname)
Exemple #2
0
    def UpdateCinemaComposite(self, view, datadescription):
        """ called from catalyst at each timestep to add to the cinema "SPEC B" database """
        if not view.IsA("vtkSMRenderViewProxy") == True:
            return

        try:
            import paraview.cinemaIO.cinema_store as CS
            import paraview.cinemaIO.explorers as explorers
            import paraview.cinemaIO.pv_explorers as pv_explorers
            import paraview.cinemaIO.pv_introspect as pv_introspect
            import paraview.simple as simple
        except ImportError as e:
            paraview.print_error("Cannot import cinema")
            paraview.print_error(e)
            return


        #figure out where to put this store
        import os.path
        vfname = view.cpFileName
        vfname = vfname[0:vfname.rfind("_")] #strip _num.ext
        fname = os.path.join(os.path.dirname(vfname),
                             "cinema",
                             os.path.basename(vfname),
                             "info.json")

        def float_limiter(x):
            #a shame, but needed to make sure python, javascript and (directory/file)name agree
            if isinstance(x, (float)):
                return '%.6e' % x #arbitrarily chose 6 significant digits
            else:
                return x

        #what time?
        timestep = datadescription.GetTimeStep()
        time = datadescription.GetTime()
        view.ViewTime = time
        formatted_time = float_limiter(time)

        #pass down user provided parameters
        co = view.cpCinemaOptions
        if "phi" in co:
            self.__UserDefinedValues["phi"] = co["phi"]
        if "theta" in co:
            self.__UserDefinedValues["theta"] = co["theta"]

        simple.Render(view)

        #figure out what we show now
        pxystate= pv_introspect.record_visibility()

        #make sure depth rasters are consistent
        view.LockBounds = 1

        p = pv_introspect.inspect()
        fs = pv_introspect.make_cinema_store(p, fname,
                                            forcetime=formatted_time,
                                            _userDefinedValues = self.__UserDefinedValues)

        #all nodes participate, but only root can writes out the files
        pm = servermanager.vtkProcessModule.GetProcessModule()
        pid = pm.GetPartitionId()

        pv_introspect.explore(fs, p, iSave=(pid==0), currentTime={'time':formatted_time})
        if pid == 0:
            fs.save()

        view.LockBounds = 0

        #restore what we showed
        pv_introspect.restore_visibility(pxystate)
Exemple #3
0
    def UpdateCinemaComposite(self, view, datadescription):
        """ called from catalyst at each timestep to add to the cinema "SPEC B" database """
        if not view.IsA("vtkSMRenderViewProxy") == True:
            return

        try:
            import paraview.cinemaIO.cinema_store as CS
            import paraview.cinemaIO.explorers as explorers
            import paraview.cinemaIO.pv_explorers as pv_explorers
            import paraview.cinemaIO.pv_introspect as pv_introspect
            import paraview.simple as simple
        except ImportError as e:
            paraview.print_error("Cannot import cinema")
            paraview.print_error(e)
            return

        #figure out where to put this store
        import os.path
        vfname = view.cpFileName
        vfname = vfname[0:vfname.rfind("_")]  #strip _num.ext
        fname = os.path.join(os.path.dirname(vfname), "cinema",
                             os.path.basename(vfname), "info.json")

        def float_limiter(x):
            #a shame, but needed to make sure python, javascript and (directory/file)name agree
            if isinstance(x, (float)):
                return '%.6e' % x  #arbitrarily chose 6 significant digits
            else:
                return x

        #what time?
        timestep = datadescription.GetTimeStep()
        time = datadescription.GetTime()
        view.ViewTime = time
        formatted_time = float_limiter(time)

        #pass down user provided parameters
        co = view.cpCinemaOptions
        if "phi" in co:
            self.__UserDefinedValues["phi"] = co["phi"]
        if "theta" in co:
            self.__UserDefinedValues["theta"] = co["theta"]

        simple.Render(view)

        #figure out what we show now
        pxystate = pv_introspect.record_visibility()

        #make sure depth rasters are consistent
        view.LockBounds = 1

        p = pv_introspect.inspect()
        l = pv_introspect.munch_tree(p)
        fs = pv_introspect.make_cinema_store(
            l,
            fname,
            forcetime=formatted_time,
            _userDefinedValues=self.__UserDefinedValues)

        #all nodes participate, but only root can writes out the files
        pm = servermanager.vtkProcessModule.GetProcessModule()
        pid = pm.GetPartitionId()

        pv_introspect.explore(fs,
                              p,
                              iSave=(pid == 0),
                              currentTime={'time': formatted_time})
        if pid == 0:
            fs.save()

        view.LockBounds = 0

        #restore what we showed
        pv_introspect.restore_visibility(pxystate)
Exemple #4
0
    def UpdateCinema(self, view, datadescription, specLevel):
        """ called from catalyst at each timestep to add to the cinema database """
        if not view.IsA("vtkSMRenderViewProxy") == True:
            return

        try:
            import paraview.cinemaIO.cinema_store as CS
            import paraview.cinemaIO.explorers as explorers
            import paraview.cinemaIO.pv_explorers as pv_explorers
            import paraview.cinemaIO.pv_introspect as pv_introspect
            import paraview.simple as simple
        except ImportError as e:
            paraview.print_error("Cannot import cinema")
            paraview.print_error(e)
            return


        #figure out where to put this store
        import os.path
        vfname = view.cpFileName
        vfname = vfname[0:vfname.rfind("_")] #strip _num.ext
        fname = os.path.join(os.path.dirname(vfname),
                             "cinema",
                             os.path.basename(vfname),
                             "info.json")

        def float_limiter(x):
            #a shame, but needed to make sure python, javascript and (directory/file)name agree
            if isinstance(x, (float)):
                return '%.6e' % x #arbitrarily chose 6 significant digits
            else:
                return x

        #what time?
        timestep = datadescription.GetTimeStep()
        time = datadescription.GetTime()
        view.ViewTime = time
        formatted_time = float_limiter(time)

        # Include camera information in the user defined parameters.
        # pv_introspect uses __CinemaTracks to customize the exploration.
        co = view.cpCinemaOptions
        camType = co["camera"]
        if "phi" in co:
            self.__CinemaTracks["phi"] = co["phi"]
        if "theta" in co:
            self.__CinemaTracks["theta"] = co["theta"]
        if "roll" in co:
            self.__CinemaTracks["roll"] = co["roll"]

        tracking_def = {}
        if "tracking" in co:
            tracking_def = co['tracking']

        #figure out what we show now
        pxystate= pv_introspect.record_visibility()
        # a conservative global bounds for consistent z scaling
        minbds, maxbds  = pv_introspect.max_bounds()

        #make sure depth rasters are consistent
        view.MaxClipBounds = [minbds, maxbds, minbds, maxbds, minbds, maxbds]
        view.LockBounds = 1

        if specLevel=="B":
            p = pv_introspect.inspect(skip_invisible=True)
        else:
            p = pv_introspect.inspect(skip_invisible=False)
        fs = pv_introspect.make_cinema_store(p, fname, view,
                                             forcetime = formatted_time,
                                             userDefined = self.__CinemaTracks,
                                             specLevel = specLevel,
                                             camType = camType)

        #all nodes participate, but only root can writes out the files
        pm = servermanager.vtkProcessModule.GetProcessModule()
        pid = pm.GetPartitionId()

        enableFloatVal = False if 'floatValues' not in co else co['floatValues']

        pv_introspect.explore(fs, p, iSave = (pid == 0), currentTime = {'time':formatted_time},
                              userDefined = self.__CinemaTracks,
                              specLevel = specLevel,
                              camType = camType,
                              tracking = tracking_def, floatValues = enableFloatVal)
        if pid == 0:
            fs.save()

        view.LockBounds = 0

        #restore what we showed
        pv_introspect.restore_visibility(pxystate)
        return os.path.basename(vfname)