PDA

View Full Version : assigning each mesh holes edges to their own array


biorhythm
04-08-2009, 11:26 AM
Hi,

If a mesh has holes in it, 'polySelectConstraint -m 3 -t 0x8000 -w 1' (followed by 'polySelectConstraint -dis' for convenience) will select all border edges. But what if a mesh has multiple holes, any ideas how the result would be arrays containing the edges for each hole instead of one array with all edges?

Thanks in advance.

Julz

biorhythm
04-08-2009, 01:07 PM
still working at it, this will tell how many holes a mesh has,

polySelectConstraint -m 3 -t 8 -h 0 ;
$selection = `ls -sl` ;
$size=selection($selection) ;
polySelectConstraint -h 0 ;

converting edge selection to verts may help, not sure how though.
ConvertSelectionToVertices ;


anyways.....

goleafsgo
04-08-2009, 02:53 PM
This is probably not the best way to do it but it might get you started...and this might only work in 2009.

Once you have only border edges selected then this will print out each set of edges:


while (0 < size(`ls -sl`))
{
string $edges[] = `ls -sl -fl`;
string $oneBorderEdgeLoop[] = `polySelectSp -q -loop $edges[0]`;

print ("\nSet of edges:\n");
print ($oneBorderEdgeLoop);

select -deselect $oneBorderEdgeLoop;
}

biorhythm
04-08-2009, 05:01 PM
Thanks for the heads up goleafsgo. unfortunately 'polySelectSp' is most likely introduced in 2009, either way its not in 8.5 (yet to upgrade)

though i do have an idea, if a border edge could be known to share a vert with another border edge, then a loop through border edges queering shared verts could be the answer.

still yet to work out how to do that though, any help would be appreciated.

Thanks,

julz.

r4inm4ker
04-09-2009, 07:30 AM
this is the brute force approach, maybe a bit slow, but it should work :



{
polySelectConstraint -m 3 -t 0x8000 -w 1 ;
polySelectConstraint -dis;
$selection = `ls -sl -fl -l` ;

string $borderShell[];
int $borderSize[];
int $currSize=0;
for($currID= 0;$currID<size($selection);$currID++)
{

if($selection[$currID]=="")
continue;

$borderShell[$currSize] = $selection[$currID];


string $tmp[]=`polyListComponentConversion -fe -tv $selection[$currID]`;
string $verts[]=`ls -fl $tmp`;

int $found=0;
int $iter=0;
int $maxIter = 20000;
do
{
$found=0;

for($nID = 0;$nID<size($selection);$nID++)
{
if($selection[$nID]=="")
continue;

if($selection[$nID] == $selection[$currID])
continue;

$tmp=`polyListComponentConversion -fe -tv $selection[$nID]`;
string $nVerts[] = `ls -fl $tmp`;


for($i=0;$i<size($verts);$i++)
{

for($j=0;$j<size($nVerts);$j++)
{
if($verts[$i] == $nVerts[$j])
{
$borderShell[$currSize] = $borderShell[$currSize] + " " + $selection[$nID];
$selection[$currID]="";
$selection[$nID] = "";
$j =!$j;
$verts[$i] = $nVerts[$j];

$found=1;
break;

}
}

if($found)
break;
}
if($found)
break;
}
$iter+=1;
}while($found && $iter<$maxIter);

$currSize+=1;
}
print $borderShell;
}

biorhythm
04-10-2009, 02:07 AM
Thanks for the mel r4inm4ker. I had that theory in mind but was no where near working out how to do. Once again, thanks.

julz

claydough
04-13-2009, 05:24 AM
ham fisted speed hack

1. get size of faces before caveman hole finder
2. caveman hole finder ->
polyCloseBorder "fill holes" ->
( $size after - $original size = "amount of holes" )
string $[] of those new faces

3. from $[] new face:
build and operate on edge array "set"
4. git rid of the cro-magnon evidence. ( Delete supporting history )




{

string $pMesh[] = `filterExpand -sm 12`;

string $allFacesPLCC[] = `polyListComponentConversion -tf $pMesh`;

string $allFaces[] = `filterExpand -sm 34 -expand 1 $allFacesPLCC`;

int $sizeFaceBefore = `size( $allFaces )`;

string $fillHole[] = `polyCloseBorder -name $allFacesPLCC`; // cro-magnon hole finder solution

string $allFacesAfterPLCC[] = `polyListComponentConversion -tf $pMesh`;

string $allFacesAfter[] = `filterExpand -sm 34 -expand 1 $allFacesAfterPLCC`;

int $sizeFaceAfter = `size( $allFacesAfter )`;

int $numberOfHoles = $sizeFaceAfter - $sizeFaceBefore;

for ( $i = $sizeFaceBefore; $i < $sizeFaceAfter; $i++ ){

string $holeEdgesPLCC[] = `polyListComponentConversion -te $allFacesAfter[$i]`;

sets -n cly_trashHoleEdgeSet `filterExpand -sm 32 -expand 1 $holeEdgesPLCC`;

}

// collect and then do something unique to each hole edge set

string $edgeHoleSets[];

string $setCleaner[] = `listSets -allSets`;

for ( $sc in $setCleaner )

if ( `gmatch $sc "cly_trash*"` )

$edgeHoleSets[size($edgeHoleSets)] = $sc;

select -clear;

int $size = 0;

for ( $e in $edgeHoleSets ){

$size += 1;

string $edges[] = `sets -q $e`;

int $edgeSizeOfHole = size(`filterExpand -sm 32 -expand 1 $edges`);

select -add $e;

print ( $edgeSizeOfHole+ " is the number of edges in hole "+ $size+ "\n" );

}

print ( "There are "+ $numberOfHoles+ " Holes\n" );

// end uniqueness

// git rid of the dirty dirty evidence in history

delete $edgeHoleSets $fillHole;

}

//end ( insert applause here )


assuming 1 object. Otherwise add a loop

// result
10 is the number of edges in hole 1

14 is the number of edges in hole 2

12 is the number of edges in hole 3

There are 3 Holes

biorhythm
04-14-2009, 02:19 AM
claydough, go the ham fisted cro-mag hack!!

"//end ( insert applause here );", :applause:

Thanks for the help, :beer:

claydough
04-14-2009, 03:24 AM
:love: Thanks! glad it was helpful.

CGTalk Moderation
04-14-2009, 03:24 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.