[Paraview-developers] String/Array List domain regular expression

Biddiscombe, John A. biddisco at cscs.ch
Tue Apr 6 09:34:52 EDT 2010


I get a lot of data where scalars are defined by names like Density, density, rho, RHO, m_c_rho, rho_ - or any other possibly name that vaguely describes the data.

I've added a couple of new fields to the string array XML - an example is best
         name="Yarray"
         command="SetYarray"
         default_values="Coords_1"
         default_regex_delimiter=","
         default_regex=".*Y,.*y,.*oords_1"
         number_of_elements="1">

Now the regex is used to search all possible scalar arrays to find the first match. Not very complex, but my first tests show that for reasonably simple regexs (and data arrays), all seems good and I'm now able to save several array selection clicks by getting the default found for me.

In order to make this work, I added to vtkSMStringVectorProperty
  // Description:
  // If this string vector has regular expression searches attached
  // then provide a hook so that the a string list domain can pass in a list
  // of possible strings from which a default can be selected
  bool GetDefaultUsesRegex();

  // Description:
  // Using the regular expression list, pick one of the possible string
  // to be used as the default value
  const char* GetDefaultValue(vtkStringList *list);

and some tweaks to vtkSMStringListDomain so that the calls are made appropriately.
unfortunately, in order to pick a default, the vtkSMStringListDomain has to copy all of its internal array values into a vtkStringList, pass them to the VectorProperty, let it choose one and then destroy the list afterwards. This is because we are not allowed to use vtkstd::anything in headers and the list is already stored internally as a vtkstd::vector< ... >

I don't like it.

however, when I'm sure I've not broken anything I'll check the stuff in. I'd be grateful if one of the ServerManager Proxy whizzes from Kitware would take a glance at the code when it goes in to see if there's a tidier (/better) way of doing it. I'm never quite sure of the ArrayListDomain/StringListDomain/StringVectorProperty/etc etc as to who is supposed to own what.

Thanks

JB


--
John Biddiscombe,                            email:biddisco @ cscs.ch
http://www.cscs.ch/
CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20100406/159316b5/attachment.htm>


More information about the Paraview-developers mailing list