@@ -149,8 +149,9 @@ def add_section(self, geological_feature=None, axis='x', value=None, **kwargs):
149149 geological_feature .name , geological_feature .min (), geological_feature .max ()))
150150 surf .colourmap (cmap , range = [geological_feature .min (), geological_feature .max ()])
151151
152- def add_isosurface (self , geological_feature , value = None , isovalue = None , paint_with = None ,
153- slices = None , colour = 'red' , nslices = None , cmap = None , ** kwargs ):
152+ def add_isosurface (self , geological_feature , value = None , isovalue = None ,
153+ paint_with = None , slices = None , colour = 'red' , nslices = None ,
154+ cmap = None , filename = None , ** kwargs ):
154155 """ Plot the surface of a geological feature
155156
156157 [extended_summary]
@@ -173,6 +174,8 @@ def add_isosurface(self, geological_feature, value = None, isovalue=None, paint_
173174 [description], by default None
174175 cmap : [type], optional
175176 [description], by default None
177+ filename: string, optional
178+ filename for exporting
176179
177180 Returns
178181 -------
@@ -188,7 +191,7 @@ def add_isosurface(self, geological_feature, value = None, isovalue=None, paint_
188191 # do isosurfacing of support using marching tetras/cubes
189192 x = np .linspace (self .bounding_box [0 , 0 ], self .bounding_box [1 , 0 ], self .nsteps [0 ])
190193 y = np .linspace (self .bounding_box [0 , 1 ], self .bounding_box [1 , 1 ], self .nsteps [1 ])
191- z = np .linspace (self .bounding_box [1 , 2 ], self .bounding_box [0 , 2 ], self .nsteps [2 ])
194+ z = np .linspace (self .bounding_box [0 , 2 ], self .bounding_box [1 , 2 ], self .nsteps [2 ])
192195 xx , yy , zz = np .meshgrid (x , y , z , indexing = 'ij' )
193196 points = np .array ([xx .flatten (), yy .flatten (), zz .flatten ()]).T
194197 val = geological_feature .evaluate_value (points )
@@ -240,9 +243,20 @@ def add_isosurface(self, geological_feature, value = None, isovalue=None, paint_
240243 except ValueError :
241244 logger .warning ("no surface to mesh, skipping" )
242245 continue
246+
247+
243248 name = geological_feature .name
244249 name = kwargs .get ('name' , name )
245250 name += '_iso_%f' % isovalue
251+ if filename is not None :
252+ try :
253+ import meshio
254+ except ImportError :
255+ logger .error ("Could not save surfaces, meshio is not installed" )
256+ meshio .write_points_cells (filename .format (name ),
257+ self .model .rescale (verts ),
258+ [("triangle" , faces )]
259+ )
246260 surf = self .lv .triangles (name )
247261 surf .vertices (verts )
248262 surf .indices (faces )
@@ -353,12 +367,12 @@ def add_model_surfaces(self, faults = True, cmap='tab20', **kwargs):
353367 if g in self .model .feature_name_index :
354368 feature = self .model .features [self .model .feature_name_index [g ]]
355369 for u , vals in self .model .stratigraphic_column [g ].items ():
356- self .add_isosurface (feature , isovalue = vals ['max' ],name = u ,colour = tab .colors [ci ,:])
370+ self .add_isosurface (feature , isovalue = vals ['max' ],name = u ,colour = tab .colors [ci ,:], ** kwargs )
357371 ci += 1
358372 if faults :
359373 for f in self .model .features :
360374 if f .type == 'fault' :
361- self .add_isosurface (f ,isovalue = 0 )
375+ self .add_isosurface (f ,isovalue = 0 , ** kwargs )
362376
363377
364378 def add_vector_field (self , geological_feature , ** kwargs ):
0 commit comments