Esempio n. 1
0
        /// <summary>
        /// Triangulates a mesh.
        /// </summary>
        /// <returns>A triangulated copy of the mesh.</returns>
        /// <remarks>
        /// Any edge and halfedge traits are not copied to the new mesh. Face traits are copied
        /// to all faces triangulated from a face.
        /// </remarks>
        public DXMesh <TEdgeTraits, TFaceTraits, THalfedgeTraits, TVertexTraits> TriangularCopy()
        {
            DXMesh <TEdgeTraits, TFaceTraits, THalfedgeTraits, TVertexTraits> triangulatedMesh = new DXMesh <TEdgeTraits, TFaceTraits, THalfedgeTraits, TVertexTraits>();
            Dictionary <DXVertex, DXVertex> newVertices = new Dictionary <DXVertex, DXVertex>();

            foreach (DXVertex v in Vertices)
            {
                newVertices[v] = triangulatedMesh.Vertices.Add(v.Traits);
            }

            foreach (DXFace f in Faces)
            {
                DXVertex[] vertices = new DXVertex[f.VertexCount];
                int        i        = 0;
                foreach (DXVertex v in f.Vertices)
                {
                    vertices[i] = newVertices[v];
                    ++i;
                }
                triangulatedMesh.Faces.AddTriangles(f.Traits, vertices);
            }

            return(triangulatedMesh);
        }
Esempio n. 2
0
 internal DXFaceCollection(DXMesh <TEdgeTraits, TFaceTraits, THalfedgeTraits, TVertexTraits> m)
 {
     mesh = m;
 }