Exemplo n.º 1
0
        public static CurveElement NearestLinesToFace(PlanarFace face, IList <CurveElement> listLines)
        {
            CurveElement curveElement = null;
            double       num          = 0.0;

            foreach (CurveElement curveElement2 in listLines)
            {
                DetailLine detailLine = curveElement2 as DetailLine;
                bool       flag       = detailLine == null;
                if (!flag)
                {
                    XYZ    endPoint = detailLine.GeometryCurve.GetEndPoint(0);
                    double num2     = Facelibry.PointToFace(endPoint, face);
                    bool   flag2    = curveElement == null;
                    if (flag2)
                    {
                        num          = num2;
                        curveElement = curveElement2;
                    }
                    else
                    {
                        bool flag3 = num2 < num;
                        if (flag3)
                        {
                            num          = num2;
                            curveElement = curveElement2;
                        }
                    }
                }
            }
            return(curveElement);
        }
Exemplo n.º 2
0
        public static PlanarFace FirstFace(IList <PlanarFace> listFace, XYZ vector)
        {
            PlanarFace         result = null;
            IList <PlanarFace> list   = Facelibry.PerpendicularFace(listFace, vector);
            double             num    = 0.0;

            foreach (PlanarFace planarFace in list)
            {
                XYZ  source = Facelibry.CenterPoint(planarFace);
                bool flag   = MathLib.IsEqual(num, 0.0, 0.0001);
                if (flag)
                {
                    num    = vector.DotProduct(source);
                    result = planarFace;
                }
                else
                {
                    double num2  = vector.DotProduct(source);
                    bool   flag2 = num2 < num;
                    if (flag2)
                    {
                        result = planarFace;
                        num    = num2;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public static IList <PlanarFace> ListNearestFace(PlanarFace face, IList <PlanarFace> listFaces)
        {
            IList <PlanarFace> list  = new List <PlanarFace>();
            PlanarFace         face2 = Facelibry.NearestFace(face, listFaces);
            XYZ    point             = Facelibry.CenterPoint(face2);
            double num        = Facelibry.PointToFace(point, face);
            XYZ    faceNormal = face.FaceNormal;
            XYZ    right      = Facelibry.CenterPoint(face);

            foreach (PlanarFace planarFace in listFaces)
            {
                XYZ  xyz  = Facelibry.CenterPoint(planarFace);
                XYZ  xyz2 = xyz - right;
                bool flag = xyz2.IsAlmostEqualTo(new XYZ());
                if (!flag)
                {
                    double num2  = Facelibry.PointToFace(xyz, face);
                    bool   flag2 = num2 <1.02 * num && num2> 0.98 * num;
                    if (flag2)
                    {
                        list.Add(planarFace);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 4
0
        public static PlanarFace LastFace(IList <PlanarFace> listFace, XYZ vector, Transform transform)
        {
            PlanarFace         result = null;
            IList <PlanarFace> list   = Facelibry.PerpendicularFace(listFace, vector, transform);
            double             num    = 0.0;

            foreach (PlanarFace planarFace in list)
            {
                XYZ xyz = planarFace.Origin;
                xyz = transform.OfPoint(xyz);
                bool flag = MathLib.IsEqual(num, 0.0, 0.0001);
                if (flag)
                {
                    num    = vector.DotProduct(xyz);
                    result = planarFace;
                }
                else
                {
                    double num2  = vector.DotProduct(xyz);
                    bool   flag2 = num2 > num;
                    if (flag2)
                    {
                        result = planarFace;
                        num    = num2;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public static IList <PlanarFace> PerpendicularFace(IList <PlanarFace> listFaces, XYZ vector, Transform transform)
        {
            IList <PlanarFace> list = new List <PlanarFace>();

            foreach (PlanarFace planarFace in listFaces)
            {
                bool flag = Facelibry.IsPerpendicular(planarFace, vector, transform);
                if (flag)
                {
                    list.Add(planarFace);
                }
            }
            return(list);
        }
Exemplo n.º 6
0
        public static PlanarFace NearestFace(PlanarFace face, IList <PlanarFace> listFaces)
        {
            PlanarFace planarFace = null;
            double     num        = 0.0;
            XYZ        faceNormal = face.FaceNormal;
            XYZ        right      = Facelibry.CenterPoint(face);

            foreach (PlanarFace planarFace2 in listFaces)
            {
                XYZ  faceNormal2 = planarFace2.FaceNormal;
                XYZ  xyz         = faceNormal.CrossProduct(faceNormal2) / (faceNormal.GetLength() * faceNormal2.GetLength());
                bool flag        = !xyz.IsAlmostEqualTo(XYZ.Zero);
                if (!flag)
                {
                    XYZ  xyz2  = Facelibry.CenterPoint(planarFace2);
                    XYZ  xyz3  = xyz2 - right;
                    bool flag2 = xyz3.IsAlmostEqualTo(new XYZ());
                    if (!flag2)
                    {
                        double num2  = Facelibry.PointToFace(xyz2, face);
                        bool   flag3 = null == planarFace && num2 > 1E-06;
                        if (flag3)
                        {
                            planarFace = planarFace2;
                            num        = num2;
                        }
                        else
                        {
                            bool flag4 = num2 <num && num2> 1E-07;
                            if (flag4)
                            {
                                planarFace = planarFace2;
                                num        = num2;
                            }
                        }
                    }
                }
            }
            return(planarFace);
        }
Exemplo n.º 7
0
        public static PlanarFace GetTopFace(IList <PlanarFace> faces, XYZ direction, Transform transform)
        {
            PlanarFace result = null;
            double     num    = double.MinValue;
            XYZ        point  = new XYZ();
            double     num2   = double.MinValue;

            foreach (PlanarFace planarFace in faces)
            {
                foreach (object obj in planarFace.EdgeLoops)
                {
                    EdgeArray edgeArray = (EdgeArray)obj;
                    foreach (object obj2 in edgeArray)
                    {
                        Edge  edge  = (Edge)obj2;
                        Curve curve = edge.AsCurve();
                        bool  flag  = curve == null;
                        if (!flag)
                        {
                            XYZ    xyz   = transform.OfPoint(curve.GetEndPoint(0));
                            XYZ    xyz2  = transform.OfPoint(curve.GetEndPoint(1));
                            double num3  = xyz.DotProduct(direction);
                            double num4  = xyz2.DotProduct(direction);
                            bool   flag2 = num3 > num2;
                            if (flag2)
                            {
                                point = xyz;
                                num2  = num3;
                            }
                            bool flag3 = num4 > num2;
                            if (flag3)
                            {
                                point = xyz2;
                                num2  = num4;
                            }
                        }
                    }
                }
            }
            List <PlanarFace> list = new List <PlanarFace>();

            foreach (PlanarFace planarFace2 in faces)
            {
                double num5  = Facelibry.PointToFace(point, planarFace2, transform);
                bool   flag4 = num5 < 0.001;
                if (flag4)
                {
                    list.Add(planarFace2);
                }
            }
            foreach (PlanarFace planarFace3 in list)
            {
                XYZ    xyz3  = transform.OfVector(planarFace3.FaceNormal);
                double num6  = xyz3.DotProduct(direction);
                bool   flag5 = num6 > num;
                if (flag5)
                {
                    result = planarFace3;
                    num    = num6;
                }
            }
            return(result);
        }