Beispiel #1
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            int      w = this.ClientSize.Width;
            int      h = this.ClientSize.Height;

            g.TranslateTransform(80, 140);
            //g.Transform = transform;
            //g.ScaleTransform(zoom, zoom);
            g.ScaleTransform(2, 2);
            g.RotateTransform(rotateAngle);
            g.RotateTransform(rotateAngleLeft);
            foreach (ThreeDPoint item in points)
            {
                g.DrawEllipse(Pens.Red, item.To2D(TheCube.GetCenter()).X - 1, item.To2D(TheCube.GetCenter()).Y - 1, 2F, 2F);
            }
            foreach (KeyValuePair <string, string> item in pointmember)
            {
                ThreeDPoint p1 = getXYZ(item.Key);
                ThreeDPoint p2 = getXYZ(item.Value);
                g.DrawLine(Pens.Black, p1.To2D(TheCube.GetCenter()), p2.To2D(TheCube.GetCenter()));
            }

            TheCubeOriginal = (ThreeDObject)((ICloneable)TheCube).Clone();
        }
Beispiel #2
0
 public void RotateAtXNegative(ThreeDPoint p, float angle)
 {
     for (int i = 0; i < Polygons.Count; i++)
     {
         ((ThreeDPolygon)Polygons[i]).RotateAtXNegative(p, angle);
     }
 }
Beispiel #3
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                string  no   = dataGridView1.Rows[e.RowIndex].Cells["NodeNo"].Value.ToString();
                string  temp = dataGridView1.Columns[e.ColumnIndex].Name.ToString();
                Default obj  = (Default)Application.OpenForms["Default"];
                if (obj != null)
                {
                    ThreeDPoint p1 = obj.getXYZ(no);
                    if (temp == "Xcor")
                    {
                        p1.X = (float)Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells["Xcor"].Value);
                    }
                    if (temp == "Ycor")
                    {
                        p1.X = (float)Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells["Ycor"].Value);
                    }
                    if (temp == "Zcor")
                    {
                        p1.X = (float)Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells["Zcor"].Value);
                    }

                    obj.pictureBox1.Invalidate();
                }
            }
        }
Beispiel #4
0
 public void RotateAtZNegative(ThreeDPoint origin, float angle)
 {
     for (int i = 0; i < Vertices.Count; i++)
     {
         ((ThreeDPoint)Vertices[i]).RotateAtZNegative(origin, angle);
     }
 }
Beispiel #5
0
        ThreeDPoint GetLeftmostPoint()
        {
            string nodemin = null;
            float  xmin    = 1000;
            float  ymin    = 1000;
            float  zmin    = 1000;

            for (int i = 0; i < Vertices.Count; i++)
            {
                ThreeDPoint nextPoint = (ThreeDPoint)Vertices[i];
                if (nextPoint.X < xmin)
                {
                    xmin = nextPoint.X;
                }
                if (nextPoint.Y < ymin)
                {
                    ymin = nextPoint.Y;
                }
                if (nextPoint.Z < zmin)
                {
                    zmin = nextPoint.Z;
                }
            }

            ThreeDPoint origin = new ThreeDPoint(xmin, ymin, zmin, nodemin);

            return(origin);
        }
Beispiel #6
0
 public void RotateAtZNegative(ThreeDPoint origin, float angle)
 {
     RotationMatrix.SetToNegativeZAxisRotation(angle);
     float[] result = RotationMatrix.VectorMultiply(new float[] { X - origin.X, Y - origin.Y, Z - origin.Z, 1 });
     X = result[0] + origin.X;
     Y = result[1] + origin.Y;
     Z = result[2] + origin.Z;
 }
Beispiel #7
0
        public ThreeDPoint GetCenter()
        {
            ThreeDPoint p = new ThreeDPoint(0, 0, 0, "0");

            for (int i = 0; i < Polygons.Count; i++)
            {
                p = p + ((ThreeDPolygon)Polygons[i]).GetCenter();
            }

            p.DivideThePoint(Polygons.Count);

            return(p);
        }
Beispiel #8
0
        public ThreeDPoint GetCenter()
        {
            ThreeDPoint p = new ThreeDPoint(0, 0, 0, null);

            for (int i = 0; i < Vertices.Count; i++)
            {
                p = p + (ThreeDPoint)Vertices[i];
            }

            p.DivideThePoint(Vertices.Count);

            return(p);
        }
Beispiel #9
0
        public PointF To2D(ThreeDPoint origin)
        {
            float zsmall = Z;

            if (zsmall == 0.0f)
            {
                zsmall = 1.0f;
            }
            //		  PointF aPoint = new PointF(Distance * X/zsmall, Distance * Y/zsmall);
            PointF aPoint = new PointF(X * (1 - (Z / Distance)), Y * (1 - Z / Distance));

            return(aPoint);
        }
Beispiel #10
0
        public ThreeDPoint getXYZ(string n)
        {
            ThreeDPoint p = new ThreeDPoint(0, 0, 0, null);

            foreach (ThreeDPoint item in points)
            {
                if (item.nodeno.Equals(n))
                {
                    return(item);
                }
            }
            return(p);
        }
Beispiel #11
0
        public void AddPoint(float x, float y, float z, string nodeno)
        {
            ThreeDPoint aPoint = new ThreeDPoint(x, y, z, nodeno);

            Vertices.Add(aPoint);
        }
Beispiel #12
0
        object ICloneable.Clone()
        {
            ThreeDPoint copyObject = new ThreeDPoint(X, Y, Z, nodeno);

            return(copyObject);
        }
Beispiel #13
0
        public void openFile() // to open a staad file
        {
            OpenFileDialog filedlg = new OpenFileDialog();

            filedlg.CheckFileExists = true;
            filedlg.CheckPathExists = true;
            filedlg.DefaultExt      = ".std";
            filedlg.Filter          = "STAAD files (*.std)|*.std";
            filedlg.Multiselect     = false;
            filedlg.Title           = "Import";
            DialogResult dr = filedlg.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string       fileName = filedlg.FileName;
                StreamReader sr       = new StreamReader(fileName);
                while (!sr.EndOfStream)
                {
                    string str = sr.ReadLine();
                    if (str == "JOINT COORDINATES") // To print joint coordinates
                    {
                        str = sr.ReadLine();
                        do
                        {
                            string[] rowData = str.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string item in rowData)
                            {
                                string[] rowData1 = item.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                st.dataGridView1.Rows.Add(rowData1);
                                string node = null;
                                double x    = 0;
                                double y    = 0;
                                double z    = 0;
                                node = rowData1[0].ToString();
                                double.TryParse(rowData1[1].ToString(), out x);
                                double.TryParse(rowData1[2].ToString(), out y);
                                double.TryParse(rowData1[3].ToString(), out z);
                                ThreeDPoint point = new ThreeDPoint((float)x, (float)y * -1, (float)z, node);
                                point.Scale(15);
                                point.Translate(new float[] { 150, 150, 0 });
                                def.points.Add(point);
                                def.pointsor = new List <ThreeDPoint>(def.points);
                            }
                            str = sr.ReadLine();
                        } while (str != "MEMBER INCIDENCES");

                        if (str == "MEMBER INCIDENCES") // to print member indences
                        {
                            str = sr.ReadLine();
                            do
                            {
                                string[] rowData = str.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                                foreach (string item in rowData)
                                {
                                    string[] rowData2 = item.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    st1.dataGridView2.Rows.Add(rowData2);
                                    string x = null;
                                    string y = null;
                                    x = rowData2[1].ToString();
                                    y = rowData2[2].ToString();
                                    def.pointmember.Add(new KeyValuePair <string, string>(x, y));
                                    def.pointsmemberOr = new List <KeyValuePair <string, string> >(def.pointmember);
                                }
                                str = sr.ReadLine();
                            } while (str != "MEMBER PROPERTY INDIAN");
                        }
                    }
                }
            }
        }