
Tue, 09/09/2003 - 12:06
Forums:
I am still struggling with OpenCascade. Today I have got a question regarding the regeneration of a Dimension.
Imagine the following:
I have got a TopoDS Shape and a related AIS_Shape.
Then I generate an AIS_LengthDimension from one face to another one. Everything is displayed correctly. So far so good ...
Now I apply a translation to the TopoDS_Shape and I call AIS_Shape.Set(TopoDS_Shape) and AIS_Shape->Redisplay(). The shape is now displayed at its new position.
But how do I reposition the Dimension ?
I had a look at the sources and everything I see is, that the Compute methods do the computation, but the documentation says, that the user shall not call this methods directly. How can I do this ?
Markus
Tue, 09/09/2003 - 13:10
I think I found the problem - but this does not help at all:
The problem is, that the referenced faces returned by AIS_LengthDimension.FirstShape() and AIS_LengthDimension.SecondShape() do not share the same location as the original faces in the TopoDS_Shape - in fact I do not know if they share the faces at all (the documentation says, that copying a TopoDS_Shape does not duplicate its shape data but generates a new location).
The question os now: How can I share the Location of two shapes ?
Has anybody played around with dimensions and has applied transformation to the underlying shapes ?
Kind regards
Markus
Tue, 09/09/2003 - 16:03
Hello,
I think you will have to do a SetFirstShape and a SetSecondShape on your dimension with the translated shape.
Tue, 09/09/2003 - 16:29
Thats true, but how to I get the translated shape ? As I said in my response to this topic: The stored shape does not reference to performed translation but shares only the underlying shape.
Markus
Tue, 09/09/2003 - 17:09
Use the shape you transform and assign to your AIS_Shape.
Tue, 09/09/2003 - 17:15
Thats excactly what I do - but this does not change the position of my AIS_LengthDimension since this references two faces with the original location !
Markus
Tue, 09/09/2003 - 17:32
Maybe were are not talking about the same thing?
I'm talking of something like this:
// transform your shape
gp_Trsf yourTransform;
BRepBuilderAPI_Transform trsf(yourTransform);
trsf.Perform(shape1);
TopoDS_Shape trsfShape1=trsf.Shape();
trsf.Perform(shape2);
TopoDS_Shape trsfShape2=trsf.Shape();
// reassign the shape
aisShape1->Set(trsfShape1);
aisShape1->Set(trsfShape1);
aisLength->SetFirstShape(trsfShape1);
aisLength->SetSecondShape(trsfShape2);
aisContext->Redisplay(aisShape1,Standard_False,Standard_True);
aisContext->Redisplay(aisShape2,Standard_False,Standard_True);
aisContext->Redisplay(aisLength,Standard_False,Standard_True);
aisContext->UpdateCurrentViewer();
So the shapes in the AIS_Shape and in the AIS_LengthDimension have to be the same...
Tue, 09/09/2003 - 20:03
Ok, I have checked your code and it works. Thanks for that.
Unfortunately it doesn't help a lot, since a get the two shapes from the AIS_InterActiveContext::SelectedShape() which returns a TopoDS_Shape and not a TopoDS_Shape &
, so I haven't got the original shapes ! Additionally the shapes are loaded from an Iges file, so I haven't got them in memory directly (as in the example above).
So the basic question is: How can I get a reference to the original shapes from an interactive selection ?
Any suggestions ?
Markus