Exemple #1
0
        /// <summary>
        /// Creates a mesh from the specified file.
        /// </summary>
        /// <param name="fileName">A string that contains the name of the file from which to create the HalfedgeMesh object.</param>
        /// <returns>The mesh object this method creates.</returns>
        public static HalfEdgeMesh  FromFile(string fileName)
        {
            HalfEdgeMesh m = null;

            using (Stream stream = File.OpenRead(fileName))
            {
                m = FromStream(stream);
            }
            return(m);
        }
        protected override void AfterMerge(HalfEdgeMesh.Vertex v)
        {
            foreach (var face in this.removed)
            {
                this.heap.Del(handle[face.Index]);
            }

            this.traits.MergeUpdate(v);
            foreach (var face in v.Faces)
            {
                ErrorPair pair = this.GetErrorPair(face);
                this.faceError[face.Index] = pair;
                this.heap.Update(handle[face.Index], pair.Error);
            }
        }
Exemple #3
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 HalfEdgeMesh  TriangularCopy()
        {
            HalfEdgeMesh triangulatedMesh           = new HalfEdgeMesh();
            Dictionary <Vertex, Vertex> newVertices = new Dictionary <Vertex, Vertex>();

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

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

            return(triangulatedMesh);
        }
 protected override double GetValue(HalfEdgeMesh.Edge target)
 {
     return TriMeshUtil.ComputeEdgeLength(target);
 }
Exemple #5
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 HalfEdgeMesh  TriangularCopy()
        {
            HalfEdgeMesh  triangulatedMesh = new HalfEdgeMesh ();
            Dictionary<Vertex, Vertex> newVertices = new Dictionary<Vertex, Vertex>();

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

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

            return triangulatedMesh;
        }
 protected override double GetValue(HalfEdgeMesh.Face target)
 {
     TriMesh.Vertex min = this.GetMinCvtVertex(target);
     return Math.Abs(this.traits.VertexDiscreteCurvature[min.Index]);
 }
 protected override double GetValue(HalfEdgeMesh.Face target)
 {
     return TriMeshUtil.ComputeAreaFace(target);
 }
Exemple #8
0
 protected override double GetValue(HalfEdgeMesh.Edge target)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 internal VertexCollection(HalfEdgeMesh m)
 {
     mesh = m;
 }
Exemple #10
0
 protected override Vector3D GetPos(HalfEdgeMesh.Edge target)
 {
     return this.edgeError[target.Index].Pos;
 }
Exemple #11
0
 /// <summary>
 /// Creates a new vertex dynamic trait on the specified mesh.
 /// </summary>
 /// <param name="mesh">The mesh to create the dynamic trait on.</param>
 public VertexDynamicTrait(HalfEdgeMesh mesh)
 {
     this.mesh = mesh;
     trait     = new TraitType[mesh.Vertices.Count];
 }
Exemple #12
0
 /// <summary>
 /// Creates a new edge dynamic trait on the specified mesh.
 /// </summary>
 /// <param name="mesh">The mesh to create the dynamic trait on.</param>
 public EdgeDynamicTrait(HalfEdgeMesh mesh)
 {
     this.mesh = mesh;
     trait     = new TraitType[mesh.Edges.Count];
 }
Exemple #13
0
 internal FaceCollection(HalfEdgeMesh m)
 {
     mesh = m;
 }
Exemple #14
0
 internal HalfedgeCollection(HalfEdgeMesh m)
 {
     mesh = m;
 }