Mon, 04/25/2022 - 15:31
Hi everyone! As for the title, I want to get the TDF_Label from TopoDS_Shape, so I use the XCAFDoc_ShapeTool::FindShape, but it doesn't work, there is my code:
// Get shape
TopoDS_Shape shape = myAISContext()->DetectedShape();
// shapeL gets from TDoc_Std_Document::Main()
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(shapeL);
// becasue I know the type of shape I choose is edge, so I transform to TopoDS_Edge
const TopoDS_Edge edge = TopoDS::Edge(shape);
TDF_Label aLabel = myAssembly->FindShape(edge);
if (aLabel.IsNull())
{
cout << "No Label" << endl;
}
else
{
cout << "Get Label" << endl;
}
And the result returns always "No Label".
Could anyone help me? Thanks.
Sun, 05/01/2022 - 17:18
Thanks, everyone, I solve it by myself. There is my code:
Wed, 05/04/2022 - 10:09
It is hard to understand the source of the problem in your initial example, because we don't know the content of original file and the shape you have got from AISContext. I may only guess that the problem in the second argument of FindShape method. "findInstance = Standard_False" by default, so, it removes the location of the searched shape. Perhaps, if you set it to True, it will work in the same way as your method, but in some more optimized way.