[Closed] Polygon Triangulation
I needed a solution to find the interior “hidden” interior edges of editable polys, a search on here found the question asked a number of times with no suitable solution (unless i missed it). Though not ideal and if someone has a better one or can improve on it…
fn GetFirstMeshFaceforPoly obj face =
(
count = 1;
for f = (face - 1) to 1 by -1 do
count += ((polyop.getfacedeg obj f) - 2);
count;
)
fn GetInteriorEdges obj face =
(
sface = GetFirstMeshFaceforPoly obj face;
eface = sface + (polyop.getfacedeg obj face) - 3;
iedges = #();
for i = sface to eface do
(
for j = 1 to 3 do
(
if getEdgeVis obj.mesh i j == false then
(
verts = (meshop.getVertsUsingEdge obj.mesh #((i - 1) * 3 + j)) as array;
appendifunique iedges [verts[1],verts[2]];
)
)
)
iedges;
)
here is my version:
fn getInteriorEdgesUsingFace node faces hidden:on = if iskindof node Editable_Poly do
(
fn isEdgeHidden mesh e = not (getEdgeVis mesh (1 + (e-1)/3) (1 + (mod (e-1) 3)))
local sel = node.selectedfaces as bitarray
node.selectedfaces = faces
mesh = copy node.mesh
edges = meshop.getedgesusingface mesh mesh.selectedfaces
verts = for e in edges where not hidden or (isEdgeHidden mesh e) collect
(
ee = (meshop.getvertsusingedge mesh e) as array
[ee[1],ee[2]]
)
node.selectedfaces = sel
delete mesh
makeUniqueArray verts
)
/*
getInteriorEdgesUsingFace (converttopoly (box())) #{2,4} hidden:on
*/
check all of them! this should to the trick:
fn GetHiddenEdges poly faces =
(
edges = polyop.getEdgesUsingFace poly faces
for i in edges where polyop.getEdgeVis poly i collect i
)
all that does is collect the existing edges ? create a 1×1 plane, collapse to editable poly, go to edge sub-selection an press the Turn button, the dotted line is the “edge” we’re are trying to find.
ah yes my bad. I don’t think its possible to access the ‘hidden’ edges in an editable poly so I’d use Denis’ mesh based function instead.
What do you need it for anyway?
can’t you use “node.mesh” in the meshop functions instead of passing a copy of it in your solution Denis ? Or are there reasons not to ?
every time when you ask node.mesh from the code the system creates a new copy of triMesh. It’s slow and eats memory. I make a copy only once.