Build object using multiple sublabels -- TNaming_Tool

Hi cascade users,

suppose i have a TDF tree like:

CHILD LABEL
|
----- Final Object
|
---- TopFace
|
---- Bottom Face
|
---- FrontFace
|
---- BackFace

I want my Final Object to be constructed from the sublabels NammingShapes TopFace,...,BackFace. i want to able to modify only one of the faces, and reconstruct the final object latter from the sublabels TopFace,....,BackFace.
Is there a way to do that?

i think i need TNaming_Tool tool, but the manual's is not clear to me.
Could someone give me an example using TNaming_Tool?

Shawn Yang's picture

Hi:
I think the "TNaming_Tool" that can let you retrieve back the shape that has been stored in the OCAF. The sample is as following:

Handle(TNaming_NamedShape) TNS;
FinalObjectLabel.FindAttribute(TNaming_NamedShape::GetID(),TNS);

TopoDS_Shape aShape=TNaming_Tool::GetShape(TNS);
....

After you get new shape, you have to modify the shape back to the FinalObjectLabel in the OCAF.

TNaming_Builder B(FinalObjectLabel);
B.Modify( aShape, aNewShape);

Then, give the "display" function, again. That will be change the shape on the screen. If you need.

Wish it can help you.

Shawn

David Jorge's picture

Thanks shawn,
this is my first attempt to work with TNamming_Tool package. And what if my finalobjectLabel is empty? it's mandatory have a nammedShape in the finalObjectLabel? I don't know if my question has any sense!

Can you give-me a more detailed example to better understand how TNamming_Builder works?

My goal it's to have the finalobject faces on the sublevel's (of the finalobjec). i'd like to treat a face independently of the the other faces, so i
can apply modifications to only one face. After doing the modification to the face, i want to reconstruct the object.

I don't know if this is the better way to do!

Joyice's picture
Shawn Yang's picture

Hi:
Handle(TNaming_NamedShape) TNS;
if (FinalObjectLabel.FindAttribute(TNaming_NamedShape::GetID(),TNS))

{ //The shape is existing in FinalObjectLabel
TopoDS_Shape aShape=TNaming_Tool::GetShape(TNS);
if (!aShape.IsNull())
{..... //Do Modify shape
}
}
else
{
.....//Set the TNaming_NamedShape attribute
}

Wish it help.

Shawn

David Jorge's picture

Shawn, im my code i'm changing the shape back to the FinalObjectLabel with:

TNaming_Builder B(FinalObjectLabel);
B.Replace( aShape, aNewShape);

and it works fine (my namedShape is updated).

What's the diference between using ::Replace and ::Modify methods of TNaming_Builder?

Thanks in advance,
David Jorge