How to accelerate the update time

Rubiofm7

CAD practitioner
Hi,

I am testing the OCC 7.5.0 version for a project about robot simulation. I'm trying to simulate a series of motions of a robot. I use some basic classes ( gp_Trsf, gp_AX1, gp_Pnt ), AIS_Shape, and its public function SetLocalTransformation to calculate and set the transformation. All done I used updateCurrentViewer in the end. But the view does not update quickly, it updates the frame in 16 ms. I want to ask whether there's a method to update the view in 10 ms or less.

Another try : I raised the FPS of the screen to 70HZ, but the update time was still about 16 ~ 18 ms.
 

natalia

Moderator
Staff member
Hello, @Rubiofm7

Please, provide more details about the AIS_Shape object that you're creating:
1. How many AIS_Shape objects do you create?
2. What does the TopoDS_Shape object contain?
3. Do you activate the AIS_Shape objects it in the context for selection purposes?

Regards, Natalia
 

Rubiofm7

CAD practitioner
Hello, @natalia

I simulate a six-joint Robot (including its base ), so the total AIS_Shape objects are 7. But Actually, the num of shapes needed to update is 6 ( the base does not move ).

I just use the default example of ImportIges function, which it seems that I don't activate the context for selection purposes and contain other things in TopoDS_Shape. And the attached photo is the ImportIges code.
1709776238249.png

And other info is that the CAD files of each joint is about 7mb.
Thanks for your help.

Regards, Rubio
 

Rubiofm7

CAD practitioner
Hello, @natalia

I want to ask further questions. Is there any way to accelerate the rendering of the CAD files I import?
When I load the files of Robot one by one by code, it takes about 13 seconds to show all fully.
Is there any way maybe compress the files by OCC or more advanced import skills?
 

natalia

Moderator
Staff member
Hello, @Rubiofm7

Now, the number of presentations and their selection status are understood.
However, the contents of the TopoDS_Shape remain unclear. Specifically, the number of geometric elements and their interconnections are unknown.

Preparing a mesh for visualization using this data could be time-consuming.
To evaluate the impact of meshing on performance, consider the following adjustment to the created AIS_Shape:

C++:
presentation->Attributes()->SetAutoTriangulation(Standard_False);

Subsequently, call Display for the shape.

The anticipated outcome is a change in the presentation's appearance or even its overall behavior in the viewer.
However, it is crucial to assess the performance impact on your model. If an improvement is observed, further adjustments to meshing parameters can be explored to optimize performance.

For simplicity, let's initially focus on a single presentation.

Regards, Natalia
 

Rubiofm7

CAD practitioner
Hello, @natalia

Thanks for the advice, do you mean that I should do that on code, here is my code
C++:
// CADModel is a NCollection_Haft of AIS_Shape
CADModel().back()->Attributes()->SetAutoTriangulation( Standard_False );

After the testing, all model imports cost about 12 sec. Just a little bit optimize the time. But the model shown on the screen will be wireframe type. ( But I want it to be shaded ). So do you have any suggestions?

Btw, what do you mean by "the geometric elements and their interconnections"? Do you mean that I should output the geometric number by TopoDS_Shape::NbChildren()? The interconnections between the CAD model are like industrial robot :
1709862382741.png
 

natalia

Moderator
Staff member
Hello @Rubiofm7

Have you attempted to use SetLocalTransformation() on the wireframe presentation? How does it affect the view update time?

Regarding loading time, have you tried using OCCT 7.8.0, which was released in December 2023? According to the release notes, it includes improvements in memory and data exchange logic: https://dev.opencascade.org/content/open-cascade-technology-780-released.

By "the geometric elements and their interconnections" I’m referring to the number of vertices, edges and faces and their types within the loaded geometry. TopoDS_Shape::NbChildren() does not provide this information.

Regards, Natalia
 

Rubiofm7

CAD practitioner
Hi @natalia,

Thanks for your reply. After I used the SetLocalTransformation with wireframe presentation, it still updates in 16ms.

I never use 7.8.0 because some API are updated that some functions I wrote before may not support.

And the loaded Geometry is TopAbs_SHAPE.

Regards, Rubio
 

JSlyadne

Administrator
Staff member
Hi @Rubiofm7,

It's quite tricky to hint you about a way to go until we can see a code dedicating to implication of trsf to robot's joints and updating the scene afterwards. Is it possible to provide the community with this piece of code and models you import? Otherwise, it's unlikely anyone can really assist you.
 

Rubiofm7

CAD practitioner
Hi @JSlyadne,

Here is my part of the code :

C++:
// set the transformation
gp_Trsf trsf1, trsf2, trsf3, trsf4, trsf5, trsf6;
gp_Ax1 axe1 = gp_Ax1( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ) );
gp_Ax1 axe2 = gp_Ax1( gp_Pnt( 30, 0, 421.7 ), gp_Dir( 0, 1, 0 ) );
gp_Ax1 axe3 = gp_Ax1( gp_Pnt( 30, 0, 1011.7 ), gp_Dir( 0, 1, 0 ) );
gp_Ax1 axe4 = gp_Ax1( gp_Pnt( 126, 0, 1046.7 ), gp_Dir( 1, 0, 0 ) );
gp_Ax1 axe5 = gp_Ax1( gp_Pnt( 615, 0, 1046.7 ), gp_Dir( 0, 1, 0 ) );
gp_Ax1 axe6 = gp_Ax1( gp_Pnt( 698, 0, 1046.7 ), gp_Dir( 1, 0, 0 ) );
trsf1.SetRotation( axe1, degree[ index - 6 ] * M_PI / 180. );
trsf2.SetRotation( axe2, degree[ index - 5 ] * M_PI / 180. );
trsf3.SetRotation( axe3, degree[ index - 4 ] * M_PI / 180. );
trsf4.SetRotation( axe4, degree[ index - 3 ] * M_PI / 180. );
trsf5.SetRotation( axe5, degree[ index - 2 ] * M_PI / 180. );
trsf6.SetRotation( axe6, degree[ index - 1 ] * M_PI / 180. );
// update model, iter is the iterator of the AIS_Shape pointer list, which stores all CAD files of Robot
( *iter )->SetLocalTransformation( trsf1 * trsf2 * trsf3 * trsf4 * trsf5 * trsf6 );
// update view
myAISContext()->UpdateCurrentViewer();

I calculated the transformation matrix one by one. And the example above is calculating the sizth joint, so it has six gp_Trsf objects.

Regards, Rubio
 

JSlyadne

Administrator
Staff member
I don't see any problem in this code. Just a naive question, do you run your application in Release mode?
 
Last edited:
Top