Hi Author,
Firtly thanks for the posting, I trying to do something simular by picking point of a surface.
I and think I've got it fully working now, which just one simple change to the code.
//xGC_MakeLine line(EyePoint, ResultPoint); <--- change this line to
GC_MakeLine line(ResultPoint, EyeDir);
I've include the complete function, sorry about the C# code :), if you have any problems just send me an e-mail.
private global::Core.Geometry.Interfaces.ICoordinate ConvertClickToPoint2(
System.Drawing.Point position,
IView view,
global::OpenCASCADE52.Geom.Interfaces.IPlane geomSurface)
{
double xEye = 0.0;
double yEye = 0.0;
double zEye = 0.0;
double xAt = 0.0;
double yAt = 0.0;
double zAt = 0.0;
unsafe
{
view.Eye(&xEye, &yEye, &zEye);
view.At(&xAt, &yAt, &zAt);
}
IPnt eyePoint = new Pnt(xEye, yEye, zEye);
IPnt atPoint = new Pnt(xAt, yAt, zAt);
//DrawLine(eyePoint, atPoint);
Debug.WriteLine(string.Format("EyePoint: {0} {1} {2}", xEye, yEye, zEye));
Debug.WriteLine(string.Format("AtPoint: {0} {1} {2}", xAt, yAt, zAt));
IVec eyeVector = new Vec(eyePoint, atPoint);
IDir eyeDir = new Dir(eyeVector);
IPln planeOfTheView = new Pln(atPoint, eyeDir);
//DrawPlane(planeOfTheView);
double x, y, z;
unsafe
{
view.Convert(position.X, position.Y, &x, &y, &z);
}
Debug.WriteLine(string.Format("XYZ: {0} {1} {2}", x, y, z));
IPnt convertedPoint = new Pnt(x, y, z);
IPnt2d convertedPointOnPlane = ProjLib.Project(planeOfTheView, convertedPoint);
IPnt resultPoint = ElSLib.Value(convertedPointOnPlane.X, convertedPointOnPlane.Y, planeOfTheView);
//DrawLine(eyePoint, resultPoint);
//IMakeLine makeLine = new MakeLine(eyePoint, resultPoint); //x
IMakeLine makeLine = new MakeLine(resultPoint, eyeDir); // project backwards from the result point using the viewing plane
//DrawLine(makeLine);
IIntCS intCS = new IntCS();
intCS.Perform(makeLine.Value, geomSurface);
if( intCS.IsDone() )
{
if( intCS.NbPoints() > 0 )
{
resultPoint = new Pnt(intCS.Point(1).XYZ); // one-based
return new global::Core.Geometry.Coordinate(resultPoint.X, resultPoint.Y, resultPoint.Z);
}
}
return null;
}
Many thanks
Commenter-1