Ejemplo n.º 1
0
 def __init__(self,
              collection_index,
              ncollections,
              init_args=None,
              **cfg_args):
     self.point_collection = MultiVarPointCollection()
     self.point_collection.setDataSlice(collection_index,
                                        istep=ncollections)
     self.collection_index = collection_index
     self.ncollections = ncollections
     self.init_args = init_args
     self.cfg_args = cfg_args
 def __init__( self, collection_index, ncollections, init_args=None, **cfg_args ):
     self.point_collection = MultiVarPointCollection() 
     self.point_collection.setDataSlice( collection_index, istep=ncollections )
     self.collection_index = collection_index
     self.ncollections = ncollections
     self.init_args = init_args
     self.cfg_args = cfg_args
class PointCollectionExecutionTarget:
    def __init__(self,
                 collection_index,
                 ncollections,
                 init_args=None,
                 **cfg_args):
        self.point_collection = MultiVarPointCollection()
        self.point_collection.setDataSlice(collection_index,
                                           istep=ncollections)
        self.collection_index = collection_index
        self.ncollections = ncollections
        self.init_args = init_args
        self.cfg_args = cfg_args

    def printLogMessage(self, msg):
        print " PointCollectionExecutionTarget %d: %s" % (
            self.collection_index, str(msg))
        sys.stdout.flush()

    def __call__(self, args_queue, result_queue):
        self.results = result_queue
        self.initialize()
        while True:
            args = list(args_queue.get(True))
            self.execute(args)

    def initialize(self):
        self.point_collection.initialize(self.init_args, **self.cfg_args)
        self.point_collection.setDataSlice(self.collection_index,
                                           istep=self.ncollections)
        self.results.put(self.packPointsData())
        self.results.put(self.packVarData())

    def execute(self, args):
        try:
            self.point_collection.execute(args)
            if args[0] == 'indices':
                data_packet = self.packIndexData()
            elif args[0] == 'points':
                data_packet = self.packPointHeightsData()
            elif args[0] == 'timestep':
                data_packet = self.packVarData()
            elif args[0] == 'ROI':
                data_packet = self.packPointsData()
            data_packet['args'] = args

            self.results.put(data_packet)
        except Exception, err:
            print >> sys.stderr, "Error executing PointCollectionExecutionTarget: ", str(
                err)
class PointCollectionExecutionTarget:

    def __init__( self, collection_index, ncollections, init_args=None, **cfg_args ):
        self.point_collection = MultiVarPointCollection() 
        self.point_collection.setDataSlice( collection_index, istep=ncollections )
        self.collection_index = collection_index
        self.ncollections = ncollections
        self.init_args = init_args
        self.cfg_args = cfg_args

    def printLogMessage(self, msg ):
        print " PointCollectionExecutionTarget %d: %s" % ( self.collection_index, str(msg) )
        sys.stdout.flush()      

    def __call__( self, args_queue, result_queue ):
        self.results = result_queue
        self.initialize()
        while True:
            args = list( args_queue.get( True ) )
            self.execute( args )
                
    def initialize( self ):
        self.point_collection.initialize( self.init_args, **self.cfg_args )
        self.point_collection.setDataSlice( self.collection_index, istep=self.ncollections )
        self.results.put( self.packPointsData() )
        self.results.put( self.packVarData() )
                       
    def execute( self, args ):
        try:
            self.point_collection.execute( args )
            if args[0] == 'indices':
                data_packet = self.packIndexData()
            elif args[0] == 'points':
                data_packet = self.packPointHeightsData()
            elif args[0] == 'timestep':
                data_packet = self.packVarData()
            elif args[0] == 'ROI':
                data_packet = self.packPointsData()
            data_packet[ 'args' ] = args
            
            self.results.put( data_packet )
        except Exception, err:
            print>>sys.stderr, "Error executing PointCollectionExecutionTarget: ", str( err )
class PointCollectionExecutionTarget:

    def __init__( self, collection_index, ncollections, init_args=None, **cfg_args ):
        self.point_collection = MultiVarPointCollection() 
        self.point_collection.setDataSlice( collection_index, istep=ncollections )
        self.collection_index = collection_index
        self.ncollections = ncollections
        self.init_args = init_args
        self.cfg_args = cfg_args

    def printLogMessage(self, msg_str ):
        print " PointCollectionExecutionTarget %d: %s" % ( self.collection_index, msg_str )
        sys.stdout.flush()      

    def __call__( self, args_queue, result_queue ):
        self.results = result_queue
        self.initialize()
        while True:
            args = list( args_queue.get( True ) )
            self.execute( args )
                
    def initialize( self ):
        self.point_collection.initialize( self.init_args, **self.cfg_args )
        self.point_collection.setDataSlice( self.collection_index, istep=self.ncollections )
        self.results.put( self.packPointsData() )
        self.results.put( self.packVarData() )
                       
    def execute( self, args ):
        self.point_collection.execute( args )
        if args[0] == 'indices':
            data_packet = self.packIndexData()
        elif args[0] == 'points':
            data_packet = self.packPointHeightsData()
        elif args[0] == 'timestep':
            data_packet = self.packVarData()
        elif args[0] == 'ROI':
            data_packet = self.packPointsData()
        data_packet[ 'args' ] = args
        self.results.put( data_packet )

    def packVarData(self):
#        print "Pack VARDATA"; sys.stdout.flush()
        data_packet = ExecutionDataPacket( ExecutionDataPacket.VARDATA, self.collection_index, self.point_collection.getVarData() )
        data_packet[ 'vrange' ] = self.point_collection.getVarDataRange() 
        data_packet[ 'grid' ] = self.point_collection.getGridType()  
        data_packet[ 'nlevels' ] = self.point_collection.getNLevels()
        data_packet[ 'bounds' ] = self.point_collection.getBounds()
        return data_packet

    def packPointsData( self ):
#        print "Pack POINTS"; sys.stdout.flush()
        data_packet = ExecutionDataPacket( ExecutionDataPacket.POINTS, self.collection_index, self.point_collection.getPoints() )
        return data_packet

    def packPointHeightsData( self ):
#        print " ExecutionTarget-%d: packPointHeightsData" % ( self.collection_index )
        data_packet = ExecutionDataPacket( ExecutionDataPacket.HEIGHTS, self.collection_index, self.point_collection.getPointHeights() )
        data_packet[ 'bounds' ] = self.point_collection.getBounds()
        return data_packet

    def packIndexData( self ):
        data_packet = ExecutionDataPacket( ExecutionDataPacket.INDICES, self.collection_index, self.point_collection.getPointIndices() )
        target = self.point_collection.getThresholdTargetType()
#        range_type = 'trange' if ( target == "vardata" ) else "crange"
#        data_packet[ target ] = self.point_collection.getThresholdTargetType() 
        data_packet[ 'target' ] = target
        data_packet[ 'trange' ] = self.point_collection.getThresholdedRange()
        return data_packet
 def __init__( self, istart, **args ):
     vtkPointCloud.__init__( self )
     self.point_collection = MultiVarPointCollection()
     self.point_collection.setDataSlice( istart, **args )
class vtkLocalPointCloud( vtkPointCloud ):

    def __init__( self, istart, **args ):
        vtkPointCloud.__init__( self )
        self.point_collection = MultiVarPointCollection()
        self.point_collection.setDataSlice( istart, **args )

    def getPointCollection( self ):
        return self.point_collection
    
    def setROI( self, roi ):
        self.point_collection.setROI( roi )
        self.initialize()
        
    def getMetadata( self ):
        return self.point_collection.getMetadata()

    def generateZScaling(self, **args ):
        z_subset_spec = args.get('spec', None )
        op_specs = [ 'points' ] + list( z_subset_spec )
        self.point_collection.execute( op_specs ) 
        self.setPointHeights( self.point_collection.getPointHeights()  )   
        self.grid_bounds = self.point_collection.getAxisBounds()
#        print "generateZScaling: Set grid bounds: %s " % str( self.grid_bounds )
        self.polydata.Modified()
        self.mapper.Modified()
        self.actor.Modified()
        self.actor.SetVisibility( True  )

    def generateSubset(self, **args ):
#        print " ++++++++++++++++++++++ vtkLocalPointCloud[%d].generateSubset: current_subset_specs: %s (%s) " % ( self.pcIndex, self.current_subset_specs, str(args) )
        self.current_subset_specs = args.get('spec', self.current_subset_specs)
#         if self.current_subset_specs[0] == 'Z3':
#             print " vtkLocalPointCloud[%d]: current_subset_specs: %s (%s) " % ( self.pcIndex, self.current_subset_specs, str(args) )
#        self.threshold_target = self.current_subset_specs[0]
        op_specs = [ spec for spec in  self.current_subset_specs.values() ]
        op_specs.insert( 0, 'indices' )
        vmin, vmax = self.point_collection.execute( op_specs )       
        self.np_index_seq = self.point_collection.selected_index_array
#        if self.threshold_target == "vardata": self.trange = ( vmin, vmax )
#        else: 
#            self.crange = ( vmin, vmax )
#            print "Set crange: ", str( self.crange )
        self.grid = self.point_collection.getGridType()
        self.current_scalar_range = self.vrange
        self.updateVertices() 
        self.updated_subset_specs = self.current_subset_specs
        
    def getNumberOfInputPoints(self): 
        return self.point_collection.getNumberOfInputPoints()
    
    def getSkipIndex(self): 
        return self.point_collection.istep
        
    def initialize(self, init_args = None, **args ):
        if init_args: self.point_collection.initialize( init_args, **args )
        else: self.point_collection.initPoints() 
        self.np_points_data = self.point_collection.getPoints()
        self.vrange = self.point_collection.getVarDataRange()
        self.initPoints( **args ) 
        self.createPolydata( **args )
        self.vardata = self.point_collection.getVarData()
        self.updateScalars() 
        self.grid_bounds = self.point_collection.getAxisBounds()
#        print "initialize: Set grid bounds: %s " % str( self.grid_bounds )
        self.nlevels = self.point_collection.getNLevels()
        self.actor.VisibilityOff()
        
    def getCenter(self):
        return ( self.point_collection.xcenter, self.point_collection.ycenter, self.point_collection.xwidth, self.point_collection.ywidth )
    
    def stepTime(self, **args): 
        if self.point_collection.stepTime( **args ):
            update_points = args.get( 'update_points', True )
            self.vardata = self.point_collection.getVarData()
            if update_points: self.generateSubset()
            self.updateScalars() 
Ejemplo n.º 8
0
class PointCollectionExecutionTarget:
    def __init__(self,
                 collection_index,
                 ncollections,
                 init_args=None,
                 **cfg_args):
        self.point_collection = MultiVarPointCollection()
        self.point_collection.setDataSlice(collection_index,
                                           istep=ncollections)
        self.collection_index = collection_index
        self.ncollections = ncollections
        self.init_args = init_args
        self.cfg_args = cfg_args

    def printLogMessage(self, msg_str):
        print " PointCollectionExecutionTarget %d: %s" % (
            self.collection_index, msg_str)
        sys.stdout.flush()

    def __call__(self, args_queue, result_queue):
        self.results = result_queue
        self.initialize()
        while True:
            args = list(args_queue.get(True))
            self.execute(args)

    def initialize(self):
        self.point_collection.initialize(self.init_args, **self.cfg_args)
        self.point_collection.setDataSlice(self.collection_index,
                                           istep=self.ncollections)
        self.results.put(self.packPointsData())
        self.results.put(self.packVarData())

    def execute(self, args):
        self.point_collection.execute(args)
        if args[0] == 'indices':
            data_packet = self.packIndexData()
        elif args[0] == 'points':
            data_packet = self.packPointHeightsData()
        elif args[0] == 'timestep':
            data_packet = self.packVarData()
        elif args[0] == 'ROI':
            data_packet = self.packPointsData()
        data_packet['args'] = args
        self.results.put(data_packet)

    def packVarData(self):
        #        print "Pack VARDATA"; sys.stdout.flush()
        data_packet = ExecutionDataPacket(ExecutionDataPacket.VARDATA,
                                          self.collection_index,
                                          self.point_collection.getVarData())
        data_packet['vrange'] = self.point_collection.getVarDataRange()
        data_packet['grid'] = self.point_collection.getGridType()
        data_packet['nlevels'] = self.point_collection.getNLevels()
        data_packet['bounds'] = self.point_collection.getBounds()
        return data_packet

    def packPointsData(self):
        #        print "Pack POINTS"; sys.stdout.flush()
        data_packet = ExecutionDataPacket(ExecutionDataPacket.POINTS,
                                          self.collection_index,
                                          self.point_collection.getPoints())
        return data_packet

    def packPointHeightsData(self):
        #        print " ExecutionTarget-%d: packPointHeightsData" % ( self.collection_index )
        data_packet = ExecutionDataPacket(
            ExecutionDataPacket.HEIGHTS, self.collection_index,
            self.point_collection.getPointHeights())
        data_packet['bounds'] = self.point_collection.getBounds()
        return data_packet

    def packIndexData(self):
        data_packet = ExecutionDataPacket(
            ExecutionDataPacket.INDICES, self.collection_index,
            self.point_collection.getPointIndices())
        target = self.point_collection.getThresholdTargetType()
        #        range_type = 'trange' if ( target == "vardata" ) else "crange"
        #        data_packet[ target ] = self.point_collection.getThresholdTargetType()
        data_packet['target'] = target
        data_packet['trange'] = self.point_collection.getThresholdedRange()
        return data_packet
Ejemplo n.º 9
0
 def __init__(self, istart, **args):
     vtkPointCloud.__init__(self)
     self.point_collection = MultiVarPointCollection()
     self.point_collection.setDataSlice(istart, **args)
Ejemplo n.º 10
0
class vtkLocalPointCloud(vtkPointCloud):
    def __init__(self, istart, **args):
        vtkPointCloud.__init__(self)
        self.point_collection = MultiVarPointCollection()
        self.point_collection.setDataSlice(istart, **args)

    def getPointCollection(self):
        return self.point_collection

    def setROI(self, roi):
        self.point_collection.setROI(roi)
        self.initialize()

    def getMetadata(self):
        return self.point_collection.getMetadata()

    def generateZScaling(self, **args):
        z_subset_spec = args.get('spec', None)
        op_specs = ['points'] + list(z_subset_spec)
        self.point_collection.execute(op_specs)
        self.setPointHeights(self.point_collection.getPointHeights())
        self.grid_bounds = self.point_collection.getAxisBounds()
        #        print "generateZScaling: Set grid bounds: %s " % str( self.grid_bounds )
        self.polydata.Modified()
        self.mapper.Modified()
        self.actor.Modified()
        self.actor.SetVisibility(True)

    def generateSubset(self, **args):
        #        print " ++++++++++++++++++++++ vtkLocalPointCloud[%d].generateSubset: current_subset_specs: %s (%s) " % ( self.pcIndex, self.current_subset_specs, str(args) )
        self.current_subset_specs = args.get('spec', self.current_subset_specs)
        #         if self.current_subset_specs[0] == 'Z3':
        #             print " vtkLocalPointCloud[%d]: current_subset_specs: %s (%s) " % ( self.pcIndex, self.current_subset_specs, str(args) )
        #        self.threshold_target = self.current_subset_specs[0]
        op_specs = [spec for spec in self.current_subset_specs.values()]
        op_specs.insert(0, 'indices')
        vmin, vmax = self.point_collection.execute(op_specs)
        self.np_index_seq = self.point_collection.selected_index_array
        #        if self.threshold_target == "vardata": self.trange = ( vmin, vmax )
        #        else:
        #            self.crange = ( vmin, vmax )
        #            print "Set crange: ", str( self.crange )
        self.grid = self.point_collection.getGridType()
        self.current_scalar_range = self.vrange
        self.updateVertices()
        self.updated_subset_specs = self.current_subset_specs

    def getNumberOfInputPoints(self):
        return self.point_collection.getNumberOfInputPoints()

    def getSkipIndex(self):
        return self.point_collection.istep

    def initialize(self, init_args=None, **args):
        if init_args: self.point_collection.initialize(init_args, **args)
        else: self.point_collection.initPoints()
        self.np_points_data = self.point_collection.getPoints()
        self.vrange = self.point_collection.getVarDataRange()
        self.initPoints(**args)
        self.createPolydata(**args)
        self.vardata = self.point_collection.getVarData()
        self.updateScalars()
        self.grid_bounds = self.point_collection.getAxisBounds()
        #        print "initialize: Set grid bounds: %s " % str( self.grid_bounds )
        self.nlevels = self.point_collection.getNLevels()
        self.actor.VisibilityOff()

    def getCenter(self):
        return (self.point_collection.xcenter, self.point_collection.ycenter,
                self.point_collection.xwidth, self.point_collection.ywidth)

    def stepTime(self, **args):
        if self.point_collection.stepTime(**args):
            update_points = args.get('update_points', True)
            self.vardata = self.point_collection.getVarData()
            if update_points: self.generateSubset()
            self.updateScalars()