Exemple #1
0
    def generate(self, config):
        
        C = config
        level_rect = ((0, 0), (int(C.length), int(C.width)))
        level_rect = geometry.AxisAligned2DRectangle(*level_rect)
        if C.length < 1 or C.width < 1:
            return
        corridor_length = int(C.length / 5)
        corridor_width = int(C.width / 5)
        corridor_length = 1 if corridor_length == 0 else corridor_length
        corridor_width = 1 if corridor_width == 0 else corridor_width
        
        if C.length < corridor_length or C.width < corridor_width:
            raise Exception, "corridor length, width should be less than that of level"

        cx = int(C.length / 2 - corridor_length / 2)
        cy = int(C.width / 2 - corridor_width / 2)
        corridor_rect = ((cx, cy), (cx + corridor_length,
                         cy + corridor_width))

        corridor_rect = geometry.AxisAligned2DRectangle(*corridor_rect)     
       
        apartments = divide_into_apartments(self.picker, level_rect, corridor_rect)

        for flat in apartments:
            (x1, y1), (x2, y2) = flat
            flat_length = abs(x2 - x1)
            flat_width = abs(y2 - y1)
            thickness = C.inner_wall_thickness
            p = draw.makePlane(flat_length, flat_width)
            p1 = draw.makePlane(flat_length-thickness * 2,
                                flat_width-thickness * 2,
                                (thickness, thickness, 0))

            p = p.cut(p1)
            p = p.Faces[0]

            p = draw._wrap_value(p)
            p = p.extrude((0, 0, C.height))

            origin = (x1, y1, 0)

            p.translate(origin)
            p.tags.append('wall')
            self.add_geom(p)

        self.make_doors(corridor_rect, C)

        for flat in apartments:
            self.make_flats(flat, C)
Exemple #2
0
    def generate(self, config):
        
        C = config

        level_rect = ((0, 0), (C.length, C.width))
        level_rect = geometry.AxisAligned2DRectangle(*level_rect)

        cx = C.length / 2 - C.corridor_length / 2
        cy = C.width / 2 - C.corridor_width / 2
        corridor_rect = ((cx, cy), (cx + C.corridor_length,
                                    cy + C.corridor_width))
        corridor_rect = geometry.AxisAligned2DRectangle(*corridor_rect)

        apartments = divide_into_apartments(
                        self.picker, level_rect, corridor_rect)

        for apartment in apartments:
            (x1, y1), (x2, y2) = apartment

            length = abs(x2 - x1)
            width = abs(y2 - y1)

            if not length or not width:
                continue

            p = draw.makePlane(length, width)
            p = p.Wires[0]
            p = draw._wrap_value(p)
            p = p.extrude((0, 0, C.height))

            origin = (x1, y1, 0)
            self.add_geom(p)
def create_plane():
    p = draw.makePlane(10, 20)
    return p
    def generate(self, config):
        # x is on horizontal,  y is on depthwards, z is on upwards
        '''
        z    y
        |   *
        |  *
        | *
        - - - x

        all units are in metres
        '''

        # in short
        '''
        pnt is where the object has to be created
        dir is in which directiong it has to be created

        draw.makeBox(length, width, height, pnt=(0,0,0), dir=(0,0,1))
        draw.makeSphere(radius, pnt=(0,0,0), dir=(0,0,1), angle1=0.5*PI, angle2=0.5*PI, angle3=2*PI)
        draw.makeCylinder(radius, height, pnt=(0,0,0), dir=(0,0,1), angle=2*PI)
        draw.makePlane(length,width, pnt=(0,0,0), dir=(0,0,1))
        draw.makePolygon([]) -- Make a polygon of a list of points
        '''

        C = config

        if C.box:
            box = draw.makeBox(1, 1, 1)
            self.add_geom(box) # adding box to the scene

            pnt = (2, 2, 2)
            o_box = draw.makeBox(1, 1, 1, pnt)
            self.add_geom(o_box) # adding another box at different point in scene

        if C.sphere:
            sphere = draw.makeSphere(2)
            self.add_geom(sphere)

            pnt = (2, 2, 2)
            o_sphere = draw.makeSphere(2, pnt)
            self.add_geom(o_sphere)

        if C.cylinder:
            cylinder = draw.makeCylinder(1, 1)
            self.add_geom(cylinder)

            pnt = (2, 2, 2)
            o_cylinder = draw.makeCylinder(1, 1, pnt)
            self.add_geom(o_cylinder)

        if C.plane:
            plane = draw.makePlane(1, 1)
            self.add_geom(plane)

            pnt = (2, 2, 2)
            o_plane = draw.makePlane(1, 1, pnt)
            self.add_geom(o_plane)

        if C.polygon:
            polygon = draw.makePolygon([(0, 0, 0),
                                        (1, 0, 0),
                                        (1, 0, 1),
                                        (0, 0, 1),
                                        (0, 0, 0)]) # this returns a wire connecting points

            face = draw.Face(polygon) # filling up the wire with mass, u can also do other things with the wire

            self.add_geom(face)
Exemple #5
0
    def generate(self, config):
        
        C = config
        flat_rect = ((0, 0), (C.length, C.width))
        flat_rect = geometry.AxisAligned2DRectangle(*flat_rect)
        center = C.length/2, C.width/2
        print flat_rect
        ps = self.get_surrounding((0,0,0,C.length,C.width,0))
        geoms = ps.get_geoms(tag='door')
        door = geoms[0]
        bb = door.BoundBox
        print bb
        (x1,y1,z1,x2,y2,z2) = (round(bb.XMin),round(bb.YMin),round(bb.ZMin),
                               round(bb.XMax),round(bb.YMax),round(bb.ZMax))

        door_width = x2 - x1
        door_center = x1 + door_width/2
        len_center = C.length/2
        wid_center = C.width/2
        door_gap = 2

#       main_door_wall is 'left'
        if x1 == 0 or x2 == 0:
            print 'left'
            if door_center > wid_center:
                hall_edge = (0,y1-door_gap)
                other_edge = (C.length/2, C.width)
            else :
                hall_edge = (0,y1+door_gap)
                other_edge = (C.length/2, 0)
            hall_edge = (0,y1-door_gap) if door_center > wid_center else (0,y1+door_gap)

#       main_door_wall is 'right'
        elif x1 == C.length or x2 == C.length:
            print 'right'
            if door_center > wid_center:
                hall_edge = (C.length,y1-door_gap)
                other_edge = (C.length/2, C.width)
            else :
                hall_edge = (C.length,y1+door_gap)
                other_edge = (C.length/2, 0)
#       main_door_wall is 'down'
        elif y1 == 0 or y2 == 0:
            print 'down'
            if door_center > len_center:
                hall_edge = (x1-door_gap,0)
                other_edge = (C.length, C.width/2)
            else :
                hall_edge = (x2+door_gap,0)
                other_edge = (0, C.width/2)
#       main_door_wall is 'up'
        elif y1 == C.width or y2 == C.width:
            print 'up'
            if door_center > len_center:
                hall_edge = (x1-door_gap,C.width)
                other_edge = (C.length, C.width/2)
            else :
                hall_edge = (x2+door_gap,C.width)
                other_edge = (0, C.width/2)
            
        hall_rect = geometry.AxisAligned2DRectangle(hall_edge, other_edge)
        common, rooms = geometry.split_overlapping_rectangles(flat_rect, hall_rect)
        
        fused = None
        
        for room in rooms:
            
            (x1, y1), (x2, y2) = room.point1, room.point2
            li = [(x1, y1), (x2, y2)]
            li.sort()
            (x1, y1), (x2, y2) = li[0], li[1]
            room_length = abs(x2 - x1)
            room_width = abs(y2 - y1)
           
            thickness = C.inner_wall_thickness
            p = draw.makePlane(room_length, room_width)
            p1 = draw.makePlane(room_length-thickness*2,
                                room_width-thickness*2,
                                (thickness,thickness,0))

            p = p.cut(p1)
            p = p.Faces[0]
            
            p = draw._wrap_value(p)
            p = p.extrude((0, 0, C.height))

            p.translate((x1, y2, 0))
            if fused:
                fused = fused.fuse(p)
            else:
                fused = p

        self.add_geom(fused)