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

Panelization Examples

     Panelization Example9

The following is an example of deformed diamond panelization with diagrid structure. It starts with the example code of diamond panelization in the section of simple panelization.

The sample input file used in the example is this.

surface10.3dm

add_library('igeo')

size(480, 360, IG.GL)

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

for surf in surfaces : 
    unum = 36
    vnum = 24
    uinc = 1.0/unum
    vinc = 1.0/vnum
    for i in range(unum) : 
        for j in range(vnum) : 
            if (i+j)%2==0 : 
                pt1 = surf.pt( (i-1)*uinc, j*vinc )
                pt2 = surf.pt( i*uinc, (j+1)*vinc )
                pt3 = surf.pt( (i+1)*uinc, j*vinc )
                pt4 = surf.pt( i*uinc, (j-1)*vinc )
                
                ISurface(pt1,pt2,pt3,pt4).clr(0.3,0.4*j*vinc,i*uinc*0.8)
    surf.del()

To deform the diamond panel, a surface is created by an array of 3 by 3 control points instead of 4 corner points. The corners of matrix of 3 by 3 control points array have same corner points with the previous code. Other points are mid points of each edge and the center of the panel region. The degree of the surface is changed to 2 to have curved shape.

add_library('igeo')

size(480, 360, IG.GL)

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

for surf in surfaces : 
    unum = 36
    vnum = 24
    uinc = 1.0/unum
    vinc = 1.0/vnum
    
    for i in range(unum) : 
        for j in range(vnum) : 
            if (i+j)%2==0 : 
                cpts = []
                cpts.append([]) # 3 x 3 matrix
                cpts.append([])
                cpts.append([])
                # [0][0], [0][1], [0][2]
                cpts[0].append(surf.pt( (i-1)*uinc, j*vinc ))
                cpts[0].append(surf.pt( (i-0.5)*uinc, (j-0.5)*vinc ))
                cpts[0].append(surf.pt( i*uinc, (j-1)*vinc ))
                # [1][0], [1][1], [1][2]
                cpts[1].append(surf.pt( (i-0.5)*uinc, (j+0.5)*vinc ))
                cpts[1].append(surf.pt( i*uinc, j*vinc, -1 ))
                cpts[1].append(surf.pt( (i+0.5)*uinc, (j-0.5)*vinc ))
                # [2][0], [2][1], [2][2]
                cpts[2].append(surf.pt( i*uinc, (j+1)*vinc ))
                cpts[2].append(surf.pt( (i+0.5)*uinc, (j+0.5)*vinc ))
                cpts[2].append(surf.pt( (i+1)*uinc, j*vinc ))
                
                ISurface( cpts, 2, 2 ).clr(0.3, 0.4*j*vinc, i*uinc*0.8)
    surf.del()

Then the front corner of a diamond panel is shifted up. Now depth of center point and the depth of the front shift is controlled by the variable centerDepth and frontDepth.

add_library('igeo')

size(480, 360, IG.GL)

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

for surf in surfaces : 
    unum = 36
    vnum = 24
    uinc = 1.0/unum
    vinc = 1.0/vnum
    
    for i in range(unum) : 
        for j in range(vnum) : 
            if (i+j)%2==0 : 
                centerDepth = -1.5
                frontDepth = -1
                
                cpts = [] 
                cpts.append([]) # 3 x 3 matrix
                cpts.append([])
                cpts.append([])
                # [0][0], [0][1], [0][2]
                cpts[0].append(surf.pt((i-1)*uinc, j*vinc))
                cpts[0].append(surf.pt((i-0.5)*uinc, (j-0.5)*vinc))
                cpts[0].append(surf.pt(i*uinc, (j-1)*vinc))
                # [1][0], [1][1], [1][2]
                cpts[1].append(surf.pt((i-0.5)*uinc, (j+0.5)*vinc))
                cpts[1].append(surf.pt(i*uinc, j*vinc, centerDepth))
                cpts[1].append(surf.pt((i+0.5)*uinc, (j-0.5)*vinc, \
                                       frontDepth/2 ))
                # [2][0], [2][1], [2][2]
                cpts[2].append(surf.pt(i*uinc, (j+1)*vinc ))
                cpts[2].append(surf.pt((i+0.5)*uinc, (j+0.5)*vinc, \
                                       frontDepth/2 ))
                cpts[2].append(surf.pt((i+1)*uinc, j*vinc, \
                                       frontDepth ))
                
                ISurface( cpts, 2, 2 ).clr(0.3, 0.4*j*vinc, i*uinc*0.8)
    surf.del()

Finally, the diagrid structure is added underneath the diamond panels. The image map is also introduced and the input bitmap is controlling the depths of panels.

The input bitmap used in the example is this.


add_library('igeo')

size(480, 360, IG.GL)

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

map = IImageMap("map4.jpg")

for surf in surfaces : 
    unum = 36
    vnum = 24
    uinc = 1.0/unum
    vinc = 1.0/vnum
    
    for i in range(unum) : 
        for j in range(vnum) : 
            if  (i+j)%2==0 : 
                val = map.get(i*uinc, j*vinc)
                
                centerDepth = -2*val
                frontDepth = -1.5*val
                
                cpts = []
                cpts.append([]) # 3 x 3 matrix
                cpts.append([])
                cpts.append([])
                # [0][0], [0][1], [0][2]
                cpts[0].append(surf.pt((i-1)*uinc, j*vinc))
                cpts[0].append(surf.pt((i-0.5)*uinc, (j-0.5)*vinc))
                cpts[0].append(surf.pt(i*uinc, (j-1)*vinc))
                # [1][0], [1][1], [1][2]
                cpts[1].append(surf.pt((i-0.5)*uinc, (j+0.5)*vinc))
                cpts[1].append(surf.pt(i*uinc, j*vinc, centerDepth))
                cpts[1].append(surf.pt((i+0.5)*uinc, (j-0.5)*vinc, \
                                       frontDepth/2))
                # [2][0], [2][1], [2][2]
                cpts[2].append(surf.pt(i*uinc, (j+1)*vinc ))
                cpts[2].append(surf.pt((i+0.5)*uinc, (j+0.5)*vinc, \
                                       frontDepth/2 ))
                cpts[2].append(surf.pt((i+1)*uinc, j*vinc, \
                                       frontDepth ))
                
                ISurface(cpts, 2, 2).clr(0.3, 0.4*j*vinc, i*uinc*0.8)
                
                structureDepth = 0.1
                structureRadius = 0.05
                pt1 = surf.pt((i-1)*uinc, j*vinc, structureDepth)
                pt2 = surf.pt(i*uinc, (j+1)*vinc, structureDepth)
                pt3 = surf.pt((i+1)*uinc, j*vinc, structureDepth)
                pt4 = surf.pt(i*uinc, (j-1)*vinc, structureDepth)
                ICylinder(pt1,pt2,structureRadius).clr(0.2)
                ICylinder(pt1,pt4,structureRadius).clr(0.2)
                if j==0 and i < unum-1 :
                    ICylinder(pt3,pt4,structureRadius).clr(0.2)
                if j==vnum-1 and i < unum-1 : 
                    ICylinder(pt2,pt3,structureRadius).clr(0.2)
    surf.del()


(back to the list of tutorials)

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