forked from Lotemn102/Ball-Pivoting-Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.py
More file actions
46 lines (33 loc) · 1.18 KB
/
point.py
File metadata and controls
46 lines (33 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import numpy as np
import utils
from typing import List
class Point:
def __init__(self, x, y, z, id, normal=None):
self.z = np.float32(z)
self.y = np.float32(y)
self.x = np.float32(x)
self.cell_code = None
self.normal = normal
self.id = id
self.is_used = False
def __lt__(self, other):
return self.z <= other.z
@property
def neighbor_nodes(self) -> List:
"""
Get all the points neighbor points.
:return: List of neighbor points.
"""
neighbor_nodes = [self.cell_code]
# Find the point's cell.
x, y, z = utils.decode_cell(self.cell_code)
# Check for each of the possible 8 neighbors if it exists.
for i in range(-1, 2):
for j in range(-1, 2):
for k in range(-1, 2):
cell_corner = x + i, y + j, z + k
if cell_corner[0] < 0 or cell_corner[1] < 0 or cell_corner[2] < 0:
continue
cell_code = utils.encode_cell(cell_corner[0], cell_corner[1], cell_corner[2])
neighbor_nodes.append(cell_code)
return neighbor_nodes