-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add Set/Get and XML macros for iterable STL container properties #973
Conversation
4bb7cf9
to
c05b36f
Compare
3491446
to
0f022db
Compare
Thanks a lot Kyle, it looks good! I would just ask for one change. We may need different implementation in the future for managing float/double and integer vectors. Therefore, it would be more future-proof if we created separate macros for float and integer (e.g., set large number of decimal digits for floats for loss-less writing to file; handle special values, such as nan, inf, ...). vtkMRMLWriteXMLStdFloatVectorMacro and vtkMRMLWriteXMLStdIntVectorMacro name should work (and of course not just the writer macros but others would need to be renamed as well). If you don't need integer vector macros then for you can just rename vtkMRML...StdVectorMacro to vtkMRML...StdFloatVectorMacro. |
Makes sense. I'll add the int macros as well. I believe that there are some integer parameters. |
7c04c1f
to
c8f8405
Compare
Any other changes to make here? |
Unless you plane to use the macro in the core in a follow up commit, could you test the new macros by either adding a new test or extending this one ? |
Sure, I'll do that. |
6d4cb0e
to
b44573d
Compare
Macros have been added to vtkMRMLNodeTest1. Vector XML methods are tested in TestReadWriteXMLProperties(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test 👍
After addressing few nitpicks, we should be all set.
ss << "<MRMLNode "; | ||
node1->WriteXML(ss, NULL); | ||
ss << " />"; | ||
std::string testString = ss.str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testString
is unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
NULL }; | ||
|
||
vtkNew<vtkMRMLNodeTestHelper1> node2; | ||
node2->ReadXMLAttributes(atts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems atts
is not used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atts is used in:
node2->ReadXMLAttributes(atts);
To populate the parameters of node2.
node2->ReadXMLAttributes(atts); | ||
|
||
if (node1->GetTestingStringVector() != node2->GetTestingStringVector()) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
b44573d
to
d4af2de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Will integrate after local build completes
Closing. Integrated in r27266 |
Thanks @jcfr! |
Adds macros to Read/Write/Print/Copy iterable properties.
Example usage:
Numeric container:
vtkMRMLWriteXMLStdVectorMacro(property, Property, std::deque<int>);
String container:
vtkMRMLWriteXMLStdStringVectorMacro(property, Property, std::vector);
See also this related merge request in VTK: https://gitlab.kitware.com/vtk/vtk/merge_requests/4427
It's not required for this change, but it adds some convenience macros for setting/getting STL containers.
Also added generic Set/Get macros that work with STL containers.
Currently, STL containers cannot use the generic vtkSetMacro/vtkGetMacro types since those macros require a "<<" operator within vtkDebugMacro
openigtlink/SlicerOpenIGTLink#36
cc: @lassoan