How can I get the Data of the projection of 3D?

when I set the projection ,I get the view in HLR example!I want know where the data is kept! I want reuse the data!Thank you!

JuryS's picture

Hi ! What algoritm of HLR you are use for this ?
If you are using HLRBRep_Algo you may use HLRBRep_HLRToShape.
I make my code for HLR on 3D_View... It's very cool. I can type here this code.

hr's picture

Yes,I use HLRBRep_HLRToShape ,for example when I bulid a cylinder in UG ,then to b-rep model,when I projected it,whether the curve contains the arc? if you have some examples ,type it here,thank you!

JuryS's picture

You can make this with calculating of the points on you 3D view and after with the point on HLR result. It's work for me with next code:

void DocumentCommon::onHideLines()
{
CleanAfterTexture();
CleanAfterHideLine(false);

TopoDS_Shape Shape;
Handle_HLRBRep_Algo myAlgo = new HLRBRep_Algo();
HLRBRep_HLRToShape aHLRToShape(myAlgo);
bool hasOne = false;
Handle_TPrsStd_AISPresentation CurrentPrs;
Handle_TNaming_NamedShape myShape;
TDF_Label LabObject;
AIS_ListOfInteractive aList;
AIS_ListIteratorOfListOfInteractive aListIterator;

Standard_Real DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz;
Standard_Boolean IsPerspective;
gp_Pnt rightBottom, leftBottom, leftTop, rightTop;
Quantity_Length aFocus = 1;
uint myX,myY;

QWorkspace* ws = myApp->getWorkspace();
MDIWindow* w = (MDIWindow*) ws->activeWindow();
View* myView = w->getView();

myX = ws->activeWindow()->size().width();
myY = ws->activeWindow()->size().height();

myView->GetProjData(DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz,IsPerspective,rightBottom, leftBottom, leftTop, rightTop, myX, myY);

Prs3d_Projector aPrs3d_Projector(IsPerspective,aFocus,DX,DY,DZ,XAt,YAt,ZAt,Vx,Vy,Vz);
HLRAlgo_Projector myProjector = aPrs3d_Projector.Projector();
myAlgo->Projector(myProjector);

//! Ñòðîþ 2 ëèíèè, ÷òîáû îïèñàòü â ðàìêó òåêóùèé âèä
TopoDS_Shape L1 = BRepBuilderAPI_MakeEdge(rightBottom,leftBottom);
TopoDS_Shape L2 = BRepBuilderAPI_MakeEdge(rightBottom,rightTop);
myAlgo->Add(L1,0); myAlgo->Add(L2,0);

//! Âûòàñêèâàþ èõ èç àëãîðèòìà
myAlgo->Update();
TopoDS_Shape myPointsShape = aHLRToShape.VCompound();
myAlgo->Remove(1);
myAlgo->Remove(2);

bool First(true);
gp_Pnt pt;
double Xmin(0),Ymin(0),Xmax(0),Ymax(0);
TopoDS_Vertex vertex;

for (TopExp_Explorer myExplorer(myPointsShape, TopAbs_COMPOUND); myExplorer.More(); myExplorer.Next())
{
for (TopExp_Explorer myPointExplorer(myExplorer.Current(),TopAbs_VERTEX); myPointExplorer.More(); myPointExplorer.Next())
{
vertex = TopoDS::Vertex(myPointExplorer.Current());
pt = BRep_Tool::Pnt(vertex);
if (First)
{
Xmin = pt.X(); Xmax = pt.X();
Ymin = pt.Y(); Ymax = pt.Y();
}
else
{
if (pt.X()Xmax) Xmax = pt.X();
if (pt.Y()Ymax) Ymax = pt.Y();
}
First = false;
}
}
gp_Pnt myControlPoint1(Xmin,Ymax,0);
gp_Pnt myControlPoint2(Xmax,Ymax,0);
gp_Pnt myControlPoint3(Xmax,Ymin,0);
gp_Pnt myControlPoint4(Xmin,Ymin,0);

myContext->DisplayedObjects(aList);
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next())
{
CurrentPrs = Handle(TPrsStd_AISPresentation)::DownCast(aListIterator.Value()->GetOwner());
if (CurrentPrs.IsNull()) continue; //Åñëè îáúåêò áåç àòòðèáóòîâ ïðåðûâàþñü
LabObject = CurrentPrs->Label();
if (!LabObject.FindAttribute(TNaming_NamedShape::GetID(),myShape)) continue; //Åñëè íå íàéäåíî òåëî ïðåðûâàþñü
myAlgo->Add(myShape->Get(),0);
hasOne = true;
myContext->SetDisplayMode(CurrentPrs->GetAIS(), 3, Standard_False); //Ïðÿ÷ó îáúåêò
}
if (!hasOne) return; //Åñëè íè îäíîãî îáúåêòà íå îòðàáîòàíî

myAlgo->Update();
myAlgo->Hide();
TopoDS_Shape needRotateShape = aHLRToShape.VCompound();

gp_Trsf trsf;
gp_Vec myVec1(myControlPoint3,myControlPoint4);
gp_Vec myVec2(myControlPoint3,myControlPoint2);
gp_Dir myDir1(myVec1);
gp_Dir myDir2(myVec2);
gp_Ax2 ax2forshape(myControlPoint3,myDir1,myDir2);
gp_Ax3 ax3forshape(ax2forshape);

gp_Vec myVec3(rightBottom,leftBottom);
gp_Vec myVec4(rightBottom,rightTop);
gp_Dir myDir3(myVec3);
gp_Dir myDir4(myVec4);
gp_Ax2 ax2forview(rightBottom,myDir3,myDir4);
gp_Ax3 ax3forview(ax2forview);

trsf.SetDisplacement(ax3forshape,ax3forview);
BRepBuilderAPI_Transform MoveByControlPoint(needRotateShape,trsf,Standard_False);

myShapeForHideLine = new AIS_Shape(MoveByControlPoint);
myContext->SetColor(myShapeForHideLine,Quantity_NOC_BLACK,Standard_False);
myContext->Display(myShapeForHideLine,0,-1,Standard_False,Standard_False);
hasHideLines = true;
myContext->UpdateCurrentViewer();
}

hr's picture

Thank you !! I think this will help me!

hr's picture

Hi,I also want to know how the edge projected from the face ? it to say the connection between the edge and face? Thank you very much for all your help!

JuryS's picture

I'm use HLR Algo with two times. For the first time I'm only extract need for me coordinate of the extracted Shape. If you know the coordinate of your points on face, you may calculate were they are. Don't forget use gp_Vec for this and all operations with Vector, like Divide... You may calculate coefficent of left bottom point of the screen / points on your face.

Also. sorry for my bad English.

hr's picture

Thank you very much!!