Max && Min of Attribute

I used to be think like just use the max and min function and you will be ready to go, however i find it more difficult to get the max and max and min of attribute or maybe it’s just the stupid me. anyway recently i find how to get the min and max and here is how:

1 – loop over all point to get the max and min but this some time is really heavy in calculation.

int all = i@numpt;
string attrib = chs("attrib");

float min = point(0, attrib, @ptnum);
float max = point(0, attrib, @ptnum);

for(int pt=0; pt < all; pt++){
    float comper = point(0, attrib, pt);
    
    if(comper < min){
        min = comper;
        }
        else{
            if(comper > max){
                max = comper;
                }
            }
    } 

2 – promote the attribute to detail then import it back to point i find this way more faster in calculation.

setdetailattrib(0, "attrib_min", @attrib, "min");
setdetailattrib(0, "attrib_max", @attrib, "max");
float min = detail(0, "attrib_min", 0);
float max = detail(0, "attrib_max", 0);

3- and if you like VOP there is a way to fit max and min of Attribute inside VOP

  • use attribute promote node to se the max and the min of your attribute
  •  merge the max and min with merge node.
  • copy the max and min with copy attribute node to your geometry.
  • inside VOP import detail attribute min and max and set them as source max and min in fit node and dest min and max as is it 0, 1.
  • export your Attribute or use it inside VOP.

 

that’s all for now please share with me in the comment below if you know better way.

 

 

 

11

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s