Ejemplo n.º 1
0
        protected override bool ThroughTriangle(FrustumParams data)
        {
            SelectedSubItems.Sort();

            //if selection filter is ByPick/VisibleByPick selects only the first triangle
            if (vp.firstOnlyInternal && !vp.processVisibleOnly && SelectedSubItems.Count > 0)
            {
                return(false);
            }

            bool through = false;

            for (int i = 0; i < Triangles.Length; i++)
            {
                if (SelectedSubItems.BinarySearch(i) >= 0)
                {
                    continue;
                }

                if (ThroughTriangle(data, GetTriangleVertices(Triangles[i])))
                {
                    SelectedSubItems.Add(i);

                    through = true;

                    if (vp.firstOnlyInternal && !vp.processVisibleOnly)
                    {
                        return(true);
                    }
                }
            }

            return(through);
        }
Ejemplo n.º 2
0
        protected override bool InsideOrCrossingFrustum(FrustumParams data)
        {
            // Computes the triangles that are inside or crossing the selection planes

            bool insideOrCrossing = false;

            for (int i = 0; i < Triangles.Length; i++)
            {
                var verts = GetTriangleVertices(Triangles[i]);
                if (Utility.InsideOrCrossingFrustum(verts[0], verts[1], verts[2], data.Frustum))
                {
                    SelectedSubItems.Add(i);

                    insideOrCrossing = true;

                    //if selection filter is ByPick/VisibleByPick selects only the first triangle
                    if (vp.firstOnlyInternal && !vp.processVisibleOnly)
                    {
                        return(true);
                    }
                }
            }

            return(insideOrCrossing);
        }
Ejemplo n.º 3
0
        protected override bool InsideOrCrossingScreenPolygon(ScreenPolygonParams data)
        {
            // Computes the triangles that are inside or crossing the screen polygon

            for (int i = 0; i < Triangles.Length; i++)
            {
                var verts = GetTriangleVertices(Triangles[i]);

                if (UtilityEx.InsideOrCrossingScreenPolygon(verts[0], verts[1], verts[2], data))
                {
                    SelectedSubItems.Add(i);
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        protected override bool ThroughTriangleScreenPolygon(ScreenPolygonParams data)
        {
            SelectedSubItems.Sort();

            for (int i = 0; i < Triangles.Length; i++)
            {
                if (SelectedSubItems.BinarySearch(i) >= 0)
                {
                    continue;
                }

                var verts = GetTriangleVertices(Triangles[i]);
                if (ThroughTriangleScreenPolygon(verts[0], verts[1], verts[2], data))
                {
                    SelectedSubItems.Add(i);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        protected override bool InsideOrCrossingScreenPolygon(ScreenPolygonParams data)
        {
            // Computes the lines that are inside or crossing the screen polygon
            for (int i = 0; i < Lines.Length; i++)
            {
                Segment2D seg;

                IndexLine line = Lines[i];
                Point3D   pt1  = Vertices[line.V1];
                Point3D   pt2  = Vertices[line.V2];

                Point3D screenP1 = vp.Camera.WorldToScreen(pt1, data.ViewFrame);
                Point3D screenP2 = vp.Camera.WorldToScreen(pt2, data.ViewFrame);

                if (screenP1.Z > 1 || screenP2.Z > 1)
                {
                    return(false);  // for perspective
                }
                seg = new Segment2D(screenP1, screenP2);

                if (UtilityEx.PointInPolygon(screenP1, data.ScreenPolygon) ||
                    UtilityEx.PointInPolygon(screenP2, data.ScreenPolygon))

                {
                    SelectedSubItems.Add(i);
                    continue;
                }

                for (int j = 0; j < data.ScreenSegments.Count; j++)
                {
                    Point2D i0;
                    if (Segment2D.Intersection(data.ScreenSegments[j], seg, out i0))

                    {
                        SelectedSubItems.Add(i);
                        break;
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        protected override bool InsideOrCrossingFrustum(FrustumParams data)
        {
            // Computes the lines that are inside or crossing the selection planes

            bool insideOrCrossing = false;

            for (int i = 0; i < Lines.Length; i++)
            {
                if (Utility.IsSegmentInsideOrCrossing(data.Frustum, new Segment3D(Vertices[Lines[i].V1], Vertices[Lines[i].V2])))
                {
                    SelectedSubItems.Add(i);

                    insideOrCrossing = true;

                    //if selection filter is ByPick/VisibleByPick selects only the first line
                    if (vp.firstOnlyInternal && !vp.processVisibleOnly)
                    {
                        return(true);
                    }
                }
            }

            return(insideOrCrossing);
        }