예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TV"></typeparam>
        /// <typeparam name="TE"></typeparam>
        public static void WriteToJson(HeGraph3d graph, string path)
        {
            WriteToJson <HeGraph3d.Vertex, HeGraph3d.Halfedge, double[], double[]>(graph, path, ToJson);

            double[] ToJson(HeGraph3d.Vertex vertex)
            {
                var p = vertex.Position;
                var n = vertex.Normal;

                return(new double[] { p.X, p.Y, p.Z, n.X, n.Y, n.Z });
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="graph"></param>
        /// <param name="setVertexAttributes"></param>
        /// <param name="setHedgeAttributes"></param>
        public static void ReadFromJson(string path, HeGraph3d graph)
        {
            ReadFromJson <HeGraph3d.Vertex, HeGraph3d.Halfedge, double[], double[]>(path, graph, FromJson);

            void FromJson(HeGraph3d.Vertex vertex, double[] values)
            {
                vertex.Position = new Vec3d(
                    values[0],
                    values[1],
                    values[2]);

                vertex.Normal = new Vec3d(
                    values[3],
                    values[4],
                    values[5]);
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="graph"></param>
        /// <param name="setVertexAttributes"></param>
        /// <param name="setHedgeAttributes"></param>
        public static void ReadFromJson(string path, HeGraph3d graph)
        {
            ReadFromJson(path, graph, FromJson);

            void FromJson(HeGraph3d.Vertex vertex, object[] attributes)
            {
                vertex.Position = new Vec3d(
                    Convert.ToDouble(attributes[0]),
                    Convert.ToDouble(attributes[1]),
                    Convert.ToDouble(attributes[2])
                    );

                // parse optional attributes
                if (attributes.Length == 6)
                {
                    vertex.Normal = new Vec3d(
                        Convert.ToDouble(attributes[3]),
                        Convert.ToDouble(attributes[4]),
                        Convert.ToDouble(attributes[5])
                        );
                }
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TV"></typeparam>
        /// <typeparam name="TE"></typeparam>
        public static void WriteToJson(HeGraph3d graph, string path)
        {
            WriteToJson(graph, path, ToJson);

            IEnumerable <object> ToJson(HeGraph3d.Vertex vertex)
            {
                var p = vertex.Position;

                yield return(p.X);

                yield return(p.Y);

                yield return(p.Z);

                var n = vertex.Normal;

                yield return(n.X);

                yield return(n.Y);

                yield return(n.Z);
            }
        }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 public void Append(HeGraph3d other)
 {
     Append(other, Set, delegate { });
 }