internal void AddInvisibleZone(double observerHeight, ProfileSurface profileSurface, Color visibleColor, Color invisibleColor, bool update = true, List <int> linesIds = null) { var invisibleSurface = new ProfileSurface(); var invisibleSurfacePoints = new List <ProfileSurfacePoint>(); var groupedLinesSegments = new List <ProfileLine>(); var isPrimitive = true; var surfaceSegments = GetLineSegments(profileSurface.LineId); if (surfaceSegments == null) { surfaceSegments = new List <ProfileSurface> { profileSurface }; isPrimitive = false; } foreach (var segment in surfaceSegments) { var firstPointDistance = segment.ProfileSurfacePoints[0].Distance; var sightLineKoef = 0.0; var isInvisibleZone = false; var observerFullHeight = observerHeight + segment.ProfileSurfacePoints[0].Z; var invisibleSurfaceSegment = new ProfileSurface(); var invisiblePoints = new List <ProfileSurfacePoint>(); invisibleSurfaceSegment.LineId = profileSurface.LineId; for (var i = 0; i < segment.ProfileSurfacePoints.Length; i++) { var currPoint = segment.ProfileSurfacePoints[i]; if (!isInvisibleZone) { if (i < segment.ProfileSurfacePoints.Length - 1) { if (CalcAngleOfVisibility(observerFullHeight, segment.ProfileSurfacePoints[i], segment.ProfileSurfacePoints[i + 1], firstPointDistance) < 0) { var firstInvisiblePoint = segment.ProfileSurfacePoints[i + 1]; if (!invisiblePoints.Exists(point => point == firstInvisiblePoint)) { invisiblePoints.Add(firstInvisiblePoint); } isInvisibleZone = true; segment.ProfileSurfacePoints[i + 1].Visible = false; sightLineKoef = (firstInvisiblePoint.Z - observerFullHeight) / (firstInvisiblePoint.Distance - firstPointDistance); i++; } } } else { if (FindY(observerFullHeight, sightLineKoef, segment.ProfileSurfacePoints[i].Distance - firstPointDistance) < segment.ProfileSurfacePoints[i].Z) { isInvisibleZone = false; invisiblePoints.Add(segment.ProfileSurfacePoints[i]); segment.ProfileSurfacePoints[i + 1].Visible = true; i++; } else { invisiblePoints.Add(segment.ProfileSurfacePoints[i]); } } currPoint.Visible = !isInvisibleZone; } invisibleSurfaceSegment.ProfileSurfacePoints = invisiblePoints.ToArray(); groupedLinesSegments.AddRange(GetLines(segment, invisibleSurfaceSegment, _profileSession.SessionId)); invisibleSurfacePoints.AddRange(invisiblePoints); } invisibleSurface.ProfileSurfacePoints = invisibleSurfacePoints.ToArray(); invisibleSurface.LineId = profileSurface.LineId; _surfaceProfileChart.AddInvisibleLine(invisibleSurface); CalcProfilesVisiblePercents(invisibleSurface, profileSurface); var profileLines = new GroupedLines { LineId = profileSurface.LineId, Lines = groupedLinesSegments, VisibleColor = ColorToEsriRgb(visibleColor), InvisibleColor = ColorToEsriRgb(invisibleColor) }; profileLines.Polylines = ProfileLinesConverter .ConvertLineToEsriPolyline(profileLines.Lines, ArcMap.Document.FocusMap.SpatialReference); if (isPrimitive) { var spatialReference = _profileSession.ProfileLines.First(line => line.Id == profileLines.LineId).SpatialReference; profileLines.Vertices = surfaceSegments.Select(surface => { var point = surface.ProfileSurfacePoints.First(); return(new ProfilePoint { X = point.X, Y = point.Y, SpatialReference = spatialReference }); } ).ToList(); profileLines.IsPrimitive = true; } if (_profileSession.Segments.Count < profileSurface.LineId - 1) { _profileSession.Segments.Add(profileLines); } else { profileLines.IsSelected = _profileSession.Segments[profileSurface.LineId - 1].IsSelected; _profileSession.Segments[profileSurface.LineId - 1] = profileLines; } InvisibleZonesChanged?.Invoke(profileLines, _profileSession.SessionId, update, linesIds); }
internal void AddProfileToTab(ProfileLine profileLine, ProfileSurface profileSurface) { View.SetCurrentChart(); _surfaceProfileChartController.AddLineToGraph(profileLine, profileSurface); }
private static List <ProfileLine> GetLines(ProfileSurface allSurface, ProfileSurface invisibleSurface, int sessionId) { var profileLines = new List <ProfileLine>(); var lineId = 1; var j = 0; var isInvisiblePointsFinished = false; if (invisibleSurface.ProfileSurfacePoints.Count() == 0) { isInvisiblePointsFinished = true; } var profileVisibleLine = new ProfileLine { Visible = true }; var profileInvisibleLine = new ProfileLine { Visible = false }; var profileVisiblePoints = new List <ProfileSurfacePoint>(); var profileInvisiblePoints = new List <ProfileSurfacePoint>(); for (int i = 0; i < allSurface.ProfileSurfacePoints.Count(); i++) { if (!isInvisiblePointsFinished && allSurface.ProfileSurfacePoints[i] == invisibleSurface.ProfileSurfacePoints[j]) { if (profileInvisiblePoints.Count == 0) { StartOfLineHandler(ref profileInvisibleLine, lineId, allSurface, i); lineId++; if (profileVisiblePoints.Count > 0) { profileLines.Add(EndOfLineHandler(profileVisibleLine, allSurface, i)); profileVisibleLine = new ProfileLine { Visible = true }; profileVisiblePoints = new List <ProfileSurfacePoint>(); } } if (i == allSurface.ProfileSurfacePoints.Count() - 1) { profileLines.Add(EndOfLineHandler(profileInvisibleLine, allSurface, i)); profileInvisibleLine = new ProfileLine { Visible = false }; profileInvisiblePoints = new List <ProfileSurfacePoint>(); } if (j == invisibleSurface.ProfileSurfacePoints.Count() - 1) { isInvisiblePointsFinished = true; } profileInvisiblePoints.Add(allSurface.ProfileSurfacePoints[i]); j++; } else { if (profileVisiblePoints.Count == 0) { StartOfLineHandler(ref profileVisibleLine, lineId, allSurface, i); lineId++; if (profileInvisiblePoints.Count > 0) { profileLines.Add(EndOfLineHandler(profileInvisibleLine, allSurface, i)); profileInvisibleLine = new ProfileLine { Visible = false }; profileInvisiblePoints = new List <ProfileSurfacePoint>(); } } if (i == allSurface.ProfileSurfacePoints.Count() - 1) { profileLines.Add(EndOfLineHandler(profileVisibleLine, allSurface, i)); profileVisibleLine = new ProfileLine { Visible = true }; profileVisiblePoints = new List <ProfileSurfacePoint>(); } profileVisiblePoints.Add(allSurface.ProfileSurfacePoints[i]); } } return(profileLines); }