PDA

View Full Version : find common edges?



romrom74
12-15-2008, 05:21 AM
hi there,
has someone already coded smthing that could help me with this? I 'd like to select edges wich are common to some selected polygons, as statistic pannel doesn't offer such a functionnality.. i'm already messing with a lscript here where I could retreive point or edges id from selected polygons and test if they're shared (equivalent), but I'm a bit stuck...

faulknermano
12-15-2008, 07:32 PM
i have two versions of this functions. first version:


findCommonEdge: poly1, poly2
{

commonPoints = nil;
if(!poly1 || !poly2)
return(commonPoints);
// get point ids of each poly
for(i=1;i<=polypointcount(poly1);i++)
{
for(j=1;j<=polypointcount(poly2);j++)
{
if(poly1.points[i] == poly2.points[j])
commonPoints[commonPoints.size()+1] = poly1.points[i];
}
}
return(commonPoints);
}


second version. this is the 'ordered version', which means it will ensure that the final selection of points is selected in the order that they get constructed as a polygon facing the correct way.



findCommonEdgeOrdered: poly1, poly2
{
commonPoints = nil;
firstPointMatch = false;
secondPointMatch = false;
// get point ids of each poly
for(i=1;i<=polypointcount(poly1);i++)
{

for(j=1;j<=polypointcount(poly2);j++)
{
if(poly1.points[i] == poly2.points[j])
{
if(i == 1) // first point is a match
firstPointMatch = true;
if(i == 2) // first point is a match
secondPointMatch = true;
commonPoints[commonPoints.size()+1] = poly1.points[i];
}
}
}

if(firstPointMatch == true && secondPointMatch == false)
{
commonPoints[commonPoints.size()+1] = commonPoints[1];
commonPoints[1] = nil;
commonPoints.pack(); commonPoints.trunc();
}

return(commonPoints);
}

romrom74
12-16-2008, 02:25 AM
Well thanks a lot faulknermano ! I'll go with the ordered one and see if I'm able to cook what I've in mind (I'm very new at this lscripting thing!) thx again.
rom