5.1.5   HGetXLD

HGetXLD (see figure 5.1) is used to access XLD objects in the HALCON database of iconic objects. The object of interest is specified by the database key obj_key. The parameter xld_type allows to specify the kind of XLD data to be accessed: It has to be set to XLD_CONTOUR_ID in case of a contour and to XLD_POLYGON_ID in case of a polygon. Corresponding to the selected type, HGetXLD expects a pointer to Hcont or a pointer to Hpoly in the parameter xld. In both cases not the underlying data within the structures Hcont or Hpoly but only the pointers to the data are copied from the database. Thus, please avoid any write access to this data. Otherwise you will encounter unpredictable side effects (changing other iconic objects). Figure 5.8 shows a simple example for how to use HGetXLD.

Note that HGetXLD automatically checks the result state of the underlying procedure with the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HGetXLD yourself.

    Hkey         obj_key;
    Hcpar        num_points;
    Hcont        *cont;

    HGetObj(proc_handle,par_num,obj_num,&obj_key);
    HGetXLD(proc_handle,obj_key,XLD_CONTOUR_ID,(void*)&cont);

    /* processing (in general this should be done calling an action proc.) */
    num_points.type  = LONG_PAR;
    num_points.par.l = cont->num;
    HPutCPar(proc_handle,1,&num_points,1);

Figure 5.8: Example for HGetXLD: Return the number of points of the contour with the index obj_num within input iconic parameter par_num.