VEX array of structs

   2970   1   0
User Avatar
Member
1 posts
Joined: Oct. 2016
Offline
Hello,

I'm a newbie with vex and I'm trying to create an array of structs in a wrangle node. I defined the struct in the outer code section as suggested here [forums.odforce.net].

my struct looks like this

struct node {
int pt;
int nbrs[];
}

After defining the struct, I have the following as VEX expression

node nd;
node array[];

// let's say we initialized the nd fields to some values

int pt = nd.pt; //works fine
int nbrs[] = nd.nbrs; //works fine

array[0] = nd; //seems to work fine
pt = array[0].pt; //nope
nd = array[0]; //nope

How do I handle situation like this one? Am I missing something on how to use struct in VEX?
Basically I cannot access the content of my array.

When I say it doesn't work I mean that the node turns red and throws an error

Error

The sub-network output operator failed to cook: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1

Warning: Errors or warnings encountered during VEX compile:

/obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1: Internal compiler error. (15,1).

Errors or warnings encountered during VEX compile:

/obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1: Internal compiler error. (15,1).

Error: Vex error: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1: Internal compiler error. (15,1)

Failed to resolve VEX code op: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1

Unable to load shader ‘op: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1’.

Warning

Errors or warnings encountered during VEX compile:

/obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1: Internal compiler error. (15,1).

Warning

Errors or warnings encountered during VEX compile:

/obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1: Internal compiler error. (15,1).

Warning

Vex error: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1: Internal compiler error. (15,1)

Failed to resolve VEX code op: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1

Unable to load shader ‘op: /obj/new_version/tree/growing_alg/find_neighbour/outer_code/attribvop1’

Any ideas?

Thank you!
User Avatar
Member
2164 posts
Joined: Sept. 2015
Offline
What I do is save an external text file with the struct code defined and use the include directive to reference it like:

#Include <C:/My External Vex files/My_Structures.h>

I noticed the issue a while back that you speak of, although I did mention it to support I don't remember if it was in the form of a bug/rfe or as an offhand comment with another bug/rfe.

Either way I tend to externalize all my vex code like functions/strucs in text files. Makes it much easier to read the various wrangles in my network.

But maybe you could submit a bug report - as it would be usefull to be able to just define the struc right in the wrangle itself.

Edit: I'm saying this not having looked at your code, because it was definitely an issue with the simplest defined structures, like only using ints and floats.

I see in your code though that one of your items is an array.

In Houdini arrays of arrays are not supported. So what I suspect is happening in this case is that your accessing an array within a struct - essentialy a heirarchy like an array of array - whereas your test assignment is simply acessing the array on the same ‘level’ eg. "array = nd; //seems to work fine"
Edited by BabaJ - Aug. 8, 2017 12:17:29
  • Quick Links