Search code examples
c#pointsurfaceeyeshot

How to check a point is inside a surface in devdept eyeshot


I want to to see if a point is inside a trimmed surface or not. In the following pictures, I think that I have a surface which has a hole inside and also a point shown as red. How to check that the point is inside a trimmed surface or not.

I used the following code but it doesn't work. In this code surfaceEntity is a Surface object in which red point is inside. pntEntity is also an entity which is the red point in the below picture.

double x = (pntEntity.BoxMax.X + pntEntity.BoxMin.X) / 2;
double y = (pntEntity.BoxMax.Y + pntEntity.BoxMin.Y) / 2;


Point3D point3D = new Point3D(x, y, 0);

if (surfaceEntity.Trimming.IsPointInside(point3D))
{
    Console.WriteLine("Inside");

}

else
{
    Console.WriteLine("Not inside");
}

Image


Solution

  • You need first to compute 2D parametric coordinates of the point point3D using surfaceEntity.Project() or surfaceEntity.ClosestPointTo(). The resulting u, v values can then be used in the Trimming.IsPointInside() call.