Topological Naming and Selection

I've got a TNaming_Selector demo working (in pythonOCC). I need advice on the best practices for working with Topological Naming. Should one always create Named Shapes for ALL subshapes of a solid (faces, edges and verts) or is it sufficient to just name (and select) the faces?

For example, my demo program uses boolean cut followed by a chamfer operation. I only need to select an edge for chamfering, so I'm only creating named shapes for the edges of all solids. This mostly works, but TNaming_Selector cannot solve for certain edges. I think my naming-structure is inadequate but I'm not sure in what way.

Any advice from Topological Naming Experts would be most welcome.

bryancole's picture

OK, I figured this out. I only need to Name faces. TNaming_Selector figures out the identity of other subshapes (edges etc.) based on the faces to which it is connected. My demo program is available in pythonOCC, in case anyone wants to take a look.

Robert Hill's picture

I'm definitely interested in taking a look. I've been struggling to make the TNaming_Selector class solve method work properly. I'm not actually using python OCC but would you be willing to share some code?

According to your post, do you mean that you need to name each face of any objects your create before you use the TNaming_Selector to select a sub-shape?

Thanks, R. Hill

bryancole's picture

Check out the the code in

pythonOCC/samples/Level2/InteractiveFeatureTree

To summarise, first you need to set up the "naming structure" . For each operation which *generates* topology from scratch (e.g. a BRepPrimAPI function), You Name the resulting shape and each of the generated sub-shape Faces. Then, for every operation which modifies a Shape, you use the .Modified(), .Generated() and .Deleted() methods on the algorithm (they all have them) to iterate over *every* generated, modified or deleted face and then you Name them all. In effect, you're creating a complete map linking all faces to the input topology which created them. This is what TNaming_Selector uses to figure out the identity of a topological feature. Setting this up isn't quite as bad as it sounds (using python, at least). The Naming operations are found in the .UpdateNaming() methods on each of the operation classes.

With the naming structure set up, you can use TNaming_Selector. From experimentation, you need to call .Solve() on the same Selector instance which performed the selection.

I expect the python code will be easier to follow than my rambling... good luck.

bryancole's picture

I should have been a bit more explicit: you can find the TNaming_Selector used in

pythonOCC/samples/Level2/InteractiveFeatureTree/occ_model.py

and the ChamferFilter class in particular.