Exemplo n.º 1
0
def run():
    n=12
    h=5.
    A = simple.sector(1.,360.,1,n,diag='u')
    B = simple.cylinder(2.,h,n,4,diag='u').reverse()
    C = A.reverse()+B+A.trl(2,h)
    S = TriSurface(C)
    export({'surface':S})

    clear()
    smoothwire()
    view('iso')
    draw(S,color=red,bkcolor=black)
Exemplo n.º 2
0
def run():
    n = 12
    h = 5.
    A = simple.sector(1., 360., 1, n, diag='u')
    B = simple.cylinder(2., h, n, 4, diag='u').reverse()
    C = A.reverse() + B + A.trl(2, h)
    S = TriSurface(C)
    export({'surface': S})

    clear()
    smoothwire()
    view('iso')
    draw(S, color=red, bkcolor=black)
Exemplo n.º 3
0
def createCone():
    res = askItems([('name','__auto__'),
                    ('radius',1.),
                    ('height',1.),
                    ('angle',360.),
                    ('div_along_radius',6),
                    ('div_along_circ',12),
                    ('diagonals','up','select',['up','down']),
                    ])
    if res:
        name = res['name']
        F = simple.sector(r=res['radius'],t=res['angle'],nr=res['div_along_radius'],nt=res['div_along_circ'],h=res['height'],diag=res['diagonals'])
        export({name:TriSurface(F)})
        selection.set([name])
        selection.draw()
Exemplo n.º 4
0
def createCone():
    _data_ = _name_ + 'createCone_data'
    res = {
        'name': '__auto__',
        'object type': 'Formex',
        'radius': 1.,
        'height': 1.,
        'angle': 360.,
        'div_along_radius': 6,
        'div_along_circ': 12,
        'diagonals': 'up',
    }
    if _data_ in pf.PF:
        res.update(pf.PF[_data_])

    res = askItems(store=res,
                   items=[
                       _I('name'),
                       _I('object type',
                          choices=['Formex', 'Mesh', 'TriSurface']),
                       _I('radius'),
                       _I('height'),
                       _I('angle'),
                       _I('div_along_radius'),
                       _I('div_along_circ'),
                       _I('diagonals', choices=['none', 'up', 'down']),
                   ])

    if res:
        pf.PF[_data_] = res
        name = res['name']
        if name == '__auto__':
            name = autoName(res['object type']).next()

        F = simple.sector(r=res['radius'],
                          t=res['angle'],
                          nr=res['div_along_radius'],
                          nt=res['div_along_circ'],
                          h=res['height'],
                          diag=res['diagonals'])

        F = convertFormex(F, res['object type'])
        export({name: F})
        selection.set([name])
        if res['object type'] == 'TriSurface':
            surface_menu.selection.set([name])
        selection.draw()
Exemplo n.º 5
0
def run():
    reset()
    clear()
    smooth()
    transparent()
    view('right')

    # Create some geometry
    S = sphere()
    T = sector(1.0,360.,6,36,h=1.0,diag='u').toSurface().scale(1.5).reverse()
    C = cylinder(1.2,1.5,24,4,diag='u').toSurface().trl([0.5,0.5,0.5]).reverse()

    # Draw the geometry with given colors/opacity
    # Settings colors and opacity in this way makes the model
    # directly ready to export as WebGL
    S.color = red
    S.alpha = 0.7
    S.caption = 'A sphere'
    S.control = ['visible','opacity','color']
    S.setNormals('avg')

    T.color = blue
    T.caption = 'A cone'
    T.alpha = 1.0
    T.control = ['visible','opacity','color']
    #S.setNormals('auto')

    C.color = 'yellow'
    C.caption = 'A cylinder'
    C.alpha = 0.8
    C.control = ['visible','opacity','color']
    #S.setNormals('auto')

    export({'sphere':S,'cone':T,'cylinder':C})

    draw([S,T,C])
    zoomAll()
    rotRight(30.)

    camera = pf.canvas.camera
    print("Camera focus: %s; eye: %s" % (camera.focus, camera.eye))

    if checkWorkdir():
        # Export everything to webgl
        W = WebGL()
        W.addScene()
        W.export('Scene1','Two spheres and a cone',createdby=True)
def createCone():
    _data_ = __name__+'_createCone_data'
    res = {
        'name' : '__auto__',
        'object type':'Formex',
        'radius': 1.,
        'height': 1.,
        'angle': 360.,
        'div_along_radius': 6,
        'div_along_circ':12,
        'diagonals':'up',
        }
    if pf.PF.has_key(_data_):
        res.update(pf.PF[_data_])
        
    res = askItems(store=res, items=[
        _I('name'),
        _I('object type',choices=['Formex','Mesh','TriSurface']),
        _I('radius'),
        _I('height'),
        _I('angle'),
        _I('div_along_radius'),
        _I('div_along_circ'),
        _I('diagonals',choices=['none','up','down']),
        ])
    
    if res:
        pf.PF[_data_] = res
        name = res['name']
        if name == '__auto__':
            name = autoName(res['object type']).next()

        F = simple.sector(r=res['radius'],t=res['angle'],nr=res['div_along_radius'],
                          nt=res['div_along_circ'],h=res['height'],diag=res['diagonals'])
        
        F = convertFormex(F,res['object type'])
        export({name:F})
        selection.set([name])
        selection.draw()
Exemplo n.º 7
0
def run():
    reset()
    smooth()
    r=3.
    h=15.
    n=64

    F = simple.sector(r,360.,n,n,h=h,diag=None)
    F.setProp(0)
    draw(F,view='bottom')
    #setDrawOptions({'bbox':None})

    print(map(str,range(4)))
    ans = ask('How many balls do you want?',['0','1','2','3'])

    try:
        nb = int(ans)
    except:
        nb = 3

    if nb > 0:
        B = simple.sphere3(n,n,r=0.9*r,bot=-90,top=90)
        B1 = B.translate([0.,0.,0.95*h])
        B1.setProp(1)
        draw(B1)

        if nb > 1:
            B2 = B.translate([0.2*r,0.,1.15*h])
            B2.setProp(2)
            draw(B2)

        if nb > 2:
            B3 = B.translate([-0.2*r,0.1*r,1.25*h])
            B3.setProp(6)
            draw(B3)

        zoomAll()
Exemplo n.º 8
0
def run():
    reset()
    smooth()
    r = 3.
    h = 15.
    n = 64

    F = simple.sector(r, 360., n, n, h=h, diag=None)
    F.setProp(0)
    draw(F, view='bottom')
    #setDrawOptions({'bbox':None})

    print(map(str, range(4)))
    ans = ask('How many balls do you want?', ['0', '1', '2', '3'])

    try:
        nb = int(ans)
    except:
        nb = 3

    if nb > 0:
        B = simple.sphere3(n, n, r=0.9 * r, bot=-90, top=90)
        B1 = B.translate([0., 0., 0.95 * h])
        B1.setProp(1)
        draw(B1)

        if nb > 1:
            B2 = B.translate([0.2 * r, 0., 1.15 * h])
            B2.setProp(2)
            draw(B2)

        if nb > 2:
            B3 = B.translate([-0.2 * r, 0.1 * r, 1.25 * h])
            B3.setProp(6)
            draw(B3)

        zoomAll()
Exemplo n.º 9
0
"""Cylinder

level = 'beginner'
topics = ['geometry', 'surface', 'cylinder']
techniques = ['import']

.. Description

Cylinder
--------
This example illustrates the use of simple.sector() and simple.cylinder()
to create a parametric cylindrical surface.

"""
import simple
from plugins.trisurface import TriSurface

n=12
h=5.
A = simple.sector(1.,360.,1,n,diag='u')
B = simple.cylinder(2.,h,n,4,diag='u').reverse()
C = A.reverse()+B+A.trl(2,h)
S = TriSurface(C)
export({'surface':S})

smoothwire()
view('iso')
draw(S,color=red)

# End
Exemplo n.º 10
0
## pyFormex is a Python implementation of Formex algebra
## Website: http://pyformex.berlios.de/
## Copyright (C) Benedict Verhegghe ([email protected]) 
##
## This program is distributed under the GNU General Public License
## version 2 or later (see file COPYING for details)
##

import simple

smooth()
r=3.
h=15.
n=64

F = simple.sector(r,360.,n,n,h=h,diag=None)
F.setProp(0)
draw(F,view='bottom')
zoomall()
zoom(1.5)


ans = ask('How many balls do you want?',['3','2','1','0'])

try:
    nb = int(ans)
except:
    nb = 3
    
if nb > 0:
    B = simple.sphere3(n,n,r=0.9*r,bot=-90,top=90)