Skip to content
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

Lauras changes #86

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

LauraConnolly
Copy link

Additional support for NDArray messages in Slicer (changed device factory and added a new device)

igtl::MessageBase::MetaDataMap& outMetaInfo)
{
igtl::NDArrayMessage::Pointer msg;
msg = igtl::NDArrayMessage::New();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a factory to create the message

bool checkCRC,
igtl::MessageBase::MetaDataMap& outMetaInfo)
{
igtl::NDArrayMessage::Pointer msg;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 space indentation

int c = msg->Unpack(checkCRC);


cbcbcpa
Copy link
Collaborator

@adamrankin adamrankin Nov 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this*?

if (!IGTLtoHeader(dynamic_pointer_cast<igtl::MessageBase>(msg), header, outMetaInfo))
return 0;

vtkSmartPointer<vtkDataArray> NDArray_msg = dest->NDArray_msg;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be copy. Create a new empty pointer
vtkSmartPointer<vtkDataArray> NDArray_msg = vtkSmartPointer<vtkDataArray>::New();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than that. You'll have to switch on the IGTL array scalar type so you create the correct type of array (vtkFloatArray, vtkIntArray, etc...)

struct ContentData
{
vtkSmartPointer<vtkDataArray> NDArray_msg;
};
Copy link
Collaborator

@adamrankin adamrankin Nov 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ContentData will also have to store what kind of scalar the array is. Use the IGTL type defines for this.

return 0;

vtkSmartPointer<vtkDataArray> NDArray_msg = dest->NDArray_msg;
NDArray_msg->Allocate(msg->GetPackSize());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't always going to be correct if the pack size contains metadata. Use the message values to determine the necessary array size.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg: msg->GetArray()->GetRawArraySize()


vtkSmartPointer<vtkDataArray> NDArray_msg = dest->NDArray_msg;
NDArray_msg->Allocate(msg->GetPackSize());
memcpy(NDArray_msg->GetVoidPointer(0), msg->GetPackPointer(), msg->GetBodySizeToRead());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above, getbodysizetoread may return incorrect array size, use msg->GetArray()->GetRawArraySize()

@lassoan
Copy link
Collaborator

lassoan commented Nov 27, 2020

@LauraConnolly thank you for the pull request. Are you sure that this is the correct version? Having the cbcbcpa text in the code would cause syntax error, so it is probably not the working version.

@adamrankin I asked Laura to commit her changes without cleaning up, so that we can have a look and fix issues. She may or may not have the time to clean things up, but I can do one round of cleanup, as long as the implementation works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants