5.5.11   HPutPElem

Names

    HPutPElem, HPutPPar
    HPutElemH, HPutCPar

Synopsis

    #include "Halcon.h"

    /* --- writing output parameters by reference */
    HPutPElem(      Hproc_handle   proc_handle,
                    int            par,
                    void           *val,
                    INT4_8         num,
                    int            type)

    HPutPPar(       Hproc_handle   proc_handle,
                    int            par,
                    Hcpar          *val,
                    INT4_8         num)

    /* --- writing output parameters by copy */
    HPutElem(       Hproc_handle   proc_handle,
                    int            parnr,
                    void const     *val,
                    INT4_8         num,
                    int            type)

    HPutElemH(      Hproc_handle   proc_handle,
                    int            par,
                    void const     *elem,
                    INT4_8         num,
                    H_HANDLE_TYPE  *HHandleInfo)

    HPutCPar(       Hproc_handle   proc_handle,
                    int            par,
                    Hcpar const    *val,
                    INT4_8         num)

Figure 5.35: Routines for writing control output parameters.

HPutPElem (see figure 5.35) writes a native array to the output control parameter with the index par. val holds the reference to the array of the according type, coded in type (LONG_PAR for arrays of type INT4_8, DOUBLE_PAR, for double, and STRING_PAR for char* arrays). The length of the array is passed in num. Instead of copying the array like HPutElem does, HPutPElem directly stores the pointer to the output control parameter and, thus, causes less overhead. Therefore, this array has to be allocated “permanently”, i.e. it must be allocated by using HAlloc (see section “Permanent Data”). Furthermore, the array must not be freed after passing it to HPutPElem. Figure 5.36 shows how to write output control data with HPutPElem.

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

    double  *d;

    HCkP(HAlloc(proc_handle,sizeof(*d)*2,&d));

    d[0] = 1.2;
    d[1] = 4.4;
    HPutPElem(proc_handle,1,d,2,DOUBLE_PAR);

Figure 5.36: Write the control parameter values [1.2,4.4] using HPutPElem.