MergeAllFaces bug


#1

There are issues with MergeAllFaces that causes bad objects, this is an example.

Extracting the coplanar surfaces in “pairs” and using Cap gives a good result, so I see no real reason for MergeAll to fail.

Thanks for taking a look.

mergeall bug.3dm (248.1 KB)


(Rajaa Issa) #2

Looks like the polysurface has two caps. When I explode, remove one cap, then join, the polysurface MergeAllFaces just fine.


#3

Hi rajaa… that is peculiar, because if I open that file, and explode and seldup there are no duplicates, and if I count the surfaces there are no double caps… are you sure you found two?


(Rajaa Issa) #4

You are right. It was a close surface, but not duplicate. It is a bug. I’v added it to the heap:
http://mcneel.myjetbrains.com/youtrack/issue/RH-27759

When I extract the outer surfaces in the above image from the polysurface, then MergeAllFaces the remaining part, it merges fine. I was able then to rejoin the extracted surface. MergeAllFaces had trouble rejoining that outer face correctly after merging the rest of the piece.


#5

Thanks Rajaa!


#6

Hi Rajaa,
I have had an idea on how to improve MergeAll, so I just spent some hours coding a solution.
First I found that it generated the same error, but not a bad object, so I replaced rs.DuplicateEdgeCurves() with rs.DuplicateSurfaceBorder() and then it works fine.

The tool I made is fast and accurate now. It handles surfaces that are coplanar but not joinable and gives a better result on multi coplanar surfaces.

Rhinos tool tool over 3 minutes on a polysurface that my script used 6 seconds to complete, with better result:

Rhino’s tool is faster at finding if there are no coplanar surfaces, but my solution is faster at solving the result.


Wish V6: Boolean merge
#7

Did another test:

Rhino’s result is the middle object and it took 8,5 seconds to calculate. The script took 0.69 seconds.


#8

How fast will it do the attached…? MergeAllFaces takes… takes… well, I’m still waiting…

–Mitch

OK, finally it finished - I don’t know how long it took, but about 15 minutes I guess - however there are holes everywhere… Not a really fair test though, there are non-manifold edges everywhere… I’m just being nasty.

625Boxes.zip (896.3 KB)


#9

This is probably a fairer test - 144 overlapping boxes, no non-manifold edges to confuse things.

Your script finished in a little over 6 seconds here, but didn’t get most of the upper/lower “merge-able” surfaces. MergeAllFaces took around 5 minutes, but did get them all…

–Mitch

144OverlapBoxes.zip (1.2 MB)


#10

I allready sent you the script in a PM :wink:


#11

Got it…


#12

Answer: 49 seconds.

I’ll add a % counter to the script so one isn’t left in the dark


(Rajaa Issa) #13

As you know, a general solution that carters for most cases can be much slower than one that solves a subset of cases, but it sure is important to find ways to improve the speed of the command. Here are a couple example cases that would be interesting to see if your script merges.

mergeallfaces_holecase.zip (22.5 KB)


#14

Yes, except it didn’t merge any of the top faces…

–Mitch


#15

It does, it checks for any coplanar surfaces, so it should be robust.

And I found the bug @Helvetosaur (and @John_Brock ), the command “rs.JoinSurfaces()” returns only one surface, even if the result is multiple surfaces…


(Rajaa Issa) #16

Holo,
Can you share the script?


#17

In order for rs.JoinSurfaces to work, they have to be in “joinable” order (which is unlikely in your case). Otherwise, you’re better off scripting rs.Command("_Join") - or perhaps RhinoCommon Rhino.Geometry.Brep.JoinBreps() method, which I think can deal with stuff that’s out of order.

–Mitch


#18

I am working on it, to fix some other bugs, but did a stupid thing and pasted it onto an empty script, and then I terminated Rhino and lost it all… pft… have to re do it, I had solved the multiple coplanar surfaces that didn’t join.


#19

I just ended up rewriting the tool, so it handled some other situations better.
But I ran into a problem with planar surf, it doesn’t handle self intersecting curves like it should.
I’ll post that as a new topic.


#20

Hi,

would be a great new feature, if such a command could merge also cylinder faces. Still better it would be if even divide 3d curved G2 surfaces within a PolySrf could be merged in a smart manner.

Thanks a lot!