So case 1, everone is entitled with a wish its snother thing if its detactable! but sure i can show you how to go about this stuff.
Well thing is its not so easy to figure out wich vert is extra. you could deleta all freestanding verts by simply selecting all verts and hitting delete.
HOWEVER! This deletes all freestanding vertexes (a freestanding vertecx is one that has only 2 incomming connections), this means if your example was a plane it would also delete the corner. Beacsue teh corner is also freestanding.
Theres realy no way of detecting wether the freestanding vertex actualy is part of the shape or not unless you can pick all those freestanding that arent foree standing manualy.
Therews a partial solution available and that asumes those extra verts dont change the shape and are truly only extra. unfortunately theres no guarantee they realy are the only extra ones. They are just the only extra ones thet are guaranteed not to have impoct on the shape.
imageine the following shape.
//lets create a plane because it has preestanding corners.
polyPlane -w 1 -h 1 -sx 10 -sy 10 -ax 0 1 0 -tx 1 -ch 1;
//lets create some inperfections
//2 easily detectable ones
polySplit -ch on -s 1 -sma 0 -ep 85 0.5 pPlaneShape1 ;
polySplit -ch on -s 1 -sma 0 -ep 32 0.382542 pPlaneShape1 ;
//detecteble but unovious
polySplit -ch on -s 1 -sma 0 -ep 1 0.467274 pPlaneShape1 ;
// a technicaly wrong one to detect! but okay
polySplit -ch on -s 1 -sma 0 -ep 133 0.624168 pPlaneShape1;
move -r 0 0.0578112 0 pPlane1.vtx[124];
// impossible to detect one follows
// or rather impossible for the computer to figure it out
// as its in general not a good iedea to let teh computer speculate
polySplit -ch on -s 1 -sma 0 -ep 20 0.393764 pPlaneShape1 ;
move -r 0.0502201 0 0 pPlane1.vtx[125];
Now its relatively easy to delete all freestanding verts select all verts and hit delete.
select -r pPlane1.vtx[0:125] ;
doDelete;
Now this also deletes corners.
Well you could easily go trough all the verts one by one and check that they are on a straight line if so delete. Now this solves apart of the problem but does not solve vertex 124 and 125
proc vector toVect(float $vect[]){
return <>;
}
{
$select=ls -flatten pPlane1.vtx[0:125];
for ($vert in $select){
string $polyInfo[];
$polyInfo=polyInfo -ve $vert;
string $buffer[];
$numTokens = tokenize $polyInfo[0] " " $buffer;
if (!($numTokens>5)){ // if it has only 2 connections
string $vert1Info[],$vert2Info[],$vert1[],$vert2[];
$vert1Info=polyInfo -ev ("pPlane1.e["+$buffer[2]+"]");
$vert2Info=polyInfo -ev ("pPlane1.e["+$buffer[3]+"]");
tokenize $vert1Info[0] " " $vert1;
tokenize $vert2Info[0] " " $vert2;
$vector1=(toVect(pointPosition ("pPlane1.vtx["+$vert1[2]+"]")) -toVect(pointPosition ("pPlane1.vtx["+$vert1[3]+"]")));
$vector2=(toVect(pointPosition ("pPlane1.vtx["+$vert2[2]+"]")) -toVect(pointPosition ("pPlane1.vtx["+$vert2[3]+"]")));
if (unit($vector1)==unit($vector2) ||unit($vector1)== -1*unit($vector2))
delete $vert;
}
}
}
Now this isnt optimal and quite specific theres a abit of redundant ops here and so on but hey ista just a aexample.
NOw this does not detect verts 124, 125
Now 124 can be detected! you chack against how many faces its connected to this is good to do before calulating the vectors as its a indicator. now thsi si easy to do
proc vector toVect(float $vect[]){
return <>;
}
{
$select=ls -flatten pPlane1.vtx[0:125];
for ($vert in $select){
string $polyInfo[];
$polyInfo=polyInfo -ve $vert;
string $buffer[];
$numTokens = tokenize $polyInfo[0] " " $buffer;
if (!($numTokens>5)){ // if it has only 2 connections
string $faceInfo[],$vert1Info[],$vert2Info[],$face[],$vert1[],$vert2[];
$faceInfo=polyInfo -vf $vert;
$tokens=tokenize $faceInfo[0] " " $face;
if ($tokens>4){
delete $vert;
continue;
}
$vert1Info=polyInfo -ev ("pPlane1.e["+$buffer[2]+"]");
$vert2Info=polyInfo -ev ("pPlane1.e["+$buffer[3]+"]");
tokenize $vert1Info[0] " " $vert1;
tokenize $vert2Info[0] " " $vert2;
$vector1=(toVect(pointPosition ("pPlane1.vtx["+$vert1[2]+"]")) -toVect(pointPosition ("pPlane1.vtx["+$vert1[3]+"]")));
$vector2=(toVect(pointPosition ("pPlane1.vtx["+$vert2[2]+"]")) -toVect(pointPosition ("pPlane1.vtx["+$vert2[3]+"]")));
if (unit($vector1)==unit($vector2) ||unit($vector1)== -1*unit($vector2))
delete $vert;
}
}
}
now this isnt optimal for many reasons (one being taht they could actualy be meaningfull)! But we still have the problematic 125, wich isnt so clear anymore, becaus etheres no way to know its not a real needed corner. YOu can iplement some heyrestic on thsi but ist not realy trustworthy.
esiest would be to select the verts and then let the user to pick wich ones he does not want,
still we are left with
PS. i should send you a invoice
but i dont.
PPS. theres atleast one redundant call to poly info in my script or rathere many the entire firsty poly info in the loop is extar but hey im not going to fix it ill leave it for thsoe who realy need this mel script. And theres still much to do here as it only works on my sample data.