Skip to content

Commit

Permalink
add Arrow.top_point() and Arrow.base_point() in #1163
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Jul 25, 2024
1 parent 683f44d commit d44315e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- add `mesh.laplacian_diffusion()`
- fix `DistanceTool` in #1158
- fix `shapes.Plane.normal` in #1159 by @smoothumut

- add `Arrow.top_point()` and `Arrow.base_point()` to extract current arrow position #1163 @smoothumut
- fix `Arrow.top_index` to produce the correct index value



Expand Down
11 changes: 7 additions & 4 deletions vedo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,7 @@ def isosurface(self, value=None, flying_edges=False) -> "vedo.mesh.Mesh":
)
return out

def isosurface_discrete(self, value=None, nsmooth=15) -> "vedo.mesh.Mesh":
def isosurface_discrete(self, values, nsmooth=15) -> "vedo.mesh.Mesh":
"""
Create boundary/isocontour surfaces from a label map (e.g., a segmented image) using a threaded,
3D version of the multiple objects/labels Surface Nets algorithm.
Expand All @@ -2097,6 +2097,11 @@ def isosurface_discrete(self, value=None, nsmooth=15) -> "vedo.mesh.Mesh":
labeled regions / objects.
(Note that on output each region [corresponding to a different segmented object] will share
points/edges on a common boundary, i.e., two neighboring objects will share the boundary that separates them).
Besides output geometry defining the surface net, the filter outputs a two-component celldata array indicating
the labels on either side of the polygons composing the output Mesh.
(This can be used for advanced operations like extracting shared/contacting boundaries between two objects.
The name of this celldata array is "BoundaryLabels").
Arguments:
value : (float, list)
Expand All @@ -2107,8 +2112,6 @@ def isosurface_discrete(self, value=None, nsmooth=15) -> "vedo.mesh.Mesh":
Examples:
- [isosurfaces2.py](https://github.com/marcomusy/vedo/tree/master/examples/volumetric/isosurfaces2.py)
"""
if not utils.is_sequence(value):
value = [value]

snets = vtki.new("SurfaceNets3D")
snets.SetInputData(self.dataset)
Expand All @@ -2122,7 +2125,7 @@ def isosurface_discrete(self, value=None, nsmooth=15) -> "vedo.mesh.Mesh":
else:
snets.SmoothingOff()

for i, val in enumerate(value):
for i, val in enumerate(values):
snets.SetValue(i, val)
snets.Update()
snets.SetOutputMeshTypeToTriangles()
Expand Down
4 changes: 2 additions & 2 deletions vedo/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ def extrude_and_trim_with(

def split(
self, maxdepth=1000, flag=False, must_share_edge=False, sort_by_area=True
) -> Union[List[Self], Self]:
) -> List[Self]:
"""
Split a mesh by connectivity and order the pieces by increasing area.
Expand Down Expand Up @@ -2350,7 +2350,7 @@ def split(
if flag:
self.pipeline = OperationNode("split mesh", parents=[self])
self._update(out)
return self
return [self]

msh = Mesh(out)
if must_share_edge:
Expand Down
10 changes: 8 additions & 2 deletions vedo/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,18 +1906,24 @@ def __init__(
super().__init__(tf.GetOutput(), c, alpha)

self.transform = LinearTransform().translate(start_pt)
# self.pos(start_pt)

self.phong().lighting("plastic")
self.actor.PickableOff()
self.actor.DragableOff()
self.base = np.array(start_pt, dtype=float) # used by pyplot
self.top = np.array(end_pt, dtype=float) # used by pyplot
self.top_index = None
self.top_index = self.source.GetTipResolution() * 4
self.fill = True # used by pyplot.__iadd__()
self.s = s if s is not None else 1 # used by pyplot.__iadd__()
self.name = "Arrow"

def top_point(self):
"""Return the current coordinates of the tip of the Arrow."""
return self.transform.transform_point(self.top)

def base_point(self):
"""Return the current coordinates of the base of the Arrow."""
return self.transform.transform_point(self.base)

class Arrows(Glyph):
"""
Expand Down
2 changes: 1 addition & 1 deletion vedo/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_version = '2024.5.2+dev05'
_version = '2024.5.2+dev06'

0 comments on commit d44315e

Please sign in to comment.