• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Face loop vertex order?

Scheduled Pinned Locked Moved Developers' Forum
15 Posts 4 Posters 2.1k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    draftomatic
    last edited by 13 Oct 2010, 23:19

    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?

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 14 Oct 2010, 06:25

      hm... not sure... never looked into iut. but you bring up an important issue. This should be information written down in the manual.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • H Offline
        honoluludesktop
        last edited by 14 Oct 2010, 08:09

        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.

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 14 Oct 2010, 08:36

          Outer-loops are always returned counter-clockwise.
          Inner-loops are always returned clockwise.
          This 'rotation' is relative to the face.normal.
          Both face.vertices and loop.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

          1 Reply Last reply Reply Quote 0
          • D Offline
            draftomatic
            last edited by 16 Oct 2010, 19:50

            @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!

            1 Reply Last reply Reply Quote 0
            • H Offline
              honoluludesktop
              last edited by 20 Oct 2010, 03:33

              TIG, I got the following error:

              Temp91.jpg
              Btw, Is there a way to tell if the inner loop is faced or not? How are multiple inner loops vertexes created?

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 20 Oct 2010, 06:25

                Did you select the face before running the code?

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • H Offline
                  honoluludesktop
                  last edited by 20 Oct 2010, 06:47

                  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.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 20 Oct 2010, 06:55

                    From the screenshot it doesn't look like you selected the face.
                    I just tried the code myself, works fine.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      honoluludesktop
                      last edited by 20 Oct 2010, 07:03

                      Hmm.... I'll try again.

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        honoluludesktop
                        last edited by 20 Oct 2010, 07:08

                        What could the problem be.....Must be with my system???????


                        temp00.jpg

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          thomthom
                          last edited by 20 Oct 2010, 07:56

                          In that example you have selected lots of edges.

                          Select only the face.

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            honoluludesktop
                            last edited by 20 Oct 2010, 08:33

                            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.


                            temp00.jpg

                            1 Reply Last reply Reply Quote 0
                            • T Offline
                              TIG Moderator
                              last edited by 20 Oct 2010, 10:38

                              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

                              1 Reply Last reply Reply Quote 0
                              • H Offline
                                honoluludesktop
                                last edited by 20 Oct 2010, 13:33

                                TIG, As you suggest, I will work on this and post what I find. Thanks.

                                1 Reply Last reply Reply Quote 0
                                • 1 / 1
                                1 / 1
                                • First post
                                  8/15
                                  Last post
                                Buy SketchPlus
                                Buy SUbD
                                Buy WrapR
                                Buy eBook
                                Buy Modelur
                                Buy Vertex Tools
                                Buy SketchCuisine
                                Buy FormFonts

                                Advertisement