PDA

View Full Version : Finding edges that share a face but no vert...


harefort
02-09-2009, 05:20 PM
Hey everybody!

I'm looking for a performant way to find an edge that shares a face but no vert with an other edge.
The failsafe way is to find all the edge of the faces that contain the first edge and then dismiss all edges that share a vert with the first edge.
But I wonder whether there is a faster way.

With getFaceEdge <int> <int> you can get all the edges of a face and I wonder whether these are sorted.
On a quad edge 1 and edge 3 seem to always fullfill my criteria.
I used this snippet to test this on a quad only poly:

aFaces = #{1..$.numFaces}
iFails = 0

for each in aFaces do
(
local aEdges = #($.getFaceEdge each 1,$.getFaceEdge each 3)
local aVerts = #{$.getEdgeVertex aEdges[1] 1,$.getEdgeVertex aEdges[1] 2,$.getEdgeVertex aEdges[2] 1,$.getEdgeVertex aEdges[2] 2}
if aVerts.numberSet != 4 then
(
iFails += 1
)
)

print iFails


Does somebody know for sure whether the edges of a face are sorted in this way?

Thanks a lot!

SyncViewS
02-09-2009, 05:53 PM
Hi harefort,
while it is sure that a quad has edges sorted out in a sequential way (1|3 and and 2|4 are always opposed and don't share verts), it's not granted the vertices order taken from a pair of opposing edges. Edge vertex 1 is the one with relative lower index value, and can't be known a priori. You cannot guess what's the first edge in a face either.

If you're looking for a way to get the edge "opposite" to another in a quad, I'd suggest a different way:

(
-- EditPolyObj: Editable Poly object
-- iStartFace: known quad face index
-- iStartEdge: known edge Index

-- get the four edges around the known face
baEdgeFromFace = polyOp.getEdgesUsingFace EditPolyObj iStartFace
-- get the vertices at the extremities of the known edge
aiVertFromEdge = polyOp.getEdgeVerts EditPolyObj iStartEdge

-- get edges sharing the first and second edge extremity
baEdgeFromVert01 = polyOp.getEdgesUsingVert EditPolyObj aiVertFromEdge[1]
baEdgeFromVert02 = polyOp.getEdgesUsingVert EditPolyObj aiVertFromEdge[2]

-- get the opposite edge as the difference of the edges surrounding the known
-- face and the new edge set from vertices
iOppositeEdge = ((baEdgeFromFace - baEdgeFromVert01 - baEdgeFromVert02) as Array)[1]
)

Tell me if you need anything more specific.

- Enrico

harefort
02-09-2009, 06:19 PM
Makes sense. Thanks for the inspiration!

Here's what I'm doing now (quad is not known):

--sPoly is editable_poly node
--iEdge is current edge we're processing
local aFaces = polyOp.getFacesUsingEdge sPoly iEdge
local aVerts = polyOp.getVertsUsingEdge sPoly iEdge
local aNotEdges = polyOp.getEdgesUsingVert sPoly aVerts
local aPotentialEdges = (polyOp.getEdgesUsingFace sPoly aFaces) - aNotEdges

CGTalk Moderation
02-09-2009, 06:19 PM
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.