Esempio n. 1
0
        public void Update(Point3D end)
        {
            _pointEnd = end;
            Rect3D rect = Helpers.GetRect3D(_pointStart.Value, _pointEnd.Value, 0.5);

            List <ISelectable> selection = new List <ISelectable>();

            foreach (ISeries series in _plot.Series)
            {
                foreach (IPoint item in series.Points)
                {
                    Point3D p3d = Helpers.GetPoint3D(item);
                    if (rect.Contains(p3d))
                    {
                        selection.Add(item);
                    }
                }
            }

            bool changed = _plot.SetSelection(selection);

            if (changed)
            {
                _selectedPoints = null;
            }
        }
Esempio n. 2
0
        // check each point on the image grid, and store the indices only
        static List <int> GetInterior(VMS.TPS.Common.Model.API.Image dose, VMS.TPS.Common.Model.API.Structure st)
        {
            List <int> result    = new List <int>();
            VVector    p         = new VVector();
            Rect3D     st_bounds = st.MeshGeometry.Bounds;

            for (int z = 0; z < dose.ZSize; ++z)
            {
                for (int y = 0; y < dose.YSize; ++y)
                {
                    for (int x = 0; x < dose.XSize; ++x)
                    {
                        p.x = x * dose.XRes;
                        p.y = y * dose.YRes;
                        p.z = z * dose.ZRes;

                        p = p + dose.Origin;

                        if (st_bounds.Contains(p.x, p.y, p.z) && // trimming
                            st.IsPointInsideSegment(p))    // this is an expensive call
                        {
                            int[,] voxels = new int[dose.XSize, dose.YSize];
                            dose.GetVoxels(z, voxels);
                            result.Add(voxels[x, y]);
                        }
                    }
                }
                GC.Collect(); // do this to avoid time out
                GC.WaitForPendingFinalizers();
            }

            return(result);
        }
        // Helper method for compiting the bounds of a set of points.  The given point
        // is added to the bounds of the given Rect3D.  The point/bounds are both passed
        // by reference for perf.  Only the bounds may be modified.
        private static void AddPointToBounds(ref Point3D point, ref Rect3D bounds)
        {
            Debug.Assert(!bounds.IsEmpty,
                         "Caller should construct the Rect3D from the first point before calling this method.");

            if (point.X < bounds.X)
            {
                bounds.SizeX += (bounds.X - point.X);
                bounds.X      = point.X;
            }
            else if (point.X > (bounds.X + bounds.SizeX))
            {
                bounds.SizeX = point.X - bounds.X;
            }

            if (point.Y < bounds.Y)
            {
                bounds.SizeY += (bounds.Y - point.Y);
                bounds.Y      = point.Y;
            }
            else if (point.Y > (bounds.Y + bounds.SizeY))
            {
                bounds.SizeY = point.Y - bounds.Y;
            }

            if (point.Z < bounds.Z)
            {
                bounds.SizeZ += (bounds.Z - point.Z);
                bounds.Z      = point.Z;
            }
            else if (point.Z > (bounds.Z + bounds.SizeZ))
            {
                bounds.SizeZ = point.Z - bounds.Z;
            }

#if NEVER
            // Because we do not store rectangles as TLRB (+ another dimension in 3D)
            // we need to compute SizeX/Y/Z which involves subtraction and introduces
            // cancelation so this assert isn't accurate.
            Debug.Assert(bounds.Contains(point),
                         "Error detect - bounds did not contain point on exit.");
#endif
        }
        private void MyZoomTo(Rect3D r3D)
        {
            if (r3D.IsEmpty)
            {
                return;
            }
            var bounds = new Rect3D(
                _viewBounds.X, _viewBounds.Y, _viewBounds.Z,
                _viewBounds.SizeX, _viewBounds.SizeY, _viewBounds.SizeZ
                );

            if (r3D.IsEmpty)
            {
                return;
            }
            var actualZoomBounds = r3D.Contains(bounds) ? bounds : r3D;

            Viewport.ZoomExtents(actualZoomBounds, 500);
        }
Esempio n. 5
0
 /// <summary>
 /// Returns true if either rectangle is inside the other or touching
 /// </summary>
 public static bool OverlapsWith(this Rect3D thisRect, Rect3D rect)
 {
     return(thisRect.IntersectsWith(rect) || thisRect.Contains(rect) || rect.Contains(thisRect));
 }