Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
earlier labelling worked for few views but this will work for all views 360 degrees
Related Issue
Closes #476
Description
use box model to be able to view all the labels in all views 360 degrees..
import pyvista as pv
from pyvista import examples
import numpy as np
Download a sample mesh (bunny model)
mesh = examples.download_bunny_coarse()
Create a Plotter object
pl = pv.Plotter()
Add the bunny mesh to the plotter
pl.add_mesh(mesh, show_edges=True, color='white')
Define the coordinate ranges for the left ear
xmin, xmax = -0.11, -0.05
ymin, ymax = 0.10, 0.18
zmin, zmax = -0.08, -0.02
Extract points within the specified ranges
points = mesh.points
mask = (
(points[:, 0] >= xmin) & (points[:, 0] <= xmax) &
(points[:, 1] >= ymin) & (points[:, 1] <= ymax) &
(points[:, 2] >= zmin) & (points[:, 2] <= zmax)
)
left_ear_points = points[mask]
#print("Extracted Points (Left Ear):")
#print(left_ear_points)
Ensure there are points in the left ear region
if left_ear_points.size > 0:
# Calculate the centroid of the extracted points
left_ear_centroid = left_ear_points.mean(axis=0)
#print("Left Ear Centroid:", left_ear_centroid)
# Add a label to the central point of the left ear
pl.add_point_labels([left_ear_centroid], ["Left Ear"], point_color='blue', point_size=10, font_size=50, text_color='black')
else:
print("No points found in the specified range for the left ear.")
Set the camera position for a better view
Adjusting the camera position to move closer to the model
pl.camera_position = [(0.1, 0.1, 0.5), # Position (closer to the model)
(0.02, 0.03, -0.02), # Focal point (focus on specific area)
(0, 1, 0)]
'''pl.camera_position = 'xy'
Ensure the plotter window is sized appropriately
pl.window_size = [800, 600]'''
Show the plot
pl.show()
Screenshots (if applicable)
Checklist