- 
                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?
Conversation
Signed-off-by: Mereshiya <[email protected]>
| 
           Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.  | 
    
Signed-off-by: Mereshiya <[email protected]>
| 
           @syncle Can you please help in reviewing it  | 
    
Signed-off-by: Mereshiya <[email protected]>
Signed-off-by: Mereshiya <[email protected]>
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.
Pull Request Overview
This PR adds an example script that demonstrates how to color octree leaf nodes based on either height (z-coordinate) or RGB colors of a point cloud. The script creates a synthetic point cloud and provides interactive visualization with keyboard controls to toggle between different coloring modes and color maps.
Key changes:
- New interactive example with height-based (jet/hot/viridis/cool) and RGB coloring modes
 - Octree leaf node coloring by averaging point colors within each node
 - Keyboard callbacks ('4' and '5') for toggling color maps and modes
 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 [] | ||
| 
               | 
          ||
| 
               | 
          
    
      
    
      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_boundary_half_edges appears 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.
| 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 | ||
| 
               | 
          ||
| 
               | 
          
    
      
    
      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_send_data appears to be unrelated to the octree coloring example. This function references RemoteFunctions that are not used in this script. Consider removing it as dead code.
| def safe_send_data(data): | |
| """Prevents RemoteFunctions.SendGarbage from failing.""" | |
| if not isinstance(data, (bytes, bytearray)): | |
| return False | |
| return True | 
| 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 | 
    
      
    
      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 | 
This PR addresses Issue #5966 by adding an example script to color octree leaf nodes based on the height (z-coordinate) or RGB colors of a point cloud. The script:
Tested with Open3D 0.16.0.
Fixes #5966