Ejemplo n.º 1
0
        void ReadNodeFile()
        {
            string[] all = File.ReadAllLines(nodeFile);
            int[] arr = ReadIntLine(GetFirstLine(all));

            foreach (var line in GetRemainingLine(all))
            {
                double[] dArr = ReadDoubleLine(line);
                TetVertex v = new TetVertex();
                v.Index = mesh.Vertices.Count;
                v.Pos = new Vector3D(dArr, 1);
                mesh.Vertices.Add(v);
            }
        }
Ejemplo n.º 2
0
        void ReadNodeFile()
        {
            string[] all = File.ReadAllLines(nodeFile);
            int[]    arr = ReadIntLine(GetFirstLine(all));

            foreach (var line in GetRemainingLine(all))
            {
                double[]  dArr = ReadDoubleLine(line);
                TetVertex v    = new TetVertex();
                v.Index = mesh.Vertices.Count;
                v.Pos   = new Vector3D(dArr, 1);
                mesh.Vertices.Add(v);
            }
        }
Ejemplo n.º 3
0
        public static Vector3D ComputeNormal(TetFace face)
        {
            if (face.OnBoundary)
            {
                return(TetMeshUtil.ComputeNormal(face));
            }
            Tetrahedron selected = CheckBoundary(face);

            if (selected == null)
            {
                return(Vector3D.Zero);
            }

            Vector3D[] v = new Vector3D[3];
            for (int i = 0; i < 3; i++)
            {
                v[i] = face.Vertices[i].Pos;
            }
            Vector3D n = (v[1] - v[0]).Cross(v[0] - v[2]).Normalize();

            foreach (var vt in selected.Vertices)
            {
                bool top = true;
                foreach (var vf in face.Vertices)
                {
                    if (vt == vf)
                    {
                        top = false;
                        break;
                    }
                }
                if (top && n.Dot(vt.Pos - v[0]) > 0)
                {
                    n = -n;
                    TetVertex temp = face.Vertices[0];
                    face.Vertices[0] = face.Vertices[2];
                    face.Vertices[2] = temp;
                    break;
                }
            }

            return(n);
        }
Ejemplo n.º 4
0
        void RefreshVertex()
        {
            TetMesh mesh = GlobalData.Instance.TetMesh;

            this.onLoad = true;
            this.vertexView.Rows.Clear();
            this.vertexView.Rows.Add(mesh.Vertices.Count);
            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                TetVertex       v   = mesh.Vertices[i];
                DataGridViewRow row = this.vertexView.Rows[i];
                row.Cells["VIndex"].Value    = v.Index;
                row.Cells["VFlag"].Value     = v.Flag;
                row.Cells["VBoundary"].Value = v.OnBoundary;

                row.Cells["VX"].Value = v.Pos.x;
                row.Cells["VY"].Value = v.Pos.y;
                row.Cells["VZ"].Value = v.Pos.z;
            }
            this.onLoad = false;
        }
Ejemplo n.º 5
0
        public static Vector3D ComputeNormal(TetFace face)
        {
            if (face.Tetras.Count != 1)
            {
                return(Vector3D.Zero);
            }
            Vector3D[] v = new Vector3D[3];
            for (int i = 0; i < 3; i++)
            {
                v[i] = face.Vertices[i].Pos;
            }
            Vector3D n = (v[1] - v[0]).Cross(v[2] - v[0]).Normalize();

            foreach (var vt in face.Tetras[0].Vertices)
            {
                bool top = true;
                foreach (var vf in face.Vertices)
                {
                    if (vt == vf)
                    {
                        top = false;
                        break;
                    }
                }
                if (top && n.Dot(vt.Pos - v[0]) > 0)
                {
                    n = -n;
                    TetVertex temp = face.Vertices[0];
                    face.Vertices[0] = face.Vertices[2];
                    face.Vertices[2] = temp;
                    break;
                }
            }

            return(n);
        }
Ejemplo n.º 6
0
 public static PlaneIntersectionType Intersect(Plane plane, TetVertex v)
 {
     return(Collision.PlaneIntersectsPoint(ref plane, ref v.Pos));
 }
Ejemplo n.º 7
0
 public static PlaneIntersectionType Intersect(Plane plane, TetVertex v)
 {
     return Collision.PlaneIntersectsPoint(ref plane, ref v.Pos);
 }