Calculate visible area of plane..

Hello!

I create a truncated plane in my code:

GC_MakePlane makePlane(pnt1,pnt2,pnt3);
Handle(Geom_Plane) geomPlane = makePlane.Value();
TopoDS_Shape aPlaneShape = BRepBuilderAPI_MakeFace(geomPlane,
0, width, 0, height );

After all view transformation (move, zoom, rotate) I want to get coordinate of visible area on my truncated plane (projection of my plane on the screen plane). I think this area can be defined by four 3D points.
Please, help me!

Thanks in advance, Damir

EricThompson's picture

I think what you need to do is call V3d_View::ProjReferenceAxe() for each corner of your window. This will give you a 3D point and direction for each corner. From these you should be able to construct a line, and then find where that line intersects your plane.

JuryS's picture

You can define your plane with two lines, not four 3Dpoint and use TopExp_Explorer to detect where your line now.
I may create this sample If you can't use this method. It's working like this:

When you have comound two lines and use Mesh;

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);

And result with FOUR point . Something like this......