face union

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
tanderson69
Posts: 1500
Joined: Thu Feb 18, 2010 1:07 am

face union

Postby tanderson69 » Sat Nov 26, 2011 12:49 am

I have attached a very simple, gui-less, demonstration application. It tries to merge two coplanar faces, of a solid, into one face. It appears to be working. The algorithm for finding the faces and building the replacement face make assumptions and it is only intended for this demonstration app. I welcome comments and I will be working on creating a "real" detection and replacement routine.
Attachments
FaceUnion1.zip
this is a zip
(133.16 KiB) Downloaded 90 times
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: face union

Postby jriegel » Sat Nov 26, 2011 9:26 am

That would be great!
Stop whining - start coding!
wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: face union

Postby wmayer » Sat Nov 26, 2011 11:06 am

Just found some hints in the OCC forum. There seems to be already a class in OOC that does it.

http://www.opencascade.org/org/forum/?s ... 1&author=1

I'll make a feature request on Mantis and this link. So, we can look at it again when starting the 0.13 development.
User avatar
tanderson69
Posts: 1500
Joined: Thu Feb 18, 2010 1:07 am

Re: face union

Postby tanderson69 » Sat Nov 26, 2011 3:11 pm

I looked at the gluer class and got the impression that it was intended for "patching" (ug term) an open shell onto a solid. I could be out in left field, because what I know about opencascade probably wouldn't fill up a sticky note.
User avatar
tanderson69
Posts: 1500
Joined: Thu Feb 18, 2010 1:07 am

Re: face union

Postby tanderson69 » Sat Dec 03, 2011 10:12 pm

Making some progress. Successfully detected "equal", adjacent planar faces and replaced with one face.
Attachments
FaceUnion2.zip
is a zip
(266.32 KiB) Downloaded 49 times
jmaustpc
Posts: 9566
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: face union

Postby jmaustpc » Sun Dec 04, 2011 3:39 am

Hi Werner
I just clicked on the occ link, it reads at one point the link "3. Fusing and coplanar feces". Obviously this sounds like what you are talking about but can I just point out that the word "feces" in the illiterate American spelling for "faeces",

I think they meant "faces".

for those who doubt

http://en.wikipedia.org/wiki/Feces

does this mean that they are saying occ is a sh## product?? :lol:


For those who don't know what "faeces" means, an Australian could refer to it as

1) a blind mullet (a "mullet" is a type of fish, a "blind mullet" is the sort you don't want to find while swimming!)
2) a log (as in "I need to lay a log")
3) a "floater"
4) and of course the universal "number 2"

If anyone has a particular desire to see one "in the wild" while in Australia, one could expect to find some examples in their native habitat, commonly a
Dunny
Long Drop
Out House
Bog

Being "built like a brick sh## house" means being built very solidly, possibly overly so, but not necessarily. It is not necessarily derogatory, more likely to be used in a simply descriptive manner. To be describe so for a women, would most likely be not considered in a positive light, however for a bloke or an inanimate object, it could easily be meant as a compliment, or simply as a description of a matter of fact.

As fascinating a subject as it is, I think I shall leave it at that. :)

Jim
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: face union

Postby NormandC » Sun Dec 04, 2011 8:29 pm

jmaustpc wrote:as in "I need to lay a log"
LOL! :lol:

English is such an expressive language. :D

As for mullets, I thought they described these? :P
wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: face union

Postby wmayer » Mon Dec 05, 2011 1:10 pm

tanderson69 wrote:Making some progress. Successfully detected "equal", adjacent planar faces and replaced with one face.
The algorithm is it ready to use as is?
User avatar
tanderson69
Posts: 1500
Joined: Thu Feb 18, 2010 1:07 am

Re: face union

Postby tanderson69 » Mon Dec 05, 2011 3:12 pm

wmayer wrote:The algorithm is it ready to use as is?
Not quite yet. I needed to do some major cleanup. I had a mess of dynamically allocated arrays. I have that done. I need to do some more class work getting the face construction to the abstracted object and prove out the abstraction to another type of face other than planes. I need to do some more tests and try to bullet proof the code. I also was thinking of doing some profiling with a many faceted solid.

I will post code sometimes for 2 reasons: 1 if somebody is interested and wants to share an opinion and 2 if I decide to quit working on it, the code will be here to review if wanted.

I stole a function the jurgen wrote for ordering edges. I am wondering if that shouldn't be abstracted into a "freecad topology api" for ease of use throughtout the system. I am sure there is/will be more.

Is it not possible to import/export the OCC ".brep" format through the freecad GUI? I can do it through the python console, but that is not fast....for me.
Attachments
FaceUnion3.zip
is a zip
(274.64 KiB) Downloaded 44 times
wmayer
Site Admin
Posts: 14887
Joined: Thu Feb 19, 2009 10:32 am

Re: face union

Postby wmayer » Mon Dec 05, 2011 4:02 pm

Not quite yet. I needed to do some major cleanup. I had a mess of dynamically allocated arrays. I have that done. I need to do some more class work getting the face construction to the abstracted object and prove out the abstraction to another type of face other than planes. I need to do some more tests and try to bullet proof the code. I also was thinking of doing some profiling with a many faceted solid.
OK. I started to integrate your algorithm and it seems to work fine. The reason why I asked this is that how you use the algorithm inside the main function of your test application doesn't really make sense to me. It works basically this way:

Code: Select all

solid=readSolid()
for (index=0; index<...;++index) {
   work = solid
   for (ind=0; ind<...;++ind) {
      // modify "work"
   }

   writeShape(work)
}
As you can see you have one input shape but several output shapes. Actually I expect also only one output shape. My second question, does this only work on solids or also on shells?
I stole a function the jurgen wrote for ordering edges. I am wondering if that shouldn't be abstracted into a "freecad topology api" for ease of use throughtout the system. I am sure there is/will be more.
It was me who wrote this function. But you're right we should this function to somewhere else and add the definition to a header file.
Is it not possible to import/export the OCC ".brep" format through the freecad GUI?
Sure! But I guess the point is that the file dialog on GNOME hides all the file extensions. So, export it with "CAD Formats" and type ".brep" as your extension.