assigning each mesh holes edges to their own array

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2009   #1
assigning each mesh holes edges to their own array

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
__________________
"I keep having this reocurring nightmare, that one of my films opens in an art house theatre" Walt Disney.
 
Old 04 April 2009   #2
Lightbulb

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.....
__________________
"I keep having this reocurring nightmare, that one of my films opens in an art house theatre" Walt Disney.
 
Old 04 April 2009   #3
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;
 }
 
 
Old 04 April 2009   #4
Lightbulb

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.
__________________
"I keep having this reocurring nightmare, that one of my films opens in an art house theatre" Walt Disney.
 
Old 04 April 2009   #5
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;
 }
 
 
Old 04 April 2009   #6
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
__________________
"I keep having this reocurring nightmare, that one of my films opens in an art house theatre" Walt Disney.
 
Old 04 April 2009   #7
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

__________________
http://www.claydough.net

Last edited by claydough : 04 April 2009 at 09:07 AM.
 
Old 04 April 2009   #8
claydough, go the ham fisted cro-mag hack!!

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

Thanks for the help,
__________________
"I keep having this reocurring nightmare, that one of my films opens in an art house theatre" Walt Disney.
 
Old 04 April 2009   #9
Thanks! glad it was helpful.
__________________
http://www.claydough.net
 
Old 04 April 2009   #10
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:03 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.