Wed, 03/16/2011 - 16:16
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
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!
Wed, 03/16/2011 - 16:27
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
Wed, 03/16/2011 - 17:14
Hi, jelle,
Hmm... If it wasn't build, it wouldn't be displayed, or I'm mistaken?
Wed, 03/16/2011 - 17:17
I don't know, but I'm curious what you are sending into the compound builder.
I'd have a look...
Wed, 03/16/2011 - 17:31
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...
Wed, 03/16/2011 - 17:54
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
Thu, 03/17/2011 - 14:00
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.
Thu, 03/17/2011 - 16:34
Hi, this may not improve performance, but did the program crash?
Fri, 03/18/2011 - 18:15
Yes, it crashes in the same situation...
Wed, 03/16/2011 - 17:37
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
Wed, 03/16/2011 - 17:47
Looking back I see what you are doing, please ignore my previous comment.
Mon, 03/21/2011 - 18:26
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?
Mon, 03/21/2011 - 18:33
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.
Mon, 03/21/2011 - 21:15
Hi, Venu,
I'm working with Windows, and valgrind is nix's utility, or not?
Mon, 03/21/2011 - 21:27
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.
Mon, 03/21/2011 - 21:30
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.
Mon, 03/21/2011 - 22:16
Thanks for this ideas, I'll try to test it.
Mon, 03/21/2011 - 23:31
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...
Mon, 03/21/2011 - 23:35
interesting... thanks for the update...
Tue, 03/22/2011 - 09:20
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.