[vtkusers] problem in using map of structure with VTK library

Mohammad Khatami mdkhatami at gmail.com
Wed Aug 6 09:52:39 EDT 2014


Hi all,
In my program I need to use map<structure, int> in the following way, but
it shows me a conflict between vtkoperator and my structure operator.

struct bin3Dh{
    int fbin;
    int gbin;
    int sbin;
};
inline bool operator>(bin3Dh left, bin3Dh right) {
    if (left.fbin > right.fbin){
        return true;
    }
    else if (left.fbin < right.fbin) {
        return false;
    }
    else if (left.gbin > right.gbin) {
        return true;
    }
    else if (left.gbin < right.gbin) {
        return false;
    }
    else if (left.sbin > right.sbin) {
            return true;
    }
    else if (left.sbin < right.sbin) {
        return false;
    }
    else{
        return false;
    }
}
map<bin3Dh, int> mapHistogram3D;
map<bin3Dh, int>::iterator it;

void create3dh(double f,double g, double s){
    bin3Dh tmphisto;
    tmphisto.fbin=int((f/frange)*256.0);
    tmphisto.gbin=int((g/grange)*256.0);
    tmphisto.sbin=int((s/srange)*256.0);
    if(mapHistogram3D.count(tmphisto)>0){
        it=mapHistogram3D.find(tmphisto);
        it->second++;
    }
    else{
        mapHistogram3D.insert(pair<bin3Dh,int>(tmphisto,1));
    }
}

Do you have any idea about this problem and how can I define operator for
my structure to use in map?

Error list:
 no known conversion for argument 1 from ‘const bin3Dh’ to ‘const
vtkWeakPointerBase&’
   operator op (const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
   ^
note: vtkstd_bool operator<(const vtkWeakPointerBase&, vtkObjectBase*)
   operator op (const vtkWeakPointerBase& l, vtkObjectBase* r) \
   ^
/usr/include/vtk-5.8/vtkWeakPointerBase.h:102:1: note: in expansion of
macro ‘VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR’
 VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(<)

Best Regards,
Mohammad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140806/a9471f86/attachment.html>


More information about the vtkusers mailing list