Exemplo n.º 1
0
        public static Vertexes GetVertexesFromPoints(List<PointData> points)
        {
            Vertexes vtxs = new Vertexes();
            gPoints gps = new gPoints();
            points.ForEach(pt => gps.Add(new gPoint(pt.X, pt.Y, pt.Z)));
            gps.RemoveEqualPoints(0.01);

            vtxs.AddRange(gps);
            return vtxs;
        }
Exemplo n.º 2
0
 public CRevit2vdl(string strFile, ProgressBar pgressBar)
 {
     progressBar1 = pgressBar;
     vec.EnsureDocument();
     vec.ActiveDocument.EnsureDefaults();
     doc           = vec.ActiveDocument;
     vec.Progress += vec_Progress;
     doc.Open(strFile);
     foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
     {
         if (vdf is vdPolyface)
         {
             vdPolyface vdp = vdf as vdPolyface;
             gPoints    gps = vdp.VertexList.Clone() as gPoints;
             gps.RemoveEqualPoints();
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// /处理polyface
        /// </summary>
        //bool <param name="vdp"></param>
        bool GetVDPBorderLine(vdPolyface vdp, vdFigure vdPf)
        {
            vdPolyface vdpOut             = new vdPolyface();
            Dictionary <string, bool> kvs = new Dictionary <string, bool>();
            Int32Array iii32 = vdp.FaceList;

            for (int i = 0; i < iii32.Count; i++)
            {
                if (vdp.FaceList[i] < 0)
                {
                    if (i % 5 != 4)
                    {
                        vdp.FaceList[i] = -vdp.FaceList[i];
                    }
                }
            }
            iii32 = vdp.FaceList;
            for (int i = 0; i < iii32.Count; i = i + 5)
            {
                AddSide(kvs, iii32[i], iii32[i + 1]);
                AddSide(kvs, iii32[i + 1], iii32[i + 2]);
                AddSide(kvs, iii32[i + 2], iii32[i]);
            }
            //找到外边界
            Int32Array i32 = ParaseSide2List(kvs, vdp.VertexList.Count + 1);

            if (i32.Count < 5)
            {
                return(false);
            }

            //找到向量
            ///int iii = 1;
            gPoints Points = vdp.VertexList;

            Points.makeClosed();
            gPoints gps = new gPoints();// Points.Clone() as gPoints;

            foreach (int ii in i32)
            {
                gps.Add(Points[ii - 1]);
            }
            gps.RemoveEqualPoints(Globals.VD_ZERO5);

            //gps.RemoveInLinePoints();

            Int32Array ii32 = new Int32Array();
            gPoints    gpss = new gPoints();


            #region  延长线段到最长

            gpss.Add(gps[0]);


            for (int i = 0; i < gps.Count - 1; i++)
            {
                //if (i == 5)
                //{
                //    int j = 0;
                //}

                if (i != gps.Count - 2)
                {
                    double dd = Globals.distPointFromLine(gps[i + 2], gps[i], gps[i + 1]);
                    if (Globals.distPointFromLine(gps[i + 2], gps[i], gps[i + 1]) < 0.2)
                    {
                        continue;
                    }
                    else
                    {
                        gpss.Add(gps[i + 1]);
                    }
                }

                if (i == gps.Count - 2)
                {
                    if (Globals.distPointFromLine(gps[1], gps[i], gps[i + 1]) < 0.2)
                    {
                        gpss.RemoveAt(0);
                    }
                    else
                    {
                        gpss.Add(gps[i + 1]);
                    }
                }
            }

            #endregion
            gpss.makeClosed();
            gpss.RemoveLast();


            //找到四条边中符合圆柱体标准的。

            if (gpss.Count % 2 != 0 || gpss.Count < 10)
            {
                return(false);
            }

            int half = gpss.Count / 2;

            gPoints gEndSide1  = new gPoints();
            gPoints gEndSide2  = new gPoints();
            gPoints gParaSide1 = new gPoints();
            gPoints gParaSide2 = new gPoints();



            for (int i = 0; i < gpss.Count / 2; i++)
            {
                Vector v1 = new Vector(gpss[i], gpss[i + 1]);
                Vector v2 = new Vector(gpss[i + half], gpss[(half + i + 1) % gpss.Count]);
                v1.Cross(v2);
                if (v1.Length < Globals.VD_ZERO6)  //说明平行
                {
                    gEndSide1.RemoveAll();
                    gEndSide2.RemoveAll();
                    gParaSide1.RemoveAll();
                    gParaSide2.RemoveAll();

                    gParaSide1.Add(gpss[i]);
                    gParaSide1.Add(gpss[i + 1]);

                    gParaSide2.Add(gpss[i + half]);
                    gParaSide2.Add(gpss[(half + i + 1) % gpss.Count]);



                    for (int j = i + 1; j < i + half; j++)
                    {
                        gEndSide1.Add(gpss[j]);
                    }

                    for (int j = i + half + 1; j < i + 2 * half; j++)
                    {
                        gEndSide2.Add(gpss[j % gpss.Count]);
                    }

                    gPoint sp1    = new gPoint();
                    gPoint sp2    = new gPoint();
                    double radius = 0.0;

                    //判断是个边是否符合圆柱体标准
                    if (!IS4SideCyln(gEndSide1, gEndSide2, gParaSide1, gParaSide2, ref sp1, ref sp2, out radius))  //不符合圆柱体标准 ,直接返回错误
                    {
                        continue;
                    }
                    gpss.RemoveAll();


                    //这里可以进行圆柱简化



                    gpss.AddRange(gEndSide1);
                    gpss.AddRange(gParaSide2);
                    gpss.AddRange(gEndSide2);
                    gpss.AddRange(gParaSide1);


                    //是否齐头圆柱,即没有切过的圆柱,如果齐圆柱头,特殊处理,此处暂时不变,



                    //

                    half = gpss.Count / 2;

                    vdpOut.VertexList = gpss;
                    vdpOut.FaceList   = new Int32Array();

                    for (int ii = 1; ii < half; ii++)
                    {
                        vdpOut.FaceList.Add(ii);
                        vdpOut.FaceList.Add(ii + 1);
                        vdpOut.FaceList.Add(gpss.Count - (ii + 1) + 1);
                        vdpOut.FaceList.Add(gpss.Count - ii + 1);
                        vdpOut.FaceList.Add(-1);
                    }


                    vdp.FaceList   = vdpOut.FaceList;
                    vdp.VertexList = vdpOut.VertexList;
                    //vdp.Invalidate();
                    //vdp.Update();

                    break;
                }
            }


            //找到两个顶边,如果多个就扔掉了。

            //GetNonParaSide(vdp.VertexList, i32, orign, vector);
            return(true);
            //Int32Array side1=
        }