Exemple #1
0
        public static XYZ GetProjectPoint(Curve line, XYZ point)
        {
            if (IsPointInLineOrExtend(CheckGeometry.ConvertLine(line), point))
            {
                return(point);
            }
            XYZ   vecL = GeomUtil.SubXYZ(line.GetEndPoint(1), line.GetEndPoint(0));
            XYZ   vecP = GeomUtil.SubXYZ(point, line.GetEndPoint(0));
            Plane p    = Plane.CreateByOriginAndBasis(line.GetEndPoint(0), GeomUtil.UnitVector(vecL), GeomUtil.UnitVector(GeomUtil.CrossMatrix(vecL, vecP)));

            return(GetProjectPoint(p, point));
        }
Exemple #2
0
        public static List <Curve> GetCurvesCut(Polygon mainPolygon, Polygon secPolygon)
        {
            PolygonComparePolygonResult res = new PolygonComparePolygonResult(mainPolygon, secPolygon);

            if (res.ListPolygon[0] != secPolygon)
            {
                throw new Exception("Secondary Polygon must inside Main Polygon!");
            }
            bool         isInside = true;
            List <Curve> cs       = new List <Curve>();

            foreach (Curve c in secPolygon.ListCurve)
            {
                LineComparePolygonResult lpRes = new LineComparePolygonResult(mainPolygon, CheckGeometry.ConvertLine(c));
                if (lpRes.Type == LineComparePolygonType.Inside)
                {
                    foreach (Curve c1 in mainPolygon.ListCurve)
                    {
                        LineCompareLineResult llres = new LineCompareLineResult(c, c1);
                        if (llres.Type == LineCompareLineType.SameDirectionLineOverlap)
                        {
                            goto Here;
                        }
                    }
                    cs.Add(c);
                }
                Here : continue;
            }
            isInside = false;
            foreach (Curve c in mainPolygon.ListCurve)
            {
                LineComparePolygonResult lpRes = new LineComparePolygonResult(secPolygon, CheckGeometry.ConvertLine(c));
                if (lpRes.Type == LineComparePolygonType.Outside)
                {
                    cs.Add(c);
                    continue;
                }
                foreach (Curve c1 in secPolygon.ListCurve)
                {
                    LineCompareLineResult llRes = new LineCompareLineResult(c, c1);
                    if (llRes.Type == LineCompareLineType.SameDirectionLineOverlap)
                    {
                        isInside = false;
                        if (llRes.ListOuterLine.Count == 0)
                        {
                            break;
                        }
                        foreach (Line l in llRes.ListOuterLine)
                        {
                            LineComparePolygonResult lpRes1 = new LineComparePolygonResult(secPolygon, l);
                            if (lpRes1.Type != LineComparePolygonType.Inside)
                            {
                                cs.Add(l);
                            }
                        }
                        break;
                    }
                }
            }
            if (isInside)
            {
                throw new Exception("Secondary Polygon must be tangential with Main Polygon!");
            }
            return(cs);
        }