示例#1
0
def display(t,
            dim=-1,
            mode=-1,
            scalarField=-1,
            vectorField1=-1, vectorField2=-1, vectorField3=-1,
            displayBB=-1,
            displayInfo=-1,
            displayIsoLegend=-1,
            meshStyle=-1,
            solidStyle=-1,
            scalarStyle=-1,
            vectorStyle=-1,
            vectorScale=-1.,
            vectorDensity=-1.,
            vectorNormalize=-1,
            vectorShowSurface=-1,
            vectorShape=-1,
            vectorProjection=-1,
            colormap=-1,
            niso=25,
            isoEdges=-0.5,
            isoScales=[],
            win=(-1,-1),
            posCam=(-999,-999,-999),
            posEye=(-999,-999,-999),
            dirCam=(-999,-999,-999),
            viewAngle=-1.,
            bgColor=-1,
            shadow=-1,
            dof=-1,
            stereo=-1,
            stereoDist=-1.,
            export="None",
            exportResolution="None",
            location='unchanged',
            offscreen=0):
    """Display pyTrees.
    Usage: display(t)"""
    global __LOCATION__
    if location != 'unchanged': __LOCATION__ = location
    if __LOCATION__ == 'nodes':
        t = C.center2Node(t, Internal.__FlowSolutionCenters__)
    else: t = C.node2Center(t)
    zoneNames = C.getZoneNames(t)
    renderTags = getRenderTags(t)
    arrays = C.getAllFields(t, 'nodes', api=2)
    CPlot.display(arrays, dim, mode, scalarField, vectorField1,
                  vectorField2, vectorField3, displayBB, displayInfo,
                  displayIsoLegend, meshStyle,
                  solidStyle, scalarStyle, vectorStyle, vectorScale, vectorDensity, vectorNormalize,
                  vectorShowSurface, vectorShape, vectorProjection,
                  colormap, niso, isoEdges, isoScales, win,
                  posCam, posEye, dirCam, viewAngle,
                  bgColor, shadow, dof, stereo, stereoDist,
                  export, exportResolution, 
                  zoneNames, renderTags, offscreen)
示例#2
0
def fly(a, bb, posCam, posEye, dirCam, step):
    CPlot.display(a, posCam=posCam, posEye=posEye, dirCam=dirCam)
    xc = 0.5 * (bb[3] + bb[0])
    yc = 0.5 * (bb[4] + bb[1])
    zc = 0.5 * (bb[5] + bb[2])
    x = posCam[0] - xc
    y = posCam[2] - yc
    z = posCam[1] - zc
    x = 10 * x / (bb[3] - bb[0])
    y = 10 * y / (bb[4] - bb[1])
    z = 30 * z / (bb[5] - bb[2])
    xp = x + step * sigma * (y - x)
    yp = y + step * (ro * x - y - x * z)
    zp = z + step * (x * y - beta * z)
    xp = xp * (bb[3] - bb[0]) * 0.1 + xc
    yp = yp * (bb[4] - bb[1]) * 0.1 + yc
    zp = zp * (bb[5] - bb[2]) / 30. + zc
    posCam[0] = xp
    posCam[1] = zp
    posCam[2] = yp
    return posCam
#!/usr/bin/python
# coding: utf-8
r"""display (array) example"""

import Generator as G
import CPlot
# import Transform as T
# import Converter as C

a = G.cart((0, 0, 0), (1, 1, 1), (18, 28, 3))
CPlot.display(a, displayBB=0, mode='mesh')

# for i in xrange(360):
#     a = T.rotate(a, (9, 14, 3.5), (0,0,1), 1.)
#     CPlot.display(a)
示例#4
0
# - unselectAllZones (array) -
import Generator as G
import CPlot
import time

a1 = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5))
a2 = G.cart((7, 0, 0), (1, 1, 1), (3, 3, 3))
CPlot.display([a1, a2])

time.sleep(2.)
CPlot.unselectAllZones()
示例#5
0
# - rotate -
# Rotation autour d'un objet
import Converter as C
import Transform as T
import CPlot


def rotate(a):
    for i in range(90 * 2):
        a = T.rotate(a, (0.5, 0, 0), (0, 0, 1), 0.5)
        CPlot.display(a)
    return a


a = C.convertFile2Arrays('dauphin2.plt', 'bin_tp')

CPlot.display(a, win=(700, 500), displayBB=0, mode=0, meshStyle=0)
a = rotate(a)

CPlot.display(a, mode=1, solidStyle=0)
a = rotate(a)

CPlot.display(a, mode=2, colormap=1)
a = rotate(a)

CPlot.display(a, mode=2, colormap=0)
a = rotate(a)

CPlot.display(a, mode=2, colormap=1)
a = rotate(a)
示例#6
0
# - delete (array) -
import Generator as G
import CPlot
import time

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cart((0, 10, 0), (1, 1, 1), (10, 10, 10))
c = G.cartTetra((11, 0, 0), (1, 1, 1), (10, 10, 10))

CPlot.display([a, b, c])
time.sleep(1)
CPlot.delete([1])
CPlot.render()
time.sleep(1)
示例#7
0
# - getMoouseState (array) -
import Generator as G
import CPlot
import time

a = G.cartTetra((0, 0, 0), (1, 1, 1), (5, 5, 1))
CPlot.display([a], dim=2)

c = 1000
while (c > 0):
    l = CPlot.getMouseState()
    time.sleep(0.5)
    print l
    c -= 1
# - display (array) -
# Offscreen using mesa
import CPlot
import Transform as T
import Geom as D

a = D.sphere( (0,0,0), 1)

# One image
CPlot.display([a], offscreen=1, bgColor=1, mode=1, meshStyle=2,
              solidStyle=1, posCam=(0,6,0), export="one.png")
CPlot.finalizeExport()

# Movie
for i in range(50):
    a = T.rotate(a, (0,0,0), (0,0,1), 1.)
    CPlot.display([a], offscreen=1, bgColor=1, mode=1, meshStyle=2,
                  solidStyle=1, posCam=(0,6,0), 
                  exportResolution='680x600', export="export.mpeg")
    CPlot.finalizeExport() # wait for end of file write
CPlot.finalizeExport(1)
import os; os._exit(0)
示例#9
0
#!/usr/bin/python
# coding: utf-8
r"""cartNGon (array)

Generator.cartNGon((xo, yo, zo), (hi, hj, hk), (ni, nj, nk))

Create a NGON mesh defined from a regular Cartesian mesh. The initial Cartesian
mesh is defined by ni x nj x nk points starting from point (xo,yo,zo) 
and of step (hi,hj,hk). Type of elements is ‘NGON’.
Parameters:
    (xo,yo,zo) (3-tuple of floats) – coordinates of the starting point
    (hi,hj,hk) (3-tuple of floats) – values of advancing step in the three
                                     directions
    (ni,nj,nk) (3-tuple of integers) – number of points in each direction

Returns:a 1D, 2D or 3D unstructured mesh
Return type:array or pyTree zone

"""
import Generator as G
import Converter as C
import CPlot

a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.2), (20, 20, 20))
CPlot.display([a], meshStyle=1)
# - moveCamera (array) -
import Geom as D
import Converter as C
import Transform as T
import CPlot

# Model
a = D.sphere((0,0,0), 1., N=20)
CPlot.display(a, posCam=(3,-1,0.7), posEye=(0,0,0))

t = 0.
for i in range(1000):
    # change model
    defo = C.initVars(a, '{df}=0.1*cos(%f)*sin(10*pi*{x})'%(t))
    defo = C.extractVars(defo, ['df'])
    b = T.deformNormals(a, defo)
    # Move camera
    CPlot.moveCamera([(3,-1,0.7),(3,5,0.7),(3,7,0.7)], N=1000, pos=i)
    CPlot.display(b)
    t += 0.05
示例#11
0
# - listen (array) -
import Converter as C
import CPlot
sockets = C.createSockets()

while True:
    out = []
    for s in sockets:
        a = C.listen(s)
        if a is not None: out.append(a)
    if out != []: CPlot.display(out)
示例#12
0
import os

import Generator as G
import Converter as C
import CPlot
import time
import Transform as T

a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5))

# dump a PNG
CPlot.display([a],
              mode=0,
              posCam=(10, 2, 2),
              posEye=(2, 2, 2),
              export='export.png',
              exportResolution='600x600',
              offscreen=2)
time.sleep(1)

# dump a MPEG movie
for i in xrange(200):
    a = T.rotate(a, (2, 2, 2), (0, 0, 1), 1)
    time.sleep(0.1)
    CPlot.display([a],
                  mode=1,
                  export='export.mpeg',
                  exportResolution='600x600',
                  offscreen=2)
time.sleep(2)
示例#13
0
# - reorder -
# Reordonne le bloc selectionne
# 's' sauvegarde le fichier
import Converter as C
import CPlot
import Transform as T
import time

a = C.convertFile2Arrays('fontaine.plt')
CPlot.display(a, mode=1, displayBB=0)

bool = 0
while (bool == 0):
    l = -1
    CPlot.display(a)
    while (l == -1):
        l = CPlot.getSelectedZone()
        s = CPlot.getKeyboard()
        if (s == "s"):
            C.convertArrays2File(a, 'out.plt')
            import sys
            sys.exit()
        time.sleep(0.1)

    # Reorder suivant le type de zone
    z = a[l - 1]
    if (len(z) == 5):  # structure
        ni = z[2]
        nj = z[3]
        nk = z[4]
        if (ni == 1):
# - display (array) -
import Generator as G
import CPlot
import Converter as C


def F(x, y):
    return x * x + y * y


a = G.cart((0, 0, 0), (1, 1, 1), (18, 28, 1))
a = C.initVars(a, 'F', F, ['x', 'y'])

CPlot.display(a, mode=3, scalarField=0, dim=2, displayIsoLegend=1)
# - getSelectedZone (array) -
import Generator as G
import CPlot
import time

a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5))
CPlot.display(a)

nz = -1
while nz == -1:
    nz = CPlot.getSelectedZone()
    time.sleep(0.1)
print('One zone has been selected: %d.' % nz)
示例#16
0
# - flush (array) -
import Generator as G
import CPlot
import Transform as T
import time

a = G.cart((0, 0, 0), (1, 1, 1), (180, 280, 300))
CPlot.display(a, mode=0)
time.sleep(2)
#CPlot.flush()
time.sleep(2)
a = T.rotate(a, (0, 0, 0), (0, 0, 1), 20.)
CPlot.display(a, mode=0)
CPlot.cplot.show()
示例#17
0
# - particles -
# Ajoute des particules se deplacant suivant la vitesse definie dans un champ
import Converter as C
import Post as P
import numpy
import CPlot

try:
    range = xrange
except:
    pass

# Solution en noeuds et en centres
a = C.convertFile2Arrays('outputn.plt')
sol = C.convertFile2Arrays('output.plt')
CPlot.display(sol, dim=2)

# Entree du point d'emission
print "Cliquez pour definir le point d'emission..."

Point = []
while Point == []:
    Point = CPlot.getActivePoint()

# Point d'emission
print "Point d'emission :", Point

# Particules
np = 20
nq = 20
nodes = C.array('x,y,z,ro,rou,rov,row,roE,cellN', np * nq, 0, 'NODE')
示例#18
0
# - getKeyboard (array) -
import Generator as G
import CPlot
import Geom as D
import time

a = G.cart((0, 0, 0), (1, 1, 1), (8, 8, 1))
CPlot.display(a, dim=2)
CPlot.setState(activateShortCuts=0)

for i in range(50):
    l = ''
    while l == '':
        l = CPlot.getKeyboard()
        time.sleep(0.1)
    try:
        a = D.text2D(l)
        CPlot.display(a)
    except:
        v = ord(l[0])
        if v == 1: print('up')
        elif v == 2: print('down')
        elif v == 3: print('left')
        elif v == 4: print('right')
        time.sleep(0.1)
        l = ''
示例#19
0
# - delete (array) -
import Generator as G
import CPlot
import time

a = G.cart( (0,0,0), (1,1,1), (10,10,10) )
b = G.cart( (11,0,0), (1,1,1), (10,10,10) )

CPlot.display([a,b]); time.sleep(1)
CPlot.delete([0]); CPlot.render(); time.sleep(1)
CPlot.delete(['S-Zone 1']); CPlot.render(); time.sleep(1)
示例#20
0
# - add (array) -
import Generator as G
import CPlot
import time

a = G.cart((0, 0, 0), (1, 1, 1), (30, 30, 30))
A = [a]
CPlot.display(A)
time.sleep(1)

b = G.cart((30, 0, 0), (1, 1, 1), (30, 30, 30))
CPlot.add(A, 0, b)
CPlot.render()
time.sleep(0.5)
# - changeBlanking (array) -
import Generator as G
import Converter as C
import CPlot
import time

a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 1))
a = C.initVars(a, 'cellN', 0)
CPlot.display(a, dim=2, mode=0)

CPlot.changeBlanking()
time.sleep(2)
CPlot.changeBlanking()
time.sleep(2)
示例#22
0
# - refine -
# Raffine une cellule d'un maillage en clickant
# 's' sauvegarde le fichier
import Converter as C
import CPlot
import Post as P
import Generator as G
import time

a = [G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))]
a = C.convertArray2Tetra(a)
CPlot.display(a, mode=0, displayBB=0, dim=2)

bool = 0
while bool == 0:
    l = []
    CPlot.display(a)
    while l == []:
        l = CPlot.getActivePointIndex()
        nz = CPlot.getSelectedZone()
        s = CPlot.getKeyboard()
        if s == "s":
            C.convertArrays2File(a, 'out.plt')
            import sys
            sys.exit()
        time.sleep(0.1)

    # Raffine
    z = a[nz]
    indic = C.array('indic', z[2].shape[1], 1, 1)
    indic = C.initVars(indic, 'indic', 0)
for i in xrange(200):
    # Defo de la surface (suivant une formule analytique)
    defo = C.initVars(s, '{df}=0.3*cos(%f)*sin(10*pi*{s}+%f)' % (time, time))
    defo = C.extractVars(defo, ['df'])
    defo = T.addkplane(defo)
    defo = T.addkplane(defo)
    cyl2 = T.deformNormals(cyl, defo)
    cyl2 = G.close(cyl2, 1.e-2)

    # Defo du maillage (suivant la surface)
    cyld = C.copy(cyl2)
    cyld[0] = 'x1,y1,z1'
    cyl3 = C.addVars([cyl, cyld])
    cyl3 = C.initVars(cyl3, 'dx={x1}-{x}')
    cyl3 = C.initVars(cyl3, 'dy={y1}-{y}')
    cyl3 = C.initVars(cyl3, 'dz={z1}-{z}')
    cyl3 = C.extractVars(cyl3, ['x', 'y', 'z', 'dx', 'dy', 'dz'])
    cylmesh2 = T.deformMesh(cylmesh, cyl3, beta=7.)

    # On verifie que l'on a pas de volume negatif
    vol = G.getVolumeMap(cylmesh2)
    minvol = C.getMinValue(vol, 'vol')
    if minvol <= 0:
        print('BEWARE!')

    # Display
    CPlot.display([cyl2] + cylmesh2, dim=2)
    time += 0.05

C.convertArrays2File([cyl2] + cylmesh2, 'out.plt')
示例#24
0
# - add (array) -
import Generator as G
import CPlot
import time

a = G.cartTetra( (0,0,0), (1,1,1), (10,10,10) )
A = [a]
CPlot.display(A); time.sleep(1)

for i in range(10):
    b = G.cartTetra( (i*10,0,0), (1,1,1), (10,10,10) )
    CPlot.add(A, 0, b); CPlot.render(); time.sleep(0.5)

for i in range(10):
    b = G.cart( (i*10,10,0), (1,1,1), (10,10,10) )
    CPlot.add(A, 0, b); CPlot.render(); time.sleep(0.5)
示例#25
0
def rotate(a):
    for i in range(90 * 2):
        a = T.rotate(a, (0.5, 0, 0), (0, 0, 1), 0.5)
        CPlot.display(a)
    return a
示例#26
0
of inner radius R1, outer radius R2, height H and with distributions in r, 
teta, z.
Distributions are arrays defining 1D meshes (x and i varying) 
giving a distribution in [0,1]. Their number of points gives ni, nj, nk.

Parameters:
    (xo,yo,zo) (3-tuple of floats) – coordinates of the starting point
    R1 (float) – value of inner radius
    R2 (float) – value of outer radius
    tetas (float) – start angle (in degree)
    tetae (float) – end angle (in degree)
    H (float) – value of cylinder height
    arrayR (array) – distribution along radius
    arrayTeta (array) – distribution along azimuth
    arrayZ (array) – distribution along height

Returns: a 3D structured mesh
Return type: array or pyTree zone

"""
import Converter as C
import Generator as G
import CPlot

r = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
teta = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
z = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
cyl = G.cylinder2((0., 0., 0.), 0.5, 1., 360., 0., 10., r, teta, z)
C.convertArrays2File([cyl], "out.plt")
CPlot.display(cyl)
示例#27
0
def CPlotDisplay__(file):
    import os.path
    ext = os.path.splitext(file)
    extension = ext[len(ext) - 1]
    if (extension == '.plt' or extension == '.PLT'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'bin_tp')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.dat' or extension == '.tp' or extension == '.DAT'
          or extension == '.TP'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_tp')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.v3d' or extension == '.V3D'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'bin_v3d')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.mesh' or extension == '.MESH'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_mesh')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.stl' or extension == '.STL'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'bin_stl')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.fig' or extension == '.FIG'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_xfig')
        CPlot.display(a, dim=2)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.svg' or extension == '.SVG'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_svg')
        CPlot.display(a, dim=2)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.pov' or extension == '.POV'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_pov')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.3ds' or extension == '.3DS'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'bin_3ds')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.obj' or extension == '.OBJ'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_obj')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.gts' or extension == '.GTS'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'fmt_gts')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.cgns' or extension == '.CGNS'):
        import Converter.PyTree as C
        import CPlot.PyTree
        a = C.convertFile2PyTree(file, 'bin_cgns')
        CPlot.PyTree.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.adf' or extension == '.ADF'):
        import Converter.PyTree as C
        import CPlot.PyTree
        a = C.convertFile2PyTree(file, 'bin_cgns')
        CPlot.PyTree.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.hdf' or extension == '.HDF'):
        import Converter.PyTree as C
        import CPlot.PyTree
        a = C.convertFile2PyTree(file, 'bin_hdf')
        CPlot.PyTree.display(a)
        CPlot.setFileName__(file)
        infLoop()
    elif (extension == '.pickle' or extension == '.PICKLE'
          or extension[0:4] == '.ref' or extension[0:4] == '.REF'):
        import Converter as C
        import CPlot
        a = C.convertFile2Arrays(file, 'bin_pickle')
        CPlot.display(a)
        CPlot.setFileName__(file)
        infLoop()
示例#28
0
# Distance field to second surface (shape2)
d2 = Dist2Walls.distance2Walls(b, [shape2],
                               type='ortho',
                               loc='nodes',
                               signed=1)
d2[0] = 'Dist2'

b = C.addVars([b, d1])
b = C.addVars([b, d2])

val = 0. * h

# Morphing
for j in range(10):

    for i in range(20):
        alpha = 1 - i / 19.
        b = C.initVars(
            b, 'Dist = ' + str(alpha) + '*{Dist1}+' + str(
                (1. - alpha)) + '*{Dist2}')
        iso = P.isoSurfMC([b], 'Dist', value=val)
        CPlot.display(iso, mode=0, meshStyle=0)

    for i in range(20):
        alpha = 1 - i / 19.
        b = C.initVars(
            b, 'Dist = ' + str(1. - alpha) + '*{Dist1}+' + str(alpha) +
            '*{Dist2}')
        iso = P.isoSurfMC([b], 'Dist', value=val)
        CPlot.display(iso, mode=0, meshStyle=0)
示例#29
0
# - getActivePointF (array) -
import Generator as G
import Converter as C
import CPlot
import time

a = G.cart((0,0,0), (1,1,1), (5,5,5))
a = C.initVars(a, '{F}={x}')
CPlot.display([a])

l = []
while l == []:
    l = CPlot.getActivePointF(); time.sleep(0.1)
print('ActivePoint: ', l)
示例#30
0
# - display (array) -
# Offscreen using FBO
import Generator as G
import CPlot
import Transform as T
import Converter as C
import Geom as D
import time

a = D.sphere((0, 0, 0), 1, N=200)

# Multi images
CPlot.display([a],
              offscreen=2,
              bgColor=1,
              mode=0,
              meshStyle=2,
              solidStyle=1,
              posCam=(0, 6, 0),
              export='one.png')

for i in range(5):
    a = T.rotate(a, (0, 0, 0), (0, 0, 1), 1.)
    CPlot.display([a],
                  offscreen=2,
                  bgColor=1,
                  mode=0,
                  meshStyle=2,
                  solidStyle=1,
                  posCam=(0, 6, 0),
                  export='one%d.png' % i)
    CPlot.finalizeExport()