Face clicking returning copies ?

Hi,

Every time I click a face I store it in a container (like a TopTools_MapOfShape for example). Then when it's clicked again ,it allows me to know if such a face has been previously clicked or not. However I have the feeling that every time a face is clicked, it is not the original face that is returned but a copy of it. So I can never know if it has been clicked before or not... and it looks like the container stores several times the same face. Any hints ?

Thanks,

Vinocell's picture

I confirm that when you click a face on the screen the TopoDS_Face returned by the function ViewerTest::PickShape() is not the original one but a copy as shown in the code below :

//=======================================================================
//function : SelectedShape
//purpose :
//=======================================================================

TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
{
if (!HasOpenedContext())
{
TopoDS_Shape aResShape;
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive());
if (!aShape.IsNull())
{
aResShape = aShape->Shape().Located (TopLoc_Location (SelectedInteractive()->Transformation()) * aShape->Shape().Location());
}

return aResShape;
}
else
{
return myLocalContexts (myCurLocalIndex)->SelectedShape();
}
}

This is due to the fact that the function Located() builds a copy of the TopoDS_Shape.
The question is : how to return the original shape ? Because I woudn't want to modify the function above...

Benjamin Bihler's picture

Shapes have the methods IsSame and IsEqual. With them you could try to compare whether the faces are the same from a geometric point of view.

Benjamin

Vinocell's picture

Hi Benjamin,
The question is if F2 is a copy of F1 do you think that (F1.IsEqual(F2) == Standard_True) and/or (F1.IsSame(F2) == Standard_True). Under which conditions i.e. for which kind of copy ?
Best regards,
V.

Benjamin Bihler's picture

Yes, both should be true for a copy of the instance. Look at the documentation in TopoDS_Shape.hxx. IsSame is true, if the shape and the location are the same, but the orientations may differ. IsEqual is true, if IsSame is true AND the orientations are the same.

Forum supervisor's picture

Dear Vinocell,
The quoted implementation corresponds to OCCT 6.8.0 and has been changed in OCCT 6.9.0 within patch for #25627 (http://tracker.dev.opencascade.org/view.php?id=25627).
Have you observed the problem on OCCT 6.9.0 release?

Best regards
FSR

Vinocell's picture

Thanks a lot for your answer but I've been working quite a lot on the 6.8.0 and I can't make the move yet to the 6.9.0 I'll keep you informed when I update my OCCT version.
Best regards,
V.