# - replace (pyTree) -
import Generator.PyTree as G
import CPlot.PyTree as CPlot
import Converter.PyTree as C
import time
dt = 0.2

a = G.cart((0, 0, 0), (1, 1, 1), (30, 30, 30))
b = G.cartHexa((0, 0, 40), (1, 1, 1), (30, 30, 30))
t = C.newPyTree(['Base', a, b])
CPlot.display(t)
time.sleep(dt)

# Replace struct
for i in range(10):
    a = G.cart((i, 0, 0), (1, 1, 1), (30, 30, 30))
    CPlot.replace(t, 1, 0, a)
    CPlot.render()
    time.sleep(dt)

# Replace non struct
for i in range(10):
    a = G.cartHexa((i, 0, 40), (1, 1, 1), (30, 30, 30))
    CPlot.replace(t, 1, 1, a)
    CPlot.render()
    time.sleep(dt)
# - moveCamera (pyTree) -
import Geom.PyTree as D
import CPlot.PyTree as CPlot
import Converter.PyTree as C
import Transform.PyTree as T
import Generator.PyTree as G

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

t = 0.
for i in range(1000):
    # change model
    C._initVars(a, '{df}=0.1*cos(%f)*sin(10*pi*{CoordinateX})' % (t))
    b = T.deformNormals(a, 'df')
    # 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
Exemple #3
0
# - lookFor (pyTree) -
import Generator.PyTree as G
import CPlot.PyTree as CPlot

a = G.cart( (0,0,0), (1,1,1), (5,5,5) )
CPlot.display(a)
CPlot.lookFor()
Exemple #4
0
# - display (pyTree) -
# Affichage du shader vector (mode solid)
import Geom.PyTree as D
import CPlot.PyTree as CPlot
import Converter.PyTree as C

a = D.sphere((0,0,0),1.,N=50)
#a = C.convertArray2Hexa(a)
C._initVars(a, '{fx}=-{CoordinateY}')
C._initVars(a, '{fy}={CoordinateX}')
C._initVars(a, '{fz}={CoordinateZ}')

C.convertPyTree2File(a, 'out.cgns')

CPlot.display(a, mode='Vector', vectorField1=0, vectorField2=1, vectorField3=2, vectorStyle=1, vectorScale=80.)
#CPlot.display(a, mode='Vector', vectorField1=0, vectorField2=1, vectorField3=2, vectorStyle=1, vectorScale=80.)
#CPlot.display(a, mode='Vector', vectorField1='fx', vectorField2='fy', vectorField3='fz', vectorStyle=1, vectorScale=80., vectorNormalize=1)
#CPlot.display(a, mode='Vector', vectorField1=0, vectorField2=1, vectorField3=2, vectorStyle=0)
#CPlot.display(a, displayBB=0, mode='Vector', vectorField1=0, vectorField2=1, vectorField3=2, vectorStyle=1, vectorScale=0.25)
#CPlot.display(a, displayBB=0, mode='Vector', vectorField1=0, vectorField2=1, vectorField3=2, vectorStyle=2, vectorScale=0.25)
#CPlot.display(a, displayBB=0, mode='Vector', vectorField1='fx', vectorField2='fy', vectorField3='fz', vectorStyle=1, vectorScale=80., vectorNormalize=1)
#CPlot.display(a, displayBB=0, mode='Vector', vectorField1=0, vectorField2=1, vectorField3=2, vectorStyle=0)


Exemple #5
0
# - listen (pyTree) -
import Converter.PyTree as C
import CPlot.PyTree as 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)
# - setState (pyTree) -
import Generator.PyTree as G
import CPlot.PyTree as CPlot
import time

a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5))
CPlot.display([a], mode='solid')
time.sleep(0.2)
CPlot.setState(posCam=(8, 8, 8), posEye=(5, 5, 5))
tsph = GP.sphere6((0, 0, 0), 1., N=3, ntype='TRI')
tsph = C.convertLO2HO(tsph, 0)
for i in range(C.getNPts(tsph)):
    x = C.getValue(tsph, 'CoordinateX', i)
    y = C.getValue(tsph, 'CoordinateY', i)
    z = C.getValue(tsph, 'CoordinateZ', i)
    nrm = sqrt(x * x + y * y + z * z)
    x /= nrm
    y /= nrm
    z /= nrm
    C.setValue(tsph, 'CoordinateX', i, x)
    C.setValue(tsph, 'CoordinateY', i, y)
    C.setValue(tsph, 'CoordinateZ', i, z)

tsph = T.translate(tsph, (3., 0, 0))
t = C.newPyTree(['Base1', 'Base2'])
t[2][1][2] += Ci.getZones(qsph)
t[2][2][2] += Ci.getZones(tsph)

for shader in [
        "Chrome", "Glass", "Wood", 'Marble', 'XRay', 'Metal', 'Granite',
        'Brick', 'Cloud', 'Gooch'
]:
    s = CPlot.addRender2Zone(t, material=shader, color='White')
    CPlot.display(s, mode="Render")
    l = ''
    while (l != 'n'):
        l = CPlot.getKeyboard()
        CPlot.resetKeyboard()
# - display (pyTree) -
# Affichage du shader smoke (mode solid)
import Geom.PyTree as D
import CPlot.PyTree as CPlot
import Converter.PyTree as C

a = D.sphere((0, 0, 0), 1.)
a = C.convertArray2Hexa(a)
a = CPlot.addRender2Zone(a, material='Smoke', color='White')
t = C.newPyTree(['Base', a])

CPlot.display(t, mode=2)
g = C.initVars(g,
               '{F}={CoordinateX}*{CoordinateX}+{CoordinateY}*{CoordinateY}')
g = C.node2Center(g, 'F')
g = CPlot.addRender2Zone(g, material='Solid', color='Iso:F')

h = T.translate(a, (0, 2.5, -5.))
h = C.initVars(h,
               '{F}={CoordinateX}*{CoordinateX}+{CoordinateY}*{CoordinateY}')
h = C.node2Center(h, 'F')
h = C.rmVars(h, ['F'])
h = T.translate(h, (0, 2.5, 0))
h = CPlot.addRender2Zone(h, material='Solid', color='Iso:centers:F')

t = C.newPyTree(['Base', a, b, c, d, e, f, g, h, i])

# Tests des shaders
CPlot.display(t, mode=2)  # mode=2 active les shaders
time.sleep(2)

# Ajout du overlay mesh
CPlot._addRender2Zone(t, meshOverlay=1)
CPlot.display(t, mode=2)
time.sleep(2)

# Ajout du blending
CPlot._addRender2Zone(t, meshOverlay=0)
for i in range(30):
    CPlot._addRender2Zone(t, blending=1. - i * 1. / 30.)
    CPlot.display(t, mode=2)
    time.sleep(0.1)
Exemple #10
0
# - setMode (pyTree) -
import Generator.PyTree as G
import CPlot.PyTree as CPlot
import time

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

CPlot.setMode(1)
time.sleep(2)
CPlot.setMode(0)
time.sleep(2)
CPlot.setMode(1)
time.sleep(2)
# - display (pyTree) -
# Affichage du shader sphere
import Geom.PyTree as D
import CPlot.PyTree as CPlot
import Converter.PyTree as C
import time

a = D.sphere((0, 0, 0), 1., N=5)
a = C.convertArray2Hexa(a)

for i in range(10):
    print(i * 2. / 5.)
    CPlot._addRender2Zone(a,
                          material='Sphere',
                          color='White',
                          shaderParameters=[1.5, i * 2. / 5.])

    CPlot.display(a, mode='render', bgColor=1)
    time.sleep(1.)