Ejemplo n.º 1
0
        public Mesh GetMesh()
        {
            Mesh m = new Mesh();

            int[] map = new int[Vertices.Count];
            for (int i = 0; i < Vertices.Count; i++)
            {
                map[i] = -1;
            }
            for (int i = 0; i < Vertices.Count; i++)
            {
                ECVertex v = Vertices[i];
                if (v.IsValid())
                {
                    map[i] = m.AddVertex(new Point3d(v.X, v.Y, v.Z));
                }
            }
            for (int i = 0; i < Faces.Count; i++)
            {
                ECFace f = Faces[i];
                if (f.IsValid())
                {
                    Triangle t = new Triangle(map[f.GetVertex(0).UId], map[f.GetVertex(1).UId], map[f.GetVertex(2).UId]);
                    m.AddFace(t);
                }
            }

            return(m);
        }
Ejemplo n.º 2
0
        public void MayFixFace(ECFace face)
        {
            ECVertex v0 = face.GetVertex(0);
            ECVertex v1 = face.GetVertex(1);
            ECVertex v2 = face.GetVertex(2);
            ECEdge   e0 = face.GetEdge(0);
            ECEdge   e1 = face.GetEdge(1);
            ECEdge   e2 = face.GetEdge(2);
            bool     a  = (v0 == v1);
            bool     b  = (v0 == v2);
            bool     c  = (v1 == v2);

            if (a && c)
            {
                KillEdge(e0);
                KillEdge(e1);
                KillEdge(e2);
                KillFace(face);
            }
            else if (a)
            {
                KillEdge(e0);
                e1.ReplaceBy(e2.Twin());
                KillFace(face);
            }
            else if (b)
            {
                KillEdge(e2);
                e0.ReplaceBy(e1.Twin());
                KillFace(face);
            }
            else if (c)
            {
                KillEdge(e1);
                e0.ReplaceBy(e2.Twin());
                KillFace(face);
            }
        }