Ejemplo n.º 1
0
        /// <summary>
        /// 开启同步操作:在Revit UI 界面中选择封闭的模型曲线链
        /// </summary>
        /// <returns></returns>
        public CurveArrArray SendSelect(out List <List <ModelCurve> > modelCurvess)
        {
            CurveArrArray profiles = new CurveArrArray(); // 每一次创建开挖土体时,在NewExtrusion方法中,要创建的实体的轮廓

            modelCurvess = new List <List <ModelCurve> >();
            //
            bool blnStop = false;

            do
            {
                blnStop = true;
                List <ModelCurve> modelCurves;
                CurveLoop         cvLoop = GetLoopedCurve(out modelCurves);
                // 检验并添加
                if (cvLoop != null && cvLoop.Any())
                {
                    CurveArray cvArr = new CurveArray();
                    foreach (Curve c in cvLoop)
                    {
                        cvArr.Append(c);
                    }

                    //
                    profiles.Append(cvArr);
                    modelCurvess.Add(modelCurves);

                    // 是否要继续添加
                    if (this._multipleClosed)
                    {
                        DialogResult res = MessageBox.Show("曲线添加成功,是否还要继续添加?", "提示", MessageBoxButtons.YesNo,
                                                           MessageBoxIcon.Question);
                        if (res == DialogResult.Yes)
                        {
                            blnStop = false;
                        }
                    }
                }
            } while (!blnStop);
            return(profiles);
        }
Ejemplo n.º 2
0
        public PointLocation IsPointInside(XYZ point)
        {
            // Check if the point is outside of the loop bounding box
            if (point.X - Epsilon < MinX ||
                point.X + Epsilon > MaxX ||
                point.Y - Epsilon < MinY ||
                point.Y + Epsilon > MaxY)
            {
                return(PointLocation.Outside);
            }

            // Check if the point is on the loop
            if (_loop2d.Any(curve => curve.Distance(point) < Epsilon))
            {
                return(PointLocation.OnTheEdge);
            }

            // Create a Line that starts from point and ends outside of the loop. Adding non-integer
            // values decreases the chances of special cases, where line passes through loop
            // endpoints. These cases can still happen and are managed by the function, but using a
            // different offset costs nothing and may help staying out of trouble. (The trouble
            // could show up when a point doesn't really lay on a line, or two points are not exactly
            // the identical. Using Epsilon helps a little, but, again, when the distance between two
            // points is exactly Epsilon, here comes the trouble.)
            var line = Line.CreateBound(point, new XYZ(MaxX + 0.1234, MaxY + 0.3456, 0));

            // Count the number of intersections between the line just created and the loop.
            // If the number of intersection is odd, then point is inside the loop.
            // Discard the solutions where the intersection is the edge start point, because these
            // intersections have already been counted when intersecting the end point of the
            // previous segments.
            var nIntersections = _loop2d
                                 .Where(edge => edge.Intersect(line) == SetComparisonResult.Overlap)
                                 .Count(edge => line.Distance(edge.GetEndPoint(0)) > Epsilon);

            return(nIntersections % 2 == 1 ? PointLocation.Inside : PointLocation.Outside);
        }