Exemplo n.º 1
0
    def __init__(self, structure, *args):
        if not common.is_dataset(structure):
            raise TypeError, 'argument structure must be StructuredPoints|StructuredGrid|UnstructuredGrid|RectilinearGrid|PolyData but got %s' % (
                type(structure))
        self.structure = structure
        for a in args:
            if common.is_string(a):
                if len(a) > 255:
                    self.skipping('striping header string to length 256')
                self.header = a[:256]
            elif common.is_pointdata(a):
                self.point_data = a
            elif common.is_celldata(a):
                self.cell_data = a
            else:
                self.skipping('unexpexted argument %s' % (type(a)))
        if self.header is None:
            self.header = 'Really cool data'
            self.warning('Using header=%s' % ( ` self.header `))
        if self.point_data is None and self.cell_data is None:
            self.warning('No data defined')

        if self.point_data is not None:
            s = self.structure.get_size()
            s1 = self.point_data.get_size()
            if s1 != s:
                raise ValueError, 'DataSet (size=%s) and PointData (size=%s) have different sizes' % (
                    s, s1)
        if self.cell_data is not None:
            s = self.structure.get_cell_size()
            s1 = self.cell_data.get_size()
            if s1 != s:
                raise ValueError, 'DataSet (cell_size=%s) and CellData (size=%s) have different sizes' % (
                    s, s1)
Exemplo n.º 2
0
    def __init__(self,structure,*args):
        if not common.is_dataset(structure):
            raise TypeError,'argument structure must be StructuredPoints|StructuredGrid|UnstructuredGrid|RectilinearGrid|PolyData but got %s'%(type(structure))
        self.structure = structure
        for a in args:
            if common.is_string(a):
                if len(a)>255:
                    self.skipping('striping header string to length 256')
                self.header = a[:256]
            elif common.is_pointdata(a):
                self.point_data = a
            elif common.is_celldata(a):
                self.cell_data = a
            else:
                self.skipping('unexpexted argument %s'%(type(a)))
        if self.header is None:
            self.header = 'Really cool data'
            self.warning('Using header=%s'%(`self.header`))
        if self.point_data is None and self.cell_data is None:
            self.warning('No data defined')

        if self.point_data is not None:
            s = self.structure.get_size()
            s1 = self.point_data.get_size()
            if s1 != s:
                raise ValueError,'DataSet (size=%s) and PointData (size=%s) have different sizes'%(s,s1)
        if self.cell_data is not None:
            s = self.structure.get_cell_size()
            s1 = self.cell_data.get_size()
            if s1 != s:
                raise ValueError,'DataSet (cell_size=%s) and CellData (size=%s) have different sizes'%(s,s1)
Exemplo n.º 3
0
    def __init__(self, *args, **kws):
        assert args, 'expected at least one argument'
        if type(args[0]) is types.StringType:
            if kws.has_key('only_structure') and kws['only_structure']:
                self.fromfile(args[0], 1)
            else:
                self.fromfile(args[0])
            return
        else:
            structure = args[0]
            args = list(args)[1:]
        if not common.is_dataset(structure):
            raise TypeError, 'argument structure must be StructuredPoints|StructuredGrid|UnstructuredGrid|RectilinearGrid|PolyData but got %s' % (
                type(structure))
        self.structure = structure
        for a in args:
            if common.is_string(a):
                if len(a) > 255:
                    self.skipping('striping header string to a length =255')
                self.header = a[:255]
            elif common.is_pointdata(a):
                self.point_data = a
            elif common.is_celldata(a):
                self.cell_data = a
            else:
                self.skipping('unexpexted argument %s' % (type(a)))
        if self.header is None:
            self.header = 'Really cool data'
            self.warning('Using header=%s' % ( ` self.header `))
        if self.point_data is None and self.cell_data is None:
            self.warning('No data defined')

        if self.point_data is not None:
            s = self.structure.get_size()
            s1 = self.point_data.get_size()
            if s1 != s:
                raise ValueError, 'DataSet (size=%s) and PointData (size=%s) have different sizes' % (
                    s, s1)
        else:
            self.point_data = PointData()
        if self.cell_data is not None:
            s = self.structure.get_cell_size()
            s1 = self.cell_data.get_size()
            if s1 != s:
                raise ValueError, 'DataSet (cell_size=%s) and CellData (size=%s) have different sizes' % (
                    s, s1)
        else:
            self.cell_data = CellData()
Exemplo n.º 4
0
    def __init__(self,*args,**kws):
        assert args,'expected at least one argument'
        if type(args[0]) is types.StringType:
            if kws.has_key('only_structure') and kws['only_structure']:
                self.fromfile(args[0],1)
            else:
                self.fromfile(args[0])
            return
        else:
            structure = args[0]
            args = list(args)[1:]
        if not common.is_dataset(structure):
            raise TypeError,'argument structure must be StructuredPoints|StructuredGrid|UnstructuredGrid|RectilinearGrid|PolyData but got %s'%(type(structure))
        self.structure = structure
        for a in args:
            if common.is_string(a):
                if len(a)>255:
                    self.skipping('striping header string to a length =255')
                self.header = a[:255]
            elif common.is_pointdata(a):
                self.point_data = a
            elif common.is_celldata(a):
                self.cell_data = a
            else:
                self.skipping('unexpexted argument %s'%(type(a)))
        if self.header is None:
            self.header = 'Really cool data'
            self.warning('Using header=%s'%(`self.header`))
        if self.point_data is None and self.cell_data is None:
            self.warning('No data defined')

        if self.point_data is not None:
            s = self.structure.get_size()
            s1 = self.point_data.get_size()
            if s1 != s:
                raise ValueError,'DataSet (size=%s) and PointData (size=%s) have different sizes'%(s,s1)
        else:
            self.point_data = PointData()
        if self.cell_data is not None:
            s = self.structure.get_cell_size()
            s1 = self.cell_data.get_size()
            if s1 != s:
                raise ValueError,'DataSet (cell_size=%s) and CellData (size=%s) have different sizes'%(s,s1)
        else:
            self.cell_data = CellData()