[vtk-developers] vtkVectorOperators

Marcus D. Hanwell marcus.hanwell at kitware.com
Tue Jan 24 08:18:25 EST 2012

On Mon, Jan 23, 2012 at 10:58 AM, David Lonie <loniedavid at gmail.com> wrote:
> On Mon, Jan 23, 2012 at 7:16 AM, Marcus D. Hanwell
> <marcus.hanwell at kitware.com> wrote:
>> Many of these functions are in a separate header, called
>> vtkVectorOperators.h, along with tests in
>> Common/Testing/Cxx/TestVectorOperators.cxx. I think it is missing
>> scalar multiplication, and possible negation (would have to check). As
>> you have everything working without, I can review the branch as is and
>> then perhaps get it using some of the operators again at some point in
>> the future.
> I took a stab at implementing these, but I've run into a
> metaprogramming issue that I'm not familiar with. I've put up a draft
> here:
> https://github.com/dlonie/VTK/commit/674474eabc45f38be7eac1406039326141c059e9
> The trouble seems to be in the macros used to generate the operators
> for the predefined types. I get this rather cryptic compiler error:

As far as I know, compound assignment operators should be member
functions. If that were the case, then most of the other operators
could actually be simplified to re-use that code on the temporary that
is returned. Did you try just implementing the minimal set of missing
operators first?
> Seems like the trouble could be the static cast from vtkVector<Type,
> Size> to vtkVectorXX (see the last line of the compiler snippet), but
> the rest of the output makes no sense to me, so I'm not sure ;-) What
> would be the most efficient way to cast the vtkVector<,> to a
> vtkVectorXX?
 The static_cast is probably not the most efficient way of doing this,
and typedefs would have yielded this behavior in a much more elegant
fashion. I was going to take another look if I ever got the chance, if
the underlying storage is the same (3 floats, 2 doubles etc) then a
reinterpret_cast would be the most efficient method of doing this as
far as I know.


More information about the vtk-developers mailing list