For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Big topology compound - maximize speed

Alena's picture
Forums: 

Hello!
Give me some advices, please.
I read a file with topology data (edges and shells) and try to display it by building a Compound. My method works for small models, by I need to display, for example, model with ~2000 edges and ~100 000 shells, and in this case all actions on model (rotation, zoom) are too slow. For model with ~70 000 edges and ~500 000 shells problem is not only in bad performance: after displaying (image appears) program crashes.
I build topology this way:
myAISContext->CloseAllContexts();
BRep_Builder builder;
TopoDS_Compound Comp;
builder.MakeCompound(Comp);
while (lines.MoveNext()) {
(*lines)->GetData (id, nd1, nd2);
builder.Add (Comp, BRepBuilderAPI_MakeEdge (gp_Pnt(nodes[nd1].x, nodes[nd1].y, nodes[nd1].z), gp_Pnt(nodes[nd2].x, nodes[nd2].y, nodes[nd2].z)));
}
while (pols.MoveNext()) {
(*pols)->GetData (id, ndc, nds);
BRepBuilderAPI_MakePolygon P;
for (int i=0; i P.Add(gp_Pnt(nodes[nds[i]].x, nodes[nds[i]].y, nodes[nds[i]].z));
builder.Add (Comp, P.Wire());
}
Handle(AIS_Shape) white = new AIS_Shape(Comp);
myAISContext->SetDisplayMode(white,0);
myAISContext->Display(white,Standard_False);
May be, I'm doing something wrong? Or there are better ways to do it? May be, it will be better to use 3d primitives?
Just in case, I specify, that I need: display a lot of edges (like lines) and a lot of shells (like polygons) with the possibility of selecting vertices (points, from which I build topology), edges and shells.
Thanks for any help!

jelle's picture

Hi Alena,

Are you sure your shape is built?
builder.Add (Comp, BRepBuilderAPI_MakeEdge (gp_Pnt(nodes[nd1].x, nodes[nd1].y, nodes[nd1].z), gp_Pnt(nodes[nd2].x, nodes[nd2].y, nodes[nd2].z)));

In PythonOCC the call is:
edg = BRepBuilderAPI_MakeEdge ( args )
edg.Build()
result= edg.Edge()

-jelle

Alena's picture

Hi, jelle,

Hmm... If it wasn't build, it wouldn't be displayed, or I'm mistaken?

jelle's picture

I don't know, but I'm curious what you are sending into the compound builder.
I'd have a look...

Alena's picture

I based on example from "Modeling algorithms" manual:
TopoDS_Edge E = BRepBuilderAPI_MakeEdge(C,V1,V2,p1,p2);
But later I modified it, because I thought, that it would be faster, and now I don't save result in TopoDS_Edge. I got the same speed and result image in the both cases...

Venugopal Gudimetla's picture

Hi Alena, like Jelle suggests, why don't you make sure the BRepBuilderAPI_MakeEdge and BRepBuilderAPI_MakePolygon indeed are done by checking through IsDone before you build the AIS object?

Venu

Alena's picture

Hi, Venu,
I tried to do this
BRepBuilderAPI_MakeEdge anEdge = BRepBuilderAPI_MakeEdge (gp_Pnt(nodes[nd1].x, nodes[nd1].y, nodes[nd1].z), gp_Pnt(nodes[nd2].x, nodes[nd2].y, nodes[nd2].z));
if (anEdge.IsDone())
builder.Add (Comp, anEdge.Edge());
But nothing has changed. Image and speed are the same.

Venugopal Gudimetla's picture

Hi, this may not improve performance, but did the program crash?

Alena's picture

Yes, it crashes in the same situation...

Venugopal Gudimetla's picture

Hi Alena,
Just throwing in my 2 cents: It appears you are reading in a line, building the edge and then displaying in a loop in that sequence. why display individual edge one at a time in a loop?
can't you:
1. loop through your lines and build a wire from those lines first
2. and then display just the TopoDS_Wire out side loop?
that way may be you will have to deal only displaying the wire object and it is faster? every time you display an object and then go and fetch a line, build it and then display it so and so forth, is a slow process in my view.

Venu

Venugopal Gudimetla's picture

Looking back I see what you are doing, please ignore my previous comment.

Alena's picture

I find in forum the advice about using SetAnimationModeOn() before, it's a little improved the performance. But program still crashes on big model from my example (with ~70 000 edges and ~500 000 shells). May be, it's not enough memory for this model?

Venugopal Gudimetla's picture

Hi Alena, in debug mode why not try using valgrind and see where it is taking time and where your memory usage problem exists? I never ran valgrind on OCC though.

Alena's picture

Hi, Venu,
I'm working with Windows, and valgrind is nix's utility, or not?

Venugopal Gudimetla's picture

Hi Alena, Thank sucks. I dont think valgrind runs on windows. As far as speed test is concerned, may be you can use timers before and after loops and see how much time it takes, that way you can narrow it down to certain function. Apart from this I am not aware of why OCC is slow. One more thing you can do is test a smaller subset of vertices. One thing is creation of objects on the heap in a loop could make your function very slow. I am sorry I am not being of much help.

Venugopal Gudimetla's picture

Also try to fetch memory of all the objects first if you can and test if the memory is available to you before you start your loops...may be your programs slows/crashes because of unavailability of memory like your mentioned.

Alena's picture

Thanks for this ideas, I'll try to test it.

Alena's picture

I explored an interesting thing. The error occurs in function myAISContext->MoveTo(x, y, myView), which calls in MouseMove event. If I comment this line, program never crashes, but there are no ability to select graphic elements...

jelle's picture

interesting... thanks for the update...

Bearloga's picture

Hi Alena,
I think you have chosen not a right method. You should try using the interactive services of mesh visualization. You can find them in MeshVS packages. In short, you create your data source inheriting the available interface, and create the interactive object MeshVS_Mesh, that can be shown in the context.
Good luck.

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.