When do I use the TNaming_Selector class ?

Hi All,

When do I use the TNaming_Builder::Select() function ? And How can I use the TNaming_Selector class ?

these classes seem to have some useful functions to identify the referred NamedShape and to regenerated a model.

However I am not sure how to use it.

Thank you for any help.

Li keda

Sergey RUIN's picture


The method TNaming_Builder::Select() is used to add in an application framework the shape with evolution "TNaming_SELECTED", NamedShapes with this evolution type aren't used in the naming process. An example of its using can be an addition a TopoDS shape that already was named after it being selected in a viewer.

The class TNaming_Selector is used to name a subshape of the context shape for example a face of the box. Here is an example:

TopoDS_Solid aBox = ...;

//...Adding box in a data framework

TNaming_Builder aBuilder(aSomeLabel); aBuilder.Generated(aBox);

//...Displaying of aBox

//...Selection of one of aBox's faces

TopoDS_Face aFace = ...; //Selected face

TDF_Label aLabel;

//...Finding|Creation of the label

TNaming_Selector aSelector(aLabel);

aSelector.Select(aFace, aBox); // Naming of aFace

// ...Modification of aBox (Ex. to increase the size)

//Solving of the face naming

TDF_LabelMap aMap; aMap.Add(aSomeLabel);


//Now the data framework contains the face of increased aBox corresponing the original face.

Handle(TNaming_NamedShape) aNS = aSelector.NamedShape();

TopoDS_Face aNewFace = TopoDS::Face(aNS.Get());

Best Regards


Li keda's picture

Thank you Sergey.

I've tried the TNaming_Selector class in a test program, but it seems not to work.

// Create a prism TopoDS_Face F1 = ...; // Create a base face

TopoDS_Shape S1 = BRepPrimAPI_MakePrism(F1, gp_Vec(0,0,100));

// Adding prism in a data framework

TDF_Label label = ...;

TNaming_Builder B1(label);


// Naming of all faces in prism

TDF_LabelList list;

TopTools_IndexedMapOfShape mapShape;

TopExp::MapShapes(S1, TopAbs_FACE, mapShape);

for(int i = 0; i < mapShape.Extent(); i++) {

// Naming of face

TNaming_Selector aSelector(label.FindChild(10+i));

TopoDS_Face face = TopoDS::Face(mapShape(i+1));

aSelector.Select(face, S1);


// Modification of prism ( modify base face and lengh )

TopoDS_Face F2 = ...; // different from F1

TopoDS_Shape S2 = BRepPrimAPI_MakePrism(F2, gp_Vec(0,0,50));

TNaming_Builder B2(label);

B2.Modify(S1, S2);

for(i = 0; i < mapShape.Extent(); i++) {

// Solving of the face naming

TDF_LabelMap mapLabel;


TNaming_Selector aSelector(label.FindChild(10+i));


// I want to get the face on S2 which is corresponding to the face on S1. But aNewFace is not.

Handle(TNaming_NamedShape) aNS = aSelector.NamedShape();

TopoDS_Face aNewFace = TopoDS::Face(aNS->Get());


when a model is edited, I want to know with which face in an original model the face in a new model correspond.

what I am doing wrong?

Li keda

Sergey RUIN's picture

Hi Li,

TNaming_Selector is not used to find correspondence between old and new shapes. The main goal of this class is to provide correct naming of selected in a viewer subshape in order to have that selected shape to be up to date when an original shape is modified.

In order all that being working you have to follow the next schema:

1. Create TopoDS_Shape (Ex. Prism)

2. Provide initial naming of the created shape.

In case of prism, use TNaming_Builder::Generated(TopoDS_Shape) for the prism itself, then using methods of BRepBuilderAPI_MakeShape base class you have to find what edge generated each face of prism and through method TNaming_NamedShape::Generated(theEdge, theFace) add this info to the dataframework. Next add the bottom and the top faces of prism.

3. Select some subshape of the prism and use TNaming_Selector to name it.

4. Modify the prism and perform step 2 to name a resulting prism using the same labels.

5. By method TNaming_Selector::Solve(aMap) solve the naming of subshape to get it being up to date. has to contain all the labels that were used to name the prism on step 2.

Best Regards