cemyuksel / cyCodeBase

An open source programming resource intended for graphics programmers.
MIT License
271 stars 60 forks source link

definition of `Vec` conflict with OpenCV's Vec definition #13

Closed xarthurx closed 2 years ago

xarthurx commented 3 years ago

headerA.h:

#include <cyCode/cyPoint.h>

sourceA.cpp:

#include headerA.h

main.h

# use library and func from OpenCV lib
# blabla

Error: image

It seems the definition of cv::Vec is somehow mixed with cy::Vec.

commenting this line: https://github.com/cemyuksel/cyCodeBase/blob/fb063c3532fb7000a6a32c578e6c7285310979d9/cyPoint.h#L48 resolves the problem temporarily.

Is it possible to fix it from the code side?

xarthurx commented 3 years ago

I tried to add one line for cy::Vec before this line: https://github.com/cemyuksel/cyCodeBase/blob/fb063c3532fb7000a6a32c578e6c7285310979d9/cyVector.h#L47 as

template <typename T, int N> class Vec;

But it does not work. My knowledge is a bit limited here...

cemyuksel commented 3 years ago

Namespaces solve such problems. You may need to be specific about the namespace in your code using cy::Vec instead of just Vec. By the way, cyPoint.h is for backward compatibility. You should use cyVector.h instead.

xarthurx commented 3 years ago

Namespaces solve such problems. You may need to be specific about the namespace in your code using cy::Vec instead of just Vec. By the way, cyPoint.h is for backward compatibility. You should use cyVector.h instead.

cyVector.h does not include the type cy::Point3f that is needed by the Poisson Sampling method?

xarthurx commented 3 years ago

Namespaces solve such problems. You may need to be specific about the namespace in your code using cy::Vec instead of just Vec. By the way, cyPoint.h is for backward compatibility. You should use cyVector.h instead.

cyVector.h does not include the type cy::Point3f that is needed by the Poisson Sampling method?

OK, I see it now. I can use the new cy::Vec3f similar to what cy::Point3f. the codebase now use similar terms as the eigen lib, all "point" is treated as "Vector".

However, you may want to change the code snippets in the tutorial here: http://www.cemyuksel.com/cyCodeBase/soln/poisson_disk_sampling.html