Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
norm = self._space.plane_normals[plane]
# Get plane width and height
idx_pair = (
axes_pairs[plane]
if plane is not None
else axes_pairs["horizontal"]
)
wh = [float(np.diff(self._root_bounds[i])) * 1.2 for i in idx_pair]
if sx is None:
sx = wh[0]
if sy is None:
sy = wh[1]
# return plane
return Plane(pos=pos, normal=norm, sx=sx, sy=sy, c=color, alpha=alpha)
:param plane: either a string with the name of one of
the predifined planes ['sagittal', 'coronal', 'horizontal']
or an instance of the Plane class from vedo.shapes
"""
if isinstance(plane, (list, tuple)):
planes = plane.copy()
else:
planes = [plane]
actors = []
for plane in planes:
if isinstance(plane, str):
plane = self.atlas.get_plane_at_point(plane=plane, **kwargs)
else:
if not isinstance(plane, Plane):
raise ValueError(
"The plane arguments should either be a Plane actor or"
+ "a string with the name of predefined planes."
+ f" Not: {plane.__type__}"
)
actors.append(plane)
self.add_actor(*actors)
return return_list_smart(actors)
planes = [plane]
if actors is None:
actors = self.actors
else:
if not isinstance(actors, (list, tuple)):
actors = [actors]
# Loop over each plane
to_return = []
for plane in planes:
# Get the plane actor
if isinstance(plane, str):
plane = self.atlas.get_plane_at_point(plane=plane, **kwargs)
else:
if not isinstance(plane, Plane):
raise ValueError(
"The plane arguments should either be a Plane actor or"
+ "a string with the name of predefined planes."
+ f" Not: {plane.__type__}"
)
# Show plane
if showplane:
self.add_actor(plane)
# Cut actors
for actor in actors:
if actor is None:
continue
try:
norm = self._space.plane_normals[plane]
# Get plane width and height
idx_pair = (
axes_pairs[plane]
if plane is not None
else axes_pairs["horizontal"]
)
wh = [float(np.diff(self._root_bounds[i])) * 1.2 for i in idx_pair]
if sx is None:
sx = wh[0]
if sy is None:
sy = wh[1]
# return plane
return Plane(pos=pos, normal=norm, sx=sx, sy=sy, c=color, alpha=alpha)