public void CreateContour(BlockTableRecord btr) { if (panelBtr.ExtentsByTile.Diagonal() < endOffset) { return; } // из всех плиток отделить торцевые плитки???? // дерево границ плиток TreeTiles = new RTree<Tuple<ObjectId, Extents3d>>(); panelBtr.Tiles.ForEach(t => { try { var r = new Rectangle(t.Item2.MinPoint.X, t.Item2.MinPoint.Y, t.Item2.MaxPoint.X, t.Item2.MaxPoint.Y, 0, 0); TreeTiles.Add(r, t); } catch { } }); // Первый угол панели - левый нижний var pt1 = getCoordTileNoEnd(panelBtr.ExtentsByTile.MinPoint, EnumCorner.LeftLower); var pt2 = getCoordTileNoEnd(new Point3d(panelBtr.ExtentsByTile.MinPoint.X, panelBtr.ExtentsByTile.MaxPoint.Y, 0), EnumCorner.LeftTop); var pt3 = getCoordTileNoEnd(panelBtr.ExtentsByTile.MaxPoint, EnumCorner.RightTop); var pt4 = getCoordTileNoEnd(new Point3d(panelBtr.ExtentsByTile.MaxPoint.X, panelBtr.ExtentsByTile.MinPoint.Y, 0), EnumCorner.RightLower); Extents3d extNoEnd = new Extents3d(pt1, pt2); extNoEnd.AddPoint(pt3); extNoEnd.AddPoint(pt4); panelBtr.ExtentsNoEnd = extNoEnd; Point3dCollection pts = new Point3dCollection(); pts.Add(pt1); pts.Add(pt2); pts.Add(pt3); pts.Add(pt4); using (Polyline3d poly = new Polyline3d(Poly3dType.SimplePoly, pts, true)) { poly.LayerId = panelBtr.CPS.IdLayerContour; btr.AppendEntity(poly); btr.Database.TransactionManager.TopTransaction.AddNewlyCreatedDBObject(poly, true); } }
/// <summary> /// Расчетная область - от точки /// </summary> private Extents3d GetCalcExtents(double maxHeight) { // высота тени - отступ по земле от расчетной точки до линии движения тени double cSunPlane; double ySunPlane = values.YShadowLineByHeight(maxHeight, out cSunPlane); // растояние до точки пересечения луча и линии тени double xRayToStart = values.GetXRay(ySunPlane, StartAnglesIllum.AngleStartOnPlane); if (xRayToStart < 0) { xRayToStart = 0; } double xRayToEnd = values.GetXRay(ySunPlane, StartAnglesIllum.AngleEndOnPlane); if (xRayToEnd > 0) { xRayToEnd = 0; } Extents3d ext = new Extents3d(); ext.AddPoint(new Point3d(ptCalc.X + xRayToEnd, ptCalc.Y - ySunPlane, 0)); ext.AddPoint(new Point3d(ptCalc.X + xRayToStart, ptCalc.Y, 0)); #if TEST //EntityHelper.AddEntityToCurrentSpace(ext.GetPolyline()); #endif return(ext); }
public static Extents3d PromptExtents([NotNull] this Editor ed, string msgPromptFirstPoint, string msgPromptsecondPoint) { var extentsPrompted = new Extents3d(); var prPtRes = ed.GetPoint(msgPromptFirstPoint); if (prPtRes.Status == PromptStatus.OK) { var prCornerRes = ed.GetCorner(msgPromptsecondPoint, prPtRes.Value); if (prCornerRes.Status == PromptStatus.OK) { extentsPrompted.AddPoint(prPtRes.Value); extentsPrompted.AddPoint(prCornerRes.Value); } else { throw new OperationCanceledException(); } } else { throw new OperationCanceledException(); } return(extentsPrompted); }
public void CreateContour(BlockTableRecord btr) { if (panelBtr.ExtentsByTile.Diagonal() < endOffset) { return; } // из всех плиток отделить торцевые плитки???? // дерево границ плиток TreeTiles = new RTree <Tuple <ObjectId, Extents3d> >(); panelBtr.Tiles.ForEach(t => { try { var r = new Rectangle(t.Item2.MinPoint.X, t.Item2.MinPoint.Y, t.Item2.MaxPoint.X, t.Item2.MaxPoint.Y, 0, 0); TreeTiles.Add(r, t); } catch { } }); // Первый угол панели - левый нижний var pt1 = getCoordTileNoEnd(panelBtr.ExtentsByTile.MinPoint, EnumCorner.LeftLower); var pt2 = getCoordTileNoEnd(new Point3d(panelBtr.ExtentsByTile.MinPoint.X, panelBtr.ExtentsByTile.MaxPoint.Y, 0), EnumCorner.LeftTop); var pt3 = getCoordTileNoEnd(panelBtr.ExtentsByTile.MaxPoint, EnumCorner.RightTop); var pt4 = getCoordTileNoEnd(new Point3d(panelBtr.ExtentsByTile.MaxPoint.X, panelBtr.ExtentsByTile.MinPoint.Y, 0), EnumCorner.RightLower); Extents3d extNoEnd = new Extents3d(pt1, pt2); extNoEnd.AddPoint(pt3); extNoEnd.AddPoint(pt4); panelBtr.ExtentsNoEnd = extNoEnd; Point3dCollection pts = new Point3dCollection(); pts.Add(pt1); pts.Add(pt2); pts.Add(pt3); pts.Add(pt4); using (Polyline3d poly = new Polyline3d(Poly3dType.SimplePoly, pts, true)) { poly.LayerId = panelBtr.CPS.IdLayerContour; btr.AppendEntity(poly); btr.Database.TransactionManager.TopTransaction.AddNewlyCreatedDBObject(poly, true); } }
/// <summary> /// 获取用户输入的矩形角点区域 /// </summary> /// <param name="baseword">基点提示</param> /// <param name="targetword">角点提示</param> /// /// <returns>用户输入的矩形角点区域</returns> public static Extents3d GetCorner(string baseword, string targetword) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Point3d basept = GetPoint(baseword); Point3d targetpt = new Point3d(); PromptCornerOptions options = new PromptCornerOptions(targetword, basept); PromptPointResult i = ed.GetCorner(options); if (i.Status == PromptStatus.OK) { targetpt = i.Value; } Extents3d ext = new Extents3d(); ext.AddPoint(targetpt); ext.AddPoint(basept); return(ext); }
private static Extents3d GetViewportBoundaryExtentsInModelSpace(Point3dCollection points) { Extents3d ext = new Extents3d(); foreach (Point3d p in points) { ext.AddPoint(p); } return ext; }
internal static Extents3d ScreenExtents( AbstractViewTableRecord vtr ) { // Get the centre of the screen in WCS and use it // with the diagonal vector to add the corners to the // extents object var ext = new Extents3d(); var vec = new Vector3d(0.5 * vtr.Width, 0.5 * vtr.Height, 0); var ctr = new Point3d(vtr.CenterPoint.X, vtr.CenterPoint.Y, 0); var dcs = Utils.Dcs2Wcs(vtr); ext.AddPoint((ctr + vec).TransformBy(dcs)); ext.AddPoint((ctr - vec).TransformBy(dcs)); return(ext); }
// Определение центра панели по блокам плиток в ней private Point2d GetCenterPanel(List <Tile> _tiles) { _extentsTiles = new Extents3d(); foreach (var tile in _tiles) { _extentsTiles.AddPoint(tile.CenterTile); } _heightPanelByTile = _extentsTiles.MaxPoint.Y - _extentsTiles.MinPoint.Y + Settings.Default.TileSeam + Settings.Default.TileHeight; return(new Point2d((_extentsTiles.MinPoint.X + _extentsTiles.MaxPoint.X) * 0.5, (_extentsTiles.MinPoint.Y + _extentsTiles.MaxPoint.Y) * 0.5)); }
/// <summary> /// Определение границ домов по точкам всех ячеек инсоляции /// </summary> private Extents3d GetExtents(List <HouseTransform> houses) { var cells = houses.SelectMany(s => s.Cells); var ext = new Extents3d(); foreach (var item in cells) { ext.AddPoint(item.PtCenter.Convert3d()); } return(ext); }
private Extents3d PromptSelectRegion() { var resPt = ed.GetPoint("\nПервый угол области:"); if (resPt.Status != PromptStatus.OK) { throw new AcadLib.CancelByUserException(); } var resPt2 = ed.GetCorner("\nВторой угол:", resPt.Value); if (resPt2.Status != PromptStatus.OK) { throw new AcadLib.CancelByUserException(); } var pt1 = resPt.Value.Trans(ed, CoordSystem.UCS, CoordSystem.WCS); var pt2 = resPt2.Value.Trans(ed, CoordSystem.UCS, CoordSystem.WCS); var ext = new Extents3d(); ext.AddPoint(pt1); ext.AddPoint(pt2); return(ext); }
public static Extents3d PromptExtents(this Editor ed, string msgPromptFirstPoint, string msgPromptsecondPoint) { Extents3d extentsPrompted = new Extents3d(); var prPtRes = ed.GetPoint(msgPromptFirstPoint); if (prPtRes.Status == PromptStatus.OK) { var prCornerRes = ed.GetCorner(msgPromptsecondPoint, prPtRes.Value); if (prCornerRes.Status == PromptStatus.OK) { extentsPrompted.AddPoint(prPtRes.Value); extentsPrompted.AddPoint(prCornerRes.Value); } else { throw new Exception("Отменено пользователем."); } } else { throw new Exception("Отменено пользователем."); } return extentsPrompted; }
public static Surface FromPoint3ds(Point3d[] points) { Extents3d extents = new Extents3d(points[0], points[0]); points.ToList().ForEach(x => extents.AddPoint(x)); Surface surf = new Surface(); surf.m_points = points; surf.m_extents = extents; surf._pointsAreGrid = false; surf.BuildTIN(); return(surf); }
private void readSurferGridData(string path) { // 读数据 double yfirst = 0; //记录第一个读出来的y坐标,如果发生变化,说明第一行数据读取完毕 List <double> databuf = new List <double>(); StreamReader sr = new StreamReader(path); int index = 0; while (!sr.EndOfStream) { string strRead = sr.ReadLine(); if (strRead != "") { string[] strs = strRead.Split(' '); databuf.Add(double.Parse(strs[2])); // 记录图幅范围,并统计行数 if (index == 0) { yfirst = double.Parse(strs[1]); Point3d pt = new Point3d(double.Parse(strs[0]), double.Parse(strs[1]), 0); m_extents.Set(pt, pt); } if (sr.EndOfStream) { m_extents.AddPoint(new Point3d(double.Parse(strs[0]), double.Parse(strs[1]), 0)); } // y值发生变化,记录下列数 if (double.Parse(strs[1]) != yfirst && m_XSize == 0) { m_XSize = index; } } index++; } m_YSize = databuf.Count / m_XSize; m_elevations = databuf.ToArray(); sr.Close(); }
public static List <ObjectId> SelectByPolygon([NotNull] this Editor ed, [NotNull] IEnumerable <Point3d> pts) { using (ed.Document.LockDocument()) { Debug.WriteLine($"SelectByPolygon IsApplicationContext={Application.DocumentManager.IsApplicationContext}."); var ext = new Extents3d(); var ptsCol = new List <Point3d>(); var wcsToUcs = ed.WCS2UCS(); foreach (var pt in pts) { ext.AddPoint(pt); var ptUCS = pt.TransformBy(wcsToUcs); ptsCol.Add(ptUCS); } ed.Zoom(ext); var selRes = ed.SelectCrossingPolygon(new Point3dCollection(ptsCol.ToArray())); if (selRes.Status == PromptStatus.OK) { return(selRes.Value.GetObjectIds().ToList()); } throw new OperationCanceledException(); } }
public static Surface FromTxtFile(string path) { List <Point3d> points = new List <Point3d>(); string[] lines = File.ReadAllLines(path); foreach (string line in lines) { if (!string.IsNullOrEmpty(line)) { string[] coords = line.Trim().Split(' '); points.Add(new Point3d(Convert.ToDouble(coords[0]), Convert.ToDouble(coords[1]), Convert.ToDouble(coords[2]))); } } Extents3d extents = new Extents3d(points[0], points[0]); points.ToList().ForEach(x => extents.AddPoint(x)); Surface surf = new Surface(); surf.m_points = points.ToArray(); surf.m_extents = extents; surf._pointsAreGrid = false; surf.BuildTIN(); return(surf); }
public void fMESHAUTO() { Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor; try { Utils.Utils.Init(); Document acDoc = acApp.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; if (!Utils.Layers.CurrentLayer().Contains("!FDS_MESH")) { Utils.Layers.SetLayer("!FDS_MESH"); } Utils.Utils.SetOrtho(false); PromptDoubleOptions snapO = new PromptDoubleOptions("\nEnter cell size:"); snapO.DefaultValue = Utils.Utils.snapUnit.X; PromptDoubleResult snap = ed.GetDouble(snapO); if (snap.Status != PromptStatus.OK || snap.Status == PromptStatus.Cancel) { goto End; } Utils.Utils.SetSnapUnit(new Point2d(snap.Value, snap.Value)); PromptPointOptions p1Option = new PromptPointOptions("\nSpecify mesh area first corner:"); p1Option.AllowNone = false; PromptPointResult p1 = ed.GetPoint(p1Option); if (p1.Status != PromptStatus.OK || p1.Status == PromptStatus.Cancel) { goto End; } var p2 = ed.GetUcsCorner("Pick mesh area opposite corner:", p1.Value); if (p2.Status != PromptStatus.OK || p2.Status == PromptStatus.Cancel) { goto End; } ObjectId recId = Utils.Utils.CreateRectangle(p1.Value, p2.Value, "!FDS_MESH"); // Vertical - pionowy // Horizontal - poziomy PromptIntegerOptions noMeshVerO = new PromptIntegerOptions("\nEnter vertical mesh number:"); noMeshVerO.DefaultValue = 1; PromptIntegerResult noMeshVer = ed.GetInteger(noMeshVerO); if (noMeshVer.Status != PromptStatus.OK || noMeshVer.Status == PromptStatus.Cancel) { goto End; } PromptIntegerOptions noMeshHorO = new PromptIntegerOptions("\nEnter horizontal mesh number:"); noMeshHorO.DefaultValue = 1; PromptIntegerResult noMeshHor = ed.GetInteger(noMeshHorO); if (noMeshHor.Status != PromptStatus.OK || noMeshHor.Status == PromptStatus.Cancel) { goto End; } // Usun zaznaczenie Utils.Utils.DeleteObject(recId); double horizontalDistance = Math.Abs(p2.Value.X - p1.Value.X); double verticalDistance = Math.Abs(p2.Value.Y - p1.Value.Y); double horizontalUnitDistance = Math.Ceiling(horizontalDistance / noMeshHor.Value / snap.Value) * snap.Value; double verticalUnitDistance = Math.Ceiling(verticalDistance / noMeshVer.Value / snap.Value) * snap.Value; horizontalUnitDistance = horizontalUnitDistance + (horizontalUnitDistance % snap.Value); verticalUnitDistance = verticalUnitDistance + (verticalUnitDistance % snap.Value); ed.WriteMessage("\nHorizontal distance:"); ed.WriteMessage(horizontalDistance.ToString()); ed.WriteMessage("\nHorizontal unit distance:"); ed.WriteMessage(horizontalUnitDistance.ToString()); Extents3d ext = new Extents3d(); ext.AddPoint(p1.Value); ext.AddPoint(p2.Value); List <double> horizontalPoints = new List <double>(); for (int i = 0; i < noMeshHor.Value; i++) { horizontalPoints.Add(ext.MinPoint.X + i * horizontalUnitDistance); } List <double> verticalPoints = new List <double>(); for (int i = 0; i < noMeshVer.Value; i++) { verticalPoints.Add(ext.MinPoint.Y + i * verticalUnitDistance); } List <double[]> boxes = new List <double[]>(); horizontalPoints.ForEach(delegate(double xPoint1) { double xPoint2 = xPoint1 + horizontalUnitDistance; if (xPoint1 == horizontalPoints.Last()) { xPoint2 = ext.MaxPoint.X; } verticalPoints.ForEach(delegate(double yPoint1) { double yPoint2 = yPoint1 + verticalUnitDistance; if (yPoint1 == verticalPoints.Last()) { yPoint2 = ext.MaxPoint.Y; } // Wyznaczanie Z do siatek // !!! Dodać filtr warstw ... // !!! Czy po Z rysujemy tez kilka siatek ... PromptSelectionResult acSSPrompt; acSSPrompt = ed.SelectCrossingWindow(new Point3d(xPoint1, yPoint1, 0), new Point3d(xPoint2, yPoint2, 0)); if (acSSPrompt.Status == PromptStatus.OK) { Extents3d extZ = new Extents3d(); SelectionSet acSSet = acSSPrompt.Value; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { foreach (var id in acSSet.GetObjectIds()) { var ent = acTrans.GetObject(id, OpenMode.ForRead) as Entity; if (ent != null) { extZ.AddExtents(ent.GeometricExtents); } } } // !!! Sprawdzic czy z jest wielokrotnoscia skoku - rysowane na innym skoku boxes.Add(new double[6] { xPoint1, xPoint2, yPoint1, yPoint2, extZ.MinPoint.Z, extZ.MaxPoint.Z }); } else { //acApp.ShowAlertDialog("No objects of objects in area"); ed.WriteMessage("\nNo mesh needed"); } }); }); if (boxes.Count > 0) { boxes.ForEach(delegate(double[] point) { Utils.Utils.CreateBox(point[0], point[1], point[2], point[3], point[4], point[5], "!FDS_MESH"); }); } End :; Utils.Utils.End(); } catch (System.Exception e) { ed.WriteMessage("\nProgram exception: " + e.ToString()); } }