public override List <SolverPreviewObject> InterestingShapeAroundPoint(gpPln planeOfTheView, Point3D point) { var qosLock = QosFactory.Instance.Get(QosNames.EdgeMatchLock); qosLock.Begin(); foreach (var edge in Geometry.SelectMany(geometricObject => geometricObject.Edges)) { // Calculate the distance from the point to the curve GeomCurve curve; var first = 0.0; var last = 0.0; unsafe { curve = BRepTool.Curve(edge.Edge, ref first, ref last); } if (curve == null) { continue; } // Add a curve domain protection if (first > last) { continue; } ExtremaExtPC extrema = null; try { var adaptor = new GeomAdaptorCurve(curve, first, last); extrema = new ExtremaExtPC(point.GpPnt, adaptor, Precision.Confusion); } catch { Log.Debug("Exception on generate extrema points"); } if (extrema == null) { continue; } if (!extrema.IsDone) { continue; } if (extrema.NbExt < 1) { continue; } // The point is on edge if (extrema.SquareDistance(1) >= CoreGlobalPreferencesSingleton.Instance.ZoomLevel * _precision) { continue; } // Generate a point on the edge by projecting var projectionPoint = new GeomAPIProjectPointOnCurve(point.GpPnt, curve); if (projectionPoint.NbPoints <= 0) { continue; } List <SolverGeometricObject> selectedEdge = Geometry.Where(geomObj => geomObj.Edges.Contains(edge)).ToList(); //LastGeometry.Clear(); //LastGeometry.AddRange(selectedEdge); var originPoint = new SolverGeometricObject(null); originPoint.AddPoint(new SolverDataPoint(new Point3D())); var result = GeomUtils.ProjectPointOnPlane(new Point3D().GpPnt, planeOfTheView, Precision.Confusion); //if(result == new gpPnt(0,0,0)) //{ // LastGeometry.Add(originPoint); //} if (selectedEdge.Count > 0 && selectedEdge.First().Edges.Count > 0) { return new List <SolverPreviewObject>() { new SolverPointResult(new Point3D(projectionPoint.NearestPoint), selectedEdge.First().Edges.First().ParentIndex) } } ; // {Text = "On Edge"}; else { return new List <SolverPreviewObject>() { new SolverPointResult(new Point3D(projectionPoint.NearestPoint)) } }; } qosLock.End(); return(new List <SolverPreviewObject>()); } }
/// <summary> /// Detects if the point is on the curve that describes the edge. /// </summary> /// <param name = "planeOfTheView"></param> /// <param name = "point"></param> /// <returns></returns> public override List <SolverPreviewObject> InterestingShapeAroundPoint(gpPln planeOfTheView, Point3D point) { var qosLock = QosFactory.Instance.Get(QosNames.EdgeContinuationMatchLock); qosLock.Begin(); foreach (var edge in LastGeometry.SelectMany(geometricObject => geometricObject.Edges)) { // Calculate the distance from the point to the curve GeomCurve curve; double first = 0; double last = 0; // unsafe { curve = BRepTool.Curve(edge.Edge, ref first, ref last); } if (curve == null) { continue; } ExtremaExtPC extrema = null; try { var adaptor = new GeomAdaptorCurve(curve); extrema = new ExtremaExtPC(point.GpPnt, adaptor, Precision.Confusion); } catch (Exception) { Log.Debug("Exception on extract paralel axis"); } if (extrema == null) { continue; } if (!extrema.IsDone) { continue; } if (extrema.NbExt < 1) { continue; } // The point is on edge if (extrema.SquareDistance(1) >= _precision) { continue; } // Generate a point on the edge by projecting var projectionPoint = new GeomAPIProjectPointOnCurve(point.GpPnt, curve); if (projectionPoint.NbPoints <= 0) { continue; } var lastPoint = curve.Value(last); return(new List <SolverPreviewObject>() { new SolverEdgeTwoPointsResult(new Point3D(projectionPoint.NearestPoint), new Point3D(lastPoint)) { Type = "Line Continuation" } }); } qosLock.End(); return(new List <SolverPreviewObject>()); }