Solution for one instance of the Topological Naming Problem

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: Topological Naming, My Take

Post by dprojects »

mfro wrote: Tue Aug 16, 2022 3:11 pm Your script solves this one single example of TNP (which is fine of course), but not TNP in general.
But the TNP problem is described at the page Topological_naming_problem page by this example right? At the solution page https://wiki.freecadweb.org/TNP_solution there is also description added. If you read it you will find out this is THE solution. Because the script is the only sample implementation of the solution.

The solution is simple and it is described at the page for everyone: "Store the key before any operation". The key may be different. If I make Chamfer at Cubes I store key for edges. But the main rule is the same. Implementation not change anything here.

Well if you have Sketch you should go to Sketch developers and tell them to store key before Sketch open. This can be implemented at many ways. Even using personal local settings files. So well. If you have issue with Pad you should ask PartDesign developers to store the key.

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Topological Naming, My Take

Post by Zolko »

Roy_043 wrote: Tue Aug 16, 2022 2:59 pm My point is that what you are proposing is not the solution of the TNP problem.
there are - at least - 2 ways to solve the topological naming problem:

  • for each operation, before a recompute, store the identifiers to the resulting shapes in some variable, make the recompute, and try to figure out how to make the old and new shapes correspond through their identifiers. This is what OCC's built-in TNaming does, and apparently what dprojects solutions does also
  • store all historical building references in some mapping table to all shapes and operations, which gives unique identifiers to shapes based on their history, and try to make it such that the identifiers can be used by subsequent operations and that these operations will preserve the model building steps. This is what realthunder's solution does
We could call the first solution a relative solution, in that it applies the toponaming algorithm only between recomputes and forgets each time what it has done, while the second solution is an absolute solution which applies the toponaming algorithm throughout the entire building history of the model by agglomerating each parent's identifier.

The issue with the first approach is that it might not work if the resulting shapes from before and after the recompute differ too much. The worry I'd have with the second approach is how well it behaves for very complex models with lots of history, including booleans, copies, clones, shapebinders ...
try the Assembly4 workbench for FreCAD — tutorials here and here
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Topological Naming, My Take

Post by GeneFC »

C_h_o_p_i_n wrote: Tue Aug 16, 2022 7:03 am Communication - talking together - might be of help in such cases. ;)
You might want to take a look before adding a smart-ass comment. :mrgreen:

Gene
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: Topological Naming, My Take

Post by chrisb »

dprojects wrote: Tue Aug 16, 2022 3:18 pm If you read it you will find out this is THE solution.
...
Well if you have Sketch you should go to Sketch developers and tell them to store key before Sketch open. This can be implemented at many ways. Even using personal local settings files. So well. If you have issue with Pad you should ask PartDesign developers to store the key.
So your script doesn't solve those cases? How can it then be THE solution?

It seems to me that you promise much more than you can hold. Alas, this does the opposite of what you may intent: people look at your script - and are disappointed. And they may fail to see what it really does. So you better describe in detail what it can do and how to apply it to other use cases. Then people can see and appreciate your work.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: Topological Naming, My Take

Post by dprojects »

Zolko wrote: Tue Aug 16, 2022 3:46 pm based on their history, and try to make it such that the identifiers can be used by subsequent operations and that these operations will preserve the model building steps. This is what realthunder's solution does
I don't know the realthunder build but I like the LinkGroup and Link features. I think this is game changer. I have problem with drilling thru Link because if I select the hole edge the drill bit is created at the base object but I like the LinkGroup and Link features very much. I solved it with Clones instead of Links Pilot holes for angles, hinges. But make a not I drill at Cubes and they are changed into Pad and than into many holes objects. So there is also the TNP solved.

But if you want build something on history, the history must be reliable. But if you make several undos or have trash in local setting files.

As I mentioned this solution I show, solved the described problem at the website. The example. But all PartDesign objects need to be created one at the other, there cannot be gap. So they are at the same plane, In fact even if you don't have Sketch you can check Vertices, you can refer to CenterOfMass, the Vertices must be at the face.

There are many ways. But this page you need to see as THE solution for macros, workbenches that other developers will be created in the future. This show some kind of approach how it can be solved. But yes the implementations may differ, even a lot, but the main rule stay the same.

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Topological Naming, My Take

Post by adrianinsaval »

The solution is too specific, from what I can see it compares the position of the face and changes the reference once if finds a face that has a similar enough center of bounding box as the initial face, but this is useless most of the time since the referenced face many times moves and/or deforms and/or rotates, this would not be solved by this approach. If you only mean to showcase the basic principle of reassigning a broken reference... does anybody actually need such a page? Isn't it common sense? IMO the page is at the very least misleading and maybe even counterproductive. In any case we could put some short explanation that a solution for TNP would have to store some data to be able to identify topology after a change of name.

similarly this page seems useless nowadays: Topological_Naming_Project should it be marked somehow as outdated/abandoned?
Zolko wrote: Tue Aug 16, 2022 3:46 pm for each operation, before a recompute, store the identifiers to the resulting shapes in some variable, make the recompute, and try to figure out how to make the old and new shapes correspond through their identifiers. This is what OCC's built-in TNaming does, and apparently what dprojects solutions does also
but how would you reliably do this without taking the history into account? This is a very poor solution IMO, it's better than nothing I guess but it would still very constantly break.
The worry I'd have with the second approach is how well it behaves for very complex models with lots of history, including booleans, copies, clones, shapebinders ...
what exactly are your worries? performance? or reliability? IMO it would be more reliable than your first option, performance wise, we would need some benchmarks but I don't expect it to have too big of a performance hit, and if it does it might only be noticeable when you do a full recompute of all objects. Also, how complex are we talking about?
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Topological Naming, My Take

Post by Kunda1 »

JFYI, I checked in with realthunder on where he's at with the patches. He said in general that it's been a tedious process - reorganizing his previous patches (i guess navigating git conflicts and cosmetic changes etc..) and dealing with the subsequent boredom of it. The amazing news is that the perhaps in the upcoming week or next, we will hopefully see the first PR for toponaming :D
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Topological Naming, My Take

Post by adrianinsaval »

That's great news, hopefully this time around it won't stall for two years and force another tedious rebase.
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: Topological Naming, My Take

Post by chrisb »

I am very very unsure how to rate and how to handle this page, which is called "TNP solution". Here are thousands of posts where we tell people that their problem comes from the topological naming problem.
Seeing the title of the page I would expect a solution for my broken project, or at least how I should have handled it.

I have given it a try:
- I have loaded a project, where I know that it breaks on a certain change
- copied the code from the wiki page
- executed it in Python console.

I see an error before even making the change, that breaks the model:

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 4, in makeTNP
NameError: name 's2' is not defined. Did you mean: 's1'?
So what now? I wouldn't call this a solution to the topological naming problem. Not at all. If it is a solution for one certain model, it's ok, but that has to be made clear.

So please rename this page. The title is (utterly) misleading.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53928
Joined: Tue Mar 17, 2015 9:14 am

Re: Topological Naming, My Take

Post by chrisb »

dprojects wrote: Tue Aug 16, 2022 10:40 am I am not sure if the wiki support adding FreeCAD files so I add this here,
I have taken the model uploaded in your post above and done the following:

- load the model. As the body showed a dangling recompute I recomputed). The model looks like this:
SnipScreenshot-70ca58.png
SnipScreenshot-70ca58.png (24.56 KiB) Viewed 1383 times
- run the script, it terminates without issues, the model looks as before
- change the attachment mode of Sketch from "Planeface" to "Objects XZ"
- The model looks - expectedly - after a recompute like this:
SnipScreenshot-82aed0.png
SnipScreenshot-82aed0.png (21.03 KiB) Viewed 1383 times
- calling moveBack() cuts a piece of the model:
SnipScreenshot-aae4e7.png
SnipScreenshot-aae4e7.png (18.92 KiB) Viewed 1383 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply