[Insight-users] Adding points to Mesh

Martin Magnusson martin.magnusson at aass.oru.se
Wed Jul 14 10:12:10 EDT 2004


I'm trying to create a Mesh with points which are not just float values, 
but I've run into problems. I hate to say this, but I don't quite 
understand how to add points to the mesh. Judging from the examples in 
the user guide, I would have thought that something like below should 
work, but it doesn't (see error message at bottom).

////test-itk-mini.cpp////////////////////////////////////////////

#include "itkSurfaceSpatialObjectPoint.h"
#include "itkMesh.h"
#include <iostream>
#include <string>

int main( int argc, char **argv )
{
   // Convenience typedefs:
   typedef itk::SurfaceSpatialObjectPoint<3> Vertex3d;
   typedef itk::CovariantVector<double, 3>   Normal3d;
   typedef itk::Mesh< Vertex3d, 1 >          Surface3d;

   Surface3d::Pointer surface = Surface3d::New();

   // Create vertices:
   for (int i = 0; i < 25; ++i)
     {
       Surface3d::PointType v;
       v[0].SetPosition( i, i, i );
       double n_tmp[3] = {i, i, i};
       itk::CovariantVector<double, 3> n( n_tmp );
       n = n / n.GetNorm();
       v[0].SetNormal( n );
       surface->SetPoint( i, v );
     }

   return 0;
}

////////////////////////////////////////////////////////////////

/home/martin/source/test/test-itk-mini.cpp: In function `int main(int,
    char**)':

/home/martin/source/test/test-itk-mini.cpp:19: request for member 
`SetPosition' in `(&v)->itk::FixedArray<TValueType, 
VLength>::operator[](int) [with TValueType = float, unsigned int VLength 
= 1](0)', which is of non-aggregate type `float'

/home/martin/source/test/test-itk-mini.cpp:23: request for member 
`SetNormal' in `(&v)->itk::FixedArray<TValueType, 
VLength>::operator[](int) [with TValueType = float, unsigned int VLength 
= 1](0)', which is of non-aggregate type `float'

make[1]: *** [test-itk-mini.o] Error 1
make: *** [default_target] Error 2



More information about the Insight-users mailing list