[Insight-users] Re: code: ImageToListAdaptor : MembershipSample
Luis Ibanez
luis . ibanez at kitware . com
Tue, 19 Aug 2003 20:59:03 -0400
Hi Zhuang,
Thanks for posting your code.
The variable "Endpoint" seems to be declared correctly,
the problem is probably related to the type definition
of ImageType, and hence "ImageType::IndexType".
If the compiler can't resolve your type "ImageType::IndexType",
it will not declare the variables either.
The problem with "relativespace" is that you are declaring
this variable as
double relativespace[3];
and passing it as parameter to a function that expects
a PixelVectorType which is actually an itk::Vector.
Please use the appropriate type (PixelVectorType) for
declaring the variable, like
PixelVectorType relativespace;
----
About the coding style here are something you may want to
avoid
1) passing std::vectors by copy
this will be slow and memory consuming. you should
rather use "const references". When you pass by copy
the actual vector is replicated in memory, sometimes
more than once.
2) declaring multiple variables in the same line.
This is very error prone and hard to maintain.
It is better to take one line per variable declaration.
You may want to take a look at the document on
coding guidelines available in InsightDocuments.
A lot of suffering can be avoided by following an
organized coding style.
Regards,
Luis
-------------------
zhuang song wrote:
>
>
> Hi Luis,
>
> Thank you very much for your email. It help me a lot. I will read the
> chapter you mentioned. I didn't find it is related before.
> For the type error in my code, I also guess it is a scope problem. I
> posted my code here. I will be very grateful if you will have time to
> check it. The problem is only in the function BSplineOptimization().
>
> Thanks a lot,
> Zhuang
>
>
>