StackOverflow during Hide operation

I use HLRBRep_Algo to get a projection of .step model. It works cool but when I tried to do this with big files (~10 - 15 Mb) the program is down on operation Hide() with StackOverflowException after Update() (Update() operation use a lot of memory as I see in task manager). Any advices? If I don’t hide lines the program is work.

Handle(HLRBRep_Algo) myAlgo = new HLRBRep_Algo();
HLRAlgo_Projector aProjector = HLRAlgo_Projector(gp_Ax2(gp_Pnt(0.,0.,0.), gp_Dir(0.,0.,-1.)));
myAlgo->Add(SS); // Add my step model
myAlgo->Projector(aProjector);
myAlgo->Update();
myAlgo->Hide(); // StackOverflow appears here

Alexey Gorshkolep's picture

Well, after a long time of analysis I found out that the problem appears during HLRBRep_Hider::Hide () function. This function contains many recursive calls and if shapes consist of many edges (20000 for example) it bring to StackOverflow. Then I decided to split my big shape into some small (1000 faces in each):

Handle(HLRBRep_Algo) myAlgo = new HLRBRep_Algo();
HLRAlgo_Projector aProjector = HLRAlgo_Projector(gp_Ax2(gp_Pnt(0.,0.,0.), gp_Dir(0.,0.,1.)));
TopExp_Explorer ex;
int counter = 0;
TopoDS_Shape sh;
BRep_Builder B;
B.MakeCompound(TopoDS::Compound(sh));
for(ex.Init(SS, TopAbs_FACE); ex.More(); ex.Next())
{
B.Add(sh, ex.Current());
counter ++;
if(counter == 1000)
{
counter = 0;
myAlgo->Add(sh);
sh.Nullify();
B.MakeCompound(TopoDS::Compound(sh));
}
}
if(counter != 0)
{
myAlgo->Add(sh);
sh.Nullify();
B.MakeCompound(TopoDS::Compound(sh));
}
myAlgo->Projector(aProjector);
myAlgo->Update();
myAlgo->Hide();
HLRBRep_HLRToShape aHLRToShape(myAlgo);
TopoDS_Shape VCompound = aHLRToShape.VCompound();
TopoDS_Shape OutLineVCompound = aHLRToShape.OutLineVCompound();
TopoDS_Shape Rg1LineVCompound = aHLRToShape.Rg1LineVCompound();

And It works!
But!!! myAlgo->Hide() calculation took ~1.5 hour (.step file 8Mb)! I think it is very very slow… May be HLRBRep_Hider needs some optimization?