Example #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);
            }
        }
Example #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);
        }
Example #4
0
 protected override double GetValue(HalfEdgeMesh.Edge target)
 {
     return TriMeshUtil.ComputeEdgeLength(target);
 }
Example #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]);
 }
Example #7
0
 protected override double GetValue(HalfEdgeMesh.Face target)
 {
     return TriMeshUtil.ComputeAreaFace(target);
 }
Example #8
0
 protected override double GetValue(HalfEdgeMesh.Edge target)
 {
     throw new NotImplementedException();
 }
Example #9
0
 internal VertexCollection(HalfEdgeMesh m)
 {
     mesh = m;
 }
Example #10
0
 protected override Vector3D GetPos(HalfEdgeMesh.Edge target)
 {
     return this.edgeError[target.Index].Pos;
 }
Example #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];
 }
Example #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];
 }
Example #13
0
 internal FaceCollection(HalfEdgeMesh m)
 {
     mesh = m;
 }
Example #14
0
 internal HalfedgeCollection(HalfEdgeMesh m)
 {
     mesh = m;
 }