Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TV"></typeparam>
        /// <typeparam name="TE"></typeparam>
        public static void WriteToJson(HeMesh3d mesh, string path)
        {
            WriteToJson(mesh, path, ToJson);

            IEnumerable <object> ToJson(HeMesh3d.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);

                var t = vertex.Texture;

                yield return(t.X);

                yield return(t.Y);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TV"></typeparam>
        /// <typeparam name="TE"></typeparam>
        public static void WriteToJson(HeMesh3d mesh, string path)
        {
            WriteToJson <HeMesh3d.Vertex, HeMesh3d.Halfedge, HeMesh3d.Face, double[], double[], double[]>(mesh, path, ToJson);

            double[] ToJson(HeMesh3d.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 });
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="mesh"></param>
        /// <param name="setVertexAttributes"></param>
        /// <param name="setHedgeAttributes"></param>
        public static void ReadFromJson(string path, HeMesh3d mesh)
        {
            ReadFromJson(path, mesh, FromJson);

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

                // parse optional attributes
                switch (attributes.Length)
                {
                case 5:
                {
                    ParseTexture(3);
                    break;
                }

                case 6:
                {
                    ParseNormal(3);
                    break;
                }

                case 8:
                {
                    ParseNormal(3);
                    ParseTexture(6);
                    break;
                }
                }

                void ParseNormal(int offset)
                {
                    vertex.Normal = new Vec3d(
                        Convert.ToDouble(attributes[offset]),
                        Convert.ToDouble(attributes[offset + 1]),
                        Convert.ToDouble(attributes[offset + 2])
                        );
                }

                void ParseTexture(int offset)
                {
                    vertex.Texture = new Vec2d(
                        Convert.ToDouble(attributes[offset]),
                        Convert.ToDouble(attributes[offset + 1])
                        );
                }
            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="mesh"></param>
        /// <param name="setVertexAttributes"></param>
        /// <param name="setHedgeAttributes"></param>
        public static void ReadFromJson(string path, HeMesh3d mesh)
        {
            ReadFromJson <HeMesh3d.Vertex, HeMesh3d.Halfedge, HeMesh3d.Face, double[], double[], double[]>(path, mesh, FromJson);

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

                vertex.Normal = new Vec3d(
                    values[3],
                    values[4],
                    values[5]);
            }
        }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <typeparam name="E"></typeparam>
 /// <typeparam name="F"></typeparam>
 /// <param name="mesh"></param>
 /// <param name="start"></param>
 /// <param name="setEdge"></param>
 public static void Unroll(HeMesh3d mesh, HeMesh3d.Face start, Action <HeMesh3d.Vertex, Vec3d> setUnrolledPosition, Func <HeMesh3d.Halfedge, double> getUnrollFactor = null)
 {
     Unroll(mesh, start, HeMesh3d.Vertex.Accessors.Position, setUnrolledPosition, getUnrollFactor);
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <typeparam name="E"></typeparam>
 /// <typeparam name="F"></typeparam>
 /// <param name="mesh"></param>
 /// <param name="start"></param>
 /// <param name="setEdge"></param>
 public static void DetachFaceCycles(HeMesh3d mesh, HeMesh3d.Face start)
 {
     DetachFaceCycles(mesh, start, Set);
 }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 public void Append(HeMesh3d other)
 {
     Append(other, Set, delegate { }, delegate { });
 }