[meeting minutes] developer meeting on how to integrate Toponaming

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!
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by wandererfan »

Zolko wrote: Sun Jul 17, 2022 11:28 am So it boils down to this: is it currently possible to create OCC objects with names chosen by FreeCAD ?
It depends.

If the code creates and manages a single object (say with BRepPrimAPI_MakeCylinder), and then only uses the whole object, you can call it anything you want.

Things are different when dealing with pieces of a shape. If you want the faces of your cylinder, then you have to iterate through the cylinder (say with TopExp_Explorer) and you get the faces in what ever order OCC wants to serve them up. Face3 is a name FC gives to the third face delivered by TopExp_Explorer.

As far as I kinow TopExp_Explorer makes no guarantees on the order subshapes are delivered, but it is consistent for a given shape. If the shape to be explored changes, then the order of subshapes will almost certainly change.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by looo »

It would be awesome to have a nice and clean interface so we can try different algorithm for the topo-naming issue. As far as I understand there is not "the one and only solution" which solves all the topo-naming issues. Maybe we could also try some machine-learning algorithm and train them by specific files where a defined solution exists. Not sure if this makes a lot of sense.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by Zolko »

wandererfan wrote: Sun Jul 17, 2022 2:51 pm
Zolko wrote: Sun Jul 17, 2022 11:28 am So it boils down to this: is it currently possible to create OCC objects with names chosen by FreeCAD ?
If you want the faces of your cylinder, then you have to iterate through the cylinder (say with TopExp_Explorer) and you get the faces in what ever order OCC wants to serve them up.
Thank-you for the explanation.

So, if I understand correctly, FreeCAD asks OCC to create a shape from (say) an extrusion of a wire made by Sketcher, and then asks OCC to cycle through the delivered shapes, and assigns the name that OCC gives back.

wandererfan wrote: Sun Jul 17, 2022 2:51 pm Face3 is a name FC gives to the third face delivered by TopExp_Explorer.
So I understand that the INDEX 3 is given by OCC (TopExp_Explorer) but is the NAME "Face3" assigned by OCC or FreeCAD ?

Because if it's FreeCAD, we could overrule OCC's TopExp_Explorer and assign another index. For example, for a sketch, we could assign as index (in the outside world) the internal index (as held by Sketcher)
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by wandererfan »

Zolko wrote: Mon Jul 18, 2022 8:38 am So I understand that the INDEX 3 is given by OCC (TopExp_Explorer) but is the NAME "Face3" assigned by OCC or FreeCAD ?
Face3 is "assigned" by FreeCAD, OCC has no such concept. The name is built as needed by combining the geometry type (Face, Edge, etc) and the index. Later, the index is extracted from the name to access geometry.

I guess you could have a mapping function to convert the OCC index into some other number and back again. That would have to touch a lot of code.
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by Zolko »

wandererfan wrote: Mon Jul 18, 2022 2:29 pm Face3 is "assigned" by FreeCAD, OCC has no such concept. The name is built as needed by combining the geometry type (Face, Edge, etc) and the index.
that's what I was looking for. Do you know where this happens in the code ? What function I can grep ?
try the Assembly4 workbench for FreCAD — tutorials here and here
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by Chris_G »

User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by wandererfan »

Zolko wrote: Mon Jul 18, 2022 2:45 pm that's what I was looking for. Do you know where this happens in the code ? What function I can grep ?
I'm weak in the Coin area, so I could be talking rubbish, but ...

As far as I know, strings like "Face3" only exist as data fields in Coin nodes and in the Selection routines that access them. You'd be looking for something like the "subElementName" in Gui/SoFCSelection.cpp but I don't know how that gets populated.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by onekk »

Not adding more to the discussion, but only to have some idea clear. Mostly for my knowledge.

Tell me if I'm guessing wrong.

From the little I know when you ask OCC to model a solid it returns a BRP object built with his internal conventions, so it is numbering faces to make a shell and then a solid.

The thing is different from "primitives" as there is no variabilty so FC could simply store that I want a cylinder of radius R and height H (and probably with angle A to obtain a portion of the shape).

So when it come to enumerate faces it is simple to see the order in the BRP file that is documented in OCCT documentation.

The problem is when you modify the object and ask for a new object as OCC has to do the process from start and the order of faces is obviously different.


Now some toughts based on the above guesses.

There is be a mean to confront the two shapes and see if some of the faces are coincident and keep a database of the faces (probably this is already done by realthunder using the complex face names he has implemented, sadly I'm on mobile and it is difficult to consult docs on a smartphone screen.)?

Why such a similar thing could not be done say using a sqlite3 database that is in the standard Python library pack, probably it would be fast when managing lot of solids in a complex project)?

Sorry for the nuisance and the clearly OT post.
TIA for any answers.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by Zolko »

wandererfan wrote: Mon Jul 18, 2022 7:40 pm As far as I know, strings like "Face3" only exist as data fields in Coin nodes and in the Selection routines that access them. You'd be looking for something like the "subElementName" in Gui/SoFCSelection.cpp but I don't know how that gets populated.
It looks like that happens in ~/src/Base/Builder3D, which contains InventorBuilder which seems to do the job :

Code: Select all

void TopoShape::exportLineSet(std::ostream& str) const
{
    Base::InventorBuilder builder(str);
    ...
    builder.addLineSet(vertices, 2, 0, 0, 0);
I think that it builds the Coin3D node, but it doesn't seem to include the Face or Edge or Vertex strings. Although there is a function to include a label to the node; but which isn't used apart by Mesh

Code: Select all

void InventorBuilder::addLabel(const char* text)
{
    result << Base::blanks(indent) << "Label { " << std::endl;
    result << Base::blanks(indent) << "  label \"" << text << "\"" << std::endl;
    result << Base::blanks(indent) << "} " << std::endl;
}
I'll open another thread to not pollute this one
try the Assembly4 workbench for FreCAD — tutorials here and here
C_h_o_p_i_n
Posts: 225
Joined: Fri Apr 26, 2019 3:14 pm

Re: [meeting minutes] developer meeting on how to integrate Toponaming

Post by C_h_o_p_i_n »

Dear All,

Like the search for the Holy Grail ...

form an very outside view part of this debate looks to me as that some Guy's start to look on ways to fix TNP other than done by realthunder ...

"No - we shouldnt do it this way - there must be something better" ( ... and invented by me ).
"No - its by me"
"No me" ....

All the last couple of years - there was no real solution ... and now ?
How about aknoledging that rt found one way to the "Holy Grail" and made it available with proof of concept.

Please jump over your shadows - It just need to be integrated.

Just my 2 cents, regards, Stefan
Post Reply