public void ReplaceDepNode(DepNode buildingNode) { if (buildingNode == null) { Debug.LogError("MapLoadManage.ReplaceDepNode buildingNode == null"); return; } //foreach (var item in BuildingList) //{ // item.ReplaceDepNode(buildingNode); //} //if (CurrentBuilding) //{ // CurrentBuilding.ReplaceDepNode(buildingNode); //} MapBuilding mapBuilding = FindMapBuilding(buildingNode); if (mapBuilding) { mapBuilding.ReplaceDepNode(buildingNode); } else { Debug.LogWarning(string.Format("MapLoadManage.ReplaceDepNode Id={0},Name={1}", buildingNode.NodeID, buildingNode.NodeName)); } }
/// <summary> /// 取消上一个的选中 /// </summary> public void DisSelectLast() { if (CurrentBuilding != null) { SwitchManager.Hide(); CurrentBuilding.DisSelect(); CurrentBuilding = null; } }
///// <summary> ///// Начальный угол в плане (радиан). Начальное значение = 0 - восход. ///// Будут определены для этой расвчетной точки индивидуально ///// </summary> //public double AngleStartOnPlane { get; private set; } ///// <summary> ///// Конечный угол в плане (радиан). Начальное значение = 180 - заход ///// </summary> //public double AngleEndOnPlane { get; private set; } public CalcPointCentral(InsPoint insPt, CalcServiceCentral insCalcService) { this.map = insPt.Model.Map; buildingOwner = insPt.Building; this.insPt = insPt; ptCalc = insPt.Point; ptCalc2d = ptCalc.Convert2d(); this.calc = insCalcService; values = insCalcService.CalcValues; //AngleStartOnPlane = values.SunCalcAngleStartOnPlane; //AngleEndOnPlane = values.SunCalcAngleEndOnPlane; StartAnglesIllum = new IllumAreaBase(insPt, ptCalc2d, values.SunCalcAngleStartOnPlane, values.SunCalcAngleEndOnPlane, Point2d.Origin, Point2d.Origin); }
private List <Point2d> GetZeroLineIntersects(MapBuilding build) { var pts = new List <Point2d>(); using (var lineZero = new Line(ptCalc, new Point3d(ptCalc.X + 100, ptCalc.Y, 0))) { var ptsIntersects = new Point3dCollection(); using (var plane = new Plane()) { lineZero.IntersectWith(build.Contour, Intersect.ExtendThis, plane, ptsIntersects, IntPtr.Zero, IntPtr.Zero); pts = ptsIntersects.Cast <Point3d>().Select(s => s.Convert2d()).ToList(); } } return(pts); }
/// <summary> /// Определение зон теней от дома, который выше расчетной линии тени - по линии через 0 /// </summary> /// <param name="build"></param> /// <returns></returns> private IIlluminationArea GetBuildingZeroLineShadows(MapBuilding build) { using (var lineZero = new Line(ptCalc, new Point3d(ptCalc.X + 100, ptCalc.Y, 0))) { #if TEST //EntityHelper.AddEntityToCurrentSpace(lineZero); #endif var ptsIntersects = new Point3dCollection(); using (var plane = new Plane()) { lineZero.IntersectWith(build.Contour, Intersect.ExtendThis, plane, ptsIntersects, IntPtr.Zero, IntPtr.Zero); var pts = build.Contour.GetPoints().Where(p => p.Y < ptCalc.Y).ToList(); pts.AddRange(ptsIntersects.Cast <Point3d>().Select(s => s.Convert2d())); if (pts.Any()) { var ilumShadow = GetIllumShadow(pts); return(ilumShadow); } } } return(null); }
/// <summary> /// 显示小地图 /// </summary> /// <param name="node"></param> public bool ShowBuildingMap(DepNode node) { if (node.ParentNode == null) { return(false); } bool flag = false; DisSelectLast(); foreach (var item in BuildingList) { if (item.Node == null) { continue; } if (item.Node.NodeName == node.ParentNode.NodeName) { CurrentBuilding = item; item.SelectFloor(node); flag = true; } } return(flag); }
private bool CorrectStartAnglesByOwnerZeroHorLineIntersects(out List <Point3d> ptsIntersectShadow) { ptsIntersectShadow = new List <Point3d> (); bool isCorrect = true; var contour = buildingOwner.Contour; // Линия через точку ноль - Горизонтально using (var lineZero = new Line(ptCalc, new Point3d(ptCalc.X + 1, ptCalc.Y, 0))) { // Линия тени - пересечение собственного дома с ней? double yShadowLine; var ptHeightCalc = GetPtCalcHeight(); var buildHeightCalc = GetHeightCalcBuilding(ptHeightCalc, buildingOwner.HeightCalc); using (var lineShadow = GetLineShadow(buildHeightCalc)) { yShadowLine = lineShadow.StartPoint.Y; #if TEST //EntityHelper.AddEntityToCurrentSpace(lineShadow); #endif using (var ptsIntersect = new Point3dCollection()) { using (var plane = new Plane()) { contour.IntersectWith(lineShadow, Intersect.OnBothOperands, plane, ptsIntersect, IntPtr.Zero, IntPtr.Zero); ptsIntersectShadow = ptsIntersect.Cast <Point3d>().ToList(); } // !!!??? Если есть пересечения с линией тени, тогда нужно разделить полилинию дома на собственную часть и внешнюю (которую считать отдельно) } if (ptsIntersectShadow.Count > 1) { // Отсечение части дома - по точкам пересечения. List <Polyline> plsSecant; if (contour.Separate(ptCalc, ptsIntersectShadow, out plHead, out plsSecant)) { if (plHead != null) { contour = plHead; } // из отсеченных частей сделать здания для дальнейшего расчета - когда будут перебираться внешние дома при расчете точки if (plsSecant != null && plsSecant.Any()) { secantBuildings = MapBuilding.CreateFakeBuildings(plsSecant, buildingOwner); } } } } #if TEST //EntityHelper.AddEntityToCurrentSpace(lineZero); #endif List <Point3d> ptsIntersectZero; using (var ptsIntersect = new Point3dCollection()) { contour.IntersectWith(lineZero, Intersect.ExtendArgument, new Plane(), ptsIntersect, IntPtr.Zero, IntPtr.Zero); ptsIntersectZero = ptsIntersect.Cast <Point3d>().OrderBy(o => o.X).ToList(); } // Разделить точки левее стартовой и правее (Запад/Восток) - для каждой петли свойестороны найти максимальный ограничивающий угол. double westAngle; if (GetStartAngleBySideIntersects(contour, ptsIntersectZero, ptsIntersectShadow, yShadowLine, false, true, false, out westAngle)) { if (westAngle < StartAnglesIllum.AngleEndOnPlane) { StartAnglesIllum.AngleEndOnPlane = westAngle; } } else { isCorrect = false; } double eastAngle; if (GetStartAngleBySideIntersects(contour, ptsIntersectZero, ptsIntersectShadow, yShadowLine, true, true, false, out eastAngle)) { if (eastAngle > StartAnglesIllum.AngleStartOnPlane) { StartAnglesIllum.AngleStartOnPlane = eastAngle; } } else { isCorrect = false; } } return(isCorrect); }
private List <IIlluminationArea> GetBuildingLineShadowBoundary(MapBuilding build, Line lineShadow, Intersect intersectMode) { var resIlumsShadows = new List <IIlluminationArea>(); if (lineShadow.Length < 1) { return(resIlumsShadows); } // Дом на границе тени, нужно строить линию пересечения с домом var ptsIntersects = new Point3dCollection(); using (var plane = new Plane()) { lineShadow.IntersectWith(build.Contour, intersectMode, plane, ptsIntersects, IntPtr.Zero, IntPtr.Zero); } // Точки пересечения дома с нулевой линей var ptsZeroIntersects = GetZeroLineIntersects(build); // Между каждыми точками пересечения определение петли полилинии и определение тени if (ptsIntersects.Count > 1) { var ptsItersectSort = ptsIntersects.Cast <Point3d>().OrderBy(o => o.X); var ptIntersectPrew = ptsItersectSort.First(); foreach (var ptIntersect in ptsItersectSort.Skip(1)) { // Если средняя точка внутри полилинии if (build.Contour.IsPointInsidePolygon(ptIntersect.Center(ptIntersectPrew))) { // Точки петли выше try { var ptsLoopAbove = build.Contour.GetLoopSideBetweenHorizontalIntersectPoints( ptIntersectPrew, ptIntersect, true, true). Where(p => p.Y <= ptCalc.Y && p.Y >= lineShadow.StartPoint.Y).ToList(); ptsLoopAbove.AddRange(ptsZeroIntersects); var ilumShadow = GetIllumShadow(ptsLoopAbove); if (ilumShadow != null) { resIlumsShadows.Add(ilumShadow); } } catch (Exception ex) { Logger.Log.Error(ex, "В методе GetBuildingLineShadowBoundary вызов build.Contour.GetLoopSideBetweenHorizontalIntersectPoints()"); } } ptIntersectPrew = ptIntersect; } } //// Точки выше найденного пересечения //var ptsContour = build.Contour.GetPoints(); //var ptsAboveLine = ptsContour.Where(p => p.Y >= lineShadow.StartPoint.Y).ToList(); //foreach (Point3d item in ptsIntersects) //{ // ptsAboveLine.Add(item.Convert2d()); //} //var ilumShadow = GetIllumShadow(ptsAboveLine); //if (ilumShadow != null) //{ // resIlumsShadows.Add(ilumShadow); //} return(resIlumsShadows); }
public BuildingVisual(MapBuilding building) { this.building = building; isOn = true; // Включена визуализация по умолчанию }
public void InsertBuildingIntoMap(MapBuilding building) { var closestGridPosition = GetClosestGridPosition(building.GetTileTopLeft()); building.SetMapGridPosition(closestGridPosition); }