Wed, 04/21/2021 - 09:56
Forums:
Hello everyone,
I'm new here and want to get some help,when I use the function BRepExtrema_DistShapeShape() to compute the mindistance of two Shape.One of them is a reduced robot model(TopoDS_Shape),another is an Artifact(TopoDS_Compound),at first ,the function was running fast,it spend approximate 100ms one time,but as time gose by,its speed will be more and more lower, I want to know why its speed get lower and how to promote its speed,maybe keep the initial speed will be ok.
I'm sorry about my poor English,and I'm so appriciate if some can give me some advice.
Thanks!
Wed, 04/21/2021 - 11:34
What do you mean "as time goes"? Function becomes slower at second / n-th call or after some changes in the shape (which then)?
Wed, 04/21/2021 - 11:52
Thank you for replying, when I get one distance of two this two shape ,I will tranlate the robot shape to a new location and use the function once again.I repeat the process about 1k times. First 20 times is fast and then become slower and slower.
Wed, 04/21/2021 - 13:50
If you are translating shape incrementally many times, then you may struggle with accumulated history in TopLoc_Location - depending on how new location is set.
Sharing the code showing how you locate the shape may reveal what might cause problems.
Wed, 04/21/2021 - 14:46
void occqtWidget::MoveShape(TopoDS_Shape& aLSObjects, gp_Vec& aVec) {
gp_Trsf theTransformation = gp_Trsf();
gp_Vec theVectorOfTranslation = aVec;
theTransformation.SetTranslation(theVectorOfTranslation);
BRepBuilderAPI_Transform myBRepTransformation = BRepBuilderAPI_Transform(aLSObjects, theTransformation, false);
aLSObjects = myBRepTransformation.Shape();
}
void occqtWidget::RotateShape(TopoDS_Shape& aLSObjects, gp_Ax1& axe, double& degree) {
gp_Trsf theTransformation = gp_Trsf();
theTransformation.SetRotation(axe, degree);
BRepBuilderAPI_Transform myBRepTransformation = BRepBuilderAPI_Transform(aLSObjects, theTransformation, false);
aLSObjects = myBRepTransformation.Shape();
}
Thanks a lot for your replying , I use this two function to tranlate my shape,whether this two function cause my problem?
Thu, 04/22/2021 - 11:51
Indeed, using BRepBuilderAPI_Transform in such way leads to continuous accumulation of transformations history:
TopoDS_Shape::Moved() is designed in such a way that result TopLoc_Location preserves the history of all multiplications. This is intended behavior required to identify different TopoDS_Shape within hierarchy with shared instances, but it might be unexpected in case of trivial transformation.
Things to consider in your code:
This is not only causes additional issues with TopLoc_Location, but actually leads to additional error accumulated by floating point math.
Store TopoDS_Shape with original location and apply final gp_Trsf to it instead of computing delta transformation at each step,
But this just answers only why your code might become slower and slower within many iterations doing similar actions.
Thu, 04/22/2021 - 15:02
I'm so appreciate about your help!We saved a lot of time because of your help.And my leader is so glad that say if you travel to China AnHui WuHu, we will receive you warmly!: )
Wed, 04/21/2021 - 11:58
I suppose you simulate motion of shapes one relative the other. In this case (especially when one object becomes surrounded by the bounding box of another one) the increasing computation time is a usual deal. Indeed, this tool is not appropriate to use in such environment.
You can look at advanced component developed for this kind of computation - Collision Detection.
Wed, 04/21/2021 - 12:14
Thank you. So how much is this advanced component developed.