Ali Al-Tobi

altobi

About Me

EXPERTISE
Technical Director
INDUSTRY
Film/TV

Connect

LOCATION
United Kingdom
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Vulkan Viewport and macOS silicon ? July 11, 2024, 2:47 p.m.

Yea I'm very disappointed in the lack of support for Apple Silicon..

find primitive neighbours? Dec. 17, 2019, 6:58 a.m.

I wrote a solution for this over in this thread:

https://www.sidefx.com/forum/topic/70966/?page=1#post-301099 [www.sidefx.com]

VEX primitive neighbours function Dec. 11, 2019, 10:40 a.m.

Hi wizards,

Here's a VEX function to get primitive neighbours either by shared points or by shared edges. Use the type function input for the two different methods (0 points, 1 edges);

function int []primneighbours (int geometry; int prim; int type)
{

    int primPts[] = primpoints(geometry, prim);
    int nearPrims[];
    int sharedPrims[];
    
    // Find primitives attached to the input primitive-points
    foreach(int num; int pt; primPts)
    {
        int ptPrims[] = pointprims(geometry, pt);
        
        foreach(int num1; int ptPrim; ptPrims)
        {
            int used = 0;
            
            foreach(int num2; int usedPrim; nearPrims)
            {
                if(usedPrim == ptPrim)
                {
                    used = 1;
                }
            }
            
            if(used == 0)
            {
                append(nearPrims, ptPrim);
            }
        }
    }
    
    // Find primitives sharing the two or more points with the input primitive
    foreach(int num3; int nearPrim; nearPrims)
    {
        int tempPrimPts[] = primpoints(geometry, nearPrim);
        int similarPts = 0;
        
        foreach(int num4; int tempPrimPt; tempPrimPts)
        {
            foreach(int num5; int primPt; primPts)
            {
                if(tempPrimPt == primPt)
                {
                    similarPts++;
                }
            }
        }
        
        if(similarPts > 1)
        {
            append(sharedPrims, nearPrim);
        }
    }
    
    // Return based on input type
    if(type > 0)
    {
        return sharedPrims;
    }
    else
    {
        return nearPrims;
    }
}


Use the function like this (outside the function itself):
int neigh[] = primneighbours(0, @primnum, 1);


Grouping neighbours example:

int neigh[] = primneighbours(0, 70, 1);
foreach(int num; int prim; neigh)
{
    setprimgroup(0, "nearPrims", prim, 1, "set");
}


Enjoy!