コード例 #1
0
ファイル: NetworkEdge.cs プロジェクト: Kirill78Z/InfoTools
            private PointOnCurve2d GetSplitPt(CivilDB.Structure str, bool start)
            {
                Curve2d strPosCurve = StructurePosCurve(str);
                CurveCurveIntersector2d intersector = new CurveCurveIntersector2d(PositionCurve, strPosCurve);

                if (intersector.NumberOfIntersectionPoints > 0)
                {
                    intersector.OrderWithRegardsTo1();
                    //взять точку пересечения, которая имеет имеет наибольший параметр PositionCurve для начальной точки
                    //и наименьший для конечной точки
                    return(start ? intersector.GetPointOnCurve1(intersector.NumberOfIntersectionPoints - 1)
                        : intersector.GetPointOnCurve1(0));
                }
                return(null);
            }
コード例 #2
0
            private bool AddIntersection(LineSegment2d intersectionSeg, LinearEntity2d vert, HatchNestingNode hatchNode, SortedSet <Node> vertSorted)
            {
                bool result = false;
                CurveCurveIntersector2d intersector = new CurveCurveIntersector2d(intersectionSeg, vert);

                if (intersector.NumberOfIntersectionPoints > 0)
                {
                    Point2d intersectionPt = intersector.GetPointOnCurve1(0).Point;
                    //если точка пересечения контура и вертикали имеет ту же координату X,
                    //что и начало или конец контура, то это пересечение не учитывается!
                    if (!Utils.LengthIsEquals(intersectionPt.X, hatchNode.Extents.MinPoint.X) &&
                        !Utils.LengthIsEquals(intersectionPt.X, hatchNode.Extents.MaxPoint.X))   //допуск
                    {
                        double param = hatchNode.Boundary.GetParameterOf(intersectionPt);

                        Node newIntersectionNode = new Node(hatchNode, param, intersectionPt);
                        if (!vertSorted.Contains(newIntersectionNode))//TODO: Нужен учет допуска???
                        {
                            result = true;
                            notVisited.Add(newIntersectionNode);

                            vertSorted.Add(newIntersectionNode);
                            SortedSet <Node> boundarySorted = null;
                            boundariesSorted.TryGetValue(hatchNode, out boundarySorted);
                            if (boundarySorted == null)
                            {
                                boundarySorted = new SortedSet <Node>(new NodeParamComparer());//сортировка по параметру!!!
                                boundariesSorted.Add(hatchNode, boundarySorted);
                            }

                            if (boundarySorted.Contains(newIntersectionNode))
                            {
                                throw new Exception("Ошибка логики обхода полигона. Получены 2 точки с одинаковым параметром на одной кривой");
                            }

                            boundarySorted.Add(newIntersectionNode);
                        }
                    }
                }
                return(result);
            }