public virtual void Intersect(double tolerance, com.epl.geometry.Point pt_intersector_point, int point_rank, double point_weight, bool b_intersecting) { pt_intersector_point.CopyTo(m_point); if (m_input_segments.Count != 1) { throw com.epl.geometry.GeometryException.GeometryInternalError(); } m_tolerance = tolerance; com.epl.geometry.SegmentIntersector.IntersectionPart part1 = m_input_segments[0]; if (b_intersecting || part1.seg._isIntersectingPoint(pt_intersector_point.GetXY(), tolerance, true)) { if (part1.seg.GetType().Value() == com.epl.geometry.Geometry.GeometryType.Line) { com.epl.geometry.Line line_1 = (com.epl.geometry.Line)(part1.seg); double t1 = line_1.GetClosestCoordinate(pt_intersector_point.GetXY(), false); m_param_1[0] = t1; // For each point of intersection, we calculate a weighted point // based on the ranks and weights of the endpoints and the // interior. int rank1 = part1.rank_interior; double weight1 = 1.0; if (t1 == 0) { rank1 = part1.rank_start; weight1 = part1.weight_start; } else { if (t1 == 1.0) { rank1 = part1.rank_end; weight1 = part1.weight_end; } } int rank2 = point_rank; double weight2 = point_weight; double ptWeight; com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D(); if (rank1 == rank2) { // for equal ranks use weighted sum com.epl.geometry.Point2D pt_1 = new com.epl.geometry.Point2D(); line_1.GetCoord2D(t1, pt_1); com.epl.geometry.Point2D pt_2 = pt_intersector_point.GetXY(); ptWeight = weight1 + weight2; double t = weight2 / ptWeight; com.epl.geometry.MathUtils.Lerp(pt_1, pt_2, t, pt); } else { // for non-equal ranks, the higher rank wins if (rank1 > rank2) { pt = new com.epl.geometry.Point2D(); line_1.GetCoord2D(t1, pt); ptWeight = weight1; } else { pt = pt_intersector_point.GetXY(); ptWeight = weight2; } } // Split the line_1, making sure the endpoints are adusted to // the weighted double t0 = 0; int i0 = -1; int count = 1; for (int i = 0; i <= count; i++) { double t = i < count ? m_param_1[i] : 1.0; if (t != t0) { com.epl.geometry.SegmentBuffer seg_buffer = NewSegmentBuffer_(); line_1.Cut(t0, t, seg_buffer); if (i0 != -1) { seg_buffer.Get().SetStartXY(pt); } if (i != count) { seg_buffer.Get().SetEndXY(pt); } t0 = t; m_result_segments_1.Add(NewIntersectionPart_(seg_buffer.Get())); } i0 = i; } m_point.SetXY(pt); return; } throw com.epl.geometry.GeometryException.GeometryInternalError(); } }