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

Omni support #106

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d8fc9a0
Added support for incoming omni messages.
LauraConnolly Jun 24, 2020
588c7c7
Working on adding support for vtkMRMLIGTLTableNode
LauraConnolly Jun 30, 2020
3efdf4e
Made changes for vtkDataArray declaration
LauraConnolly Jun 30, 2020
e4df47e
Changes in July.
LauraConnolly Jul 27, 2020
b341e36
Most recent changes.
LauraConnolly Jul 27, 2020
0ac835d
Fixed how nd array messages are added to vtkmrml table NodeInfoMapType
LauraConnolly Nov 26, 2020
ddccacd
ENH: Remove unnecessary find_package(Slicer)
Sunderlandkyl Jul 31, 2020
238e99c
BUG: Fix typo in MRML std::string vector copy macro
Sunderlandkyl Aug 25, 2020
ac6473d
COMP: Restore backwards compatibility with Slicer 4.10.2
Sunderlandkyl Aug 25, 2020
b37b2bb
COMP: Fix bundling of OpenIGTLinkIO external project adding VTK depen…
jcfr Oct 30, 2020
019e449
ENH: Add support for transferring markups fiducial node as POINT message
lassoan Nov 20, 2020
8b75cac
BUG: Fix typo in OpenIGTLink message metadata MEMLNodeName -> MRMLNod…
lassoan Nov 21, 2020
913c303
COMP: Fix build error on macOS
lassoan Dec 16, 2020
aec89b0
ENH: Ensure correct spacing and origin when receiving an igtl Image m…
adamrankin Dec 19, 2020
34b4c61
ENH: Add launcher paths for bundling into custom app
sjh26 Feb 8, 2021
a446059
Bug: Query node device name fix.
leochan2009 Mar 15, 2021
07810f3
Revert "Bug: Query node device name fix."
leochan2009 Mar 19, 2021
b01c782
Feature: backward compatiblity. legacy program can send data without …
leochan2009 Mar 19, 2021
618b625
BUG: forward the mrml node when new device added. Improvement: remove…
leochan2009 Mar 29, 2021
d822610
Improvement: use a OriginalNodeName attribute to store the original n…
leochan2009 Apr 3, 2021
c31e970
BUG:label map name empty. LabelVolume is never created by openigtlin…
leochan2009 Apr 5, 2021
e705412
ENH: Restore removed RegisterIncomingMRMLNode function
Sunderlandkyl May 3, 2021
1435ec9
ENH: Add base class for scripted ultrasound parameter widgets
Sunderlandkyl Jul 23, 2021
a64e0b3
BUG: Fix crash when OriginalNodeName attribute is not defined
Sunderlandkyl Jul 23, 2021
83fa3b2
ENH: Add missing igtlioCommand methods to vtkSlicerOpenIGTLinkCommand
Sunderlandkyl Jul 23, 2021
c94ab05
BUG: Instantiate nodes using default scene parameters
Sunderlandkyl Jul 23, 2021
8c95b64
ENH: Update PeriodicProcess to use SlicerRenderBlocker
Sunderlandkyl Jul 23, 2021
5837a53
COMP: Remove text node so that extension builds in custom app
cpinter Sep 7, 2019
68c6d67
ENH: Add an UltrasoundRemoteControl widget for controlling TGC
markasselin Jun 21, 2021
8454084
COMP: Fix subproject configuration if Python was installed
cpinter Sep 30, 2021
3369407
ENH: Add support for Markups ROI for reconstructed volume rendering
Sunderlandkyl Nov 4, 2021
8fbb196
Added support for incoming omni messages.
LauraConnolly Jun 24, 2020
136c924
Working on adding support for vtkMRMLIGTLTableNode
LauraConnolly Jun 30, 2020
693ed9d
Made changes for vtkDataArray declaration
LauraConnolly Jun 30, 2020
0f17a37
Most recent changes.
LauraConnolly Jul 27, 2020
7836fa3
vtkMRMLIGTLConnectorNode code is up to date now - so it OpenIGTLinkIO…
LauraConnolly Nov 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 75 additions & 6 deletions OpenIGTLinkIF/MRML/vtkMRMLIGTLConnectorNode.cxx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/*=auto=========================================================================

Portions (c) Copyright 2009 Brigham and Women's Hospital (BWH) All Rights Reserved.

See Doc/copyright/copyright.txt
or http://www.slicer.org/copyright/copyright.txt for details.

Program: 3D Slicer
Module: $RCSfile: vtkMRMLConnectorNode.cxx,v $
Date: $Date: 2006/03/17 15:10:10 $
Version: $Revision: 1.2 $

=========================================================================auto=*/

// OpenIGTLink includes
Expand All @@ -24,6 +20,7 @@ Version: $Revision: 1.2 $
#include <igtlioLabelMetaDevice.h>
#include <igtlioPolyDataDevice.h>
#include <igtlioPointDevice.h>
#include <igtlioNDArrayDevice.h>
#include <igtlioStatusDevice.h>
#include <igtlioStringDevice.h>
#include <igtlioTransformDevice.h>
Expand All @@ -35,6 +32,7 @@ Version: $Revision: 1.2 $
// OpenIGTLinkIF MRML includes
#include "vtkMRMLIGTLConnectorNode.h"
#include "vtkMRMLIGTLStatusNode.h"
#include "vtkMRMLTableNode.h"
#include "vtkMRMLImageMetaListNode.h"
#include "vtkMRMLLabelMetaListNode.h"
#include "vtkMRMLTextNode.h"
Expand All @@ -44,6 +42,7 @@ Version: $Revision: 1.2 $
// MRML includes
#include <vtkMRMLColorLogic.h>
#include <vtkMRMLColorTableNode.h>
#include <vtkMRMLTableNode.h>
#include <vtkMRMLLinearTransformNode.h>
#include <vtkMRMLModelNode.h>
#include <vtkMRMLScalarVolumeDisplayNode.h>
Expand All @@ -52,15 +51,22 @@ Version: $Revision: 1.2 $
#include <vtkMRMLVectorVolumeDisplayNode.h>
#include <vtkMRMLVectorVolumeNode.h>
#include <vtkMRMLVolumeNode.h>
#include <vtkMRMLTableNode.h>

// VTK includes
#include <vtkCollection.h>
#include <vtkImageData.h>
#include <vtkMatrix4x4.h>
#include <vtkMutexLock.h>
#include <vtkPolyData.h>
#include <vtkTable.h>
#include <vtkTable.h>
#include <vtkTimerLog.h>
#include <vtkWeakPointer.h>
#include <vtkDataArray.h>
#include <vtkTableToArray.h>

#include <igtlioNDArrayConverter.h>

// vtksys includes
#include <vtksys/SystemTools.hxx>
Expand Down Expand Up @@ -187,6 +193,15 @@ unsigned int vtkMRMLIGTLConnectorNode::vtkInternal::AssignOutGoingNodeToDevice(v
statusDevice->SetContent(content);
modifiedEvent = vtkMRMLIGTLStatusNode::StatusModifiedEvent;
}
else if (device->GetDeviceType().compare("NDARRAY") == 0)
{
vtkMRMLTableNode* tableNode = vtkMRMLTableNode::SafeDownCast(node);
vtkDataArray* arr = vtkDataArray::SafeDownCast(tableNode->GetTable()->GetColumn(0));
//arr->SetComponent(0,0, arr); // This changed
igtlioNDArrayConverter::ContentData content = { arr };
//device->SetContent(content);
//modifiedEvent = vtkMRMLTableNode::ArrayModifiedEvent;
}
else if (device->GetDeviceType().compare("TRANSFORM") == 0)
{
igtlioTransformDevice* transformDevice = static_cast<igtlioTransformDevice*>(device.GetPointer());
Expand Down Expand Up @@ -290,18 +305,25 @@ void vtkMRMLIGTLConnectorNode::vtkInternal::ProcessIncomingDeviceModifiedEvent(
vtkObject* vtkNotUsed(caller), unsigned long vtkNotUsed(event), igtlioDevice* modifiedDevice)
{
vtkMRMLNode* modifiedNode = this->GetMRMLNodeforDevice(modifiedDevice);

if (!modifiedNode)
{
// Could not find or add node.
return;
}

int wasModifyingNode = modifiedNode->StartModify();

const std::string deviceType = modifiedDevice->GetDeviceType();
const std::string deviceName = modifiedDevice->GetDeviceName();

std::cout << deviceType << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove all print statements

std::cout << deviceName << std::endl;
int diff = strcmp(deviceType.c_str(), "NDARRAY");
std::cout << diff << std::endl;
if (this->External->GetNodeTagFromDeviceType(deviceType.c_str()).size() > 0)
{
std::cout << "anything" << std::endl;
if (strcmp(deviceType.c_str(), "IMAGE") == 0)
{
igtlioImageDevice* imageDevice = reinterpret_cast<igtlioImageDevice*>(modifiedDevice);
Expand Down Expand Up @@ -360,6 +382,32 @@ void vtkMRMLIGTLConnectorNode::vtkInternal::ProcessIncomingDeviceModifiedEvent(
statusNode->Modified();
}
}
else if (strcmp(deviceType.c_str(), "NDARRAY") == 0)
{
std::cout << "Device type is nd array" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove commented lines and re-indent to 2 spaces

igtlioNDArrayDevice* ndarraydevice = reinterpret_cast<igtlioNDArrayDevice*>(modifiedDevice);
if (strcmp(modifiedNode->GetName(), deviceName.c_str()) == 0)
{
std::cout << "In this NDArray" << std::endl;
vtkMRMLTableNode* tablenode = vtkMRMLTableNode::SafeDownCast(modifiedNode);
vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
//vtkDataArray* dataarray = vtkDataArray::SafeDownCast(ndarraydevice->GetContent().NDArray_msg);
vtkCollection* collectionRef = vtkCollection::SafeDownCast(ndarraydevice->GetContent().collection);

//dataarray->InsertTuple(0, 0, );

/*table->AddColumn(collection);
tablenode->SetAndObserveTable(table);
tablenode->Modified();*/
for (int i = 0; i < collectionRef->GetNumberOfItems(); ++i) {
vtkDataArray* collection = vtkDataArray::SafeDownCast(ndarraydevice->GetContent().collection->GetItemAsObject(i));
table->AddColumn(collection);
tablenode->SetAndObserveTable(table);
tablenode->Modified();
}

}
}
else if (strcmp(deviceType.c_str(), "TRANSFORM") == 0)
{
igtlioTransformDevice* transformDevice = reinterpret_cast<igtlioTransformDevice*>(modifiedDevice);
Expand Down Expand Up @@ -753,6 +801,22 @@ vtkMRMLNode* vtkMRMLIGTLConnectorNode::vtkInternal::GetMRMLNodeforDevice(igtlioD
this->External->RegisterIncomingMRMLNode(statusNode, device);
return statusNode;
}
else if (strcmp(device->GetDeviceType().c_str(), "NDARRAY") == 0)
{
vtkSmartPointer<vtkMRMLTableNode> tableNode = vtkMRMLTableNode::SafeDownCast(this->External->GetScene()->GetFirstNode(deviceName.c_str(), "vtkMRMLTableNode"));
if (tableNode)
{
this->External->RegisterIncomingMRMLNode(tableNode, device);
return tableNode;
}
tableNode = vtkSmartPointer<vtkMRMLTableNode>::New();
tableNode->SetName(deviceName.c_str());
vtkCollection* dataArray = vtkCollection::SafeDownCast(tableNode->GetTable()->GetColumn(0));
this->External->GetScene()->AddNode(tableNode);
this->External->RegisterIncomingMRMLNode(tableNode, device);
return tableNode;
}

else if (strcmp(device->GetDeviceType().c_str(), "TRANSFORM") == 0)
{
vtkSmartPointer<vtkMRMLTransformNode> transformNode =
Expand Down Expand Up @@ -1077,6 +1141,7 @@ vtkMRMLIGTLConnectorNode::vtkMRMLIGTLConnectorNode()
this->Internal->DeviceTypeToNodeTagMap["IMGMETA"] = std::vector<std::string>(1, "ImageMetaList");
this->Internal->DeviceTypeToNodeTagMap["LBMETA"] = std::vector<std::string>(1, "LabelMetaList");
this->Internal->DeviceTypeToNodeTagMap["TDATA"] = std::vector<std::string>(1, "IGTLTrackingDataSplitter");
this->Internal->DeviceTypeToNodeTagMap["NDARRAY"] = std::vector<std::string>(1, "TableNode");
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1152,6 +1217,10 @@ std::vector<std::string> vtkMRMLIGTLConnectorNode::GetDeviceTypeFromMRMLNodeType
return std::vector<std::string>(1, "STRING");
}
return std::vector<std::string>(0);
if (strcmp(nodeTag, "NDArrayMessage") == 0)
{
return std::vector<std::string>(1, "NDARRAY");
}
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -2534,4 +2603,4 @@ void vtkMRMLIGTLConnectorNode::SetCheckCRC(bool check)
bool vtkMRMLIGTLConnectorNode::GetCheckCRC()
{
return (this->Internal->IOConnector->GetCheckCRC() != 0);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please restore the newline at the end of the file