16 #include "igtlImageMessage.h" 17 #include "igtlTransformMessage.h" 18 #include "igtlPositionMessage.h" 19 #include "igtlStatusMessage.h" 20 #include "igtlImageMetaMessage.h" 21 #include "igtlPointMessage.h" 22 #include "igtlTrajectoryMessage.h" 23 #include "igtlStringMessage.h" 24 #include "igtlSensorMessage.h" 25 #include "igtlBindMessage.h" 26 #include "igtlPolyDataMessage.h" 27 #include "igtlQuaternionTrackingDataMessage.h" 28 #include "igtlCapabilityMessage.h" 29 #include "igtlNDArrayMessage.h" 30 #include "igtlTrackingDataMessage.h" 31 #include "igtlColorTableMessage.h" 32 #include "igtlLabelMetaMessage.h" 39 #include "itksys/SystemTools.hxx" 61 bool copySuccess =
false;
62 igtl::TransformMessage::Pointer clone_ = igtl::TransformMessage::New();
67 igtl::TransformMessage* original = (igtl::TransformMessage*)original_;
70 copySuccess = clone_->Copy(original);
78 original->GetMatrix(mat);
79 clone_->SetMatrix(mat);
83 original->GetNormals(normals);
84 clone_->SetNormals(normals);
88 original->GetPosition(position);
89 clone_->SetPosition(position);
91 return igtl::MessageBase::Pointer(clone_.GetPointer());
165 mitk::IGTLMessageCloneHandler::Pointer cloneHandler)
174 this->
m_NewMethods[messageTypeName] = messageTypeNewPointer;
178 mitk::IGTLMessageCloneHandler::Pointer cloneHandler)
183 mitk::IGTLMessageCloneHandler::Pointer
192 MITK_ERROR(
"IGTLMessageFactory") << messageTypeName <<
193 " message type is not registered to factory!";
195 mitkThrow() << messageTypeName <<
" message type is not registered to factory!";
200 igtl::MessageBase::Pointer
214 MITK_ERROR(
"IGTLMessageFactory") << messageTypeName <<
215 " message type is not registered to factory!";
219 igtl::MessageBase::Pointer
224 if (newPointer !=
nullptr)
234 std::list<std::string>
237 std::list<std::string> allGetMessages;
238 for (std::map<std::string, PointerToMessageBaseNew>::const_iterator it =
242 if (it->first.find(
"GET_") != std::string::npos ||
243 it->first.find(
"STT_") != std::string::npos ||
244 it->first.find(
"STP_") != std::string::npos ||
245 it->first.find(
"RTS_") != std::string::npos)
247 allGetMessages.push_back(it->first);
251 return allGetMessages;
254 igtl::MessageBase::Pointer
257 std::string messageType;
260 if (msgHeader.IsNull())
262 messageType =
"NONE";
266 messageType = msgHeader->GetDeviceType();
270 messageType = itksys::SystemTools::UpperCase(messageType);
286 MITK_ERROR(
"IGTLMessageFactory") <<
"Unknown IGT message type: " virtual IGTLMessageFactory::PointerToMessageBaseNew GetMessageTypeNewPointer(std::string messageTypeName)
Get pointer to message type new function, or nullptr if the message type not registered Usage: igtl::...
std::list< std::string > GetAvailableMessageRequestTypes()
Returns available get messages.
std::map< std::string, mitk::IGTLMessageCloneHandler::Pointer > m_CloneHandlers
Map igt message types and the Clone() methods.
std::map< std::string, PointerToMessageBaseNew > m_NewMethods
Map igt message types and the New() static methods of igtl::MessageBase classes.
igtl::MessageBase::Pointer CreateInstance(std::string messageTypeName)
Creates a new message instance fitting to the given type.
void AddMessageType(std::string messageTypeName, IGTLMessageFactory::PointerToMessageBaseNew messageTypeNewPointer, mitk::IGTLMessageCloneHandler::Pointer cloneHandler)
Add message type name and pointer to IGTL message new function and the clone handler.
#define mitkIGTMessageCloneClassMacro(messagetype, classname)
virtual void AddMessageNewMethod(std::string messageTypeName, IGTLMessageFactory::PointerToMessageBaseNew messageTypeNewPointer)
Add message type name and pointer to IGTL message new function Usage: AddMessageType("IMAGE", (PointerToMessageBaseNew)&igtl::ImageMessage::New);.
virtual void AddMessageCloneHandler(std::string msgTypeName, mitk::IGTLMessageCloneHandler::Pointer msgCloneHandler)
Adds a clone function for the specified message type.
igtl::MessageBase::Pointer(* PointerToMessageBaseNew)()
Function pointer for storing New() static methods of igtl::MessageBase classes.
~IGTLMessageFactory() override
virtual mitk::IGTLMessageCloneHandler::Pointer GetCloneHandler(std::string messageTypeName)
Get pointer to message type clone function, or nullptr if the message type is not registered Usage: i...