• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

How do you intersect two faces?

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 3 Posters 619 Views 3 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.
  • C Offline
    CAUL
    last edited by 4 Jun 2014, 11:40

    I want to intersect two groups ( g0, g1) and put the intersection edges in a third group. Since intersect_with is very slow on complex geometry it should pay to find pairs of faces from g0 and g1 that might intersect and then intersect those pairs separately. An example, I have two groups with roughly 11000 faces each. This requires 121 million face/face comparisons, however, with some space hashing this number drops to ~400.000 from which ~4000 pairs of potential face intersections are extracted (ie. face pairs whose bounding boxes intersect). The whole procedure takes about a second. (To intersect the groups from the UI takes 16 minutes..)

    Now, is there a way in sketchup to intersect just two faces? I'm at loss on how to use intersect_with for this and the Geom class contains only plane/plane intersection.

    1 Reply Last reply Reply Quote 0
    • J Offline
      jolran
      last edited by 4 Jun 2014, 14:18

      Join the party...

      intersect_with is slow, but probably necessary evil.

      That's quite a large collection you are having.

      I found it ever so slightly faster in 2Dboolean to intersect with 1 of the groups containing edges only, to cut out the desired frame of desired geometry. But in your case that might not aid.
      I reported a strange behavior from that that never got answered, or maybe it's so well known it did not deserve an answer..

      "Edge collection still remembers face" - error, sort of thing..(scroll to my post)
      http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=55238%26amp;hilit=+intersect

      There was some post long time ago about using linesweeps instead, in the Cartesian plane.
      And perhaps break edges on "hit". I don't think it's trivial to build something like that..
      Maybe if it could be ported to C doing the calculations, however the cost..

      TIG's many plugins use intersections quite often. You should dig in there..

      If you would come up with something revolutionary you'd be a hero..

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by 4 Jun 2014, 14:30

        The heart of your problem is that intersect_with is an instance method of the Entities collection class. So, you need to create a temporary Entities collection and copy one of the Faces into it. For instance (assuming that the Faces are drawn in model coordinates - otherwise you will need to use something other than the identity Transformation):

        
        temp_ents = Sketchup.active_model.entities.add_group.entities # can reuse this if purge between pairs of Faces
        temp_ents.add_face(face1.edges)
        ident = Geom;;Transformation.new
        intersect_arr = temp_ents.intersect_with(false, ident, temp_ents, ident, false, face2)
        
        

        Because it is all Ruby, I don't know whether this will actually be any faster than letting the built-in function handle the whole thing though.

        Steve

        1 Reply Last reply Reply Quote 0
        • J Offline
          jolran
          last edited by 4 Jun 2014, 15:05

          This is what I do (sort of) in 2dboolean. But with 11000 faces 😕 ...

          @unknownuser said:

          Because it is all Ruby, I don't know whether this will actually be any faster than letting the built-in function handle the whole thing though.

          20 seconds is better than 25 😄 every optimization counts or are worth trying

          1 Reply Last reply Reply Quote 0
          • C Offline
            CAUL
            last edited by 4 Jun 2014, 21:31

            Thanks for the replies!

            slbaumgartner, splendid advice. It worked much smoother than I thought it would. The code is attached below. Here are some results from intersecting the two columns in the example file:

            • Intersect from UI: 983s

            • Outer shell (*****): 161s

            • g0.intersect_with g1 (******): 104s

            • Intersect face pairs: 4s

            () Outer shell is probably dominated by the intersect
            (
            *) In order to produce all edges for coplanar cuts two calls to intersect_with has to be made with the groups reversed. The result above is for a single call.


            cuttest.zip


            CAUL_CutTest0.3.rb

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

            Advertisement