예제 #1
0
        /// <summary>Add 4 nodes and 2 triangles to the solution.</summary>
        private void CreateSuperBox(FaceExList dynamics)
        {
            int    count = this.m_nodes.Count;
            double x0    = default(double);
            double x1    = default(double);
            double y0    = default(double);
            double y1    = default(double);

            this.m_nodes.BoundingBox(10.0, true, ref x0, ref x1, ref y0, ref y1);
            Node2 node1 = new Node2(x0, y0, -100);
            Node2 node2 = new Node2(x0, y1, -101);
            Node2 node3 = new Node2(x1, y0, -102);
            Node2 node4 = new Node2(x1, y1, -103);

            this.m_nodes.Append(node1);
            this.m_nodes.Append(node2);
            this.m_nodes.Append(node3);
            this.m_nodes.Append(node4);
            this.m_nodes.Sort(Node2List.NodeListSort.X);
            this.set_SuperBoxIndex(0, this.m_nodes.InternalList.IndexOf(node1));
            this.set_SuperBoxIndex(1, this.get_SuperBoxIndex(0) + 1);
            this.set_SuperBoxIndex(2, this.m_nodes.Count - 2);
            this.set_SuperBoxIndex(3, this.m_nodes.Count - 1);
            dynamics.AddFace(this.get_SuperBoxIndex(0), this.get_SuperBoxIndex(2), this.get_SuperBoxIndex(3), this.m_nodes);
            dynamics.AddFace(this.get_SuperBoxIndex(0), this.get_SuperBoxIndex(3), this.get_SuperBoxIndex(1), this.m_nodes);
        }
예제 #2
0
        private bool Triangulate()
        {
            FaceExList dynamics = new FaceExList(this.m_nodes.Count);

            this.m_faces.Clear();
            this.m_faces.Capacity = this.m_nodes.Count * 2;
            bool flag;

            if (this.m_nodes == null)
            {
                flag = false;
            }
            else if (this.m_nodes.Count < 3)
            {
                flag = false;
            }
            else
            {
                this.CreateSuperBox(dynamics);
                List <FaceEx> F    = new List <FaceEx>();
                int           num1 = this.get_SuperBoxIndex(1) + 1;
                int           num2 = this.get_SuperBoxIndex(2) - 1;
                for (int C = num1; C <= num2; ++C)
                {
                    Node2 node = this.m_nodes[C];
                    dynamics.MigrateStaticFaces(this.m_faces, node.x);
                    F.Clear();
                    if (dynamics.CullFaces(node.x, node.y, F) != 0)
                    {
                        EdgeList edgeList = new EdgeList(F);
                        edgeList.TrimHighValenceEdges();
                        int num3 = edgeList.Count - 1;
                        for (int index = 0; index <= num3; ++index)
                        {
                            dynamics.AddFace(edgeList[index].A, edgeList[index].B, C, this.m_nodes);
                        }
                    }
                }
                dynamics.MigrateRemainingFaces(this.m_faces);
                this.DestroySuperBox();
                this.SolveStaticOrientation();
                flag = true;
            }
            return(flag);
        }