Esempio n. 1
0
def normalFromPoints(vertA, vertB, vertC):
    vAB = vertA.vectorToPoint(vertB)
    vAC = vertA.vectorToPoint(vertC)
    vAB = pyeuclid.Vector3(vAB.x, vAB.y, vAB.z)
    vAC = pyeuclid.Vector3(vAC.x, vAC.y, vAC.z)
    calculatedNormal = vAB.cross(vAC)
    calculatedNormal = Point(calculatedNormal.x, calculatedNormal.y, calculatedNormal.z).normalized()
    return calculatedNormal.multiplyConst(-1.0)
Esempio n. 2
0
 def get_all_rows(self):
     if self.is_teacher:
         raise Exception('Unsupported Operation')
     table = pd.read_csv(self.path, sep=',')
     table = table.to_dict(orient='records')
     for i in range(len(table)):
         row = table[i]
         table[i] = TableRow(row.get('path'),
                             Point(row.get('feature').split(' ')),
                             Point(row.get('cluster').split(' ')))
     return table
Esempio n. 3
0
 def find_nearest_to(self, point: Point):
     current = self.cache
     temp = None
     minimal = point.distance_to(current)
     cluster_set = {x for x in self.graph.get_points()}
     cluster_set.discard(current)
     while True:
         the_smallest = float('inf')
         neighbours = self.graph.get_neighbours(current)
         cluster_set.difference_update(neighbours)
         for neighbour in neighbours:
             dist = neighbour.distance_to(point)
             if dist < the_smallest:
                 the_smallest = dist
                 temp = neighbour
         # noinspection PyChainedComparisons
         if the_smallest < minimal and len(
                 cluster_set) != 0 and minimal != 0:
             minimal = the_smallest
             current = temp
         else:
             break
     self.cache = current
     return current
     pass
Esempio n. 4
0
 def get_feature(self, filename: str):
     table = pd.read_csv(self.path, sep=',')
     table = table[table.path == filename]
     table = table.to_dict(orient='records')
     if len(table) == 0:
         return None
     return Point(table[0].get('feature').split(' '))
Esempio n. 5
0
    def find_nearest_to(self, point: Point):
        set_a = set(self.graph.get_points())

        point_current = set_a.pop()
        num_current_distance = point.distance_to(point_current)

        list_neighbors = self.graph.get_neighbours_list(point_current)
        while len(list_neighbors) != 0:
            # Get shortest distance among neighbors
            list_distances = list(
                map(lambda x: x[1].distance_to(point), list_neighbors))
            num_new_distance = min(list_distances)

            if num_current_distance < num_new_distance:
                return point_current

            # Update current distance
            num_current_distance = num_new_distance

            # Update point_current
            index_of_new_distance = list_distances.index(num_new_distance)
            point_current = list_neighbors[index_of_new_distance][1]

            # Update set_a
            for neighbor in list_neighbors:
                set_a.discard(neighbor)

            # Update list_neighbors
            filter_only_a_marked_points = filter(
                lambda x: x[1] in set_a,
                self.graph.get_neighbours_list(point_current))
            list_neighbors = list(filter_only_a_marked_points)

        return point_current
Esempio n. 6
0
 def find_nearest_to(self, point: Point):
     clusters = list(self.graph.graph.keys())
     dif = float('inf')
     nearest = None
     for cluster in clusters:
         dist = point.distance_to(cluster)
         if dist < dif:
             dif = dist
             nearest = cluster
     return nearest
     pass
Esempio n. 7
0
    def run(self):
        self.dir_watcher.start()
        old_name = None

        while True:
            changes = self.queue.get()

            for action, filename in changes:
                if filename is None or filename[-4:] != '.tif':
                    continue
                full_filename = os.path.join(self.target_path, filename)

                if action == 2 or os.path.getsize(full_filename) != 0:
                    if action == 1:
                        pass

                    elif action == 2:
                        row = TableRow(filename, None)
                        self.job_queue.put({
                            "teacher": self.is_teacher,
                            "action": action,
                            "row": row
                        })
                        pass

                    elif action == 3:
                        point = Point(self.content_grubber.get_info(full_filename))
                        row = TableRow(filename, point)
                        self.job_queue.put({
                            "teacher": self.is_teacher,
                            "action": action,
                            "row": row
                        })
                        pass

                    elif action == 4:
                        old_name = full_filename
                        pass

                    elif action == 5:
                        self.job_queue.put({
                            "teacher": self.is_teacher,
                            "action": action,
                            "old_name": old_name,
                            "new_name": full_filename,
                            "row": None
                        })
                        pass

                    else:
                        raise Exception("Unsupported Operation")
Esempio n. 8
0
from geometry.Point import Point
from geometry.Tesseract import Tesseract

tesseract = Tesseract(Point([0,0,0]))
current_neighbors = [Point([0,1,0]), Point([0,2,0])]
other_points = [Point([1,0,0]), Point([0, -1, 0]), Point([-1, 0, 0]), Point([0, 0, 1]), Point([0, 0, -1]), Point([0, 0, -2])]

for point in tesseract.get_new_neighbors(current_neighbors, other_points):
    print(point)
 def get(self, geometry_name):
     return {
         'Polygon': Polygon(),
         'MultiPolygon': MultiPolygon(),
         'Point': Point()
     }[geometry_name]
Esempio n. 10
0
 def __init__(self, x, y, z, index= -1):
     Point.__init__(self, x, y, z)
     self.faces = []
     self.index = index