Exemple #1
0
        private static void CreateMesh <MESH>(IMeshConstructor <MESH> constructor, MeshDescriptor des)
        {
            constructor.PushTriangleMesh(des.Vertices, des.Faces);

            for (int i = 0; i < des.Vertices; i++)
            {
                constructor.AddVertex(CGAL_GetPoint2f(i));
            }

            for (int i = 0; i < des.Faces; i++)
            {
                TriangleIndex triangle = CGAL_GetTriangle(i);
                constructor.AddFace(triangle);
            }

            for (int i = 0; i < des.Faces; i++)
            {
                TriangleIndex triangle = CGAL_GetNeighbor(i);
                constructor.AddFaceConnection(i, triangle);
            }
        }
Exemple #2
0
        private static void CreateMesh <MESH>(IMeshConstructor <MESH> constructor, MeshDescriptor des)
        {
            constructor.PushTriangleMesh(des.Vertices, des.Faces);

            for (int i = 0; i < des.Vertices; i++)
            {
                constructor.AddVertex(CGAL_GetPoint2f(i));
            }

            for (int i = 0; i < des.Faces; i++)
            {
                TriangleIndex triangle = CGAL_GetTriangle(i);
                Vector2f      a        = CGAL_GetPoint2f(triangle.i0);
                Vector2f      b        = CGAL_GetPoint2f(triangle.i1);
                Vector2f      c        = CGAL_GetPoint2f(triangle.i2);

                Vector2f p = (a + b + c) / 3.0f;

                if (PolygonIntersection2.ContainsPoint(p))
                {
                    constructor.AddFace(triangle);
                }
            }
        }