1414 _color_map = ModuleImportRaiser (_error_message_vedo_import , err )
1515 _get_color = ModuleImportRaiser (_error_message_vedo_import , err )
1616
17+ from gustaf import Faces as _Faces
1718from gustaf import Vertices as _Vertices
19+ from gustaf import Volumes as _Volumes
1820
1921from splinepy .utils .log import debug as _debug
2022from splinepy .utils .log import warning as _warning
@@ -196,8 +198,8 @@ def _export_spline_field(spline, svg_element, box_min_x, box_max_y, **kwargs):
196198 showable = sampled_spline .showable ()
197199
198200 # Discretize colors
199- if kwargs .get ("n_colors" , None ) is not None :
200- n_colors = kwargs .get ("n_colors" , None )
201+ if kwargs .get ("n_colors" ) is not None :
202+ n_colors = kwargs .get ("n_colors" )
201203 cmap_key = spline .show_options .get ("cmap" , "jet" )
202204 vmin = kwargs .get ("vmin" , spline .show_options .get ("vmin" , None ))
203205 vmax = kwargs .get ("vmax" , spline .show_options .get ("vmax" , None ))
@@ -260,8 +262,11 @@ def _export_gustaf_object(
260262 r , g , b = _get_color (gus_object .show_options .get ("c" , "red" ))
261263 a = gus_object .show_options .get ("alpha" , 1.0 )
262264 radius = gus_object .show_options .get ("r" , 0.1 )
265+ stroke_width = gus_object .show_options .get ("lw" , 0.1 )
263266
264- if isinstance (gus_object , _Vertices ):
267+ if isinstance (gus_object , _Vertices ) and not isinstance (
268+ gus_object , _Faces
269+ ):
265270 data_name = gus_object .show_options .get ("data" , None )
266271 if data_name is not None :
267272 # Retrieve information on colors and values
@@ -307,7 +312,7 @@ def _export_gustaf_object(
307312 )
308313
309314 # Set text options
310- if kwargs .get ("font_family" , None ) is not None :
315+ if kwargs .get ("font_family" ) is not None :
311316 svg_labels .attrib ["font-family" ] = kwargs ["font_family" ]
312317
313318 svg_labels .attrib ["font-size" ] = str (kwargs .get ("font_size" , 0.1 ))
@@ -330,6 +335,31 @@ def _export_gustaf_object(
330335 dy = str (dx ),
331336 )
332337 text_element .text = label
338+ if isinstance (gus_object , _Faces ) and not isinstance (gus_object , _Volumes ):
339+ svg_faces = _ET .SubElement (
340+ svg_spline_element ,
341+ "g" ,
342+ id = "faces" ,
343+ style = (
344+ f"fill:none;stroke:{ _rgb_2_hex (r ,g ,b )} ;stroke-opacity:{ a } ;"
345+ f"stroke-width:{ stroke_width } ;stroke-linecap:round"
346+ ),
347+ )
348+
349+ # Create a new face-group
350+ for face in gus_object .faces :
351+ edge_points = gus_object .vertices [[* face , face [0 ]], :]
352+
353+ _ET .SubElement (
354+ svg_faces ,
355+ "polyline" ,
356+ points = " " .join (
357+ [
358+ str (xx - box_min_x ) + "," + str (box_max_y - xy )
359+ for (xx , xy ) in edge_points
360+ ]
361+ ),
362+ )
333363
334364 else :
335365 raise NotImplementedError (
@@ -479,7 +509,7 @@ def _export_control_mesh(
479509 )
480510
481511 # Set text options
482- if kwargs .get ("font_family" , None ) is not None :
512+ if kwargs .get ("font_family" ) is not None :
483513 svg_control_point_ids .attrib ["font-family" ] = kwargs ["font_family" ]
484514 svg_control_point_ids .attrib ["font-size" ] = str (
485515 kwargs .get ("font_size" , 0.1 )
@@ -746,7 +776,7 @@ def _add_scalar_bar(svg_element, box_size, **kwargs):
746776 )
747777
748778 # Set text options
749- if kwargs .get ("font_family" , None ) is not None :
779+ if kwargs .get ("font_family" ) is not None :
750780 svg_tick_labels .attrib ["font-family" ] = kwargs ["font_family" ]
751781 svg_tick_labels .attrib ["font-size" ] = str (
752782 kwargs .get ("scalarbar_font_size" , stroke_width * 20 )
@@ -1305,8 +1335,7 @@ def export(
13051335 scalarbar_offset = kwargs ["scalarbar_offset" ]
13061336 # Check if required arguments have been passed
13071337 if scalarbar and (
1308- (kwargs .get ("vmin" , None ) is None )
1309- or (kwargs .get ("vmax" , None ) is None )
1338+ (kwargs .get ("vmin" ) is None ) or (kwargs .get ("vmax" ) is None )
13101339 ):
13111340 raise ValueError (
13121341 "`vmin` and `vmax` must be passed alon with scalarbar to ensure"
0 commit comments