LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using "array handle pointer" in a call library node

Hi,

I'm working on Mac Os X and I just wrote a framework for image processing.
I have a function that returns me an array of pointers on arrays of int. Size of arrays can vary.
I'm calling this function through an "interface function" to make it compatible with LV. This interface function is declared like this :

    void border_extract(Image * In,Image * Out,int *** polygones,int ** Nbp,int * NbPoly)

where :
     int ***polygones is the used to get the adresse of the array of pointers on arrays of int.
     int ** Nbp is used to get to number of points of each polygone (to know the sizes of the arrays of int of the polygones)
     int *  NbPoly is the number of polygones in order to know the size of the array of pointers.

I know that my code is working well (I checked that with Xcode debugger).

My problem is to retrieve the data after the call library node (cln), indeed the cln is configured as following :

    for polygones : array handle pointer on int 32;
    for Nbp : array handle on int 32;
    for NbPoly : array data pointer;

The question : How to cast the ***polygones (in labview) to get all the arrays of int?

I hope my question is clear enough.... I thank you for the answers.

Marc
0 Kudos
Message 1 of 3
(3,791 Views)


@MarcC wrote:
Hi,

I'm working on Mac Os X and I just wrote a framework for image processing.
I have a function that returns me an array of pointers on arrays of int. Size of arrays can vary.
I'm calling this function through an "interface function" to make it compatible with LV. This interface function is declared like this :

    void border_extract(Image * In,Image * Out,int *** polygones,int ** Nbp,int * NbPoly)

where :
     int ***polygones is the used to get the adresse of the array of pointers on arrays of int.
     int ** Nbp is used to get to number of points of each polygone (to know the sizes of the arrays of int of the polygones)
     int *  NbPoly is the number of polygones in order to know the size of the array of pointers.

I know that my code is working well (I checked that with Xcode debugger).

My problem is to retrieve the data after the call library node (cln), indeed the cln is configured as following :

    for polygones : array handle pointer on int 32;
    for Nbp : array handle on int 32;
    for NbPoly : array data pointer;

The question : How to cast the ***polygones (in labview) to get all the arrays of int?

I hope my question is clear enough.... I thank you for the answers.

Marc


There is no cast for that. Your configuration really creates something like this:

typedef struct { int32 dimSize; int32 elm[0]} ArrRec, **ArrHandle;

void border_extract(Image * In,Image * Out,ArrHandle *polygones, ArrHandle Nbp,int * NbPoly);

You can clearly see that this is not the same as what you expect. And there is no way to get what you want in the Call Library Node directly. LabVIEW arrays are special things that LabVIEW stores in something called a handle. And an array of arrays will be an array of handles in LabVIEW. LabVIEW handles are something you can not directly interface from other environments as they need to be created, resized and deallocated with LabVIEW specific memory manager functions. In general a handle should be considered private to the environment that created them and can usually not be passed between different code libraries unless they are specifically made to interface with each other.

There are a number of possiblities for you. You can write a function that takes LabVIEW compatible datatypes and configure the CLN node to Adapt to Type. This would probably create an array of array of arrays. A quite interesting construct to go insane on.

Or you can create a function that somehow can return individual sub arrays based on an index passed to it.

Whatever you do, make sure the array is allocated in LabVIEW properly. There is no net or safety line between the LabVIEW diagram and your external code that can magically guess what the external code library might need in terms of memory to write its return information in. As long as you stay in LabVIEW self each LabVIEW node does know how much memory it will need and will allocate this automatically. In C allocation of memory is almost always the responsibility of the caller and here this is the LabVIEW diagram. Yet LabVIEW can not know this so you have to do this on your own.

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(3,772 Views)
Thank you for your answer,

I solved my problem by using indexing of my arrays and I retrieve them one by bone.

Thank you for all your explanations on the handles, now I understand the difference between array in C and array in LV.

Marc
0 Kudos
Message 3 of 3
(3,767 Views)