Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions examples/python/Shape_detection_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,32 @@
datadir = os.environ.get('DATADIR', '../data')
datafile = datadir+'/cube.pwn'

points = Point_set_3(datafile)
print(points.size(), "points read")
# Creating an empty set of points and their normals
points = Point_set_3()
points.add_normal_map()

# Reading all lines
point_normal_file = open(datafile, "rb")
point_normal_lines = point_normal_file.readlines()

# Per line split the string, convert the values into floats,
# feed point and vector with it and insert it into our point set.
for line in point_normal_lines:
line = [float(entry) for entry in line.split()]
px, py, pz, nx, ny, nz = line
point_location = Point_3(px, py, pz)
point_normal = Vector_3(nx, ny, nz)
points.insert(point_location, point_normal)

print(points.size(), "points read from Python")

# NOTE: The following lines remove the content in our point set
# and reload the contents directly from our file.
points.clear()
points.read(datafile)

print(points.size(), "points read from file")
# NOTE END

print("Detecting planes with region growing (sphere query)")
plane_map = points.add_int_map("plane_index")
Expand Down