2020from gustaf .helpers .options import Option as _Option
2121
2222if TYPE_CHECKING :
23+ import sys
2324 from typing import Any
2425
25- from gustaf .edges import EdgesShowOption as _EdgesShowOption
26- from gustaf .faces import FacesShowOption as _FacesShowOption
26+ if sys .version_info >= (3 , 10 ):
27+ from typing import Self
28+ else :
29+ from typing_extensions import Self
30+
2731 from gustaf .helpers .data import Unique2DFloats as _Unique2DFloats
28- from gustaf .volumes import VolumesShowOption as _VolumesShowOption
2932
3033
3134class VerticesShowOption (_helpers .options .ShowOption ):
@@ -226,9 +229,7 @@ def vertex_data(self) -> _VertexData:
226229 return self ._vertex_data
227230
228231 @property
229- def show_options (
230- self ,
231- ) -> _EdgesShowOption | _FacesShowOption | _VolumesShowOption :
232+ def show_options (self ) -> _helpers .options .ShowOption :
232233 """
233234 Returns a show option manager for this object. Behaves similar to
234235 dict.
@@ -262,7 +263,7 @@ def whatami(self) -> str:
262263
263264 @_helpers .data .ComputedMeshData .depends_on (["vertices" ])
264265 def unique_vertices (
265- self , tolerance : Any | None = None , ** kwargs : Any
266+ self , tolerance : float | None = None , ** kwargs : Any
266267 ) -> _Unique2DFloats :
267268 """Returns a namedtuple that holds unique vertices info. Unique here
268269 means "close-enough-within-tolerance".
@@ -343,7 +344,7 @@ def bounds_diagonal_norm(self) -> float:
343344
344345 def update_vertices (
345346 self , mask : _np .ndarray , inverse : _np .ndarray | None = None
346- ) -> Any :
347+ ) -> Vertices :
347348 """Update vertices with a mask. In other words, keeps only masked
348349 vertices. Adapted from `github.com/mikedh/trimesh`. Updates
349350 connectivity accordingly too.
@@ -394,14 +395,14 @@ def update_vertices(
394395 vertices = vertices [mask ]
395396
396397 def update_vertex_data (
397- obj : Any , m : _np .ndarray , vertex_data : dict
398+ obj : Vertices , mask : _np .ndarray , vertex_data : dict
398399 ) -> Any :
399400 """apply mask to vertex data if there's any."""
400401 new_data = _helpers .data .VertexData (obj )
401402
402403 for key , values in vertex_data .items ():
403404 # should work, since this is called after updating vertices
404- new_data [key ] = values [m ]
405+ new_data [key ] = values [mask ]
405406
406407 obj ._vertex_data = new_data
407408
@@ -434,7 +435,7 @@ def select_vertices(self, ranges: list[list[float]]) -> _np.ndarray:
434435 """
435436 return _utils .arr .select_with_ranges (self .vertices , ranges )
436437
437- def remove_vertices (self , ids ) :
438+ def remove_vertices (self , ids : _np . ndarray ) -> Vertices :
438439 """Removes vertices with given vertex ids.
439440
440441 Parameters
@@ -451,8 +452,8 @@ def remove_vertices(self, ids):
451452 return self .update_vertices (mask )
452453
453454 def merge_vertices (
454- self , tolerance : Any | None = None , ** kwargs : Any
455- ) -> Any :
455+ self , tolerance : float | None = None , ** kwargs : Any
456+ ) -> Vertices :
456457 """Based on unique vertices, merge vertices if it is mergeable.
457458
458459 Parameters
@@ -503,7 +504,7 @@ def show(self, **kwargs):
503504 """
504505 return _show .show (self , ** kwargs )
505506
506- def copy (self ) -> Any :
507+ def copy (self ) -> Vertices :
507508 """Returns deepcopy of self.
508509
509510 Parameters
@@ -525,7 +526,7 @@ def copy(self) -> Any:
525526 return copied
526527
527528 @classmethod
528- def concat (cls , * instances : Any ) -> Any :
529+ def concat (cls , * instances : Vertices ) -> Vertices :
529530 """Sequentially put them together to make one object.
530531
531532 Parameters
@@ -590,7 +591,7 @@ def is_concatable(inst: Any) -> bool:
590591 else :
591592 return Vertices (vertices = _np .vstack (vertices ))
592593
593- def __add__ (self , to_add ) :
594+ def __add__ (self , to_add : Self ) -> Self :
594595 """Concat in form of +.
595596
596597 Parameters
0 commit comments