@@ -17,6 +17,12 @@ class Well:
1717 well_path : str
1818 polyline : pv .PolyData
1919 tube : pv .PolyData
20+
21+
22+ @dataclass
23+ class WellActor :
24+ """A WellActor stores the VTK Actor representing a well."""
25+ well_path : str
2026 actor : pv .Actor
2127
2228
@@ -28,6 +34,7 @@ def __init__( self, size: float, amplification: float ) -> None:
2834 A Well in GEOS could a InternalWell or a Vtkwell.
2935 """
3036 self ._wells : list [ Well ] = []
37+ self ._wells_actors : list [ WellActor ] = []
3138
3239 self .size : float = size
3340 self .amplification : float = amplification
@@ -51,7 +58,8 @@ def add_mesh( self, mesh: pv.PolyData, mesh_path: str ) -> int:
5158 radius = self .size * ( self .STARTING_VALUE / 100 )
5259 tube = mesh .tube ( radius = radius , n_sides = 50 )
5360
54- self ._wells .append ( Well ( mesh_path , mesh , tube , pv .Actor () ) )
61+ self ._wells .append ( Well ( mesh_path , mesh , tube ) )
62+ self ._wells_actors .append ( WellActor ( mesh_path , pv .Actor () ) )
5563
5664 return len ( self ._wells ) - 1
5765
@@ -78,21 +86,21 @@ def get_tube_size( self ) -> float:
7886
7987 def append_actor ( self , perforation_path : str , tube_actor : pv .Actor ) -> None :
8088 """Append a given actor, typically the Actor returned by the pv.Plotter() when a given mes is added."""
81- index = self ._get_index_from_perforation ( perforation_path )
89+ index = self ._get_actor_index_from_perforation ( perforation_path )
8290 if index == - 1 :
8391 print ( "Cannot found the well to remove from path: " , perforation_path )
8492 return
8593
86- self ._wells [ index ].actor = tube_actor
94+ self ._wells_actors [ index ].actor = tube_actor
8795
8896 def get_actor ( self , perforation_path : str ) -> pv .Actor | None :
8997 """Retrieve the polyline linked to a given perforation path."""
90- index = self ._get_index_from_perforation ( perforation_path )
98+ index = self ._get_actor_index_from_perforation ( perforation_path )
9199 if index == - 1 :
92100 print ( "Cannot found the well to remove from path: " , perforation_path )
93101 return None
94102
95- return self ._wells [ index ].actor
103+ return self ._wells_actors [ index ].actor
96104
97105 def update ( self , value : float ) -> None :
98106 """Update the radius of the tubes."""
@@ -108,6 +116,14 @@ def remove( self, perforation_path: str ) -> None:
108116
109117 self ._wells .remove ( self ._wells [ index ] )
110118
119+ def remove_actor ( self , perforation_path : str ) -> None :
120+ """Clear all data stored in this class."""
121+ index = self ._get_actor_index_from_perforation ( perforation_path )
122+ if index == - 1 :
123+ print ( "Cannot found the well to remove from path: " , perforation_path )
124+
125+ self ._wells_actors .remove ( self ._wells_actors [ index ] )
126+
111127 def _get_index_from_perforation ( self , perforation_path : str ) -> int :
112128 """Retrieve the well associated to a given perforation, otherwise return -1."""
113129 index = - 1
@@ -121,6 +137,19 @@ def _get_index_from_perforation( self, perforation_path: str ) -> int:
121137
122138 return index
123139
140+ def _get_actor_index_from_perforation ( self , perforation_path : str ) -> int :
141+ """Retrieve the well actor associated to a given perforation, otherwise return -1."""
142+ index = - 1
143+ if len ( self ._wells_actors ) == 0 :
144+ return index
145+
146+ for i in range ( 0 , len ( self ._wells_actors ) ):
147+ if self ._wells_actors [ i ].well_path in perforation_path :
148+ index = i
149+ break
150+
151+ return index
152+
124153 def get_number_of_wells ( self ) -> int :
125154 """Get the number of wells in the viewer."""
126155 return len ( self ._wells )
0 commit comments