How to remove curves on surface after projection with HLR

I obtained some projection results with HLR. But some curves on surface are in the projection results, and I want to remove them. Is anybody can give me some suggestion? The code I use mostly comes from a paper called "HLR Optimization" in this forum. Here is the code I am using.

Handle(Prs3d_Presentation) aHideLinesPrs = new Prs3d_Presentation(myAISContext->CurrentViewer()->Viewer(), Standard_True);
Standard_Boolean hasHideLines = true;
//

double DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz;
Standard_Boolean IsPerspective;
double aFocus = 0.0;

CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

// Get the active MDI child window.
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();

// or CMDIChildWnd *pChild = pFrame->MDIGetActive();

// Get the active view attached to the active MDI child
// window.
CImportExportView *pView = (CImportExportView *) pChild->GetActiveView();

pView->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();//Slow
//Handle_HLRBRep_PolyAlgo myHlAlgo = new HLRBRep_PolyAlgo();

//HLR for 10-20 times faster
//BRepBuilderAPI_Sewing mySewing(1.0e-06,true,false,false,false);
myHlAlgo->Projector(aPrs3d_Projector->Projector());

AIS_ListOfInteractive aList;
AIS_ListIteratorOfListOfInteractive aListIterator;
myAISContext->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);
}

myAISContext->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;
myAISContext->UpdateCurrentViewer();

JuryS's picture

In some cases HLR don't remove lines. Here need some modifications of intersections. May you attach your screenshot of result view?

George Feng's picture

Thanks for your replication.
This problem has been resolved. Edges obtained by projection with HLR to a 2D plane can be classified to several groups by HLRBRep_HLRToShape, which includes VCompound, Rg1LineVCompound, RgNLineVCompound, OutLineVCompound, IsoLineVCompound, HCompound, Rg1LineHCompound, RgNLineHCompound, OutLineHCompound, IsoLineHCompound. What I need is to classify these edges just before projection to a 2D plane, but I did not find this function. So I modified the HLRBRep_HLRToShape, and the projection to 2D plane is removed from this function and the classification function is reserved. The curves on surface are stored in the RgNLineVCompound and RgNLineHCompound, and other curves ares stored in VCompound, Rg1LineVCompound, OutLineVCompound, IsoLineVCompound, HCompound, Rg1LineHCompound, OutLineHCompound, IsoLineHCompound. Then I can display the projection results without curves on surface now.

The Modification in HLRBRep_HLRToShape is done as follows:
B.Add(Result,HLRBRep::MakeEdge(ed.Geometry(),sta,end));
to
B.Add(Result,ed.ChangeGeometry().Curve().Edge());