コード例 #1
0
ファイル: RectsToQuads.cs プロジェクト: katascope/Glyphics2
        //Remove redundant quads to reduce total count
        public static int RemoveRedundantQuads(QuadList quads)
        {
            int removedCount = 0;

            for (int me = 0; me < quads.Count; me++)
            {
                for (int you = me; you < quads.Count; you++)
                {
                    if (me != you)
                    {
                        Quad meQuad  = quads.GetQuad(me);
                        Quad youQuad = quads.GetQuad(you);
                        //I saw a duplicate
                        if ((meQuad.Pt1.IsEqualTo(youQuad.Pt1)) &&
                            (meQuad.Pt2.IsEqualTo(youQuad.Pt2)))
                        {
                            //we have a redundancy
                            removedCount++;
                            quads.RemoveQuad(youQuad);
                        }
                    }
                }
            }
            return(removedCount);
        }
コード例 #2
0
        //Convert rectangle to its 6 quads
        public static QuadList RectToQuads(Rect rect)
        {
            QuadList quads = new QuadList();

            Quad quadTopper = new Quad(rect.Pt1[0], rect.Pt2[1], rect.Pt1[2], rect.Pt2[0], rect.Pt2[1], rect.Pt2[2]);

            quadTopper.Properties = rect.Properties.Clone();
            Quad quadBottom = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt1[2], rect.Pt2[0], rect.Pt1[1], rect.Pt2[2]);

            quadBottom.Properties = rect.Properties.Clone();

            Quad quadFront = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt2[2], rect.Pt2[0], rect.Pt2[1], rect.Pt2[2]);

            quadFront.Properties = rect.Properties.Clone();
            Quad quadBack = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt1[2], rect.Pt2[0], rect.Pt2[1], rect.Pt1[2]);

            quadBack.Properties = rect.Properties.Clone();

            Quad quadRight = new Quad(rect.Pt2[0], rect.Pt1[1], rect.Pt1[2], rect.Pt2[0], rect.Pt2[1], rect.Pt2[2]);

            quadRight.Properties = rect.Properties.Clone();
            Quad quadLeft = new Quad(rect.Pt1[0], rect.Pt1[1], rect.Pt1[2], rect.Pt1[0], rect.Pt2[1], rect.Pt2[2]);

            quadLeft.Properties = rect.Properties.Clone();

            quads.AddQuad(quadFront);
            quads.AddQuad(quadBack);
            quads.AddQuad(quadTopper);
            quads.AddQuad(quadBottom);
            quads.AddQuad(quadRight);
            quads.AddQuad(quadLeft);

            return(quads);
        }
コード例 #3
0
        //Convert 6 Quads to 12 triangles, along the faces of a cube
        public static void RectToTrianglesCube(ref List <Triangle> triangles, Rect rect)
        {
            QuadList quads = RectToQuads(rect);

            //RectToTrianglesCube(ref triangles, rect);

            foreach (Quad quad in quads)
            {
                Triangles twoTriangles = QuadToTwoTriangles(quad);
                triangles.Add(twoTriangles.GetTriangleArray()[0]);
                triangles.Add(twoTriangles.GetTriangleArray()[1]);
            }
        }
コード例 #4
0
        public void FromSerializedRects(SerializedRects inSerializedRects)
        {
            SerializedRects = inSerializedRects;
            Rects           = RasterLib.RasterApi.SerializedRectsToRects(SerializedRects);

            if ((enableFlags & enables.DoQuads) == enables.DoQuads)
            {
                Quads = RasterLib.RasterApi.RectsToQuads(Rects);
            }

            if ((enableFlags & enables.DoTriangles) == enables.DoTriangles)
            {
                FromQuads(Quads);
            }
        }
コード例 #5
0
ファイル: RectsToQuads.cs プロジェクト: katascope/Glyphics2
        //Convert rectangles to their 6 quads
        public static QuadList RectsToQuads(RectList rectSet)
        {
            QuadList quadsMacro = new QuadList();

            foreach (Rect rect in rectSet)
            {
                QuadList quads = RectToQuads(rect);

                foreach (Quad quad in quads)
                {
                    quadsMacro.AddQuad(quad);
                }
            }

            //Remove redundant ones automatically
            RemoveRedundantQuads(quadsMacro);

            return(quadsMacro);
        }
コード例 #6
0
ファイル: QuadList.cs プロジェクト: katascope/Glyphics2
        //True if same
        public bool IsEqualTo(QuadList quads)
        {
            if (quads == null || quads.Count != Count)
            {
                return(false);
            }

            for (int i = 0; i < Count; i++)
            {
                Quad quad1 = quads.GetQuad(i);
                Quad quad2 = Quads[i];

                if (quad1.IsEqualTo(quad2) == false)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #7
0
        //convert a quad to its two triangles
        public static Triangles QuadsToTriangles(QuadList quads)
        {
            var triangleList = new List <Triangle>();

            foreach (Quad quad in quads)
            {
                Triangles triangles = QuadToTwoTriangles(quad);
                triangles.GetTriangleArray()[0].CalcNormal();
                triangles.GetTriangleArray()[1].CalcNormal();
                triangleList.Add(triangles.GetTriangleArray()[0]);
                triangleList.Add(triangles.GetTriangleArray()[1]);
            }

            Triangles trianglesPack = new Triangles();

            trianglesPack.SetTriangles(triangleList.ToArray());

            return(trianglesPack);
        }
コード例 #8
0
        //This should be deprecated as it creates it's own vertices instead of using STL
        public static Triangles RectsToTrianglesCube(RectList rectSet)
        {
            var triangles = new List <Triangle>();

            //Iterate through reach rectangle(volume/cube) creating triangles
            foreach (Rect rect in rectSet)
            {
                QuadList quads = RectToQuads(rect);
                //RectToTrianglesCube(ref triangles, rect);

                foreach (Quad quad in quads)
                {
                    Triangles twoTriangles = QuadToTwoTriangles(quad);
                    triangles.Add(twoTriangles.GetTriangleArray()[0]);
                    triangles.Add(twoTriangles.GetTriangleArray()[1]);
                }
            }

            return(new Triangles(triangles.ToArray()));
        }
コード例 #9
0
ファイル: RasterApi.cs プロジェクト: katascope/Glyphics2
 public static Triangles QuadsToTriangles(QuadList quads)
 {
     return(TriangleConverter.QuadsToTriangles(quads));
 }
コード例 #10
0
ファイル: RasterApi.cs プロジェクト: katascope/Glyphics2
 public static int RemoveRedundantQuads(QuadList quads)
 {
     return(RectConverter.RemoveRedundantQuads(quads));
 }
コード例 #11
0
 public void FromQuads(QuadList quads)
 {
     Triangles = TriangleConverter.QuadsToTriangles(quads);
     FromTriangles(Triangles);
 }
コード例 #12
0
 public DownSolver(QuadList inQuads)
 {
     FromQuads(inQuads);
 }