
Wed, 03/30/2011 - 00:47
Hi, guys !
Does anybody make optimized code for HLR Algo ?
Now I'm use next:
double DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz;
bool IsPerspective;
double aFocus = 0.0;
myViews.at(findActiveWindow())->getView()->GetProjData(DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz,IsPerspective);
Handle_Prs3d_Projector aPrs3d_Projector = new Prs3d_Projector(IsPerspective,aFocus,DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz);
Handle_HLRBRep_Algo myHlAlgo = new HLRBRep_Algo();
myHlAlgo->Projector(aPrs3d_Projector->Projector());
AIS_ListOfInteractive aList;
AIS_ListIteratorOfListOfInteractive aListIterator;
myContext->DisplayedObjects(aList);
if (aList.IsEmpty()) return true;
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next())
{
Handle(AIS_InteractiveObject) aisShp = aListIterator.Value();
if (aisShp->Transparency()
{
TopoDS_Shape myShape = Handle(AIS_Shape)::DownCast(aisShp)->Shape();
myHlAlgo->Add(myShape,0);
}
myContext->SetDisplayMode(aisShp, 3, Standard_False); //Ïðÿ÷ó îáúåêò
}
myHlAlgo->Update();
myHlAlgo->Hide();
HLRAlgo_EdgeIterator myEdgeIterator;
double U1,U2;
BRepAdaptor_Curve TheCurve;
TColgp_SequenceOfPnt Points;
Handle_HLRBRep_Data aDS = myHlAlgo->DataStructure();
for (int i=1;iNbEdges();i++){
myEdgeIterator.InitVisible
(aDS->EDataArray().ChangeValue(i).Status());
while (myEdgeIterator.MoreVisible())
{
aDS->EDataArray().ChangeValue(i);
TheCurve = aDS->EDataArray()
.ChangeValue(i)
.ChangeGeometry()
.Curve();
float t1,t2;
myEdgeIterator.Visible(U1,t1,U2,t2);
StdPrs_DeflectionCurve::Add(aHideLinesPrs,TheCurve,U1,U2,0.02, Points, 0.2,true);
myEdgeIterator.NextVisible();
}
}
aHideLinesPrs->Color(Quantity_NOC_BLACK);
aHideLinesPrs->Display();
hasHideLines = true;
myContext->UpdateCurrentViewer();
and It's working Cool, but very-very slowly.
This problem with HLRBRep_Hider.cxx.
And I can't understand why this work very slowly, but I know that more software, like AutoCAD make this more faster.
Can anybody help me to optimize HLRBRep_Hider or we can work together for this ???
Wed, 03/30/2011 - 00:51
Also in HLRBRep_Hider some classifications, but I don't need use this. I want to see, without any calculating the View with hiden lines and thats all.
May we can create additional fuction for this ?
Tue, 04/12/2011 - 05:27
+ ~45% of perfomance (for the sample 11.095 sec vs 4.095) with next:
HLRBRep_InternalAlgo.cxx:
//=======================================================================
//function : Hide
//purpose :
//=======================================================================
void HLRBRep_InternalAlgo::Hide ()
{
if (myDS.IsNull()) return;
Standard_Integer n = myShapes.Length();
InitEdgeStatus();
for (Standard_Integer i = 1; i <= n; i++)
Hide(i);
for (Standard_Integer i = 1; i <= n; i++)
for (Standard_Integer j = 1; j <= n; j++)
if (i != j) Hide(i,j);
}
//=======================================================================
//function : Hide
//purpose :
//=======================================================================
void HLRBRep_InternalAlgo::Hide (const Standard_Integer I)
{
SelectFace(I);
HideSelected(I,Standard_True);
}
//=======================================================================
//function : Hide
//purpose :
//=======================================================================
void HLRBRep_InternalAlgo::Hide (const Standard_Integer I,
const Standard_Integer J)
{
Standard_Integer* MinMaxShBI =
(Standard_Integer*)myShapes(I).MinMax();
Standard_Integer* MinMaxShBJ =
(Standard_Integer*)myShapes(J).MinMax();
if (((MaxShBJ1 - MinShBI1) & 0x80008000) == 0 &&
((MaxShBI1 - MinShBJ1) & 0x80008000) == 0 &&
((MaxShBJ2 - MinShBI2) & 0x80008000) == 0 &&
((MaxShBI2 - MinShBJ2) & 0x80008000) == 0 &&
((MaxShBJ3 - MinShBI3) & 0x80008000) == 0 &&
((MaxShBI3 - MinShBJ3) & 0x80008000) == 0 &&
((MaxShBJ4 - MinShBI4) & 0x80008000) == 0 &&
((MaxShBI4 - MinShBJ4) & 0x80008000) == 0 &&
((MaxShBJ5 - MinShBI5) & 0x80008000) == 0 &&
((MaxShBI5 - MinShBJ5) & 0x80008000) == 0 &&
((MaxShBJ6 - MinShBI6) & 0x80008000) == 0 &&
((MaxShBI6 - MinShBJ6) & 0x80008000) == 0 &&
((MaxShBJ7 - MinShBI7) & 0x80008000) == 0 &&
((MaxShBJ8 - MinShBI8) & 0x80008000) == 0) {
SelectFace(J);
HideSelected(I,Standard_False);
}
}
//=======================================================================
//function : HideSelected
//purpose :
//=======================================================================
void HLRBRep_InternalAlgo::HideSelected (const Standard_Integer I,
const Standard_Boolean /*SideFace*/)
{
HLRBRep_ShapeBounds& SB = myShapes(I);
Standard_Integer v1,v2,e1,e2,f1,f2;
SB.Bounds(v1,v2,e1,e2,f1,f2);
if (e2 >= e1) {
myDS->InitBoundSort(SB.MinMax(),e1,e2);
HLRBRep_Hider Cache(myDS);
HLRBRep_FaceData* fd;
Standard_Integer nf = myDS->NbFaces();
HLRBRep_Array1OfFData& FD = myDS->FDataArray();
for (Standard_Integer f = 1; f <= nf; f++) {
fd=&(FD.ChangeValue(f));
if (fd->Selected()) {
Cache.Hide(f,myMapOfShapeTool);
}
}
}
}
Also in HLRBRep_Hider.cxx :
for (; myDS->MoreEdge(); myDS->NextEdge()) { // loop on the Edges
Standard_Integer E = myDS->Edge(); // *****************
HLRBRep_EdgeData& ed = myEData(E);
HLRAlgo_EdgeStatus& ES = ed.Status();
if (ES.AllHidden())
continue;
Maybe this changes may included in next OCC Release or OCC650PATCH?