Example #1
0
        def _loadSeq(filenames, fileobjs, name, task):
            with f:
                fileobjs = list(map(Future.get, fileobjs))
                name = name or fileobjs[0].getName()
                obj = MeshSceneObject(name, [o.datasets[0] for o in fileobjs],
                                      self,
                                      filenames=filenames)

                for i, o in enumerate(fileobjs):
                    descdata = o.kwargs['descdata']
                    if not isinstance(descdata,
                                      str) and 'timestep' in descdata:
                        obj.timestepList[i] = int(descdata['timestep'])

                f.setObject(obj)
    ('tris',ElemType._Tri1NL,triinds),
    ('quads',ElemType._Quad1NL,quadinds),
    ('quadfieldtopo',ElemType._Quad1NL,quadfieldtopo,False)
]

fields=[
    ('trifield',trifield,'tris'), # per-vertex field for triangles
    ('trielemfield',trielemfield,'tris'), # per-element field for triangles
    ('quadfield',quadfield,'quads','quadfieldtopo'), # per-vertex field for quads
    ('quadelemfield',quadelemfield,'quads'), # per-element field for quads
    ('nodefield',nodefield) # per-node field for whole mesh
]

ds=PyDataSet('MeshTest',nodes,inds,fields)

obj=MeshSceneObject('Test',ds)
mgr.addSceneObject(obj)

# render the triangle field
rep=obj.createRepr(ReprType._volume,0)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial(mat,field='trifield')

# render the quad field
rep=obj.createRepr(ReprType._volume,10)
mgr.addSceneObjectRepr(rep)
rep.setPosition(vec3(0,0,-1.1))
rep.applyMaterial(mat,field='quadfield')

# render the per-elem triangle field
rep=obj.createRepr(ReprType._volume,10)
Example #3
0
dds = []
for i in xrange(10):
    n1 = nodes.clone()  # clone the nodes
    n1.mul(vec3(1 + i * 0.1, 1, 1))  # scale the nodes in the X direction
    field = [n1.getAt(j).lenSq() for j in xrange(n1.n())
             ]  # generate a field defined as the squared length of each node
    fieldmat = listToMatrix(
        field, 'LenSq'
    )  # convert field, the matrix for each timestep has the same name "LenSq"
    dds.append(PyDataSet(
        'ds%i' % i, n1, [inds],
        [fieldmat
         ]))  # create the dataset, each shares the matrix `inds' which is safe

obj = MeshSceneObject(
    'LinBox', dds
)  # create the MeshSceneObject, note that this object's "plugin" attribute is None here
mgr.addSceneObject(
    obj
)  # add it to the scene, the manager will assign its plugin attribute to be the default mesh plugin

rep = obj.createRepr(ReprType._volume, 10, externalOnly=True)
mgr.addSceneObjectRepr(rep)

mgr.setCameraSeeAll()
mgr.controller.setRotation(-0.6, 0.6)
mgr.setAxesType(AxesType._cornerTR)

rep.applyMaterial(
    mgr.getMaterial('Rainbow'),
    field='LenSq')  # shortcut way to apply the material with the chosen field
Example #4
0
#
# Eidolon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Eidolon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

import sys
sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ElemType, ReprType
from TestUtils import generateTestMeshDS

ds = generateTestMeshDS(ElemType._Tri1NL, 5)

obj = MeshSceneObject('Sphere', ds)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._volume, 0)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')

mgr.setCameraSeeAll()
Example #5
0
        def _loadFile(filename, name, task):
            basename = name or os.path.basename(filename).split('.')[0]
            name = uniqueStr(
                basename, [o.getName() for o in self.mgr.enumSceneObjects()])
            ds = None

            tree = ET.parse(filename)
            root = tree.getroot()
            unstruc = root.find('UnstructuredGrid')
            poly = root.find('PolyData')
            appended = root.find('AppendedData')
            compressor = _get(root, 'compressor')
            byteorder = '<' if root.get(
                'byte_order') == 'LittleEndian' else '>'

            #if appended and _get(appended,'encoding').lower()=='base64':
            #    appended=base64.decodestring(root.find('AppendedData').text)

            if unstruc is not None:
                pieces = list(unstruc)

                points = pieces[0].find('Points')
                cells = pieces[0].find('Cells')
                celldata = pieces[0].find('CellData')
                pointdata = pieces[0].find('PointData')
                nodearray = points.find('DataArray')

                if celldata is None:
                    celldata = []
                if pointdata is None:
                    pointdata = []

                nodes = readNodes(nodearray, byteorder, compressor)

                connectivity = first(
                    i for i in cells
                    if i.get('Name').lower() == 'connectivity')
                types = first(i for i in cells
                              if i.get('Name').lower() == 'types')
                offsets = first(i for i in cells
                                if i.get('Name').lower() == 'offsets')

                indlist = readArray(
                    connectivity, byteorder,
                    compressor).tolist()  # faster as Python list?
                fields = readFields(celldata, pointdata, byteorder, compressor)

                celltypes = readArray(types, byteorder, compressor)
                offlist = readArray(offsets, byteorder, compressor)
                cellofflist = np.vstack((celltypes, offlist)).T.tolist(
                )  # pair each cell type entry with its width entry

                assert len(celltypes) == len(offlist)

                # map cell type IDs to IndexMatrix objects for containing the indices of that type and node ordering list
                indmats = {
                    i: (IndexMatrix(n + 'Inds', e, 0, len(s)), s)
                    for n, i, e, s in CellTypes
                }

                for celltype, off in cellofflist:
                    indmat, _ = indmats.get(celltype, (None, []))
                    if indmat is not None:  # only found for those cell types we understand (ie. not polygon)
                        indmat.append(*indlist[off - indmat.m():off])

                inds = []
                for ind, order in indmats.values(
                ):  # collect and reorder all non-empty index matrices
                    if ind.n() > 0:
                        ind[:, :] = np.asarray(
                            ind
                        )[:,
                          order]  # reorder columns to match CHeart node ordering
                        inds.append(ind)

                ds = PyDataSet('vtk', nodes, inds, fields)

            elif poly is not None:
                pieces = list(poly)

                #numPoints=int(_get(pieces[0],'NumberOfPoints')

                points = pieces[0].find('Points')
                celldata = pieces[0].find('CellData')
                pointdata = pieces[0].find('PointData')
                nodearray = points.find('DataArray')
                nodes = readNodes(nodearray, byteorder, compressor)
                inds = []

                lines = IndexMatrix('lines', ElemType._Line1NL, 0, 2)
                tris = IndexMatrix('tris', ElemType._Tri1NL, 0, 3)
                quads = IndexMatrix('quads', ElemType._Quad1NL, 0, 4)

                for a, b in yieldConnectedOffsets(pieces[0].find('Lines'),
                                                  byteorder, compressor):
                    lines.append(a, b)

                for strip in yieldConnectedOffsets(pieces[0].find('Strips'),
                                                   byteorder, compressor):
                    for a, b, c in eidolon.successive(strip, 3):
                        tris.append(a, b, c)

                for poly in yieldConnectedOffsets(pieces[0].find('Polys'),
                                                  byteorder, compressor):
                    if len(poly) == 2:
                        lines.append(*poly)
                    elif len(poly) == 3:
                        tris.append(*poly)
                    elif len(poly) == 4:
                        quads.append(*poly)

                    # TODO: read in arbitrary polygon and triangulate?

                if len(lines) > 0:
                    inds.append(lines)

                if len(tris) > 0:
                    inds.append(tris)

                if len(quads) > 0:
                    quads[:, :] = np.asarray(quads)[:, CellTypes.Quad[-1]]
                    inds.append(quads)

                fields = readFields(celldata, pointdata, byteorder, compressor)

                ds = PyDataSet('vtk', nodes, inds, fields)
            else:
                raise NotImplementedError('Dataset not understood yet')

            f.setObject(
                MeshSceneObject(name,
                                ds,
                                self,
                                filename=filename,
                                isXML=True,
                                descdata=''))
Example #6
0
# 
# This file is part of Eidolon.
#
# Eidolon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# Eidolon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

from eidolon import vec3, PyDataSet, MeshSceneObject, ReprType

nodes=[vec3(0,0,0),vec3(2,0,0),vec3(5,0,0),vec3(10,0,0)]
field=[0.0,1.0,2.0,3.0]
ds=PyDataSet('PtDS',nodes,[],[('vals',field)])

obj=MeshSceneObject('Pts',ds)
mgr.addSceneObject(obj)

rep=obj.createRepr(ReprType._glyph,glyphname='sphere', sfield= 'vals',glyphscale=(1,1,1))
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow',field='vals')

mgr.setCameraSeeAll()
Example #7
0
        def _loadFile(filename, name, strdata, task):
            result = self.parseString(strdata or open(filename).read())

            basename = name or os.path.basename(filename).split('.')[0]
            name = uniqueStr(
                basename, [o.getName() for o in self.mgr.enumSceneObjects()])

            version, desc, data = result[:3]
            pointattrs = [a for a in result[3:] if a[0] == 'POINT_DATA']
            cellattrs = [a for a in result[3:] if a[0] == 'CELL_DATA']

            ds = None
            indmats = []
            metamap = {
                VTKProps.desc: desc,
                VTKProps.version: str(version),
                VTKProps.datasettype: data[0]
            }

            # interpret dataset blocks
            if data[0] == DatasetTypes._UNSTRUCTURED_GRID:
                nodes, cells, celltypes = data[1:]

                # map cell types to the indices of members of `cells' of that type
                typeindices = {}
                for i in range(celltypes.n()):
                    typeindices.setdefault(celltypes.getAt(i), []).append(i)

                for ctype, inds in typeindices.items():
                    tname, elemtypename, sortinds = first(
                        (n, e, s) for n, i, e, s in CellTypes
                        if i == ctype) or (None, None, None)
                    matname = '' if tname == None else uniqueStr(
                        tname, [i.getName() for i in indmats], '')
                    if tname == CellTypes._Poly:
                        mat = IndexMatrix(matname, elemtypename, 0)
                        polyinds = IndexMatrix(matname + 'Inds',
                                               VTKProps._polyinds, 0, 2)
                        mat.meta(VTKProps._polyinds, polyinds.getName())
                        indmats.append(mat)
                        indmats.append(polyinds)

                        for ind in inds:
                            row = cells.getRow(ind)
                            length = row[0]
                            polyinds.append(mat.n(), mat.n() + length)
                            for r in row[1:length + 1]:
                                mat.append(r)

                    elif tname != None:
                        elemtype = ElemType[elemtypename]
                        mat = IndexMatrix(matname, elemtypename, 0,
                                          elemtype.numNodes())
                        indmats.append(mat)
                        for ind in inds:
                            sortedinds = eidolon.indexList(
                                sortinds,
                                cells.getRow(ind)[1:])
                            mat.append(*sortedinds)

            elif data[0] == DatasetTypes._STRUCTURED_GRID:
                dims, nodes = data[1:]
                dimx, dimy, dimz = map(int, dims)

                assert dimx > 1
                assert dimy > 1
                assert dimz > 1

                _, inds = eidolon.generateHexBox(dimx - 2, dimy - 2, dimz - 2)

                inds = eidolon.listToMatrix(inds, 'hexes')
                inds.setType(ElemType._Hex1NL)

                indmats = [inds]
                metamap[VTKProps._griddims] = repr((dimx, dimy, dimz))

            elif data[0] == DatasetTypes._POLYDATA:
                nodes = data[1]
                polyelems = data[2:]

                lines = IndexMatrix('lines', ElemType._Line1NL, 0, 2)
                tris = IndexMatrix('tris', ElemType._Tri1NL, 0, 3)
                quads = IndexMatrix('quads', ElemType._Quad1NL, 0, 4)

                for pname, numelems, numvals, ind in polyelems:
                    n = 0
                    if pname == 'POLYGONS':
                        while n < ind.n():
                            polylen = ind.getAt(n)
                            if polylen == 2:
                                lines.append(ind.getAt(n + 1),
                                             ind.getAt(n + 2))
                            elif polylen == 3:
                                tris.append(ind.getAt(n + 1), ind.getAt(n + 2),
                                            ind.getAt(n + 3))
                            elif polylen == 4:
                                quads.append(ind.getAt(n + 1),
                                             ind.getAt(n + 2),
                                             ind.getAt(n + 4),
                                             ind.getAt(n + 3))

                            n += polylen + 1

                if len(tris) > 0:
                    indmats.append(tris)
                if len(quads) > 0:
                    indmats.append(quads)
                if len(lines) > 0:
                    indmats.append(lines)
            else:
                raise NotImplementedError(
                    'Dataset type %s not understood yet' % str(data[0]))

            ds = PyDataSet('vtk', nodes, indmats)
            for k, v in metamap.items():
                ds.meta(k, v)

            # read attributes into fields
            for attr in list(pointattrs) + list(cellattrs):
                for attrtype in attr[2:]:
                    atype = str(attrtype[0])

                    spatialname = first(
                        ds.indices.keys())  # TODO: choose a better topology

                    if atype == AttrTypes._FIELD:
                        for fname, width, length, dtype, dat in attrtype[3:]:
                            assert (width * length) == dat.n()
                            assert length == nodes.n(
                            ) or length == ds.indices[spatialname].n()

                            dat.setName(fname)
                            dat.setM(width)
                            dat.meta(StdProps._topology, spatialname)
                            dat.meta(StdProps._spatial, spatialname)
                            dat.meta(VTKProps._attrtype, atype)
                            ds.setDataField(dat)
                    else:
                        dat = attrtype[-1]
                        dat.setName(str(attrtype[1]))
                        dat.meta(StdProps._topology, spatialname)
                        dat.meta(StdProps._spatial, spatialname)
                        dat.meta(VTKProps._attrtype, atype)
                        ds.setDataField(dat)

                        if atype in (AttrTypes._NORMALS, AttrTypes._VECTORS):
                            dat.setM(3)
                        elif atype == AttrTypes._LOOKUP_TABLE:
                            dat.setM(4)
                        elif atype == AttrTypes._TENSORS:
                            dat.setM(9)
                        elif atype in (AttrTypes._TEXTURE_COORDINATES,
                                       AttrTypes._COLOR_SCALARS):
                            dat.setM(attrtype[2])
                        elif atype == AttrTypes._SCALARS:
                            if isinstance(attrtype[3], int):
                                dat.setM(attrtype[3])
                            if attrtype[3] == AttrTypes._LOOKUP_TABLE:
                                dat.meta(AttrTypes._LOOKUP_TABLE,
                                         str(attrtype[4]))
                            elif attrtype[4] == AttrTypes._LOOKUP_TABLE:
                                dat.meta(AttrTypes._LOOKUP_TABLE,
                                         str(attrtype[5]))

            try:
                descdata = eval(
                    desc
                )  # if desc is a Python object (eg. timestep number) attempt to evaluate it
            except:
                descdata = desc  # just a normal string

            f.setObject(
                MeshSceneObject(name,
                                ds,
                                self,
                                filename=filename,
                                descdata=descdata,
                                result=result))
Example #8
0
pos=vec3(-10,20,-15)
rot=rotator(0.1,-0.2,0.13)
w,h,d=31,42,53

nodesz,indsz=generateArrow(5)
nodesz=[(n+vec3.Z())*vec3(w,d,h)*vec3(0.1,0.1,0.5) for n in nodesz]
nodesx=[rotator(vec3(0,1,0),halfpi)*n for n in nodesz]
nodesy=[rotator(vec3(1,0,0),-halfpi)*n for n in nodesz]

nodes=[(rot*n)+pos for n in (nodesx+nodesy+nodesz)]
nlen=len(nodesz)
indices=indsz+[(i+nlen,j+nlen,k+nlen) for i,j,k in indsz]+[(i+nlen*2,j+nlen*2,k+nlen*2) for i,j,k in indsz]
field=[2.0]*nlen+[1.0]*nlen+[0.0]*nlen

axes=MeshSceneObject('Axes',TriDataSet('tris',nodes,indices,[('col',field)]))
mgr.addSceneObject(axes)

arep=axes.createRepr(ReprType._volume)
mgr.addSceneObjectRepr(arep)
arep.applyMaterial('Rainbow',field='col')


obj=ImgPlugin.createTestImage(w,d,h,1,pos,rot)
mgr.addSceneObject(obj)

rep=obj.createRepr(ReprType._imgstack)
mgr.addSceneObjectRepr(rep)

rep.useTexFiltering(False)
Example #9
0
from eidolon import MeshSceneObject, ElemType, ReprType, vec3, frange
from TestUtils import generateTestMeshDS

dds = []
for i in frange(0, 1, 0.05):
    i = math.sin(i * math.pi * 2)
    ds = generateTestMeshDS(ElemType._Tri1NL, 5)
    nodes = ds.getNodes()
    nodes.mul(vec3(2.0 + i, 1.0, 2.0 - i))

    dist = ds.getDataField('dist')
    for n in range(dist.n()):
        dist.setAt(nodes.getAt(n).distTo(vec3(0.25)), n)

    dds.append(ds)

obj = MeshSceneObject('Sphere', dds)
mgr.addSceneObject(obj)
obj.setTimestepList(list(frange(0, 1, 0.05)))

rep = obj.createRepr(ReprType._volume, 0)
mgr.addSceneObjectRepr(rep)

mgr.setCameraSeeAll()

rep.applyMaterial('Rainbow', field='dist')

mgr.setTimeStepsPerSec(1)
mgr.setTimeFPS(60)
mgr.play()
Example #10
0
sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ImageSceneObject, ElemType, ReprType
from TestUtils import generateTimeSphereImages, generateTimeSphereMeshes

step = 0.1

images = generateTimeSphereImages(step)
obj = ImageSceneObject('Sphere', [], images)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._imgtimestack)
mgr.addSceneObjectRepr(rep)

dds, steps = generateTimeSphereMeshes(step)
obj1 = MeshSceneObject('Sphere', dds)
obj1.setTimestepList(steps)
mgr.addSceneObject(obj1)

rep1 = obj1.createRepr(ReprType._volume, 0)
mgr.addSceneObjectRepr(rep1)
rep1.applyMaterial('Rainbow', field='dist')

d = mgr.create2DView()


@mgr.callThreadSafe
def _set():
    d.setSecondary(rep1.getName(), True)
    d.setImageStackPosition(24)
Example #11
0
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

import sys

sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ElemType, vec3, listToMatrix, ReprType
from TestUtils import generateTestMeshDS

ds = generateTestMeshDS(ElemType._Tri1NL, 4)
nodes = ds.getNodes()
dirs = listToMatrix([tuple(nodes.getAt(i)) for i in range(nodes.n())], 'dirs')
ds.setDataField(dirs)

obj = MeshSceneObject('Sphere', ds)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._point)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')
rep.setScale(vec3(1.5))

rep1 = obj.createRepr(ReprType._glyph,
                      glyphname='sphere',
                      sfield='dist',
                      glyphscale=(0.015, 0.015, 0.015))
mgr.addSceneObjectRepr(rep1)
rep1.applyMaterial('Rainbow', field='dist')

rep2 = obj.createRepr(ReprType._glyph,
Example #12
0
# Eidolon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Eidolon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

import sys

sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ElemType, ReprType
from TestUtils import generateTestMeshDS

ds = generateTestMeshDS(ElemType._Tet1NL, 8)

obj = MeshSceneObject('Tets', ds)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._volume, 2)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')

mgr.setCameraSeeAll()
Example #13
0
def importMeshes(x4):
    '''Import meshes from the X4DF object `x4', returning a list of MeshSceneObject instances.'''
    arrs = {a.name: a for a in x4.arrays}
    results = []

    for m in x4.meshes:
        name, ts, mnodes, topos, dfs, _ = m
        topomats = []
        dss = []
        timesteps = [0]
        filenames = []
        dfmap = dict()

        for df in dfs:
            dfmap.setdefault(df.name, []).append(df)

        # sort fields by timestep
        for dfn in dfmap:
            dfmap[dfn] = sorted(dfmap[dfn], key=lambda i: (i.timestep or 0))

        # determine timestep from timescheme value, node timestep values, or field timestep values
        if len(mnodes) > 1 or ts or len(dfs) > 1:
            if ts:  # convert timescheme to timestep list
                timesteps = frange(ts[0], ts[1] * len(mnodes), ts[1])
            elif len(mnodes) > 1:
                timesteps = [n.timestep or i for i, n in enumerate(mnodes)]
            else:
                timedf = first(dfs for dfs in dfmap.values() if len(dfs) > 1)
                if timedf:
                    timesteps = [
                        df.timestep or i for i, df in enumerate(timedf)
                    ]

        assert len(timesteps) == len(mnodes) or len(timesteps) == len(
            first(dfmap.values()))

        # read topologies in first, these get copied between timesteps
        for t in topos:
            tname, tsrc, et, spatial, _ = t
            arr = array2MatrixForm(arrs[tsrc].data, np.uint32)
            tmat = eidolon.IndexMatrix(tname, et or '', *arr.shape)
            filenames.append(arrs[tsrc].filename)

            if spatial:
                tmat.meta(StdProps._spatial, spatial)
                tmat.meta(StdProps._isspatial, 'False')
            else:
                tmat.meta(StdProps._isspatial, 'True')

            np.asarray(tmat)[:, :] = arr
            topomats.append(tmat)

        # read each timestep, first copying the nodes then the field for the timestep or cloning static fields
        for i in range(len(timesteps)):
            fields = []
            arr = arrs[mnodes[i].src].data
            initnodes = arrs.get(mnodes[i].initialnodes,
                                 0)  # get initial nodes or default 0
            filenames.append(arrs[mnodes[i].src].filename)

            nmat = eidolon.Vec3Matrix('nodes%i' % i, arr.shape[0])
            np.asarray(nmat)[:, :] = array2MatrixForm(arr + initnodes,
                                                      np.double)

            # read in each field, there will be a separate entry for this timestep or a single entry that is copied for each timestep
            for dfs in dfmap.values():
                findex = 0 if len(
                    dfs
                ) == 1 else i  # choose the first field value if this field is static, every timestep gets a copy
                fname, src, _, ftopo, fspatial, fieldtype, _ = dfs[findex]
                arr = array2MatrixForm(arrs[src].data, np.double)
                filenames.append(arrs[src].filename)

                fmat = eidolon.RealMatrix(fname, *arr.shape)
                fmat.meta(StdProps._topology, ftopo)
                fmat.meta(StdProps._spatial, fspatial)
                fmat.meta(StdProps._elemdata,
                          str(fieldtype == validFieldTypes[0]))
                fmat.meta(StdProps._timecopy, str(len(dfs) > 1))

                np.asarray(fmat)[:, :] = arr
                fields.append(fmat)

            dss.append(
                eidolon.PyDataSet('%s%i' % (name, i), nmat, topomats, fields))

        obj = MeshSceneObject(name,
                              dss,
                              filenames=list(filter(bool, filenames)))

        # set timestep list if needed
        if len(timesteps) > 1:
            obj.setTimestepList(list(map(ast.literal_eval, timesteps)))

        results.append(obj)

    return results
Example #14
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

import sys
sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ElemType, ReprType, vec3
from TestUtils import generateTestMeshDS

ds = generateTestMeshDS(ElemType._Tet2NL, 7)

obj = MeshSceneObject('Tets', ds)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._node)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')

rep = obj.createRepr(ReprType._point, 2, drawInternal=True, externalOnly=False)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')
rep.setPosition(vec3(1.1, 0, 0))

rep = obj.createRepr(ReprType._line, 2, drawInternal=True, externalOnly=False)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')
rep.setPosition(vec3(0, 0, -1.1))
Example #15
0
# Eidolon is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Eidolon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

import sys, time

sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ElemType, ReprType
from TestUtils import generateTestMeshDS

ds = generateTestMeshDS(ElemType._Hex1NL, 10)

obj = MeshSceneObject('Hexes', ds)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._volume)
mgr.addSceneObjectRepr(rep)
rep.applyMaterial('Rainbow', field='dist')

mgr.setCameraSeeAll()
Example #16
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program (LICENSE.txt).  If not, see <http://www.gnu.org/licenses/>

import sys
sys.path.append(scriptdir + '..')

from eidolon import MeshSceneObject, ElemType, ReprType, ValueFunc
from TestUtils import generateTestMeshDS

ds = generateTestMeshDS(ElemType._Tet2NL, 7)

obj = MeshSceneObject('Tets', ds)
mgr.addSceneObject(obj)

rep = obj.createRepr(ReprType._line, 0)
mgr.addSceneObjectRepr(rep)

mgr.setCameraSeeAll()

rep = obj.createRepr(ReprType._isosurf,
                     5,
                     field='dist',
                     numitervals=5,
                     minv=0.0,
                     maxv=0.75,
                     valfunc=ValueFunc.Magnitude)
mgr.addSceneObjectRepr(rep)