Face loop vertex order?
-
Is there an order to Loop.vertices retrieved from Faces? I think I read somewhere that outer_loop is guaranteed to be counter-clockwise. What about inner loops?
Just did a quick check on a donut-like face, and the outer loop is CCW, but the inner loop is CW. Is that always the case?
-
hm... not sure... never looked into iut. but you bring up an important issue. This should be information written down in the manual.
-
When I import a 3dface from a Dxf file, the direction of the front face determines the direction the vertices's are drawn. As I recall, when the front side is visible, the vertices's are CCW, and when the back face is seen, the vertices's are CW.
-
Outer-loops are always returned counter-clockwise.
Inner-loops are always returned clockwise.
This 'rotation' is relative to theface.normal
.
Bothface.vertices
andloop.vertices
are 'ordered' - starting from a non-specific vertex.To demonstrate it to yourself use this snippet...
[NB: you must have selected a face with inner and outer loops beforehand]m=Sketchup.active_model;es=m.active_entities;f=m.selection[0];o=f.outer_loop;ls=f.loops-[o];i="outer#t000";o.vertices.each{|v|es.add_text(i,v.position,[2,2,2]);i.next!};i="inner#000";ls.each{|l|l.vertices.each{|v|es.add_text(i,v.position,[2,2,2]);i.next!}};
-
@tig said:
Outer-loops are always returned counter-clockwise.
Inner-loops are always returned clockwise.Thanks TIG, I know you've posted on this before... just wanted to be sure!
-
TIG, I got the following error:
Btw, Is there a way to tell if the inner loop is faced or not? How are multiple inner loops vertexes created? -
Did you select the face before running the code?
-
Yes, I ran it in web console. The error message says that the problem is that the outer_loop is not a method for edges, so I tried to do a loop for faces, but failed.
-
From the screenshot it doesn't look like you selected the face.
I just tried the code myself, works fine. -
Hmm.... I'll try again.
-
What could the problem be.....Must be with my system???????
-
In that example you have selected lots of edges.
Select only the face.
-
Got it. I was previously selecting everything. Guess I'am not too good at following instructions. The top image is with selection of the outer ring, and the bottom image is that of the center. Btw, I have on-board Intel at home, so OpenGl fails here for me, and face selection isn't clear.
When I draw faces by lines, going clock wise, or counter clockwise creates different sides of a face. but clearly (now to me), that is a situation unrelated to this.
Too bad I can't use this to find holes in faces generated by closed Dxf polyline data.
-
A loop that is ONLY an outer-loop returns its vertices counter-clockwise.
A loop that is an inner-loop only OR that is an outer-loop to one face BUT also formers an inner-loop to another face returns its vertices clockwise - even if it is the outer-loop to a face you are testing - you can of course check for the loop's duplicity and take that into account.
You need two sample DXFs - one with a face+hole and the other the same but with the hole filled - then you could find the difference ?
There are rules about face normal and loop direction for CAD 3D Faces ? Are you following these ?? -
TIG, As you suggest, I will work on this and post what I find. Thanks.
Advertisement