Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: Shape_detection: Loading the points the Python way #157

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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