[Insight-users] How to create an array of itk::Matrix
Tanweer Rashid
trash001 at odu.edu
Mon Nov 26 18:47:02 EST 2012
Hi,
I am trying to create an array of itk::Matrix. My code is as follows:
typedef itk::Matrix<double, 512, 3> MatrixShapeType;
MatrixShapeType mShapes[10];
for (int i = 0; i < numberOfShapes; i++) {
mShapes[i].Fill(0);
for (int j = 0; j < numberOfPoints; j++) {
typedef itk::PointSet<double, 3> PointSetType;
typedef PointSetType::PointType PointType;
PointType p = s[0]->GetPoint(i);
mShapes[i](j, 0) = p[0];
mShapes[i](j, 1) = p[1];
mShapes[i](j, 2) = p[2];
}
}
cout << mShapes[0] << std::endl;
The error that I keep getting is:
Link:
2> Creating library C:/Users/trash001/Desktop/Simplex
Sphereoids/build/Debug/SimplexSphereoids.lib and object
C:/Users/trash001/Desktop/Simplex
Sphereoids/build/Debug/SimplexSphereoids.exp
2>main.obj : error LNK2019: unresolved external symbol "public: class
vnl_matrix_fixed<double,512,3> & __thiscall
vnl_matrix_fixed<double,512,3>::fill(double)" (?fill@?$vnl_matrix_fixed at N
$0CAA@$02@@QAEAAV1 at N@Z) referenced in function "public: void __thiscall
itk::Matrix<double,512,3>::Fill(double const &)" (?Fill@?$Matrix at N$0CAA@
$02 at itk@@QAEXABN at Z)
2>main.obj : error LNK2019: unresolved external symbol "public: void
__thiscall vnl_matrix_fixed<double,512,3>::print(class
std::basic_ostream<char,struct std::char_traits<char> > &)const " (?print@
?$vnl_matrix_fixed at N$0CAA@$02@@QBEXAAV?$basic_ostream at DU?$char_traits at D@std@
@@std@@@Z) referenced in function "class std::basic_ostream<char,struct
std::char_traits<char> > & __cdecl operator<<<double,512,3>(class
std::basic_ostream<char,struct std::char_traits<char> > &,class
vnl_matrix_fixed<double,512,3> const &)" (??$?6N$0CAA@$02@
@YAAAV?$basic_ostream at DU?$char_traits at D@std@@@std@@AAV01 at ABV
?$vnl_matrix_fixed at N$0CAA@$02@@@Z)
2>C:\Users\trash001\Desktop\Simplex
Sphereoids\build\Debug\SimplexSphereoids.exe : fatal error LNK1120: 2
unresolved externals
2>
2>Build FAILED.
I have tried modifying the matrix example code appropriately, and it works
fine, and gives the expected outputs. That code is as follows:
typedef itk::Matrix<double, 3, 3> MatrixType;
MatrixType M[3];
M[0](0,0) = 1.0;
M[0](0,1) = 2.0;
M[0](0,2) = 3.0;
M[0](1,0) = 4.0;
M[0](1,1) = 5.0;
M[0](1,2) = 6.0;
M[0](2,0) = 7.0;
M[0](2,1) = 8.0;
M[0](2,2) = 9.0;
std::cout << "M: " << M[0] << std::endl;
M[0].Fill(0);
std::cout << "M: " << M[0] << std::endl;
cin.get();
I use MSVS2010, and my CMakeLists.txt is as follows:
# Project Client Server
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT( SimplexSphereoids )
FIND_PACKAGE ( ITK )
IF ( ITK_FOUND )
INCLUDE( ${USE_ITK_FILE} )
ENDIF( ITK_FOUND )
FIND_PACKAGE ( VTK )
IF ( VTK_FOUND )
INCLUDE( ${USE_VTK_FILE} )
ENDIF( VTK_FOUND )
INCLUDE_DIRECTORIES(${SimplexSphereoids_SOURCE_DIR})
ADD_EXECUTABLE( SimplexSphereoids main.cpp )
TARGET_LINK_LIBRARIES ( SimplexSphereoids ${ITK_LIBRARIES} ${VTK_LIBRARIES})
- - - Thanks,
--
Tanweer Rashid
MSVE Dept.
Old Dominion University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121126/5c60c953/attachment.htm>
More information about the Insight-users
mailing list