c++ - template functions for points with x,y,z and points with x(), y(), z() -


i work lot point clouds, , use lot pcl , eigen libraries. points in pcl have .x .y , .z public members. points in eigen have .x() .y() , .z()

i find myself writing function 1 point type , calling creating temp point convert 1 type other:

e.g.

void f(const eigen::vector3d &p) { ... } pcl::pointxyz p; f(eigen::vector3d(p.x, p.y, p.z); 

to further complicate problem, pcl points come in various types: xyz, xyzrgb, xyzn, etc. (see http://pointclouds.org/documentation/tutorials/adding_custom_ptype.php) , eigen vectors come in several types well: vector3d doubles , vecto3f floats, both specialization of matrix type (see http://eigen.tuxfamily.org/dox/group__matrixtypedefs.html)

i wondering if there template specialization magic incantation invoked avoid that, i.e. detect whether point type has .x() or .x , use appropriately.

if don't want fuss around sfinae, can use nice built in maps in pcl , use eigen cast function

instead of constructing eigen::vector3d type , passing f(), following

pcl::pointxyz p; f(p.getvector3fmap().cast<double>); 

getvector3fmap() available built in pcl types.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -