Esempio n. 1
0
        public LDIndexLineList toIndexLineList()
        {
            //NOTE: もっと効率化できる気がするが、ボトルネックになったらやる
            LDIndexLineList lineList = new LDIndexLineList();

            for (int i = 0; i < this.size(); i++)
            {
                LDTriangle tri = this.at(i);

                LDIndexLine line1 = tri.getLine1();
                if (!lineList.hasIndexLine(line1))
                {
                    lineList.Add(line1);
                }

                LDIndexLine line2 = tri.getLine2();
                if (!lineList.hasIndexLine(line2))
                {
                    lineList.Add(line2);
                }

                LDIndexLine line3 = tri.getLine3();
                if (!lineList.hasIndexLine(line3))
                {
                    lineList.Add(line3);
                }
            }
            return(lineList);
        }
Esempio n. 2
0
        public void getRelatedLinesTest_simple()
        {
            LDTriangleList  triangles = simpleTriangle();
            LDIndexLineList compare   = new LDIndexLineList();

            compare.Add(new LDIndexLine(0, 1));
            compare.Add(new LDIndexLine(0, 2));

            LDIndexLineList result = triangles.getRelatedLines(0);

            TestUtil.COMPARE(result, compare);
        }
Esempio n. 3
0
        public void toIndexLineListTest_simple()
        {
            LDTriangleList triangles = simpleTriangle();

            LDIndexLineList compare = new LDIndexLineList();
            LDIndexLine     line_1  = new LDIndexLine(0, 1);
            LDIndexLine     line_2  = new LDIndexLine(1, 2);
            LDIndexLine     line_3  = new LDIndexLine(2, 0);

            compare.Add(line_1);
            compare.Add(line_2);
            compare.Add(line_3);

            LDIndexLineList result = triangles.toIndexLineList();

            TestUtil.COMPARE(result, compare);
        }
Esempio n. 4
0
        public void constructTest()
        {
            List <int> int_list = new List <int>();

            int_list.Add(0);
            int_list.Add(1);
            int_list.Add(2);
            int_list.Add(3);
            //	int_list.push_back(0);
            LDIndexLineList list = new LDIndexLineList(int_list);

            LDIndexLineList compare = new LDIndexLineList();

            compare.Add(new LDIndexLine(0, 1));
            compare.Add(new LDIndexLine(1, 2));
            compare.Add(new LDIndexLine(2, 3));
            compare.Add(new LDIndexLine(3, 0));
            TestUtil.COMPARE(list, compare);
        }
Esempio n. 5
0
        public LDIndexLineList getRelatedLines(int pointIndex)
        {
            LDIndexLineList result = new LDIndexLineList();

            LDIndexLine line1 = getLine1();
            LDIndexLine line2 = getLine2();
            LDIndexLine line3 = getLine3();

            if (line1.hasIndex(pointIndex))
            {
                result.Add(line1);
            }
            if (line2.hasIndex(pointIndex))
            {
                result.Add(line2);
            }
            if (line3.hasIndex(pointIndex))
            {
                result.Add(line3);
            }

            return(result);
        }
Esempio n. 6
0
        public LDIndexLineList getInnerIndexLines()
        {
            LDIndexLineList result = new LDIndexLineList();

            for (int row = 0; row < getRowArrayLength(); ++row)
            {
                if (row == 0 || row + 1 == getRowArrayLength())
                {
                    continue;
                }
                for (int col = 0; col < getColumnArrayLength(); ++col)
                {
                    if (col == 0 || col + 1 == getColumnArrayLength())
                    {
                        continue;
                    }
                    //その点から左と上
                    result.Add(getIndexLine(row, col - 1, row, col));
                    result.Add(getIndexLine(row - 1, col, row, col));

                    if (row + 2 == getRowArrayLength())
                    {
                        //最後だけ下も追加
                        result.Add(new LDIndexLine(getPointIndex(row, col), getPointIndex(row + 1, col)));
                    }

                    if (col + 2 == getColumnArrayLength())
                    {
                        //最後だけ右も追加
                        result.Add(new LDIndexLine(getPointIndex(row, col), getPointIndex(row, col + 1)));
                    }
                }
            }

            return(result);
        }
Esempio n. 7
0
        //その頂点を含む線分リストを取得
        public LDIndexLineList getRelatedLines(int pointIndex)
        {
            LDIndexLineList result = new LDIndexLineList();

            foreach (var t in this)
            {
                LDIndexLineList lines = t.getRelatedLines(pointIndex);

                foreach (var line in lines)
                {
                    result.Add(line);
                }
            }

            return(result);
        }