示例#1
0
        private void AddLevelData()
        {
            if (Levels == null)
            {
                return;
            }

            vdLayer layer = vDraw.ActiveDocument.Layers.FindName(_gGridLayerName);

            if (layer == null)
            {
                layer = new vdLayer(vDraw.ActiveDocument, _gGridLayerName);
                vDraw.ActiveDocument.Layers.Add(layer);
            }

            foreach (var lv in Levels)
            {
                vdXProperty vdx1 = new vdXProperty
                {
                    Name      = lv.Name,
                    PropValue = (Tools.Ft2MmScale * lv.Height).ToString()
                };
                layer.XProperties.AddItem(vdx1);
            }
        }
示例#2
0
        public static ulong AddRectImageHatch(LJJSPoint leftBottomInsertPt, double rectHeigh, double rectWidth, string imagePath, double hatchScale, List <StrValueProperty> additionImageLst)
        {
            vdXProperties tmppro        = new vdXProperties();
            gPoint        leftBottomPt  = new gPoint(leftBottomInsertPt.XValue, leftBottomInsertPt.YValue);
            gPoint        leftTopPt     = new gPoint(leftBottomInsertPt.XValue, leftBottomInsertPt.YValue + DrawCommonData.DirectionUp * rectHeigh);
            gPoint        rightBottomPt = new gPoint(leftBottomInsertPt.XValue + rectWidth * DrawCommonData.DirectionRight, leftBottomInsertPt.YValue);
            gPoint        rightTopPt    = new gPoint(leftBottomInsertPt.XValue + rectWidth * DrawCommonData.DirectionRight, leftBottomInsertPt.YValue + DrawCommonData.DirectionUp * rectHeigh);

            Vertexes hatchRect = new Vertexes();

            hatchRect.Add(leftBottomPt);
            hatchRect.Add(leftTopPt);
            hatchRect.Add(rightTopPt);
            hatchRect.Add(rightBottomPt);
            if (null != additionImageLst && additionImageLst.Count > 0)
            {
                for (int i = 0; i < additionImageLst.Count; i++)
                {
                    StrValueProperty tmp = additionImageLst[i];
                    if (!string.IsNullOrEmpty(tmp.PropertyName) && !string.IsNullOrEmpty(tmp.PropertyValue))
                    {
                        vdXProperty tmpproperty = new vdXProperty();
                        tmpproperty.Name      = tmp.PropertyName;
                        tmpproperty.PropValue = tmp.PropertyValue;
                        tmppro.AddItem(tmpproperty);
                    }
                }
            }
            return(VectorDrawHelper.AddHatchImageToFigure(DrawCommonData.activeDocument, hatchRect, "", imagePath, hatchScale, tmppro));
        }
示例#3
0
        /// <summary>
        /// 找到对应的点和向量
        /// </summary>
        /// <param name="i32">定点数组</param>
        /// <param name="points">坐标数组</param>
        /// <param name="vdPf">父图形,里面存点和向量</param>
        /// <param name="orgin">输出找到的点</param>
        /// <param name="vector">输出找到的向量</param>
        /// <returns>是否找到</returns>
        ///
        bool FindPointVector(gPoints Points, vdPolyface vdp, vdFigure vdPf, ref gPoint orign, ref Vector vector)
        {
            int iii = 1;

            while (true)
            {
                string strName = "POINTVECTOR" + iii.ToString();
                iii++;
                vdXProperty vdx = vdPf.XProperties.FindName(strName);
                if (vdx != null)
                {
                    string   strValue = (string)vdx.PropValue;
                    string[] strs     = strValue.Split(new char[] { ',' });
                    orign  = new gPoint(double.Parse(strs[0]), double.Parse(strs[1]), double.Parse(strs[2]));
                    vector = new Vector(double.Parse(strs[3]), double.Parse(strs[4]), double.Parse(strs[5]));



                    double d    = -1.0;
                    gPoint gEnd = orign + vector;


                    int currenti = 0;
                    for (int i = 0; i < Points.Count; i++)
                    {
                        currenti = i;
                        gPoint gp = Points[i];
                        double dd = gp.DistanceFromLine(orign, gEnd);
                        if (d < 0)
                        {
                            d = dd;
                        }
                        else
                        {
                            if (Math.Abs(dd - d) > Globals.VD_ZERO5)
                            {
                                //MessageBox.Show("Error!");
                                break;
                            }
                        }
                    }
                    if (currenti == Points.Count - 1)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
示例#4
0
        private void CreatePoint(ModelPoint pt, double radius)
        {
            vdInsert vdi = new vdInsert(vDraw.ActiveDocument, GetSphereBlk(), new gPoint(pt.x, pt.y, pt.z), 0, radius, radius, radius);

            vDraw.ActiveDocument.ActiveLayOut.Entities.Add(vdi);

            vdXProperty vdx = new vdXProperty();

            vdx.Name      = "#PointName";
            vdx.PropValue = pt.Name;
            vdi.XProperties.Add(vdx);

            vDraw.ActiveDocument.Redraw(false);
        }
示例#5
0
        bool FindPointVector(Int32Array i32, gPoints Points, vdFigure vdPf, ref gPoint orign, ref Vector vector)
        {
            int iii = 1;

            while (true)
            {
                string strName = "POINTVECTOR" + iii.ToString();
                iii++;
                vdXProperty vdx = vdPf.XProperties.FindName(strName);
                if (vdx != null)
                {
                    string   strValue = (string)vdx.PropValue;
                    string[] strs     = strValue.Split(new char[] { ',' });
                    orign  = new gPoint(double.Parse(strs[0]), double.Parse(strs[1]), double.Parse(strs[2]));
                    vector = new Vector(double.Parse(strs[3]), double.Parse(strs[4]), double.Parse(strs[5]));
                    double d = -1.0;

                    for (int i = 0; i < i32.Count; i++)
                    {
                        gPoint gEnd = orign + vector;
                        gPoint gp   = Points[i32[i]];
                        double dd   = gp.DistanceFromLine(orign, gEnd);
                        if (d < 0)
                        {
                            d = dd;
                        }
                        else
                        {
                            if (Math.Abs(dd - d) > Globals.VD_ZERO5)
                            {
                                break;
                            }
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
示例#6
0
        /// <summary>
        /// 处理车位编号
        /// </summary>
        /// <returns></returns>
        void ProCarNum(vdDocument doc, string PropName, double width, double height)
        {
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
            {
                if (vdf is vdInsert)
                {
                    vdInsert vdi = vdf as vdInsert;

                    vdXProperty vdx = vdi.XProperties.FindName(PropName);
                    if (vdx != null)
                    {
                        //删除原来的文字
                        vdBlock vdb = vdi.Block;
                        for (int i = vdb.Entities.Count - 1; i >= 0; i--)
                        {
                            if (vdb.Entities[i] is vdText)
                            {
                                vdb.Entities.RemoveAt(i);
                            }
                        }
                        //文字样式
                        vdTextstyle vdts = doc.TextStyles.FindName("车位编号");
                        if (vdts == null)
                        {
                            vdts        = new vdTextstyle(doc);
                            vdts.Height = height / 5.0;
                        }
                        //字体
                        vdText vdt = new vdText(doc);
                        vdt.Style      = vdts;
                        vdt.TextString = vdx.PropValue.ToString();
                        vdt.HorJustify = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter;
                        vdt.VerJustify = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen;


                        Box bb = vdb.BoundingBox();
                        vdt.InsertionPoint = new gPoint(bb.MidPoint.x, bb.Min.y + height / 2.0, bb.Min.z);
                        vdb.Entities.Add(vdt);
                    }
                }
            }
        }
示例#7
0
        /// <summary>
        /// /处理polyface
        /// </summary>
        //bool <param name="vdp"></param>
        bool GetVDPBorderLine(vdPolyface vdp, vdFigure vdPf)
        {
            Vector vec = vdp.VertexList.GetNormal();

            if (vdp.VertexList.Is2D(0.0001, vec))
            {
                return(false);
            }

            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;

            //if (i32.Count < 10) return false;
            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();
            //vdPolyline vdp11 = new vdPolyline(doc,new Vertexes(gpss));
            //doc.ActiveLayOut.Entities.Add(vdp11);

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

            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_ZERO7)  //说明平行
                {
                    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);


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

                    //

                    //


                    gpss.RemoveEqualPoints();
                    gpss.makeClosed();
                    gpss.RemoveLast();

                    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;

                    ////加一个标记,以后好合并
                    vdXProperty vdx = vdp.XProperties.Add("IsPart");
                    vdx.PropValue = true;

                    break;
                }
            }


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

            //GetNonParaSide(vdp.VertexList, i32, orign, vector);
            return(true);
            //Int32Array side1=
        }
示例#8
0
        public void Convert(string outFileName)
        {
            SetProgress(5);
            Dictionary <string, bool> kvs = new Dictionary <string, bool>();

            int ipr   = 0;
            int count = doc.Blocks.Count;

            foreach (vdBlock vdb in doc.Blocks)   //处理块中的面片
            {
                ipr++;

                foreach (vdFigure vdf1 in vdb.Entities)
                {
                    if (vdf1 is vdPolyface)
                    {
                        vdPolyface vdff = vdf1 as vdPolyface;
                        bool       ret  = GetVDPBorderLine(vdff, null); //处理圆柱
                        if (!ret)
                        {
                            Merge3DFace(vdff);    //合并面片到四边形
                        }
                    }
                }


                //while (true)   //合并圆柱体
                //{
                //    vdArray< vdFigure> tmps=new vdArray<vdFigure>();
                //    for (int i = 0; i < vdb.Entities.Count; i++)
                //    {
                //        vdFigure vdf = vdb.Entities[i];
                //        if (vdf is vdPolyface)
                //        {
                //            vdPolyface vdff1 = vdf as vdPolyface;
                //            for (int j = 0; j < vdb.Entities.Count; j++)
                //            {
                //                if (vdb.Entities[j] is vdPolyface)
                //                {
                //                    vdPolyface vdff2 = vdb.Entities[j] as vdPolyface;

                //                    vdff1.MergePolyface(vdff2);
                //                }

                //            }
                //        }
                //    }
                //}


                SetProgress(5 + (ipr * 65) / count);
            }


            ipr = 0;
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)  //合并处理处理当前的面片
            {
                ipr++;

                for (int i = vdf.XProperties.Count - 1; i >= 0; i--)
                {
                    vdXProperty vdx = vdf.XProperties[i];
                    if (vdx.Name.StartsWith("CylinderFaceData") || vdx.Name.StartsWith("POINTVECTOR"))
                    {
                        vdf.XProperties.RemoveItem(vdx);
                    }
                }

                if (vdf is vdPolyface)
                {
                    kvs.Clear();
                    vdPolyface vdp = vdf as vdPolyface;


                    bool ret = GetVDPBorderLine(vdp, vdp);   //处理圆柱体

                    if (!ret)
                    {
                        Merge3DFace(vdp);   //合并到四边形
                    }
                }

                SetProgress(70 + (ipr * 30) / doc.ActiveLayOut.Entities.Count);
            }

            //圆柱片试图合并成圆柱

            doc.Purge();
            SaveAs(outFileName);

            MessageBox.Show("转化已完成!");
        }
示例#9
0
        /// <summary>
        /// 替换字体
        /// </summary>
        /// <param name="vdbs"></param>
        private void ReplaceText(vdBlocks vdbs, vdDocument doc, double width, double height, string PropName)
        {
            //doc.Purge();
            Dictionary <string, string> BlksMap    = new Dictionary <string, string>();
            Dictionary <string, string> BlksMapTmp = new Dictionary <string, string>();

            //删除车位编号
            foreach (vdFigure vdf in doc.ActiveLayOut.Entities)
            {
                if (vdf is vdInsert)
                {
                    vdInsert    vdi = vdf as vdInsert;
                    vdXProperty vdx = vdi.XProperties.FindName(PropName);
                    if (vdx != null)
                    {
                        string  strName = vdx.PropValue.ToString();
                        vdBlock vdb     = vdi.Block;
                        Box     box     = vdb.BoundingBox();

                        Box textbox            = new Box(new gPoint(box.MidPoint.x - width / 2.0, box.Min.y), new gPoint(box.MidPoint.x + width / 2.0, box.Min.y + height));
                        vdArray <vdFigure> vda = new vdArray <vdFigure>();
                        foreach (vdFigure vdff in vdb.Entities)
                        {
                            if (vdff is vdPolyface)
                            {
                                if (vdff.BoundingBox.BoxInBox(textbox))
                                {
                                    vda.AddItem(vdff);
                                }
                            }
                        }

                        Box b = new Box();
                        foreach (vdFigure vdf1 in vda)
                        {
                            b.AddBox(vdf1.BoundingBox);
                            vdb.Entities.RemoveItem(vdf1);
                        }

                        //文字样式
                        vdTextstyle vdts = doc.TextStyles.FindName("车位编号");
                        if (vdts == null)
                        {
                            vdts        = new vdTextstyle(doc);
                            vdts.Name   = "车位编号";
                            vdts.Height = b.Height;
                            //MessageBox.Show(b.Height.ToString());
                            doc.TextStyles.Add(vdts);
                        }

                        //文字
                        vdText vdt = new vdText(doc);
                        vdt.Style          = vdts;
                        vdt.TextString     = vdx.PropValue.ToString();
                        vdt.HorJustify     = VectorDraw.Professional.Constants.VdConstHorJust.VdTextHorCenter;
                        vdt.VerJustify     = VectorDraw.Professional.Constants.VdConstVerJust.VdTextVerCen;
                        vdt.InsertionPoint = b.MidPoint;
                        vdb.Entities.AddItem(vdt);

                        vdf.Invalidate();
                        vdf.Update();
                        string ssss = GetBlkMd5(vdi.Block);

                        if (!BlksMap.ContainsKey(vdi.Block.Name))
                        {
                            BlksMap.Add(vdi.Block.Name, ssss);
                        }
                        else
                        {
                            MessageBox.Show("可能存在重复编号的车位,请仔细查看!");
                        }
                    }
                }
            }

            //查找md5的计数

            Dictionary <string, int> md5count = new Dictionary <string, int>();

            foreach (KeyValuePair <string, string> kv in BlksMap)
            {
                if (!md5count.ContainsKey(kv.Value))
                {
                    md5count.Add(kv.Value, 1);
                }
                else
                {
                    md5count[kv.Value]++;
                }
            }

            foreach (KeyValuePair <string, string> kv in BlksMap)
            {
                if (md5count[kv.Value] > 1)
                {
                    vdBlock vdb2 = doc.Blocks.FindName(kv.Value);
                    vdBlock vdb  = doc.Blocks.FindName(kv.Key);
                    if (vdb2 == null)  //md5码的块不存在的话
                    {
                        if (vdb != null)
                        {
                            vdBlock vdb1 = vdb.Clone(doc) as vdBlock;
                            for (int i = vdb1.Entities.Count - 1; i >= 0; i--)
                            {
                                if (vdb1.Entities[i] is vdText)
                                {
                                    vdb1.Entities.RemoveItem(vdb1.Entities[i]);
                                }
                            }
                            vdb1.Name = kv.Value;
                            doc.Blocks.Add(vdb1);
                        }
                    }
                    //原来的内容作为一个块,加进去

                    for (int i = vdb.Entities.Count - 1; i >= 0; i--)
                    {
                        if (!(vdb.Entities[i] is vdText))
                        {
                            vdb.Entities.RemoveItem(vdb.Entities[i]);
                        }
                    }

                    //vdb.Entities.RemoveAll();
                    vdInsert vdi = new vdInsert(doc);
                    vdi.Block = doc.Blocks.FindName(kv.Value);  //
                    vdb.Entities.Add(vdi);

                    //将字体加上去

                    vdb.Update();
                }
            }

            //ProCarNum(doc, PropName, width, height);  //处理车位编号
        }