Skip to content

Commit

Permalink
Merge pull request #138 from tokjun/apply-vtk-indent-style
Browse files Browse the repository at this point in the history
Apply VTK indent style.
  • Loading branch information
leochan2009 authored Jun 28, 2017
2 parents 5a1bd33 + 05d31ec commit 92bc3d7
Show file tree
Hide file tree
Showing 42 changed files with 3,857 additions and 3,819 deletions.
44 changes: 24 additions & 20 deletions Source/igtlCommandMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,30 @@

namespace
{
bool isEncodingValid(int encoding)
{
for( int i = 0; i < NUM_ENCODINGS-1; ++i )

bool isEncodingValid(int encoding)
{
for( int i = 0; i < NUM_ENCODINGS-1; ++i )
{
if( encoding == igtl::CommandMessage::validEncodings[i] )
if( encoding == igtl::CommandMessage::validEncodings[i] )
{
return true;
return true;
}
}
return false;
}
return false;
}

}


namespace igtl {

const int CommandMessage::validEncodings[NUM_ENCODINGS] = {3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,109,110,111,112,113,114,115,116,117,118,119,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2011,2044,2045,2010,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2081,2082,2083,2084,2085,2086,2087,2088,2089,2090,2091,2092,2093,2094,2095,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2250,2251,2252,2253,2254,2255,2256,2257,2258,2259,2260};

CommandMessage::CommandMessage()
: MessageBase()
, m_CommandId(0)
, m_Encoding(3)
, m_CommandId(0)
, m_Encoding(3)
{
memset(m_CommandName, 0, IGTL_COMMAND_NAME_SIZE);
this->m_HeaderVersion = IGTL_HEADER_VERSION_2;
Expand All @@ -56,8 +60,8 @@ CommandMessage::CommandMessage()
CommandMessage::~CommandMessage()
{
}


int CommandMessage::SetCommandId(igtlUint32 aId)
{
this->m_CommandId = aId;
Expand All @@ -68,9 +72,9 @@ int CommandMessage::SetCommandId(igtlUint32 aId)
int CommandMessage::SetCommandName(const char* aCommandName)
{
if (strlen(aCommandName) > IGTL_COMMAND_NAME_SIZE) /* If the length is beyond the range specified by the spec */
{
{
return 0;
}
}
strcpy((char*)m_CommandName, aCommandName);
return 1;
}
Expand Down Expand Up @@ -107,9 +111,9 @@ int CommandMessage::SetCommandContent(const std::string & string)
int CommandMessage::SetContentEncoding(igtlUint16 enc)
{
if( !isEncodingValid(enc) )
{
{
return 0;
}
}
this->m_Encoding = enc;
return 1;
}
Expand Down Expand Up @@ -211,9 +215,9 @@ int CommandMessage::UnpackContent()
int RTSCommandMessage::SetCommandErrorString(const char* anErrorString)
{
if (strlen(anErrorString) > IGTL_COMMAND_NAME_SIZE) /* If the length is beyond the range specified by the spec */
{
{
return 0;
}
}
strcpy((char*)m_CommandName, anErrorString);
return 1;
}
Expand All @@ -222,9 +226,9 @@ int RTSCommandMessage::SetCommandErrorString(const char* anErrorString)
int RTSCommandMessage::SetCommandErrorString(const std::string& anErrorString)
{
if( anErrorString.length() > IGTL_COMMAND_NAME_SIZE )
{
{
return 0;
}
}
strcpy((char*)m_CommandName, anErrorString.c_str());
return 1;
}
Expand All @@ -248,4 +252,4 @@ RTSCommandMessage::~RTSCommandMessage()

}

} // namespace igtl
} // namespace igtl
136 changes: 69 additions & 67 deletions Source/igtlImageMessage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ ImageMessage::ImageMessage():
{
for (int i = 0; i < 3; i ++)
{
dimensions[i] = 0;
spacing[i] = 0.0;
subDimensions[i] = 0;
subOffset[i] = 0;
dimensions[i] = 0;
spacing[i] = 0.0;
subDimensions[i] = 0;
subOffset[i] = 0;
}
for (int i = 0; i < 4; i ++)
{
for (int j = 0; j < 4; j ++)
{
matrix[i][j] = (i == j ? 1.0 : 0.0);
}
for (int j = 0; j < 4; j ++)
{
matrix[i][j] = (i == j ? 1.0 : 0.0);
}
}

endian = ENDIAN_BIG;
Expand Down Expand Up @@ -116,17 +116,17 @@ int ImageMessage::SetSubVolume(int dim[3], int off[3])
off[1] + dim[1] <= dimensions[1] &&
off[2] + dim[2] <= dimensions[2])
{
subDimensions[0] = dim[0];
subDimensions[1] = dim[1];
subDimensions[2] = dim[2];
subOffset[0] = off[0];
subOffset[1] = off[1];
subOffset[2] = off[2];
return 1;
subDimensions[0] = dim[0];
subDimensions[1] = dim[1];
subDimensions[2] = dim[2];
subOffset[0] = off[0];
subOffset[1] = off[1];
subOffset[2] = off[2];
return 1;
}
else
{
return 0;
return 0;
}
}

Expand All @@ -137,17 +137,17 @@ int ImageMessage::SetSubVolume(int dimi, int dimj, int dimk, int offi, int offj,
offj + dimj <= dimensions[1] &&
offk + dimk <= dimensions[2])
{
subDimensions[0] = dimi;
subDimensions[1] = dimj;
subDimensions[2] = dimk;
subOffset[0] = offi;
subOffset[1] = offj;
subOffset[2] = offk;
return 1;
subDimensions[0] = dimi;
subDimensions[1] = dimj;
subDimensions[2] = dimk;
subOffset[0] = offi;
subOffset[1] = offj;
subOffset[2] = offk;
return 1;
}
else
{
return 0;
return 0;
}
}

Expand Down Expand Up @@ -378,12 +378,13 @@ int ImageMessage::PackContent()
float norm_j[3];
float norm_k[3];

for (int i = 0; i < 3; i ++) {
for (int i = 0; i < 3; i ++)
{
norm_i[i] = matrix[i][0];
norm_j[i] = matrix[i][1];
norm_k[i] = matrix[i][2];
origin[i] = matrix[i][3];
}
}

igtl_image_set_matrix(this->spacing, origin,
norm_i, norm_j, norm_k,
Expand All @@ -408,53 +409,54 @@ int ImageMessage::UnpackContent()

if (image_header->header_version == IGTL_IMAGE_HEADER_VERSION)
{
// Image format version 1
this->scalarType = image_header->scalar_type;
this->numComponents = image_header->num_components;
this->endian = image_header->endian;
this->coordinate = image_header->coord;
this->dimensions[0] = image_header->size[0];
this->dimensions[1] = image_header->size[1];
this->dimensions[2] = image_header->size[2];
this->subOffset[0] = image_header->subvol_offset[0];
this->subOffset[1] = image_header->subvol_offset[1];
this->subOffset[2] = image_header->subvol_offset[2];
this->subDimensions[0] = image_header->subvol_size[0];
this->subDimensions[1] = image_header->subvol_size[1];
this->subDimensions[2] = image_header->subvol_size[2];

// Set image orientation
float rspacing[3];
float origin[3];
float norm_i[3];
float norm_j[3];
float norm_k[3];

igtl_image_get_matrix(rspacing, origin,
norm_i, norm_j, norm_k,
image_header);

for (int i = 0; i < 3; i ++) {
this->spacing[i] = rspacing[i];
matrix[i][0] = norm_i[i];
matrix[i][1] = norm_j[i];
matrix[i][2] = norm_k[i];
matrix[i][3] = origin[i];
// Image format version 1
this->scalarType = image_header->scalar_type;
this->numComponents = image_header->num_components;
this->endian = image_header->endian;
this->coordinate = image_header->coord;
this->dimensions[0] = image_header->size[0];
this->dimensions[1] = image_header->size[1];
this->dimensions[2] = image_header->size[2];
this->subOffset[0] = image_header->subvol_offset[0];
this->subOffset[1] = image_header->subvol_offset[1];
this->subOffset[2] = image_header->subvol_offset[2];
this->subDimensions[0] = image_header->subvol_size[0];
this->subDimensions[1] = image_header->subvol_size[1];
this->subDimensions[2] = image_header->subvol_size[2];

// Set image orientation
float rspacing[3];
float origin[3];
float norm_i[3];
float norm_j[3];
float norm_k[3];

igtl_image_get_matrix(rspacing, origin,
norm_i, norm_j, norm_k,
image_header);

for (int i = 0; i < 3; i ++)
{
this->spacing[i] = rspacing[i];
matrix[i][0] = norm_i[i];
matrix[i][1] = norm_j[i];
matrix[i][2] = norm_k[i];
matrix[i][3] = origin[i];
}

matrix[3][0] = 0.0;
matrix[3][1] = 0.0;
matrix[3][2] = 0.0;
matrix[3][3] = 1.0;
matrix[3][0] = 0.0;
matrix[3][1] = 0.0;
matrix[3][2] = 0.0;
matrix[3][3] = 1.0;

m_Image = &m_ImageHeader[IGTL_IMAGE_HEADER_SIZE];
m_Image = &m_ImageHeader[IGTL_IMAGE_HEADER_SIZE];

return 1;
return 1;
}
else
{
// Incompatible version.
return 0;
// Incompatible version.
return 0;
}
}

Expand All @@ -473,4 +475,4 @@ int ImageMessage::GetNumComponents()
}


} // namespace igtl
} // namespace igtl
Loading

0 comments on commit 92bc3d7

Please sign in to comment.