Ejemplo n.º 1
0
 def push(self, value):
     if (self.size == 0):
         self.tail = Node(value)
         self.head = self.tail
         self.size = self.size + 1
         return
     self.tail.next = Node(value)
     self.tail = self.tail.next
     self.size = self.size + 1
Ejemplo n.º 2
0
def read_nodes_file() -> None:
    f = open(AppData.file_nodes, 'r')
    for line in f:
        parts = line.split()
        AppData.nodes.append(
            Node(int(parts[0]), float(parts[1]), float(parts[2])))
    # for node in AppData.nodes:
    # print(node)
    f.close()
Ejemplo n.º 3
0
 def put(self, key, value):
     if key in self.map:
         node = self.map.get(key)
         self.list.remove(node)
         node.value = value
         self.list.append_front(node)
         # pass
     else:
         node = Node(key, value)
         if self.size >= self.capacity:
             old_node = self.list.remove()
             self.map.pop(old_node.key)
             self.size -= 1
         self.list.append_front(node)
         self.map[key] = node
         self.size += 1
Ejemplo n.º 4
0
	def put(self,key,value):
		if self.capacity == 0:
			return
		if key in self.map:
			node = self.map.get(key)
			self.list.remove(node)
			node.value = value
			self.list.append(node)
		else:
			if self.size == self.capacity:
				node = self.list.pop()
				del self.map[node.key]
				self.size -= 1
			node = Node(key,value)
			self.list.append(node)
			self.map[key] = node
			self.size += 1
Ejemplo n.º 5
0
    def create_regular_grid(self, img, horizontal_tiles, show_marked):
        height_image = img.shape[0]
        width_image = img.shape[1]
        current_x = 0
        current_y = 0
        side = width_image / horizontal_tiles
        square = Square(side, Point(current_x, current_y))
        vertical_tiles = height_image / side
        node = Node(square)
        node.mark(img)
        if show_marked or not node.marked:
            self.nodes.append(node)

        for i in range(0, int(math.ceil(vertical_tiles))):
            for j in range(0, int(horizontal_tiles)):

                square = Square(side, Point(current_x, current_y))
                node = Node(square)
                node.mark(img)
                if show_marked or not node.marked:
                    self.nodes.append(node)
                current_x += side
            current_x = 0
            current_y += side
Ejemplo n.º 6
0
 def __init__(self, data):
     Node.__init__(self, data)
Ejemplo n.º 7
0
    def create_quad_tree(self, img, depth, show_marked):
        width_image = img.shape[1]
        current_x = 0
        current_y = 0
        current_depth = 0
        side = width_image
        square = Square(side, Point(current_x, current_y))
        node = Node(square)
        node.mark(img)
        self.nodes.append(node)

        while self.get_num_marked() > 0 and current_depth < depth:
            new_nodes = []
            aux_list = self.nodes.copy()
            for n in self.nodes:
                if n.marked:
                    s1, s2, s3, s4 = n.divide()
                    s1 = Node(s1)
                    s1.mark(img)
                    s2 = Node(s2)
                    s2.mark(img)
                    s3 = Node(s3)
                    s3.mark(img)
                    s4 = Node(s4)
                    s4.mark(img)
                    aux_list.remove(n)
                    if show_marked or current_depth < depth - 1:
                        new_nodes = new_nodes + [s1, s2, s3, s4]
            self.nodes = aux_list
            self.nodes = self.nodes + new_nodes
            new_nodes.clear()
            current_depth += 1
Ejemplo n.º 8
0
    def create(self, type, name='', parent=None):
        result = Node(type, parent)

        general = General()
        general.setName(name)
        result.addComponent(general)

        if type == NodeType.Sphere:
            result.addComponent(Transform())
            result.addComponent(Sphere())
            result.addComponent(PhongMaterial())

        result.init()
        return result
Ejemplo n.º 9
0
 def push(self, value):
     if (self.head == None):
         self.head = Node(value)
         return
     self.head = Node(value, self.head)
Ejemplo n.º 10
0
 def newNode(self, id, label="", eLabel=""):
     Node(id, label, parent=self.currentNode, eLabel=eLabel)
Ejemplo n.º 11
0
 def init(self, id, label=""):
     node = Node(id, label=label)
     self.roots.append(node)
     self.currentNode = node
     self.currentRoot = node