예제 #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);
        }
예제 #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);//線の延長戦上に離れたところ
        }
예제 #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); //線の延長戦上に離れたところ
        }
예제 #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);
 }
예제 #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);
        }
예제 #6
0
파일: LDUvMesh.cs 프로젝트: johndpope/math
 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();
 }
예제 #7
0
파일: LDUvMesh.cs 프로젝트: KajitaLD/math
 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();
 }
예제 #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);
        }
예제 #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);
        }
예제 #10
0
파일: LDTriangle.cs 프로젝트: KajitaLD/math
        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;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #14
0
파일: LDUvMesh.cs 프로젝트: johndpope/math
 public bool existsLine(LDIndexLine line)
 {
     return(m_lines.Contains(line));
 } //既にある線かチェックする
예제 #15
0
파일: LDUvMesh.cs 프로젝트: johndpope/math
 public bool deleteLine(LDIndexLine line)
 {
     return(m_lines.Remove(line));
 }
예제 #16
0
 public LDLine getLine(LDIndexLine line)
 {
     return(new LDLine(getPoint(line.getIndex1()), getPoint(line.getIndex2())));
 }
예제 #17
0
 public LDLine getLine(LDIndexLine line)
 {
     return new LDLine(getPoint(line.getIndex1()), getPoint(line.getIndex2()));
 }
예제 #18
0
파일: LDTriangle.cs 프로젝트: KajitaLD/math
        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;
        }
예제 #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);
        }
예제 #20
0
파일: LDUvMesh.cs 프로젝트: KajitaLD/math
 public bool deleteLine(LDIndexLine line)
 {
     return m_lines.Remove(line);
 }
예제 #21
0
파일: LDUvMesh.cs 프로젝트: KajitaLD/math
 public bool existsLine(LDIndexLine line)
 {
     return m_lines.Contains(line);
 }