Exemplo n.º 1
0
        public string GetWeight(string vertexToName)
        {
            if (Name == vertexToName && Edges.All(e => e.VertexTo.Name != vertexToName))
            {
                return(string.Empty);
            }

            return(Edges.First(e => e.VertexTo.Name == vertexToName).GetWeightString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether the mesh is a valid triangle mesh.
        /// </summary>
        /// <returns>
        /// <see langword="true"/> if the mesh is a valid triangle mesh; otherwise,
        /// <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// <para>
        /// This method checks if the mesh consists only of triangle faces without edges or vertices
        /// that are not connected to a face.
        /// </para>
        /// <para>
        /// This method does not check whether the mesh <see cref="IsValid()"/>.
        /// </para>
        /// </remarks>
        public bool IsTriangleMesh()
        {
            if (Vertices.Count > 0 && Faces.Count == 0)
            {
                return(false);
            }

            return(Faces.All(f => f.Holes == null) &&       // No holes allowed.
                   Edges.All(e => e.Face == null ||
                             e.Next != null &&              // Face boundary consists of exactly 3 edges.
                             e.Next.Next == e.Previous &&
                             e.Next != e.Previous));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determines whether this mesh is a closed mesh.
        /// </summary>
        /// <returns>
        /// <see langword="true"/> if this instance is a closed mesh; otherwise, <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// <para>
        /// In a closed mesh all edges are connected to 2 faces. For example: The mesh of a sphere is a
        /// closed mesh. An object with holes, like a pullover, is not closed. A flat object, like a
        /// curtain, is closed if both sides are modeled with faces. It is not closed if only a one side
        /// is modeled with faces. (A single vertex is considered as closed. A single edge-pair is also
        /// considered as closed.)
        /// </para>
        /// <para>
        /// This method does not check whether the mesh <see cref="IsValid()"/>.
        /// </para>
        /// </remarks>
        public bool IsClosed()
        {
            // Empty mesh is not closed.
            if (Vertex == null)
            {
                return(false);
            }

            // A single edge-pair is closed.
            if (Faces.Count == 0 && Edges.Count <= 2)
            {
                return(true);
            }

            return(Faces.All(f => f.Holes == null) &&   // No holes allowed.
                   Edges.All(e => e.Face != null &&     // Faces on both sides of the edge.
                             e.Twin != null &&
                             e.Twin.Face != null));
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Defines the face curvature. Depends on DefineEdgeAngle
 /// </summary>
 public void DefineFaceCurvature()
 {
     if (Edges.Any(e => e == null || e.Curvature == CurvatureType.Undefined))
     {
         Curvature = CurvatureType.Undefined;
     }
     else if (Edges.All(e => e.Curvature != CurvatureType.Concave))
     {
         Curvature = CurvatureType.Convex;
     }
     else if (Edges.All(e => e.Curvature != CurvatureType.Convex))
     {
         Curvature = CurvatureType.Concave;
     }
     else
     {
         Curvature = CurvatureType.SaddleOrFlat;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Defines vertex curvature
 /// </summary>
 private void DefineCurvature()
 {
     if (Edges.Any(e => e.Curvature == CurvatureType.Undefined))
     {
         _curvature = CurvatureType.Undefined;
     }
     else if (Edges.All(e => e.Curvature == CurvatureType.SaddleOrFlat))
     {
         _curvature = CurvatureType.SaddleOrFlat;
     }
     else if (Edges.Any(e => e.Curvature != CurvatureType.Convex))
     {
         _curvature = CurvatureType.Concave;
     }
     else if (Edges.Any(e => e.Curvature != CurvatureType.Concave))
     {
         _curvature = CurvatureType.Convex;
     }
     else
     {
         _curvature = CurvatureType.SaddleOrFlat;
     }
 }
Exemplo n.º 6
0
        // TODO: Add error messages to IsXxx method, so that users see where the problem is.

        /// <summary>
        /// Gets a value indicating whether the tags of all components in the mesh are equal to the
        /// given tag value.
        /// </summary>
        /// <param name="tag">The reference tag value.</param>
        /// <returns>
        /// <see langword="true"/> if the tags of all components are equal to <paramref name="tag"/>;
        /// otherwise, <see langword="false"/>.
        /// </returns>
        public bool AreTagsEqualTo(int tag)
        {
            return(Vertices.All(vertex => vertex.Tag == tag) &&
                   Edges.All(edge => edge.Tag == tag) &&
                   Faces.All(face => face.Tag == tag));
        }