How to obtain the "correct" shape from a reference label of a XDE Document


I am trying to obtain a shape from a label as a particular case of a reference label.
Please, see my example :

Handle(XCAFDoc_ShapeTool) theAssembly ...
theAssembly->IsReference(aCheckLabel) returns Standard_True.

TopoDS_Shape aShape theAssembly->GetShape(aCheckLabel);
This shape is not correctly located.
I have read the explanation of this result in the documentation of XDE ...

The method to obtain the location of the shape is :
TopLoc_Location aLocation= theAssembly->GetLocation(aCheckLabel);

How is it possible to obtain the shape correctly located ?

I have tried :
aShape.Moved(aLocation); the result is bad.

If someone, can help me ...

Forum supervisor's picture

Dear Denis,

Valid method to get shape with location is the next:
Standard_Boolean XCAFDoc_ShapeTool::GetShape (const TDF_Label& L, TopoDS_Shape& S);

Draw command to get shape from the specified label of the document - "XGetShape". This method returns located shape if location for shape is presented in the document.
Please find below Draw reproducer:
pload ALL
box a 0 0 0 10 10 10
ttranslate a 100 0 0

XNewDoc D1
XAddShape D1 a 1
### => 0:1:1:1
erase a
XGetShape r D1 0:1:1:1
dump r
After that you will
The variable 'r' will contain the box at the specified before location. Simple dump (using 'dump' draw command) proves it:
Dump of 1 Locations

1 :
Elementary location
( 1 0 0 100 )
( 0 1 0 0 )
( 0 0 1 0 )

Best regards

Denis Teissandier's picture

Thank you very much for your assistance.
The different components are correctly located if I explore the father assembly on the first level of the following example :

Standard_Boolean isassembly= theAssembly->GetComponents(anAssemblyLabel, childs, Standard_False);
But, in this case, some components are displayed as Compound and not as Solid (It is my objective).

If I replace Standard_False by Standard_True, the components are not correctly located.
In this case, the components are displayed as Solid.

So, to complete your answer, is it possible to know about a way to obtain correctly located Solids ?
Best regards,

Forum supervisor's picture

Dear Denis,
If you need our further assistance you may contact us via the Contact Form
We will try to find a solution/workaround acceptable for you.
Training and e-learning courses are also at your disposal -
Best regards