PDA

View Full Version : Polygon Triangulation


Klunk
12-08-2010, 03:20 PM
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;
)

Gravey
12-08-2010, 03:26 PM
try using polyop.getEdgeVis <Poly poly> <int edge>

Klunk
12-08-2010, 03:30 PM
yeah but what edge do you check ?

denisT
12-08-2010, 04:20 PM
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
*/

Gravey
12-08-2010, 04:27 PM
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
)

Klunk
12-08-2010, 04:37 PM
all that does is collect the existing edges ? create a 1x1 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.

Klunk
12-08-2010, 05:09 PM
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 ?

denisT
12-08-2010, 05:16 PM
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.

Gravey
12-09-2010, 02:30 AM
all that does is collect the existing edges ? create a 1x1 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?

CGTalk Moderation
12-09-2010, 02:30 AM
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.