예제 #1
0
        protected override void OnPolygonComplete(Polygon2f input)
        {
            polygon = input;

            polygon.MakeCCW();
            polygon.BuildIndices();
            polygon.BuildHoleIndices();

            if (polygon.IsSimple)
            {
                if (mode == TRIANGULATION_MODE.CONSTRAINTED)
                {
                    mesh = ConstraintedTriangulation2.Triangulate(polygon);
                }
                else
                {
                    ConformingCriteria criteria = new ConformingCriteria();
                    criteria.angBounds  = 0.125f;
                    criteria.lenBounds  = 0.2f;
                    criteria.iterations = iterations;
                    mesh = ConformingTriangulation2.Triangulate(polygon, criteria);
                }
            }
            else
            {
                mesh = new Mesh2f(0, 0);
            }
        }
예제 #2
0
        public static Mesh2f ToIndexableMesh2f <VERTEX, EDGE, FACE>(HBMesh <VERTEX, EDGE, FACE> mesh, int faceVertices = 0)
            where VERTEX : HBVertex2f, new()
            where EDGE : HBEdge, new()
            where FACE : HBFace, new()
        {
            int    numPositions = mesh.Vertices.Count;
            Mesh2f indexed      = new Mesh2f(numPositions);

            for (int i = 0; i < numPositions; i++)
            {
                indexed.Positions[i] = mesh.Vertices[i].Position;
            }

            if (faceVertices == 0)
            {
                //no faces. Mesh represents edge lines.
                indexed.SetIndices(CreateEdgeIndices(mesh));
            }
            else
            {
                indexed.SetIndices(CreateFaceIndices(mesh, faceVertices));
            }

            return(indexed);
        }
        void Start()
        {
            points = new Vector2f[100];
            FillWithRandom(points);

            lines = CreateLines();

            mesh = ConstraintedTriangulation2.Triangulate(lines, points);
        }
예제 #4
0
파일: Mesh2fTest.cs 프로젝트: andybak/CGAL
        public void SetPositions()
        {
            Mesh2f mesh = new Mesh2f(1);

            int size = 10;

            Vector2f[] positions = new Vector2f[size];
            for (int i = 0; i < size; i++)
            {
                positions[i] = new Vector2f(i);
            }

            mesh.SetPositions(positions);

            CollectionAssert.AreEqual(positions, mesh.Positions);
        }
예제 #5
0
        public void Triangulate()
        {
            Polygon2f polygon = CreatePolygon2.FromBox(new Vector2f(-1), new Vector2f(1));

            Mesh2f mesh = ConstraintedTriangulation2.Triangulate(polygon);

            Assert.AreEqual(4, mesh.VerticesCount);
            Assert.AreEqual(6, mesh.IndicesCount);

            for (int i = 0; i < mesh.IndicesCount / 3; i++)
            {
                Vector2f   a   = mesh.Positions[mesh.Indices[i * 3 + 0]];
                Vector2f   b   = mesh.Positions[mesh.Indices[i * 3 + 1]];
                Vector2f   c   = mesh.Positions[mesh.Indices[i * 3 + 2]];
                Triangle2f tri = new Triangle2f(a, b, c);

                Assert.IsTrue(tri.SignedArea > 0);
            }
        }
예제 #6
0
        protected override void OnPolygonComplete(Polygon2f input)
        {
            polygon = input;

            polygon.MakeCCW();
            polygon.BuildIndices();
            polygon.BuildHoleIndices();

            if (polygon.IsSimple)
            {
                var constructor = new HBMeshConstructor <HBVertex2f, HBEdge, HBFace>();
                PolygonSkeleton2.CreateInteriorSkeleton(polygon, constructor);
                var mesh = constructor.PopMesh();

                line = HBMeshConversion.ToIndexableMesh2f(mesh);
            }
            else
            {
                line = null;
            }
        }
예제 #7
0
 protected override void OnPolygonCleared()
 {
     line = null;
 }