# - deformMesh (pyTree) -
import Generator.PyTree as G
import Transform.PyTree as T
import Converter.PyTree as C
import Geom.PyTree as D

a1 = D.sphere6((0, 0, 0), 1, 20)
a1 = C.convertArray2Tetra(a1)
a1 = T.join(a1)
point = C.getValue(a1, 'GridCoordinates', 0)
a2 = T.deformPoint(a1, point, (0.1, 0.05, 0.2), 0.5, 2.)
delta = C.diffArrays(a2, a1)
deltax = C.getField('DCoordinateX', delta)
deltay = C.getField('DCoordinateY', delta)
deltaz = C.getField('DCoordinateZ', delta)
for noz in xrange(len(deltax)):
    deltax[noz][0] = 'dx'
    deltay[noz][0] = 'dy'
    deltaz[noz][0] = 'dz'
a1 = C.setFields(deltax, a1, 'nodes')
a1 = C.setFields(deltay, a1, 'nodes')
a1 = C.setFields(deltaz, a1, 'nodes')

m = D.sphere6((0, 0, 0), 2, 20)
m = T.deformMesh(m, a1)
C.convertPyTree2File(m, "out.cgns")
Пример #2
0
def sculpt():
    if CTK.t == []: return
    if CTK.__MAINTREE__ <= 0:
        CTK.TXT.insert('START', 'Fail on a temporary tree.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    TOOLS = createTools()
    #CTK.display(TOOLS)

    bbox = G.bbox(CTK.t)
    size = max(bbox[3] - bbox[0], bbox[4] - bbox[1], bbox[5] - bbox[2])
    CPlot.unselectAllZones()

    w = WIDGETS['sculpt']
    if CTK.__BUSY__ == False:
        CTK.__BUSY__ = True
        TTK.sunkButton(w)
        CPlot.setState(cursor=1)
        while CTK.__BUSY__:
            l = []
            while l == []:
                nz = CPlot.getSelectedZone()
                l = CPlot.getActivePointIndex()
                time.sleep(CPlot.__timeStep__)
                w.update()
                if (CTK.__BUSY__ == False): break
            if CTK.__BUSY__:
                nob = CTK.Nb[nz] + 1
                noz = CTK.Nz[nz]
                CTK.saveTree()
                depth = 0.5 * WIDGETS['depth'].get() / 100.
                depth = size * depth
                width = 0.5 * WIDGETS['width'].get() / 100.
                width = size * width
                brushType = VARS[2].get()
                z = CTK.t[2][nob][2][noz]
                posCam = CPlot.getState('posCam')
                posEye = CPlot.getState('posEye')
                vect = (posEye[0] - posCam[0], posEye[1] - posCam[1],
                        posEye[2] - posCam[2])
                if brushType == 'Deform':
                    click = CPlot.getActivePoint()
                    point = (click[0], click[1], click[2])
                    z = T.deformPoint(z, point, vect, depth, width)
                    CTK.replace(CTK.t, nob, noz, z)
                elif brushType == 'Sphere':
                    click = CPlot.getActivePoint()
                    center = (click[0], click[1], click[2])
                    s = D.sphere(center, depth, N=10)
                    s = C.convertArray2Tetra(s)
                    s = G.close(s)
                    z = C.convertArray2Tetra(z)
                    z = G.close(z)
                    z = XOR.booleanMinus(z, s)
                    CTK.replace(CTK.t, nob, noz, z)
                elif brushType == 'Cube':
                    click = CPlot.getActivePoint()
                    center = (click[0], click[1], click[2])
                    s = D.sphere(center, depth, N=20)
                    s = C.convertArray2Tetra(s)
                    s = G.close(s)
                    z = C.convertArray2Tetra(z)
                    z = G.close(z)
                    z = XOR.booleanMinus(z, s)
                    CTK.replace(CTK.t, nob, noz, z)
                CTK.TKTREE.updateApp()
                CPlot.unselectAllZones()
                CPlot.render()
        CTK.__BUSY__ = False
        TTK.raiseButton(w)
        CPlot.setState(cursor=0)
    else:
        CTK.__BUSY__ = False
        TTK.raiseButton(w)
        CPlot.setState(cursor=0)
Пример #3
0
# - deformPoint (PyTree) -
import Generator.PyTree as G
import Transform.PyTree as T
import Converter.PyTree as C
import KCore.test as test

# zone structuree 2d
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 2))
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2])
a = C.addVars(a, 'F')
a = C.addVars(a, 'centers:G')
a = T.deformPoint(a, (0, 0, 0), (0.1, 0.1, 0.), 0.5, 0.4)
test.testT(a, 1)

# zone structuree 3d
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2, 3])
a = C.addVars(a, 'F')
a = C.addVars(a, 'centers:G')
a = T.deformPoint(a, (0, 0, 0), (0.1, 0.1, 0.), 0.5, 0.4)
test.testT(a, 2)

# traitement sur l'arbre
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 2))
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin')
a = C.addVars(a, 'F')
# - deformPoint (PyTree) -
import Generator.PyTree as G
import Transform.PyTree as T
import Converter.PyTree as C

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
a = T.deformPoint(a, (0, 0, 0), (0.1, 0.1, 1.), 0.5, 0.4)
C.convertPyTree2File(a, "out.cgns")