public static DPoint3d closestPointOnSurf(DPoint3d point, ISurface surf, double tol) { Bentley.Interop.MicroStationDGN.Point3d cpRef = new Bentley.Interop.MicroStationDGN.Point3d(); cpRef.X = point.X; cpRef.Y = point.Y; cpRef.Z = point.Z; Bentley.Interop.MicroStationDGN.Point3d cp = new Bentley.Interop.MicroStationDGN.Point3d(); Bentley.Interop.MicroStationDGN.Point2d cp2d = new Bentley.Interop.MicroStationDGN.Point2d(); GeometryTools.BSplineSurfaceComputeMinimumDistance(ref cp, ref cp2d, ref cpRef, tol, surf.com_bsplineSurface); return new DPoint3d(cp.X, cp.Y, cp.Z); }
public static DPoint3d closestPointOnSurf(DPoint3d point, ISurface surf, double tol, out double Dist, out Point2d UV, out DVector3d normal) { Bentley.Interop.MicroStationDGN.Point3d cpRef = new Bentley.Interop.MicroStationDGN.Point3d(); cpRef.X = point.X; cpRef.Y = point.Y; cpRef.Z = point.Z; Bentley.Interop.MicroStationDGN.Point3d cp = new Bentley.Interop.MicroStationDGN.Point3d(); Bentley.Interop.MicroStationDGN.Point2d cp2d = new Bentley.Interop.MicroStationDGN.Point2d(); Dist = GeometryTools.BSplineSurfaceComputeMinimumDistance(ref cp, ref cp2d, ref cpRef, tol, surf.com_bsplineSurface); UV = new Point2d(); UV.X = cp2d.X; UV.Y = cp2d.Y; normal = NormalAtUVParameterOnSurface(surf.com_bsplineSurface, UV.X, UV.Y); return new DPoint3d(cp.X, cp.Y, cp.Z); }
public static void ScanBSplineSurface() { BCOM.Application app = Program.COM_App; BCOM.ElementScanCriteria sc = new BCOM.ElementScanCriteriaClass(); sc.ExcludeAllTypes(); sc.IncludeType(BCOM.MsdElementType.BsplineSurface); var ee = app.ActiveModelReference.Scan(sc); //var firstcurrent = ee.Current; var bsplinesurface = new List <BCOM.BsplineSurface>(); while (ee.MoveNext()) { bsplinesurface.Add(ee.Current.AsBsplineSurfaceElement().ExtractBsplineSurface()); } //foreach (var surface in bsplinesurface) //{ // //var surfacehandler = app.CreatePropertyHandler(surface); // //string s= surfacehandler.GetDisplayString(); //} BCOM.Point3d p1 = app.Point3dFromXYZ(200, 110, 100); BCOM.Ray3d ray1 = new Bentley.Interop.MicroStationDGN.Ray3d() { Origin = app.Point3dFromXYZ(200, 110, 100), Direction = app.Point3dFromXYZ(0, 0, -200) }; BCOM.Point3d insertpoint = app.Point3dZero(); BCOM.Point2d uv = app.Point2dZero(); foreach (var bsp in bsplinesurface) { if (bsp.IntersectRay3d(ref insertpoint, ref uv, ref ray1)) { string s = insertpoint.ToString(); string s2 = uv.ToString(); } } }