Skip to content

Commit

Permalink
Merge pull request #217 from leochan2009/master
Browse files Browse the repository at this point in the history
FEATURE: user has the temptation to reuse the Messages, this commit f…
  • Loading branch information
tokjun authored Oct 23, 2019
2 parents eb71a36 + 0c0a09a commit 67ee4ac
Show file tree
Hide file tree
Showing 25 changed files with 340 additions and 15 deletions.
1 change: 0 additions & 1 deletion Examples/Tracker/TrackerClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ int main(int argc, char* argv[])
igtl::Matrix4x4 matrix;
GetRandomTestMatrix(matrix);
ts->GetTime();
transMsg->InitPack();
transMsg->SetMatrix(matrix);
transMsg->SetTimeStamp(ts);
transMsg->Pack();
Expand Down
1 change: 0 additions & 1 deletion Examples/Tracker/TrackerClient2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ int main(int argc, char* argv[])
float quaternion[4];

GetRandomTestVectors(position, quaternion);
positionMsg->InitPack();
positionMsg->SetPosition(position);
positionMsg->SetQuaternion(quaternion);
positionMsg->Pack();
Expand Down
1 change: 0 additions & 1 deletion Examples/Tracker/TrackerClient3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ int main(int argc, char* argv[])
{
for (int i = 0; i < numdev; i ++)
{
transMsg->InitPack();
transMsg->SetDeviceName(devicename[i]);
igtl::Matrix4x4 matrix;
GetRandomTestMatrix(matrix, phi[i], theta[i]);
Expand Down
1 change: 0 additions & 1 deletion Examples/Tracker/TrackerServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ int main(int argc, char* argv[])
{
igtl::Matrix4x4 matrix;
GetRandomTestMatrix(matrix);
transMsg->InitPack();
transMsg->SetDeviceName("Tracker");
transMsg->SetMatrix(matrix);
transMsg->Pack();
Expand Down
7 changes: 6 additions & 1 deletion Source/igtlBindMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void BindMessageBase::Init()

int BindMessageBase::SetNumberOfChildMessages(unsigned int n)
{
m_IsBodyPacked = false;
this->m_ChildMessages.resize(n);
return this->m_ChildMessages.size();
}
Expand All @@ -57,6 +58,7 @@ int BindMessageBase::AppendChildMessage(igtl::MessageBase * child)
{
if (this->m_ChildMessages.size() < 0xFFFF)
{
m_IsBodyPacked = false;
ChildMessageInfo info;
#if OpenIGTLink_HEADER_VERSION >= 2
info.type = child->GetMessageType();
Expand All @@ -81,6 +83,7 @@ int BindMessageBase::SetChildMessage(unsigned int i, igtl::MessageBase * child)
{
if (i < this->m_ChildMessages.size())
{
m_IsBodyPacked = false;
#if OpenIGTLink_HEADER_VERSION >= 2
this->m_ChildMessages[i].type = child->GetMessageType();
#else
Expand Down Expand Up @@ -300,6 +303,7 @@ int GetBindMessage::AppendChildMessage(const char * type, const char * name)
if (strlen(type) < IGTL_HEADER_TYPE_SIZE &&
strlen(name) < IGTL_HEADER_NAME_SIZE)
{
m_IsBodyPacked = false;
BindMessageBase::ChildMessageInfo info;
info.type = type;
info.name = name;
Expand Down Expand Up @@ -408,6 +412,7 @@ StartBindMessage::~StartBindMessage()

void StartBindMessage::SetResolution(igtlUint64 res)
{
m_IsBodyPacked = false;
this->m_Resolution = res;
}

Expand Down Expand Up @@ -534,4 +539,4 @@ int RTSBindMessage::UnpackContent()



} // namespace igtl
} // namespace igtl
4 changes: 3 additions & 1 deletion Source/igtlCapabilityMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CapabilityMessage::~CapabilityMessage()

void CapabilityMessage::SetTypes(std::vector<std::string> types)
{
m_IsBodyPacked = false;
this->m_TypeNames.clear();
this->m_TypeNames = types;
}
Expand All @@ -61,6 +62,7 @@ int CapabilityMessage::SetType(int id, const char* type)
{
if (id < (int)this->m_TypeNames.size() && strlen(type) < IGTL_HEADER_TYPE_SIZE)
{
m_IsBodyPacked = false;
this->m_TypeNames[id] = type;
return 1;
}
Expand Down Expand Up @@ -152,4 +154,4 @@ int CapabilityMessage::UnpackContent()
}


} // namespace igtl
} // namespace igtl
7 changes: 7 additions & 0 deletions Source/igtlCommandMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ CommandMessage::~CommandMessage()

int CommandMessage::SetCommandId(igtlUint32 aId)
{
m_IsBodyPacked = false;
this->m_CommandId = aId;
return 1;
}
Expand All @@ -75,6 +76,7 @@ int CommandMessage::SetCommandName(const char* aCommandName)
{
return 0;
}
m_IsBodyPacked = false;
strcpy((char*)m_CommandName, aCommandName);
return 1;
}
Expand All @@ -92,6 +94,7 @@ int CommandMessage::SetCommandContent(const char* string)
{
return 0;
}
m_IsBodyPacked = false;
this->m_Command = string;
return (int) this->m_Command.length();
}
Expand All @@ -103,6 +106,7 @@ int CommandMessage::SetCommandContent(const std::string & string)
{
return 0;
}
m_IsBodyPacked = false;
this->m_Command = string;
return (int) this->m_Command.length();
}
Expand All @@ -114,6 +118,7 @@ int CommandMessage::SetContentEncoding(igtlUint16 enc)
{
return 0;
}
m_IsBodyPacked = false;
this->m_Encoding = enc;
return 1;
}
Expand Down Expand Up @@ -218,6 +223,7 @@ int RTSCommandMessage::SetCommandErrorString(const char* anErrorString)
{
return 0;
}
m_IsBodyPacked = false;
strcpy((char*)m_CommandName, anErrorString);
return 1;
}
Expand All @@ -229,6 +235,7 @@ int RTSCommandMessage::SetCommandErrorString(const std::string& anErrorString)
{
return 0;
}
m_IsBodyPacked = false;
strcpy((char*)m_CommandName, anErrorString.c_str());
return 1;
}
Expand Down
11 changes: 11 additions & 0 deletions Source/igtlImageMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ImageMessage::~ImageMessage()

void ImageMessage::SetDimensions(int s[3])
{
m_IsBodyPacked = false;
dimensions[0] = s[0];
dimensions[1] = s[1];
dimensions[2] = s[2];
Expand All @@ -82,6 +83,7 @@ void ImageMessage::SetDimensions(int s[3])

void ImageMessage::SetDimensions(int i, int j, int k)
{
m_IsBodyPacked = false;
dimensions[0] = i;
dimensions[1] = j;
dimensions[2] = k;
Expand Down Expand Up @@ -116,6 +118,7 @@ int ImageMessage::SetSubVolume(int dim[3], int off[3])
off[1] + dim[1] <= dimensions[1] &&
off[2] + dim[2] <= dimensions[2])
{
m_IsBodyPacked = false;
subDimensions[0] = dim[0];
subDimensions[1] = dim[1];
subDimensions[2] = dim[2];
Expand All @@ -137,6 +140,7 @@ int ImageMessage::SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj,
offj + dimj <= dimensions[1] &&
offk + dimk <= dimensions[2])
{
m_IsBodyPacked = false;
subDimensions[0] = dimi;
subDimensions[1] = dimj;
subDimensions[2] = dimk;
Expand Down Expand Up @@ -175,13 +179,15 @@ void ImageMessage::GetSubVolume(int &dimi, int &dimj, int &dimk,

void ImageMessage::SetSpacing(float s[3])
{
m_IsBodyPacked = false;
spacing[0] = s[0];
spacing[1] = s[1];
spacing[2] = s[2];
}

void ImageMessage::SetSpacing(float si, float sj, float sk)
{
m_IsBodyPacked = false;
spacing[0] = si;
spacing[1] = sj;
spacing[2] = sk;
Expand All @@ -203,13 +209,15 @@ void ImageMessage::GetSpacing(float &si, float &sj, float &sk)

void ImageMessage::SetOrigin(float p[3])
{
m_IsBodyPacked = false;
matrix[0][3] = p[0];
matrix[1][3] = p[1];
matrix[2][3] = p[2];
}

void ImageMessage::SetOrigin(float px, float py, float pz)
{
m_IsBodyPacked = false;
matrix[0][3] = px;
matrix[1][3] = py;
matrix[2][3] = pz;
Expand All @@ -231,6 +239,7 @@ void ImageMessage::GetOrigin(float &px, float &py, float &pz)

void ImageMessage::SetNormals(float o[3][3])
{
m_IsBodyPacked = false;
matrix[0][0] = o[0][0];
matrix[0][1] = o[0][1];
matrix[0][2] = o[0][2];
Expand All @@ -244,6 +253,7 @@ void ImageMessage::SetNormals(float o[3][3])

void ImageMessage::SetNormals(float t[3], float s[3], float n[3])
{
m_IsBodyPacked = false;
matrix[0][0] = t[0];
matrix[1][0] = t[1];
matrix[2][0] = t[2];
Expand Down Expand Up @@ -283,6 +293,7 @@ void ImageMessage::GetNormals(float t[3], float s[3], float n[3])

void ImageMessage::SetMatrix(Matrix4x4& mat)
{
m_IsBodyPacked = false;
matrix[0][0] = mat[0][0];
matrix[1][0] = mat[1][0];
matrix[2][0] = mat[2][0];
Expand Down
11 changes: 11 additions & 0 deletions Source/igtlImageMessage2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ ImageMessage2::~ImageMessage2()

void ImageMessage2::SetDimensions(int s[3])
{
m_IsBodyPacked = false;
dimensions[0] = s[0];
dimensions[1] = s[1];
dimensions[2] = s[2];
Expand All @@ -116,6 +117,7 @@ void ImageMessage2::SetDimensions(int s[3])

void ImageMessage2::SetDimensions(int i, int j, int k)
{
m_IsBodyPacked = false;
dimensions[0] = i;
dimensions[1] = j;
dimensions[2] = k;
Expand Down Expand Up @@ -150,6 +152,7 @@ int ImageMessage2::SetSubVolume(int dim[3], int off[3])
off[1] + dim[1] <= dimensions[1] &&
off[2] + dim[2] <= dimensions[2])
{
m_IsBodyPacked = false;
subDimensions[0] = dim[0];
subDimensions[1] = dim[1];
subDimensions[2] = dim[2];
Expand All @@ -171,6 +174,7 @@ int ImageMessage2::SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj
offj + dimj <= dimensions[1] &&
offk + dimk <= dimensions[2])
{
m_IsBodyPacked = false;
subDimensions[0] = dimi;
subDimensions[1] = dimj;
subDimensions[2] = dimk;
Expand Down Expand Up @@ -209,13 +213,15 @@ void ImageMessage2::GetSubVolume(int &dimi, int &dimj, int &dimk,

void ImageMessage2::SetSpacing(float s[3])
{
m_IsBodyPacked = false;
spacing[0] = s[0];
spacing[1] = s[1];
spacing[2] = s[2];
}

void ImageMessage2::SetSpacing(float si, float sj, float sk)
{
m_IsBodyPacked = false;
spacing[0] = si;
spacing[1] = sj;
spacing[2] = sk;
Expand All @@ -237,13 +243,15 @@ void ImageMessage2::GetSpacing(float &si, float &sj, float &sk)

void ImageMessage2::SetOrigin(float p[3])
{
m_IsBodyPacked = false;
matrix[0][3] = p[0];
matrix[1][3] = p[1];
matrix[2][3] = p[2];
}

void ImageMessage2::SetOrigin(float px, float py, float pz)
{
m_IsBodyPacked = false;
matrix[0][3] = px;
matrix[1][3] = py;
matrix[2][3] = pz;
Expand All @@ -265,6 +273,7 @@ void ImageMessage2::GetOrigin(float &px, float &py, float &pz)

void ImageMessage2::SetNormals(float o[3][3])
{
m_IsBodyPacked = false;
matrix[0][0] = o[0][0];
matrix[0][1] = o[0][1];
matrix[0][2] = o[0][2];
Expand All @@ -278,6 +287,7 @@ void ImageMessage2::SetNormals(float o[3][3])

void ImageMessage2::SetNormals(float t[3], float s[3], float n[3])
{
m_IsBodyPacked = false;
matrix[0][0] = t[0];
matrix[1][0] = t[1];
matrix[2][0] = t[2];
Expand Down Expand Up @@ -317,6 +327,7 @@ void ImageMessage2::GetNormals(float t[3], float s[3], float n[3])

void ImageMessage2::SetMatrix(Matrix4x4& mat)
{
m_IsBodyPacked = false;
matrix[0][0] = mat[0][0];
matrix[1][0] = mat[1][0];
matrix[2][0] = mat[2][0];
Expand Down
3 changes: 2 additions & 1 deletion Source/igtlImageMetaMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ ImageMetaMessage::~ImageMetaMessage()

int ImageMetaMessage::AddImageMetaElement(ImageMetaElement::Pointer& elem)
{
m_IsBodyPacked = false;
this->m_ImageMetaList.push_back(elem);
return this->m_ImageMetaList.size();
}
Expand Down Expand Up @@ -330,4 +331,4 @@ int ImageMetaMessage::UnpackContent()
return 1;
}

} // namespace igtl
} // namespace igtl
3 changes: 2 additions & 1 deletion Source/igtlLabelMetaMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ LabelMetaMessage::~LabelMetaMessage()

int LabelMetaMessage::AddLabelMetaElement(LabelMetaElement::Pointer& elem)
{
m_IsBodyPacked = false;
this->m_LabelMetaList.push_back(elem);
return this->m_LabelMetaList.size();
}
Expand Down Expand Up @@ -295,4 +296,4 @@ int LabelMetaMessage::UnpackContent()
return 1;
}

} // namespace igtl
} // namespace igtl
3 changes: 2 additions & 1 deletion Source/igtlNDArrayMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ NDArrayMessage::~NDArrayMessage()

int NDArrayMessage::SetArray(int type, ArrayBase * a)
{
m_IsBodyPacked = false;
// Check if type is valid
if (type < 2 || type > 13 ||
type == 8 || type == 9 || type == 12)
Expand Down Expand Up @@ -287,4 +288,4 @@ int NDArrayMessage::UnpackContent()
return 1;
}

} // namespace igtl
} // namespace igtl
3 changes: 2 additions & 1 deletion Source/igtlPointMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ PointMessage::~PointMessage()

int PointMessage::AddPointElement(PointElement::Pointer& elem)
{
m_IsBodyPacked = false;
this->m_PointList.push_back(elem);
return this->m_PointList.size();
}
Expand Down Expand Up @@ -296,4 +297,4 @@ int PointMessage::UnpackContent()
return 1;
}

} // namespace igtl
} // namespace igtl
Loading

0 comments on commit 67ee4ac

Please sign in to comment.