Topological Naming, My Take

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Topological Naming, My Take

Post by triplus »

realthunder wrote: Wed Mar 21, 2018 11:19 am But, fear not, once you double click the fillet, it can magically suggest you the correct edge. So you know that I can deduce the related edges, but choose not to do it automatically. Because I think it is better to be explicit here, like many other fancy CAD do. Maybe that'll make FreeCAD feel 'expensive', too.
As long as i can turn it off and just let the algorithm do its job directly. I am OK with "expensive feel". ;)

As for the rest. I have a feeling this implementation is now getting close to the white paper proposal @ickby made?
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Topological Naming, My Take

Post by realthunder »

New version released! The topological naming algorithm is published here.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
emills2
Posts: 884
Joined: Tue Apr 28, 2015 11:23 pm

Re: Topological Naming, My Take

Post by emills2 »

As far as nesting and complexity, have you considered just slapping an integer ID reference/link on the name string once it gets too big? then you could look up the details of the string if it gets flagged as modified. expandable-contractable hierarchy type of deal. (i can't really digest the main algorithm, just commenting on the naming examples form the short videos)

this is already quite a mouthful

Code: Select all

RFI_FUS1_Face6;M(2_Face2);M(FUS1_Face6;M2,FUS2_Face2;M2)
and this model is just getting started!

This has all the right elements as far as i can tell: unique IDs on everything, no ID reuse, maintain link history...a real database!

edit: i guess you're already doing the hierarchy, by looking at the refined fusion video. anyways, cool stuff.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Topological Naming, My Take

Post by realthunder »

emills2 wrote: Sat Mar 31, 2018 9:03 pm As far as nesting and complexity, have you considered just slapping an integer ID reference/link on the name string once it gets too big? then you could look up the details of the string if it gets flagged as modified. expandable-contractable hierarchy type of deal. (i can't really digest the main algorithm, just commenting on the naming examples form the short videos)
Yes, there is string hasher here for this purpose. It is by default on, so for a refined face you will be seeing something like RFI_#F12;M#14.

At a high level, the naming algorithm takes four steps to try to name as many elements as possible,

1) find any unchanged and named elements that appear in both the input and out shape, and just copy those names over to the new shape.
2) assign names for generated (with postfix ;G) and modified (;M) elements,
3) for all unnamed elements, assign an indexed based name using its upper named element. e.g. if a face is named RFI_#F11, its unnamed edges will be named as RFI_#F11;U1, RFI_#F11;U2, etc. In this step, an element may be assigned multiple names, if it appear in more than one named upper elements.
4) for all remaining unnamed elements, use the combination of lower named elements as its name. e.g. if a face has all its edges named, then the face will be named as FUS_(edge1,edge2,edge3);L, something like that.

There is no guarantee, but the algorithm can name all the element in my not so formal tests.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Topological Naming, My Take

Post by realthunder »

Latest development.

First, I have ported PartDesign to adopt the element mapping, but haven't thoroughly tested it yet. Can someone please provide me some big PartDesign models for testing?

Second, I have improved the naming scheme for tracing back modeling history. As a demonstration, I extended Part view provider face coloring to use the element map for mapping child shape colors. It is now supported for all Part::Feature derived objects. By default, only face color mapping is enabled, otherwise you'll see a lot of white edges mapped from extrusion through a sketch, which I guess people won't like. To enable/disable color mapping, use Part view providers new property, MapFaceColor, MapLineColor, MapPointColor.

Image


The screencast also shows how to override individual element colors. The element references are stable, thanks to the new topo naming. Unlike fillet, if an element reference is gone, it will auto deduce related elements for coloring. To color any element in Python,

Code: Select all

# obtain the existing overridden colors as a dict(name:color)
colors = App.ActiveDocument.Cut.ViewObject.ElementColors
colors['Face6'] = (1.0, 0.0, 0.0) # add some more element color
App.ActiveDocument.Cut.ViewObject.ElementColors = colors
To show the element evolving history

Code: Select all

from pprint import pprint
pprint(App.ActiveDocument.Cut.getElementHistory('Face2'))
[('Fusion', '#31;:M#30;RFI;:T2:3', []),
 ('Cylinder', 'Face3', ['Face3;:M2;FUS;:T2:5'])]
It returns a list of tuple(sourceObjName, sourceElementName, [intermediateName...]). The intermediateName are intermediate modeling steps. The above result means

Code: Select all

# Cut.Face2 comes from a Fusion element, the 'RFI' op code indicates the last modeling step is refine.
'Fusion', '#31;:M#30;RFI;:T2:3' 

# The above refined element, comes from Cylinder.Face3, with an intermediate modeling step, and its 
# op code 'FUS' means it is a fusion operation.
('Cylinder', 'Face3', ['Face3;:M2;FUS;:T2:5'])
The Cut.Face2 (the bottom face of the cut object) obviously comes from more than one source face. The history trace right now only decodes the first source shape (in tag+name sorting order), and therefore will give you a linear history. It is also possible to return the full history tree by decoding the ;:M#30 marker above. #30 means it's stored in hasher table entry 0x30. It will tell you the rest of the source shape element names.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Topological Naming, My Take

Post by DeepSOIC »

@realthunder, you never stop to amaze me, how you seemingly easily solve problems freecad has been facing for like forever!
I would love if you would become one of the lead developers, with direct access to FC official repo (apparently, your code output vastly overwhelms Werner's capacity of reviewing). @Werner, @Yorik, what do you think?
freecad-heini-1
Veteran
Posts: 7790
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: Topological Naming, My Take

Post by freecad-heini-1 »

Whow @realthunder, what a great job.

Now you are deep into Freecad color. Is there any possibility to change the transparency factor for one ore more faces?
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Topological Naming, My Take

Post by realthunder »

DeepSOIC wrote: Tue Apr 10, 2018 11:24 am @realthunder, you never stop to amaze me, how you seemingly easily solve problems freecad has been facing for like forever!
I would love if you would become one of the lead developers, with direct access to FC official repo (apparently, your code output vastly overwhelms Werner's capacity of reviewing). @Werner, @Yorik, what do you think?
Thanks for the appreciation!

freecad-heini-1 wrote: Tue Apr 10, 2018 11:53 am Now you are deep into Freecad color. Is there any possibility to change the transparency factor for one ore more faces?
Yes, sure. See below. Once any face has any transparency, the selection and pre-selection behavior changes as shown below. The selected face will have the transparency of the first transparent face of the object. I could have honoured the actual transparency of the selected face, but choose not to do so, for the sake of (slightly better) performance, and also not disturbing too much the already quite complicated transparency rendering logic.

Image
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
freecad-heini-1
Veteran
Posts: 7790
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: Topological Naming, My Take

Post by freecad-heini-1 »

Whow! Very nice - Alpha Channel for set colors!
Is that integrated in your new appimage (Ubuntu), as well as all the new topo naming improvements?
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Topological Naming, My Take

Post by realthunder »

freecad-heini-1 wrote: Wed Apr 11, 2018 11:34 am Whow! Very nice - Alpha Channel for set colors!
Is that integrated in your new appimage (Ubuntu), as well as all the new topo naming improvements?
Not yet, but new release is coming soon.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
Post Reply