diff --git a/docs/changes.md b/docs/changes.md index 88906110..9e9abb52 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -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 diff --git a/vedo/core.py b/vedo/core.py index 43bf1b5c..b52e4e82 100644 --- a/vedo/core.py +++ b/vedo/core.py @@ -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. @@ -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) @@ -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) @@ -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() diff --git a/vedo/mesh.py b/vedo/mesh.py index d68bb365..e976e151 100644 --- a/vedo/mesh.py +++ b/vedo/mesh.py @@ -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. @@ -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: diff --git a/vedo/shapes.py b/vedo/shapes.py index 9a4d35ba..3cb27697 100644 --- a/vedo/shapes.py +++ b/vedo/shapes.py @@ -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): """ diff --git a/vedo/version.py b/vedo/version.py index 7fd241c8..af146f59 100644 --- a/vedo/version.py +++ b/vedo/version.py @@ -1 +1 @@ -_version = '2024.5.2+dev05' +_version = '2024.5.2+dev06'