[Insight-users] Adding points to Mesh

Luis Ibanez luis.ibanez at kitware.com
Wed Jul 14 13:54:09 EDT 2004


Hi Martin,

The first template parameter of the itk::Mesh defines the
pixel type to be associated with the Mesh.

Note that regardless of that pixel type an itk::Mesh
*always* has points.

Therefore, you don't need to make your node type to be
the combination of a Point and a CovariantVector. You
just need the CovariantVector because you get the Point
for free as part of the normal itk::Mesh infrastructure.


You should instantiate your Mesh as:

    const unsigned int Dimension = 3;
    typedef itk::CovariantVector<double, Dimension>   Normal3d;
    typedef itk::Mesh< Normal3d, Dimension >          Surface3d;


and insert points like:


    typedef Surface3d::PointType                      Point3d;

    unsigned int i = 0;

    Point3d point;
    point[0] = 13.90;
    point[1] = 46.90;
    point[2] = 89.90;

    Normal3d normal;
    normal[0] = 1.2;
    normal[1] = 1.9;
    normal[2] = 1.5;

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

    surface->SetPoint( i, point );
    surface->SetPointData( i, normal );


Then you will insert the normals by using the
methods for PointData.


Please look at the example in the SoftwareGuide that describes
how to use Normals in an itk::PointSet, which is the parent
class of the itk::Mesh.


      http://www.itk.org/ItkSoftwareGuide.pdf


You will find this example in Section 4.6.2., pdf-page 84.


The associated source code example can be found at:


    Insight/Examples/DataRepresentation/Mesh/
                 PointSetWithCovariantVectors.cxx





   Regards,


      Luis


-------------------
Martin Magnusson wrote:

> 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
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 





More information about the Insight-users mailing list