delete vertex from quad-poly delets the poly
-
hi there,
i have the case, where i want to delete some vertecies of quad-polies and want them to turn into tri-polies.
this would feel quite intuitive to me. but instead the whole poly gets deleted. (i suppose there are cases where this behavior is also quite useful)the neighbors need to stay in their exact spot - so 'optimize' or melting with neighors is out.
probably stitchandsew would be an option, but it would involve quite some code, compared to a simple 'delete'.
so is there any other tool or trick, that might do what i want?
-
Hello @datamilch,
Thank you for reaching out to us. While you were posting, I did some work on the forum and the file attachments went into test instance of our Forum which I did not end up using due multiple incompatibilities of plugins which we use. In case you consider these image relevants to your question, I have to ask you to provide them again.
Cheers,
Ferdinand -
-
Hey @datamilch,
Thank you for providing them again and please excuse the inconvenience.
Cheers,
Ferdinand -
Hey @datamilch,
Thank you for reaching out to us. Your question is a bit ambiguous, as you talk about wanting to 'delete vertices of quad-polys and want them to turn into tri-polys' but show us an image series which just deletes two quads. You do not need any commands (
CallCommand
,SendModelingCOmmand
) for that, as the core of the operation is quite simple. When you have a quadQ {a, b, c, d}
, then removing the pointn
in it just means leaving it out and repeating the last point.So, to construct a tri with
b
being removed would bea, c, d, d
, and constructing a tri ford
being removed would bea, b, c, c
. It is important to keep the order of vertices, as the winding direction of a polygon determines its normal. So,a, c, d, d
andd, c, a, a
occupy the same space but have reversed normals. Onlya, c, d, d
has the same winding order and normal as its origin quada, b, c, d
. So, it would be something like this:quad: c4d.CPolygon # A polygon i: int # A vertex index # Construct a triangle with the point with the index #i being removed from #quad. if not quad.IsTriangle() and quad.b == i: tri: c4d.CPolygon = c4d.CPolygon(quad.a, quad.c, quad.d, quad.d)
This all might sound a bit complicated but is not that hard to do. What is a bit trickier is to detect the point to remove. Here your question is also a bit ambiguous as you do not specify if the points which should be removed are provided by the user or should be detected. If not, you would to test:
- For each polygon
P
in a meshM
:- Test if it is triangle, and if so continue.
- For each point
q
in the polygonP
:- Test if both edges
e1
ande2
connected toq
have only one polygon (i.e.,Q
) attached to them. - If so, you found a point of a quad that is at the border of the mesh. There are of course literal corner cases where this little test might not produce an output humans consider sensible: Imagine a singular perfect right-angled quad as the input mesh. This algorithm would turn it into a triangle. Intended? Catching these special cases can get much more involved.
- Test if both edges
For
1.2.1
you can use Neighbor.GetEdgePolys. You should start with writing the script yourself, we will help you then along the way when you struggle, but we cannot write things from start to finish for you.Cheers,
Ferdinand - For each polygon
-
@ferdinand thanks for your explanation and sorry for the ambiguouty!
the second image showed what currently happens, but not what i wanted.
so converting a quad to tri is more like reordering the verticies and leaving one out. makes sens. hope i find the time to test it next weekend ...
finding the points is already done, but thanks for the hint. most of the time i use a little trick: select all points, shrink selection, grow selection. then points, that were only connectet to two border-verticies will not be reselectet, you can invert the selection and have the points. but border-points of n-gons will be selectet too. for these i do have a script that makes use of the neighbor function.
1.2.2. yes i'm aware of the right-angled quad cases, and luckily they don't matter in my case. but thanks for pointing it out. i find it super cool how alert you are! appreciate it alot.
-