I'm trying to pick a point on a shape.
I've read alot of good methods on the forum and have applied two methods one found on:
and the other found on:
I've used an algorithm that gets a 3D point (ResultPoint) on a plane orthogonal to the point of view.
From there I've decomposed the shape into faces (then surfaces) to use the GeomAPI_IntCS class to find the intersection between a "line" (from EyePoint to ResultPoint) and the given face.
The final ResultPoint I get is incorrect. It too seems to lies on a plane (it seems to be a plane that one of the faces is on).
Furthermore, "line" intersects with all of the faces in my shape. (currently I'm playing with a cube (12 triangles)).
Can somebody let me know where I'm going wrong here.
I've supplied the code that I'm using:
Thanks in advance
aView->Eye(xEye, yEye, zEye);
aView->At(xAt, yAt, zAt);
gp_Pnt EyePoint(xEye, yEye, zEye);
gp_Pnt AtPoint(xAt, yAt, zAt);
gp_Vec EyeVector(EyePoint, AtPoint);
gp_Pln PlaneOfView = gp_Pln(AtPoint, EyeDir);
Standard_Real theX, theY, theZ;
aView->Convert(x, y, theX, theY, theZ);
gp_Pnt ConvertedPoint (theX, theY, theZ);
gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfView, ConvertedPoint);
gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfView);
GC_MakeLine line(EyePoint, ResultPoint);
int iii = 0;
for (exp.Init(myShape, TopAbs_FACE); exp.More(); exp.Next())
TopoDS_Face face = TopoDS::Face(exp.Current());
const GeomAdaptor_Surface& geomAdapSurf = surface.Surface();
const Handle(Geom_Surface)& geomSurf = geomAdapSurf.Surface();
ResultPoint = gp_Pnt(inCS.Point(1).XYZ());
a3dPoint = ResultPoint;