4444#include < Core/Datatypes/Legacy/Field/VMesh.h>
4545#include < Core/Datatypes/Legacy/Field/VField.h>
4646#include < Core/Datatypes/MatrixTypeConversions.h>
47- #include < boost/assign/std/vector.hpp >
47+ #include < Core/Logging/Log.h >
4848
4949using namespace SCIRun ;
5050using namespace SCIRun ::MatlabIO;
5151using namespace SCIRun ::Core::Logging;
5252using namespace SCIRun ::Core::Datatypes;
53- using namespace boost ::assign;
5453
5554// Currently the property converter only manages strings
5655// all other data is ignored both on Matlab side as well
@@ -161,8 +160,8 @@ matlabarray::mitype matlabconverter::convertnrrdtype(int type)
161160
162161bool matlabconverter::isvalidmatrixname (const std::string& name)
163162{
164- const std::string validchar (" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" );
165- const std::string validstartchar (" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" );
163+ static const std::string validchar (" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" );
164+ static const std::string validstartchar (" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" );
166165
167166 bool valid = true ;
168167 bool foundchar = false ;
@@ -186,167 +185,12 @@ bool matlabconverter::isvalidmatrixname(const std::string& name)
186185 if (name[p] == validchar[q]) { foundchar = true ; break ; }
187186 }
188187 }
189- if (foundchar == false ) { valid = false ; break ; }
188+ if (! foundchar) { valid = false ; break ; }
190189 }
191190 return (valid);
192191}
193192
194193#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
195- void matlabconverter::mlPropertyTOsciProperty (matlabarray &ma,PropertyManager *handle)
196- {
197- int numfields;
198- matlabarray::mlclass mclass;
199- matlabarray subarray;
200- std::string propname;
201- std::string propval;
202- matlabarray proparray;
203-
204- std::string dummyinfo;
205- int matrixscore;
206- int fieldscore;
207-
208- NrrdDataHandle nrrd;
209- MatrixHandle matrix;
210- FieldHandle field;
211-
212- // properties are stored in field property
213- int propindex = ma.getfieldnameindexCI (" property" );
214-
215- if (propindex > -1 )
216- { // field property exists
217-
218- proparray = ma.getfield (0 ,propindex);
219- if (proparray.isempty ()) return ;
220-
221- numfields = proparray.getnumfields ();
222-
223- for (int p=0 ; p<numfields; p++)
224- {
225- subarray = proparray.getfield (0 ,p);
226- mclass = subarray.getclass ();
227-
228- // Check whether property is string
229- // In the property manager string are STL strings
230- if (mclass == matlabarray::mlSTRING)
231- { // only string arrays are converted
232- propname = proparray.getfieldname (p);
233- propval = subarray.getstring ();
234- handle->set_property (propname,propval,false );
235- continue ;
236- }
237-
238- if ((fieldscore = sciFieldCompatible (subarray,dummyinfo)))
239- {
240- if (fieldscore > 1 )
241- {
242- propname = proparray.getfieldname (p);
243- mlArrayTOsciField (subarray,field);
244- handle->set_property (propname,field,false );
245- continue ;
246- }
247- }
248-
249- if ((matrixscore = sciMatrixCompatible (subarray,dummyinfo)))
250- {
251- if (matrixscore > 1 )
252- {
253- propname = proparray.getfieldname (p);
254- mlArrayTOsciMatrix (subarray,matrix);
255- handle->set_property (propname,matrix,false );
256- continue ;
257- }
258- else
259- {
260- if (sciNrrdDataCompatible (subarray,dummyinfo))
261- {
262- propname = proparray.getfieldname (p);
263- mlArrayTOsciNrrdData (subarray,nrrd);
264- handle->set_property (propname,nrrd,false );
265- continue ;
266- }
267- propname = proparray.getfieldname (p);
268- mlArrayTOsciMatrix (subarray,matrix);
269- handle->set_property (propname,matrix,false );
270- continue ;
271- }
272- }
273-
274- if (sciNrrdDataCompatible (subarray,dummyinfo))
275- {
276- propname = proparray.getfieldname (p);
277- mlArrayTOsciNrrdData (subarray,nrrd);
278- handle->set_property (propname,nrrd,false );
279- continue ;
280- }
281- if (fieldscore > 0 )
282- {
283- propname = proparray.getfieldname (p);
284- mlArrayTOsciField (subarray,field);
285- handle->set_property (propname,field,false );
286- continue ;
287- }
288- }
289- }
290- }
291-
292- void matlabconverter::sciPropertyTOmlProperty (PropertyManager *handle,matlabarray &ma)
293- {
294- size_t numfields;
295- matlabarray proparray;
296- std::string propname;
297- std::string propvalue;
298- matlabarray subarray;
299-
300- StringHandle str;
301- MatrixHandle matrix;
302- NrrdDataHandle nrrd;
303- FieldHandle field;
304-
305- proparray.createstructarray ();
306- numfields = handle->nproperties ();
307-
308- for (size_t p=0 ;p<numfields;p++)
309- {
310- propname = handle->get_property_name (p);
311- if (handle->get_property (propname,propvalue))
312- {
313- subarray.createstringarray (propvalue);
314- proparray.setfield (0 ,propname,subarray);
315- }
316- if (handle->get_property (propname,nrrd))
317- {
318- subarray.clear ();
319- bool oldnumericarray_ = numericarray_;
320- numericarray_ = true ;
321- sciNrrdDataTOmlArray (nrrd,subarray);
322- numericarray_ = oldnumericarray_;
323- proparray.setfield (0 ,propname,subarray);
324- }
325- if (handle->get_property (propname,matrix))
326- {
327- subarray.clear ();
328- bool oldnumericarray_ = numericarray_;
329- numericarray_ = true ;
330- sciMatrixTOmlArray (matrix,subarray);
331- numericarray_ = oldnumericarray_;
332- proparray.setfield (0 ,propname,subarray);
333- }
334- if (handle->get_property (propname,field))
335- {
336- subarray.clear ();
337- sciFieldTOmlArray (field,subarray);
338- proparray.setfield (0 ,propname,subarray);
339- }
340- if (handle->get_property (propname,str))
341- {
342- subarray.clear ();
343- sciStringTOmlArray (str,subarray);
344- proparray.setfield (0 ,propname,subarray);
345- }
346- }
347- ma.setfield (0 ," property" ,proparray);
348- }
349-
350194int matlabconverter::sciColorMapCompatible (matlabarray &ma, std::string &infotext, bool postremark)
351195{
352196 infotext = " " ;
@@ -465,15 +309,17 @@ int matlabconverter::sciMatrixCompatible(const matlabarray &ma, std::string &inf
465309 if (index == -1 ) index = ma.getfieldnameindexCI (" tensorfield" );
466310 if (index == -1 )
467311 {
468- if (postremark) remark (std::string (" Matrix '" + ma.getname () + " ' cannot be translated into a SCIRun Matrix (cannot find a field with data: create a .data field)." ));
312+ if (postremark)
313+ SCIRun::logWarning (" Matlab object '{}' cannot be translated into a SCIRun Field (cannot find a field with data: create a .data field)." , ma.getname ());
469314 return (0 ); // incompatible
470315 }
471316
472317 int numel;
473318 numel = ma.getnumelements ();
474319 if (numel > 1 )
475320 {
476- if (postremark) remark (std::string (" Matrix '" + ma.getname () + " ' cannot be translated into a SCIRun Matrix (the struct matrix is not 1x1: do not define more than one matrix)." ));
321+ if (postremark)
322+ remark (std::string (" Matrix '" + ma.getname () + " ' cannot be translated into a SCIRun Matrix (the struct matrix is not 1x1: do not define more than one matrix)." ));
477323 return (0 ); // incompatible
478324 }
479325
@@ -1442,8 +1288,8 @@ void matlabconverter::sciNrrdDataTOmlArray(NrrdDataHandle scinrrd, matlabarray &
14421288 mlarray.setfield (0 ," data" ,matrix);
14431289
14441290 // Set the properties of the axis
1445- std::vector<std::string> axisfieldnames;
1446- axisfieldnames += " size" , " spacing" , " min" , " max" , " center" , " label" , " unit" ;
1291+ const std::vector<std::string> axisfieldnames =
1292+ { " size" , " spacing" , " min" , " max" , " center" , " label" , " unit" } ;
14471293
14481294 Nrrd *nrrdptr;
14491295 nrrdptr = scinrrd->getNrrd ();
@@ -1453,7 +1299,7 @@ void matlabconverter::sciNrrdDataTOmlArray(NrrdDataHandle scinrrd, matlabarray &
14531299 dims[0 ] = nrrdptr->dim ;
14541300 dims[1 ] = 1 ;
14551301
1456- axisma.createstructarray (dims,axisfieldnames);
1302+ axisma.createstructarray (dims, axisfieldnames);
14571303
14581304 for (int p=0 ; p<static_cast <int >(nrrdptr->dim ); p++ )
14591305 {
@@ -1531,11 +1377,11 @@ void matlabconverter::sciNrrdDataTOmlArray(NrrdDataHandle scinrrd, matlabarray &
15311377// LatVolMesh
15321378// any suggestions for other types that need support ??
15331379
1534- int matlabconverter::sciFieldCompatible (const matlabarray& mlarray,std::string & infostring, bool postremark)
1380+ int matlabconverter::sciFieldCompatible (const matlabarray& mlarray, std::string& infostring, bool postremark)
15351381{
15361382 MatlabToFieldAlgo algo;
15371383 algo.setreporter (pr_);
1538- return ( algo.analyze_iscompatible (mlarray,infostring,postremark) );
1384+ return algo.analyze_iscompatible (mlarray, infostring, postremark);
15391385}
15401386
15411387void matlabconverter::mlArrayTOsciField (const matlabarray& mlarray, FieldHandle &scifield)
@@ -1708,18 +1554,18 @@ int matlabconverter::sciBundleCompatible(matlabarray &mlarray, std::string &info
17081554 for (int p = 0 ; p < nfields; p++)
17091555 {
17101556 subarray = mlarray.getfield (0 ,p);
1711- if (sciStringCompatible (subarray,dummyinfo,false )) { numstrings++; continue ; }
1557+ if (sciStringCompatible (subarray, dummyinfo, false )) { numstrings++; continue ; }
17121558 if (prefer_bundles) {if (sciBundleCompatible (subarray,dummyinfo,false )) { numbundles++; continue ; } }
1713- int score = sciFieldCompatible (subarray,dummyinfo,false );
1559+ int score = sciFieldCompatible (subarray, dummyinfo, false );
17141560 if (prefer_fields)
17151561 if (score > 0 ) { numfields++; continue ; }
17161562 else
17171563 if (score > 1 ) { numfields++; continue ; }
1718- if (prefer_nrrds) { if (sciNrrdDataCompatible (subarray,dummyinfo,false )) { numnrrds++; continue ; } }
1564+ if (prefer_nrrds) { if (sciNrrdDataCompatible (subarray, dummyinfo, false )) { numnrrds++; continue ; } }
17191565 if (sciMatrixCompatible (subarray,dummyinfo,false )) { nummatrices++; continue ; }
1720- if (!prefer_nrrds) { if (sciNrrdDataCompatible (subarray,dummyinfo,false )) { numnrrds++; continue ; } }
1566+ if (!prefer_nrrds) { if (sciNrrdDataCompatible (subarray, dummyinfo, false )) { numnrrds++; continue ; } }
17211567 if (score) { numfields++; continue ; }
1722- if (sciBundleCompatible (subarray,dummyinfo,false )) { numbundles++; continue ; }
1568+ if (sciBundleCompatible (subarray, dummyinfo, false )) { numbundles++; continue ; }
17231569 }
17241570
17251571 if (numfields+nummatrices+numnrrds+numbundles+numstrings == 0 )
@@ -1795,7 +1641,7 @@ void matlabconverter::mlArrayTOsciBundle(matlabarray &mlarray,BundleHandle &scib
17951641 }
17961642 }
17971643
1798- int score = sciFieldCompatible (subarray,dummyinfo,false );
1644+ int score = sciFieldCompatible (subarray, dummyinfo, false );
17991645 if (score > 1 )
18001646 {
18011647 FieldHandle field;
0 commit comments