예제 #1
0
 public override FilterValueSetParam GetFilterValue(
     MatchedEventMap matchedEvents,
     ExprEvaluatorContext exprEvaluatorContext,
     StatementContextFilterEvalEnv filterEvalEnv)
 {
     var x = XEval.GetFilterValueDouble(matchedEvents, exprEvaluatorContext, filterEvalEnv);
     var y = YEval.GetFilterValueDouble(matchedEvents, exprEvaluatorContext, filterEvalEnv);
     var width = WidthEval.GetFilterValueDouble(matchedEvents, exprEvaluatorContext, filterEvalEnv);
     var height = HeightEval.GetFilterValueDouble(matchedEvents, exprEvaluatorContext, filterEvalEnv);
     var rectangle = new XYWHRectangle(x, y, width, height);
     var lookupable = lkupable.Make(matchedEvents, exprEvaluatorContext);
     return new FilterValueSetParamImpl(lookupable, FilterOperator, rectangle);
 }
        public IList <SupportRectangleWithId> Generate(
            Random random,
            int numPoints,
            double x,
            double y,
            double width,
            double height)
        {
            IDictionary <XYWHRectangle, SupportRectangleWithId> rectangles = new Dictionary <XYWHRectangle, SupportRectangleWithId>();
            var pointNum = 0;

            while (rectangles.Count < numPoints)
            {
                double rx;
                double ry;
                double rwidth;
                double rheight;
                while (true)
                {
                    rx      = x + width * random.NextDouble() - 5;
                    ry      = y + height * random.NextDouble() - 5;
                    rwidth  = width * random.NextDouble();
                    rheight = height * random.NextDouble();
                    if (BoundingBox.IntersectsBoxIncludingEnd(x, y, x + width, y + height, rx, ry, rwidth, rheight))
                    {
                        break;
                    }
                }

                var rectangle = new XYWHRectangle(rx, ry, rwidth, rheight);
                if (rectangles.ContainsKey(rectangle))
                {
                    continue;
                }

                rectangles.Put(rectangle, new SupportRectangleWithId("P" + pointNum, rectangle.X, rectangle.Y, rectangle.W, rectangle.H));
                pointNum++;
            }

            return(new List <SupportRectangleWithId>(rectangles.Values));
        }
예제 #3
0
 protected bool Equals(XYWHRectangle other)
 {
     return X.Equals(other.X) && Y.Equals(other.Y) && W.Equals(other.W) && H.Equals(other.H);
 }