Beispiel #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);
        }
Beispiel #2
0
        /*
        public void serializeTest()
        {
            const char* name = "lineList";
            QSharedPointer<LDIndexLineList> src(new LDIndexLineList);
            src->push_back(LDIndexLine(0, 1));

            //シリアライズ
            SerializeHelper::writeBoostXml(name, src);

            //デシリアライズ
            auto dst = SerializeHelper::readBoostXml<LDIndexLineList>(name);

            QVERIFY(*(dst.data()) == *(src.data()));
        }
        */
        public void hitTest()
        {
            LDIndexLineList lines = new LDIndexLineList();
            LDIndexLine line_1 = new LDIndexLine(0, 1);
            LDIndexLine line_2 = new LDIndexLine(1, 2);
            LDIndexLine line_3 = new LDIndexLine(2, 3);
            LDIndexLine line_4 = new LDIndexLine(3, 0);
            lines.add(line_1);
            lines.add(line_2);
            lines.add(line_3);
            lines.add(line_4);

            LDPointList points = new LDPointList();
            points.Add(new LDPoint(0, 0));
            points.Add(new LDPoint(100, 0));
            points.Add(new LDPoint(100, 100));
            points.Add(new LDPoint(0, 100));

            TestUtil.COMPARE(lines.isHit(points, new LDPoint(0, 0), 1), true);//頂点上
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 0), 1), true);//線上
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 1), 3), true);//線からちょっと離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 4), 3), false);//線から範囲外に離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(200, 0), 3), false);//線の延長戦上に離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(200, 1), 3), false);//線の延長戦上に離れたところ
        }
Beispiel #3
0
        /*
         * public void serializeTest()
         * {
         *  const char* name = "lineList";
         *  QSharedPointer<LDIndexLineList> src(new LDIndexLineList);
         *  src->push_back(LDIndexLine(0, 1));
         *
         *  //シリアライズ
         *  SerializeHelper::writeBoostXml(name, src);
         *
         *  //デシリアライズ
         *  auto dst = SerializeHelper::readBoostXml<LDIndexLineList>(name);
         *
         *  QVERIFY(*(dst.data()) == *(src.data()));
         * }
         */

        public void hitTest()
        {
            LDIndexLineList lines  = new LDIndexLineList();
            LDIndexLine     line_1 = new LDIndexLine(0, 1);
            LDIndexLine     line_2 = new LDIndexLine(1, 2);
            LDIndexLine     line_3 = new LDIndexLine(2, 3);
            LDIndexLine     line_4 = new LDIndexLine(3, 0);

            lines.add(line_1);
            lines.add(line_2);
            lines.add(line_3);
            lines.add(line_4);

            LDPointList points = new LDPointList();

            points.Add(new LDPoint(0, 0));
            points.Add(new LDPoint(100, 0));
            points.Add(new LDPoint(100, 100));
            points.Add(new LDPoint(0, 100));


            TestUtil.COMPARE(lines.isHit(points, new LDPoint(0, 0), 1), true);    //頂点上
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 0), 1), true);   //線上
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 1), 3), true);   //線からちょっと離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(50, 4), 3), false);  //線から範囲外に離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(200, 0), 3), false); //線の延長戦上に離れたところ
            TestUtil.COMPARE(lines.isHit(points, new LDPoint(200, 1), 3), false); //線の延長戦上に離れたところ
        }
Beispiel #4
0
 public void findTest_simple()
 {
     LDTriangleList triangles = simpleTriangle();
     LDTriangleList compare = simpleTriangle();
     LDIndexLine line=new LDIndexLine(0, 2);
     LDTriangleList resulut = triangles.find(line);
     TestUtil.COMPARE(resulut, compare);
 }
Beispiel #5
0
        public void findTest_simple()
        {
            LDTriangleList triangles = simpleTriangle();
            LDTriangleList compare   = simpleTriangle();
            LDIndexLine    line      = new LDIndexLine(0, 2);
            LDTriangleList resulut   = triangles.find(line);

            TestUtil.COMPARE(resulut, compare);
        }
Beispiel #6
0
 public void addLine(LDIndexLine line)
 {
     if (!existsLine(line))
     {
         m_lines.Add(line);
     }
     else
     {
         common.Critical("exist line came ! check line before this method called");
     }
     m_lines.sort();
 }
Beispiel #7
0
 public void addLine(LDIndexLine line)
 {
     if (!existsLine(line))
     {
         m_lines.Add(line);
     }
     else
     {
         common.Critical("exist line came ! check line before this method called");
     }
     m_lines.sort();
 }
Beispiel #8
0
        public LDTriangleList find(LDIndexLine line)
        {
            LDTriangleList result = new LDTriangleList();

            foreach (var t in this)
            {
                if (t.containsLine(line))
                {
                    result.Add(t);
                }
            }
            return(result);
        }
Beispiel #9
0
        public bool containsLine(LDIndexLine l)
        {
            if (l.hasIndex(m_index1) && l.hasIndex(m_index2))
            {
                return(true);
            }
            if (l.hasIndex(m_index2) && l.hasIndex(m_index3))
            {
                return(true);
            }
            if (l.hasIndex(m_index1) && l.hasIndex(m_index3))
            {
                return(true);
            }

            return(false);
        }
Beispiel #10
0
        public bool containsLine(LDIndexLine l)
        {
            if (l.hasIndex(m_index1) && l.hasIndex(m_index2))
            {
                return true;
            }
            if (l.hasIndex(m_index2) && l.hasIndex(m_index3))
            {
                return true;
            }
            if (l.hasIndex(m_index1) && l.hasIndex(m_index3))
            {
                return true;
            }

            return false;
        }
Beispiel #11
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);
        }
Beispiel #12
0
        public int getIndexWithoutLine(LDIndexLine l)
        {
            Debug.Assert(containsLine(l));

            if (!l.hasIndex(m_index1))
            {
                return(m_index1);
            }
            if (!l.hasIndex(m_index2))
            {
                return(m_index2);
            }
            if (!l.hasIndex(m_index3))
            {
                return(m_index3);
            }
            return(-1);
        }
Beispiel #13
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);
        }
Beispiel #14
0
 public bool existsLine(LDIndexLine line)
 {
     return(m_lines.Contains(line));
 } //既にある線かチェックする
Beispiel #15
0
 public bool deleteLine(LDIndexLine line)
 {
     return(m_lines.Remove(line));
 }
Beispiel #16
0
 public LDLine getLine(LDIndexLine line)
 {
     return(new LDLine(getPoint(line.getIndex1()), getPoint(line.getIndex2())));
 }
Beispiel #17
0
 public LDLine getLine(LDIndexLine line)
 {
     return new LDLine(getPoint(line.getIndex1()), getPoint(line.getIndex2()));
 }
Beispiel #18
0
        public int getIndexWithoutLine(LDIndexLine l)
        {
            Debug.Assert(containsLine(l));

            if (!l.hasIndex(m_index1))
            {
                return m_index1;
            }
            if (!l.hasIndex(m_index2))
            {
                return m_index2;
            }
            if (!l.hasIndex(m_index3))
            {
                return m_index3;
            }
            return -1;
        }
Beispiel #19
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);
        }
Beispiel #20
0
 public bool deleteLine(LDIndexLine line)
 {
     return m_lines.Remove(line);
 }
Beispiel #21
0
 public bool existsLine(LDIndexLine line)
 {
     return m_lines.Contains(line);
 }