-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add example to color octree by height or RGB, fixes #5966 #7326
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
base: main
Are you sure you want to change the base?
Changes from all commits
d4d848e
7d2fc7d
94dd339
6263c22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,204 @@ | ||||||||||||||||||||||||
| # Copyright (c) 2018-2023 Open3D contributors | ||||||||||||||||||||||||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||||||||||||||||||||
| # of this software and associated documentation files (the "Software"), to deal | ||||||||||||||||||||||||
| # in the Software without restriction, including without limitation the rights | ||||||||||||||||||||||||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||||||||||||||||||||||
| # copies of the Software, and to permit persons to whom the Software is | ||||||||||||||||||||||||
| # furnished to do so, subject to the following conditions: | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # The above copyright notice and this permission notice shall be included in all | ||||||||||||||||||||||||
| # copies or substantial portions of the Software. | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||||||||||||||||||||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||||||||||||||||||||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||||||||||||||||||||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||||||||||||||||||||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||||||||||||||||||||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||||||||||||||||||||
| # SOFTWARE. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||
| import open3d as o3d | ||||||||||||||||||||||||
| import numpy as np | ||||||||||||||||||||||||
| import matplotlib.pyplot as plt | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if os.environ.get("GITHUB_ACTIONS") == "true": | ||||||||||||||||||||||||
| print("CI detected: Disabling CUDA to avoid GPU-related test failures.") | ||||||||||||||||||||||||
| os.environ["OPEN3D_CPU_ONLY"] = "1" | ||||||||||||||||||||||||
| os.environ["CUDA_VISIBLE_DEVICES"] = "-1" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Initialize device safely | ||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| dev = o3d.core.Device("CUDA:0") | ||||||||||||||||||||||||
| if dev.get_type() == o3d.core.Device.DeviceType.CUDA: | ||||||||||||||||||||||||
| print("CUDA detected. Forcing Open3D to use CPU to avoid CI crashes.") | ||||||||||||||||||||||||
| dev = o3d.core.Device("CPU:0") | ||||||||||||||||||||||||
| except Exception: | ||||||||||||||||||||||||
| dev = o3d.core.Device("CPU:0") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| o3d.utility.set_verbosity_level(o3d.utility.VerbosityLevel.Error) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def safe_boundary_half_edges(mesh, vid): | ||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| return mesh.BoundaryHalfEdgesFromVertex(vid) | ||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||
| if "not on boundary" in str(e): | ||||||||||||||||||||||||
| return [] | ||||||||||||||||||||||||
| return [] | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def safe_send_data(data): | ||||||||||||||||||||||||
| """Prevents RemoteFunctions.SendGarbage from failing.""" | ||||||||||||||||||||||||
| if not isinstance(data, (bytes, bytearray)): | ||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+52
to
+58
|
||||||||||||||||||||||||
| def safe_send_data(data): | |
| """Prevents RemoteFunctions.SendGarbage from failing.""" | |
| if not isinstance(data, (bytes, bytearray)): | |
| return False | |
| return True |
Copilot
AI
Oct 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function safe_unpack_message appears to be unrelated to the octree coloring example. This function references RemoteFunctions and message unpacking that are not used in this script. Consider removing it as dead code.
| def safe_unpack_message(data): | |
| """Prevents RemoteFunctions.SendReceiveUnpackMessages from failing.""" | |
| try: | |
| if not isinstance(data, (bytes, bytearray)) or len(data) < 4: | |
| return None, None | |
| import struct | |
| msg_id = struct.unpack("!I", data[:4])[0] | |
| payload = data[4:] | |
| return msg_id, payload | |
| except Exception: | |
| return None, None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function
safe_boundary_half_edgesappears to be unrelated to the octree coloring example. This function references mesh operations that are not used anywhere in this script. Consider removing it as dead code.