How to remove points but keep lines?

   2609   12   2
User Avatar
Member
4 posts
Joined: July 2023
Offline
I want to remove the selected points in Figure 1 (these points have been defined in the group) but keep the lines. I hope it looks like picture 2 after removing. I tried 'remove inline points', but it didn't work as expected.

Can anyone help?
Thank you so much!
Edited by Candace Sun - Aug. 3, 2023 01:34:31

Attachments:
2023_07_28_15_38.08.bmp (1.1 MB)
2023_07_28_15_38.21.bmp (1.1 MB)
RemovePoints.hip (153.5 KB)

User Avatar
Member
8555 posts
Joined: July 2007
Offline
assuming your polygons are closed or if they are open that the end points are not in your point group

you can use Blast SOP and specify your group
or Delete SOP set to Points

however Facet SOP with Remove Inline Points should work in your case as well, with same assumptions
Edited by tamte - Aug. 1, 2023 16:03:05
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
56 posts
Joined: April 2008
Offline
64669804
I want to remove the selected points in Figure 1 (these points have been defined in the group) but keep the lines. I hope it looks like picture 2 after removing. I tried 'remove inline points', but it didn't work as expected.
In this case you can try filtering points by calculating point angles with vex.
int pts[]=expandpointgroup(0,'group1');
int nb_pts2[];
string edges='',edge;

//
foreach(int pt;pts)
{
    int nb_pts[]=neighbours(0,pt);
    for(int i=0;i<len(nb_pts);i++)
    {
        int ingrp=inpointgroup(0,'group1',nb_pts[i]);
        if(!ingrp)
            {   
                pop(nb_pts,i);
            }
        else
            push(nb_pts2,nb_pts[i]);
    }
    //printf('%d\n',len(nb_pts));
    
    //
    int pt_nb0=nb_pts[0];
    int pt_nb1=nb_pts[1];
    vector pos0=point(0,'P',pt_nb0);
    vector pos1=point(0,'P',pt_nb1);
    vector cur_pos=point(0,'P',pt);
    vector dir0=normalize(pos0-cur_pos);
    vector dir1=normalize(pos1-cur_pos);
    
    float angle=degrees(acos(dot(dir0,dir1)));
    setpointattrib(0,'angle',pt,angle,'set');
    if(angle>175)
    {
        setpointgroup(0,'smooth_pts',pt,1,'set');
    }
    
}

Attachments:
calculate_pointangle.hip (129.5 KB)

User Avatar
Member
4 posts
Joined: July 2023
Offline
Thank you very much for your replies, but I followed your approach and still haven't got the result I want. I uploaded my hip file, can you please use my file to achieve it?
Thank you for your time!
Edited by Candace Sun - Aug. 3, 2023 01:35:39

Attachments:
RemovePoints.hip (153.5 KB)

User Avatar
Member
8555 posts
Joined: July 2007
Offline
your outline are made of many curve segments
the best is to convert them to closed curves using PolyPath
then you can remove inline points using Facet SOP
and if you want open back up using Ends SOP

Attachments:
RemovePoints_fix.hipnc (162.5 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
1738 posts
Joined: May 2006
Offline
Ah, it's because you don't have 1 path, its lots of little segments that happen to line up next to each other.

A polypath sop will join them all into a single primitive, then you can use facet with 'remove inline points'.

Attachments:
RemovePoints_fix.hip (173.7 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
1738 posts
Joined: May 2006
Offline
DAMNIT TOMAS BEAT ME AGAIN
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
4 posts
Joined: July 2023
Offline
tamte
your outline are made of many curve segments
the best is to convert them to closed curves using PolyPath
then you can remove inline points using Facet SOP
and if you want open back up using Ends SOP
That's exactly what I want! Thank you Tomas, this is really helpful!
I don't know why when I added 'PolyPath' in my own file, it was displayed differently from your file, but luckily the 'Ends' solved this problem finally.
Edited by Candace Sun - Aug. 3, 2023 05:20:15

Attachments:
2023_08_03_17_17.35.bmp (1.6 MB)

User Avatar
Member
4 posts
Joined: July 2023
Offline
Also thanks to Benyee and mestela!
User Avatar
Member
7 posts
Joined: Jan. 2022
Offline
Didn't know Facet did that, I solved this issue recently by comparing each point's neighbouring points and deleting said points if they were both on the same axis. Only works if your lines are perfectly straight, I guess.
User Avatar
Member
117 posts
Joined: Aug. 2017
Offline
vector src0 = point(0,"P",hedge_srcpoint(0,@vtxnum));
vector dst0 = point(0,"P",hedge_dstpoint(0,@vtxnum));
vector dir0 = normalize(dst0-src0);

int nexth = hedge_next(0,@vtxnum);
vector src1 = point(0,"P",hedge_srcpoint(0,nexth));
vector dst1 = point(0,"P",hedge_dstpoint(0,nexth));
vector dir1 = normalize(dst1-src1);

if(dot(dir0,dir1)>1-0.002){
    
    removevertex(0,nexth);
    int pt = vertexpoint(0,nexth);
    int l = len(pointvertices(0,pt));
    if(l<2) removepoint(0,pt);
}

sec solution
int nears[] = neighbours(0, @ptnum);
vector last_dir = point(0, "P", nears[0])-point(0, "P", @ptnum);
vector next_dir = point(0, "P", nears[1])-point(0, "P", @ptnum);
if(abs(dot(last_dir,next_dir))>0.99){
    removepoint(0,@ptnum);
}
Edited by cncverkstad - Aug. 22, 2023 05:56:32
Conservation of Momentum
User Avatar
Member
60 posts
Joined: Nov. 2021
Offline
Can't you just do this?

if(@N == {1, 0, 0} || @N == {0, 0, 1} || @N == {-1, 0, 0} || @N == {0, 0, -1}){
removepoint(0, @ptnum);
}

Should work since you want to remove all points that are either pointing -x/+x or -z/+z
Edited by eaniix - Aug. 19, 2023 08:38:46
User Avatar
Member
131 posts
Joined: Aug. 2012
Offline
eaniix
Can't you just do this?

if(@N == {1, 0, 0} || @N == {0, 0, 1} || @N == {-1, 0, 0} || @N == {0, 0, -1}){
removepoint(0, @ptnum);
}

Should work since you want to remove all points that are either pointing -x/+x or -z/+z

Not the wisest to perform direct == comparisons when working with possible floating point values. Fuse > Polypath > Facet (remove inline) is the "Houdini" solution that will work regardless of orientation.
  • Quick Links