home processing download documents tutorial python tutorial gallery source about
 Python Tutorials (back to the list of tutorials)

Panelization Examples

     Panelization Example7

The following is an example of extruding circles with its depth controlled by a bitmap image.

surface7.3dm

The input bitmap used in the example is this.

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface7.3dm")
surfaces = IG.surfaces()

map = IImageMap("map4.jpg")

for surf in surfaces :
    unum = 100
    vnum = 50
    uinc = 1.0/unum
    vinc = 1.0/vnum
    for i in range(unum) :
        for j in range(vnum) : 
            val = map.get( i*uinc, j*vinc )
            
            pt = surf.pt( i*uinc, j*vinc )
            nml = surf.nml( i*uinc, j*vinc )
            cir = ICircle(pt, nml, 0.1)
            
            IG.extrude(cir, val*-2).clr(0)
    surf.del()

Then the generation of circles and surfaces are also controlled by a probabilistic switch responding to the bitmap input.

add_library('igeo')

size(480, 360, IG.GL)

IG.open("surface7.3dm")
surfaces = IG.surfaces()

map = IImageMap("map4.jpg")

for surf in surfaces :
    unum = 200
    vnum = 100
    uinc = 1.0/unum
    vinc = 1.0/vnum
    for i in range(unum) :
        for j in range(vnum) : 
            val = map.get( i*uinc, j*vinc )
            
            if IRand.pct(val*100) : 
                pt = surf.pt( i*uinc, j*vinc )
                nml = surf.nml( i*uinc, j*vinc )
                cir = ICircle(pt, nml, 0.05)
                
                IG.extrude(cir, -2*val).clr(0)
    surf.del()


(back to the list of tutorials)

HOME
FOR PROCESSING
DOWNLOAD
DOCUMENTS
TUTORIALS (Java / Python)
GALLERY
SOURCE CODE(GitHub)
ABOUT