Esempio n. 1
0
        // TIN输出等值线
        static void DumpContourTIN()
        {
            List <GeomPoint> newPoints = new List <GeomPoint>();

            foreach (var edge_val in trackedEdges)
            {
                Edge      edge = edge_val.Item1; double val = edge_val.Item2;
                Vector2   pos   = edge.Item1 * (1 - val) + edge.Item2 * val;
                GeomPoint newPt = new GeomPoint(pos.X, pos.Y, idxPoint++, currValue);
                geomPoints.Add(newPt);
                newPoints.Add(newPt);
            }

            // 成环判断
            var tmp = currEdges[trackedEdges[0].Item1].Intersect(currEdges[trackedEdges.Last().Item1]);

            if (tmp.Count() > 0)
            {
                newPoints.Add(newPoints[0]);
            }

            // 创建弧段并重置
            geomArcs.Add(new GeomArc(newPoints, idxArc++, currValue));
            trackedEdges = new List <Tuple <Edge, double> >();
        }
Esempio n. 2
0
        // 导出并重置当前已搜索等值线
        static void DumpContourGrid()
        {
            List <GeomPoint> newPoints = new List <GeomPoint>();

            foreach (Vector2 offset in trackedPoints)
            {
                GeomPoint newPt = new GeomPoint(
                    offset.X.Lerp(0, nx, currGrid.XMin, currGrid.XMax),
                    offset.Y.Lerp(0, ny, currGrid.YMin, currGrid.YMax),
                    idxPoint++,
                    currValue
                    );
                geomPoints.Add(newPt);
                newPoints.Add(newPt);
            }
            // 内部点判断
            if (newPoints[0].X != currGrid.XMin && newPoints[0].X != currGrid.XMax &&
                newPoints[0].Y != currGrid.YMin && newPoints[0].Y != currGrid.YMax)
            {
                newPoints.Add(newPoints[0]);
            }
            geomArcs.Add(new GeomArc(newPoints, idxArc++, currValue));

            trackedPoints = new List <Vector2>();
        }
Esempio n. 3
0
        // 使用指定点序列与末点创建弧段,并加入全局序列
        static void DumpArc(ref List <GeomPoint> points, GeomPoint ender)
        {
            points.Add(ender);
            var newArc = Arc(points);

            points = new List <GeomPoint>(new GeomPoint[] { ender });
            if (newArc != null)
            {
                cArc.Add(newArc);
            }
        }
Esempio n. 4
0
        // 2.1 从指定弧段与端点开始搜索相连多边形
        static void PolyTopoGroup(GeomPoint pt, GeomArc arc)
        {
            inners = new HashSet <GeomPoly>();
            stack  = new LinkedList <Tuple <GeomPoint, GeomArc> >();
            stack.AddFirst(new Tuple <GeomPoint, GeomArc>(pt, arc));

            while (stack.Count > 0)
            {
                var data = stack.First;
                stack.RemoveFirst();
                PolyTopoUnit(data.Value);
            }

            if (inners.Count == 0)
            {
                return;
            }

            // 获取并删除外包多边形(面积最大)
            GeomPoly outer = null;

            if (inners.Count > 1)
            {
                outer = null;
                foreach (var poly in inners)
                {
                    if (outer == null || outer.OuterArea < poly.OuterArea)
                    {
                        outer = poly;
                    }
                }
                inners.Remove(outer);
            }
            else
            {
                outer = inners.First();
            }

            // 加入待处理孔洞列表
            holesGroup.Add(new Tuple <GeomPoly, HashSet <GeomPoly> >(outer, inners));

            cPoly.AddRange(inners);
        }
Esempio n. 5
0
        // 由MBR创建分割弧段
        static IEnumerable <GeomArc> SplitMBR(Rect MBR)
        {
            var xs = new double[] {
                MBR.XMin,
                (MBR.XMin + MBR.XMax) / 2,
                MBR.XMax,
            };
            var ys = new double[] {
                MBR.YMin,
                (MBR.YMin + MBR.YMax) / 2,
                MBR.YMax,
            };
            var pts = new GeomPoint[3, 3];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    pts[i, j] = Point(new Vector2(xs[i], ys[j]));
                }
            }

            GeomPoint[] tmp;
            for (int i = 0; i < 2; i++)
            {
                // 横线+竖线
                for (int j = 0; j < 3; j++)
                {
                    tmp = new GeomPoint[] { pts[i, j], pts[i + 1, j] };
                    yield return(new GeomArc(tmp));

                    tmp = new GeomPoint[] { pts[j, i], pts[j, i + 1] };
                    yield return(new GeomArc(tmp));
                }

                // 斜线
                tmp = new GeomPoint[] { pts[i, i], pts[i + 1, i + 1] };
                yield return(new GeomArc(tmp));

                tmp = new GeomPoint[] { pts[i, 2 - i], pts[i + 1, 1 - i] };
                yield return(new GeomArc(tmp));
            }
        }
Esempio n. 6
0
        // 复制指定弧段为新弧段,并对点去重
        static GeomArc Arc(IEnumerable <GeomPoint> points)
        {
            var       pool   = new List <GeomPoint>();
            GeomPoint lastPt = null;

            foreach (var pt in points)
            {
                var newPt = Point(pt);
                if (newPt == lastPt)
                {
                    continue;                  // 去重
                }
                pool.Add(lastPt = newPt);
            }
            if (pool.Count < 2)
            {
                return(null);
            }
            return(new GeomArc(pool));
        }
Esempio n. 7
0
        // 2.1.1 搜索相连多边形:单元操作,返回当前搜索
        static void PolyTopoUnit(Tuple <GeomPoint, GeomArc> data)
        {
            if (arcUsed.Contains(data))
            {
                return;
            }
            var res = new List <Tuple <GeomPoint, GeomArc> >();

            // 搜索直到首尾相接
            while (true)
            {
                // 加入当前弧段
                res.Add(data);
                arcUsed.Add(data);
                // 获取下一弧段
                GeomPoint prevPt  = data.Item1;
                GeomArc   prevArc = data.Item2;
                GeomPoint nextPt  = prevArc.First;
                if (nextPt == prevPt)
                {
                    nextPt = prevArc.Last;
                }
                GeomArc nextArc = vertNext[nextPt][data.Item2];
                data = new Tuple <GeomPoint, GeomArc>(nextPt, prevArc); // 同弧段不同顶点
                if (!arcUsed.Contains(data))
                {
                    stack.AddFirst(data);
                }
                data = new Tuple <GeomPoint, GeomArc>(nextPt, nextArc);
                // 首尾相接时跳出
                if (data.Equals(res[0]))
                {
                    break;
                }
            }

            // 创造多边形
            var newPoly = new GeomPoly(from pair in res select pair.Item2);

            inners.Add(newPoly);
        }
Esempio n. 8
0
        public static ComplexGeometry ExecuteStages(Point centerLocation)
        {
            var finalGeometry = new List <Geometry>();

            var pointsList = GeomPoint.CreatePoints();

            finalGeometry.Add(pointsList);
            var linesList = GeomLine.CreateLines(pointsList);

            finalGeometry.Add(linesList);
            var ellipse = GeomEllipse.CreateEllipse(linesList);

            finalGeometry.Add(ellipse);
            var circle = GeomCircle.CreateCircle(ellipse);

            finalGeometry.Add(circle);
            var boundingBox = GeomBoundingBox.CreateBoundingBox(ellipse);

            finalGeometry.Add(boundingBox);

            return(finalGeometry);
        }
Esempio n. 9
0
        public EdgeInfo(TopoShape edge, int idx, int faceIdx, double length)
        {
            Curve = new GeomCurve();
            Curve.Initialize(edge);
            Index     = idx;
            FaceIndex = faceIdx;
            var start = Curve.Value(Curve.FirstParameter());
            var end   = Curve.Value(Curve.LastParameter());

            Direction = end - start;
            Direction.Normalize();
            Length = length;

            var pts = GlobalInstance.TopoExplor.ExplorVertices(edge);

            for (int ii = 0; ii < pts.Size(); ++ii)
            {
                GeomPoint gp = new GeomPoint();
                gp.Initialize(pts.GetAt(ii));

                Vertices.Add(new VertexInfo(gp.GetPoint(), ii, idx, faceIdx));
            }
        }
Esempio n. 10
0
 // 导出CSV至点图层
 public static void OutputPoints(List <List <CSVNode> > source, List <GeomPoint> points, bool header, int colX, int colY, int colValue = -1, int colID = -1, int colName = -1)
 {
     // 创建图层
     for (int i = header ? 1 : 0; i < table.Count; i++)
     {
         List <CSVNode> line = table[i];
         double         x    = colX >= 0 ? (double)line[colX].valueNum : 0;
         double         y    = colY >= 0 ? (double)line[colY].valueNum : 0;
         GeomPoint      pt   = new GeomPoint(x, y, i);
         if (colID >= 0)
         {
             pt.id = line[colID].valueInt;
         }
         if (colName >= 0)
         {
             pt.name = line[colName].valueString;
         }
         if (colValue >= 0)
         {
             pt.value = (double)line[colValue].valueNum;
         }
         points.Add(pt);
     }
 }
Esempio n. 11
0
 public AISPoint(GeomPoint aComponent)
     :
     base(AIS_Point_Ctor121385BD(aComponent.Instance))
 {
 }
Esempio n. 12
0
 public void SetPoints(GeomPoint P1, GeomPoint P2)
 {
     AIS_Line_SetPoints2A4E6D38(Instance, P1.Instance, P2.Instance);
 }
Esempio n. 13
0
 public void Points(GeomPoint PStart, GeomPoint PEnd)
 {
     AIS_Line_Points2A4E6D38(Instance, PStart.Instance, PEnd.Instance);
 }
Esempio n. 14
0
 public AISLine(GeomPoint aStartPoint, GeomPoint aEndPoint)
     :
     base(AIS_Line_Ctor2A4E6D38(aStartPoint.Instance, aEndPoint.Instance))
 {
 }