예제 #1
0
        public static DisNetPipe Parse(string str)
        {
            DisNetPipe dnPipe = new DisNetPipe();

            str = str.Replace(",", " ");
            while (str.IndexOf("  ") != -1)
            {
                str = str.Replace("  ", " ");
            }
            string[] values = str.Split(new char[] { ' ' });

            //if (values.Length == 9)
            //{
            int i = 0;

            dnPipe.No           = int.Parse(values[i]); i++;
            dnPipe.StartPoint.x = double.Parse(values[i]); i++;
            dnPipe.StartPoint.y = double.Parse(values[i]); i++;
            dnPipe.StartPoint.z = double.Parse(values[i]); i++;
            dnPipe.EndPoint.x   = double.Parse(values[i]); i++;
            dnPipe.EndPoint.y   = double.Parse(values[i]); i++;
            dnPipe.EndPoint.z   = double.Parse(values[i]); i++;
            dnPipe.Length       = double.Parse(values[i]); i++;
            dnPipe.Diameter     = double.Parse(values[i]); i++;
            //}
            return(dnPipe);
        }
예제 #2
0
 public static void ReadPipes(string fileName)
 {
     //System.IO.StreamReader sr = new System.IO.StreamReader("C:\\HareKrishna.txt");
     System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
     lstPipe.Clear();
     while (sr.EndOfStream == false)
     {
         try
         {
             //pts.Add(GetPoint(sr.ReadLine()));
             lstPipe.Add(DisNetPipe.Parse(sr.ReadLine()));
         }
         catch (Exception exx)
         {
         }
     }
 }
예제 #3
0
        public static void CmdPipe3DFromText(vdDocument doc, string txtFileName)
        {
            Color  pipeColor = Color.Green;
            double pipeSize  = 100.0d;

            vdLayer pipeLay = new vdLayer();

            pipeLay.Name = "Pipes";
            pipeLay.SetUnRegisterDocument(doc);
            pipeLay.setDocumentDefaults();
            doc.Layers.AddItem(pipeLay);
            doc.ActiveLayer = pipeLay;


            vdLayer nodeBallLay = new vdLayer();

            nodeBallLay.Name = "NodalData";
            nodeBallLay.SetUnRegisterDocument(doc);
            nodeBallLay.setDocumentDefaults();
            doc.Layers.AddItem(nodeBallLay);
            nodeBallLay.PenColor = new vdColor(Color.Red);



            string fName = txtFileName;

            ReadPipes(fName);
            HEADSNeed.DisNet.frmDrawPipe fdp = new HEADSNeed.DisNet.frmDrawPipe();
            if (fdp.ShowDialog() == DialogResult.OK)
            {
                pipeColor = fdp.PipeColor;
                pipeSize  = fdp.PipeSize;
                //doc.ActiveLayer.PenColor = new vdColor(pipeColor);
                pipeLay.PenColor = new vdColor(pipeColor);
            }
            else
            {
                return;
            }
            for (int i = 0; i < lstPipe.Count; i++)
            {
                try
                {
                    DisNetPipe dnPipe = lstPipe[i];
                    vdCircle   cir    = new vdCircle();
                    cir.Center = dnPipe.StartPoint;
                    cir.Radius = dnPipe.Diameter * pipeSize;
                    //cir.Radius = dnPipe.Diameter;
                    cir.ExtrusionVector = Vector.CreateExtrusion(dnPipe.StartPoint, dnPipe.EndPoint);
                    cir.SetUnRegisterDocument(doc);
                    cir.setDocumentDefaults();
                    cir.Layer = pipeLay;

                    doc.ActionLayout.Entities.AddItem(cir);
                    cir.Thickness = dnPipe.Length;
                    //cir.PenColor = new vdColor(cl);
                    doc.CommandAction.CmdSphere(dnPipe.EndPoint, cir.Radius, 10, 10);
                    doc.ActiveLayer = nodeBallLay;
                    doc.CommandAction.CmdSphere(dnPipe.EndPoint, cir.Radius + 5.0d, 15, 10);
                    doc.ActiveLayer = pipeLay;
                    doc.CommandAction.Zoom("E", 100, 100);

                    if (i == 0)
                    {
                        vdPolyline pline = new vdPolyline();
                        pline.VertexList.Add(new gPoint(cir.Center.x - 35.0d, cir.Center.y + 25.0d, cir.Center.z));
                        pline.VertexList.Add(new gPoint(cir.Center.x - 35.0d, cir.Center.y, cir.Center.z));
                        pline.VertexList.Add(new gPoint(cir.Center.x + 35.0d, cir.Center.y, cir.Center.z));
                        pline.VertexList.Add(new gPoint(cir.Center.x + 35.0d, cir.Center.y + 25.0d, cir.Center.z));
                        pline.SetUnRegisterDocument(doc);
                        pline.setDocumentDefaults();

                        pline.PenColor = new vdColor(Color.LightPink);
                        pline.PenWidth = 2.0d;
                        doc.ActionLayout.Entities.AddItem(pline);


                        vdLine ln = new vdLine();
                        ln.SetUnRegisterDocument(doc);
                        ln.setDocumentDefaults();

                        ln.StartPoint = (pline.VertexList[0] + pline.VertexList[1]) / 2;
                        ln.EndPoint   = (pline.VertexList[2] + pline.VertexList[3]) / 2;
                        ln.PenColor   = new vdColor(Color.LightPink);
                        ln.PenWidth   = 2.0d;
                        doc.ActionLayout.Entities.AddItem(ln);

                        vdText tx = new vdText();
                        tx.SetUnRegisterDocument(doc);
                        tx.setDocumentDefaults();
                        tx.InsertionPoint = new gPoint(ln.StartPoint.x + 2.0d, ln.StartPoint.y + 3.0d, ln.StartPoint.z);
                        tx.TextString     = "SOURCE";
                        tx.PenColor       = new vdColor(Color.LightPink);
                        tx.Height         = 10.0d;

                        doc.ActionLayout.Entities.AddItem(tx);
                    }

                    //doc.Redraw(true);
                }
                catch (Exception exx)
                {
                }
            }
            doc.RenderMode = vdRender.Mode.Wire2dGdiPlus;
            doc.CommandAction.RegenAll();
            doc.Redraw(true);
        }
예제 #4
0
        public static void CmdPipe3D(vdDocument doc)
        {
            Color  pipeColor = Color.Green;
            double pipeSize  = 100.0d;

            vdLayer pipeLay = new vdLayer();

            pipeLay.Name = "Pipes";
            pipeLay.SetUnRegisterDocument(doc);
            pipeLay.setDocumentDefaults();
            doc.Layers.AddItem(pipeLay);
            doc.ActiveLayer = pipeLay;


            //OpenFileDialog ofd = new OpenFileDialog();
            //string fName = "";

            //ofd.Title = "SELECT DisNet Pipe Details File";
            //ofd.Filter = "Text File|*.txt";



            //if (ofd.ShowDialog() != DialogResult.Cancel)
            //{
            //    fName = ofd.FileName;
            //    ReadPipes(fName);
            //    HEADSNeed.DisNet.frmDrawPipe fdp = new HEADSNeed.DisNet.frmDrawPipe();
            //    if (fdp.ShowDialog() == DialogResult.OK)
            //    {
            //        pipeColor = fdp.PipeColor;
            //        pipeSize = fdp.PipeSize;
            //        //doc.ActiveLayer.PenColor = new vdColor(pipeColor);
            //        pipeLay.PenColor = new vdColor(pipeColor);
            //    }
            //    else
            //        return;
            //}

            //ReadPipes("C:\\DisNetPoints.txt");

            for (int i = 0; i < lstPipe.Count; i++)
            {
                try
                {
                    DisNetPipe dnPipe = lstPipe[i];
                    vdCircle   cir    = new vdCircle();
                    cir.Center = dnPipe.StartPoint;
                    cir.Radius = dnPipe.Diameter * pipeSize;
                    //cir.Radius = dnPipe.Diameter;
                    cir.ExtrusionVector = Vector.CreateExtrusion(dnPipe.StartPoint, dnPipe.EndPoint);
                    cir.SetUnRegisterDocument(doc);
                    cir.setDocumentDefaults();
                    cir.Layer = pipeLay;

                    doc.ActionLayout.Entities.AddItem(cir);
                    cir.Thickness = dnPipe.Length;
                    //cir.PenColor = new vdColor(cl);
                    doc.CommandAction.CmdSphere(dnPipe.EndPoint, cir.Radius, 10, 10);
                    doc.CommandAction.Zoom("E", 100, 100);



                    //doc.Redraw(true);
                }
                catch (Exception exx)
                {
                }
            }
            doc.RenderMode = vdRender.Mode.Render;
            doc.CommandAction.RegenAll();
            doc.Redraw(true);
        }