Esempio n. 1
0
        public override Expression Build(IEnumerable <Expression> arguments)
        {
            var source          = arguments.First();
            var parameterType   = source.Type.GetGenericArguments()[0];
            var valueParameter  = Expression.Parameter(typeof(object));
            var viewParameter   = Expression.Parameter(typeof(RollingGraphVisualizer));
            var elementVariable = Expression.Variable(parameterType);

            Controller          = new VisualizerController();
            Controller.Capacity = Capacity.GetValueOrDefault();

            var selectedIndex = GraphHelper.SelectIndexMember(elementVariable, IndexSelector, out Controller.IndexLabel);

            Controller.IndexType = selectedIndex.Type;
            if (selectedIndex.Type != typeof(double) && selectedIndex.Type != typeof(string))
            {
                selectedIndex = Expression.Convert(selectedIndex, typeof(double));
            }

            var selectedValues = GraphHelper.SelectDataValues(elementVariable, ValueSelector, out Controller.ValueLabels);
            var showBody       = Expression.Block(new[] { elementVariable },
                                                  Expression.Assign(elementVariable, Expression.Convert(valueParameter, parameterType)),
                                                  Expression.Call(viewParameter, nameof(RollingGraphVisualizer.AddValues), null, selectedIndex, selectedValues));

            Controller.AddValues = Expression.Lambda <Action <object, RollingGraphVisualizer> >(showBody, valueParameter, viewParameter).Compile();
            return(Expression.Call(typeof(RollingGraphBuilder), nameof(Process), new[] { parameterType }, source));
        }
Esempio n. 2
0
        public override Expression Build(IEnumerable <Expression> arguments)
        {
            var source          = arguments.First();
            var parameterType   = source.Type.GetGenericArguments()[0];
            var valueParameter  = Expression.Parameter(typeof(object));
            var viewParameter   = Expression.Parameter(typeof(RollingGraphView));
            var elementVariable = Expression.Variable(parameterType);

            Controller = new VisualizerController();

            Expression selectedX;
            var        selectorX = IndexSelector;

            if (!string.IsNullOrEmpty(selectorX))
            {
                selectedX             = ExpressionHelper.SelectMembers(elementVariable, selectorX).First();
                Controller.IndexLabel = selectorX;
            }
            else
            {
                selectedX             = Expression.Property(null, typeof(DateTime), "Now");
                Controller.IndexLabel = "Time";
            }

            if (selectedX.Type == typeof(DateTimeOffset))
            {
                selectedX = Expression.Property(selectedX, "DateTime");
            }
            if (selectedX.Type == typeof(DateTime))
            {
                selectedX = Expression.Convert(selectedX, typeof(ZedGraph.XDate));
            }
            Controller.IndexType = selectedX.Type;
            selectedX            = Expression.Convert(selectedX, typeof(double));

            Expression showBody;
            var        selectedMembers = ExpressionHelper.SelectMembers(elementVariable, ElementSelector)
                                         .SelectMany(GraphHelper.UnwrapMemberAccess)
                                         .Select(x => x.Type.IsArray ? x : Expression.Convert(x, typeof(object))).ToArray();

            if (selectedMembers.Length == 1 && selectedMembers[0].Type.IsArray)
            {
                var selectedValues = Expression.Convert(selectedMembers[0], typeof(Array));
                showBody = Expression.Block(new[] { elementVariable },
                                            Expression.Assign(elementVariable, Expression.Convert(valueParameter, parameterType)),
                                            Expression.Call(typeof(RollingGraphBuilder), "ShowArrayValues", null, viewParameter, selectedX, selectedValues));
            }
            else
            {
                var selectedValues = Expression.NewArrayInit(typeof(object), selectedMembers);
                showBody = Expression.Block(new[] { elementVariable },
                                            Expression.Assign(elementVariable, Expression.Convert(valueParameter, parameterType)),
                                            Expression.Call(viewParameter, "AddValues", null, selectedX, selectedValues));
            }

            Controller.NumSeries = selectedMembers.Length;
            Controller.Show      = Expression.Lambda <Action <object, RollingGraphView> >(showBody, valueParameter, viewParameter).Compile();
            return(Expression.Call(typeof(RollingGraphBuilder), "Process", new[] { parameterType }, source));
        }
Esempio n. 3
0
        public void Initialize(VisualizerController controller, VisualPayload payload)
        {
            payload.VisualData.Bound.ChildVisualizer(controller, this);

            //Bound.Data = payload.Data;  // discriminate this bound

            Payload = payload;
        }
Esempio n. 4
0
 public void ClearBoundVisualizer(VisualizerController controller)
 {
     if (BoundVisualizers.ContainsKey(controller))
     {
         BoundVisualizers[controller].DestroyVisualizer();
         BoundVisualizers.Remove(controller);
     }
 }
    public void StartVisualization(HashSet <MyVector2> points)
    {
        controller = GetComponent <VisualizerController>();

        StartCoroutine(RunVisualization(points));

        //Start by showing all points
        ShowPoints(points);
    }
    public void InitVisualization(HashSet <MyVector2> points)
    {
        controller = GetComponent <VisualizerController>();

        //VISUALIZE
        //Generate meshes for all points
        ShowAllPoints(points);

        StartCoroutine(RunAlgorithm(new List <MyVector2>(points)));
    }
Esempio n. 7
0
    //
    // For visualization when pressing Play button
    //

    private void Start()
    {
        GenerateTriangulation();


        //To access standardized methods for visualizations
        VisualizerController visualizerController = GetComponent <VisualizerController>();

        //Generate the meshes and materials once
        meshes = visualizerController.GenerateTriangulationMesh(triangulation, shouldUnNormalize: false);

        materials = visualizerController.GenerateRandomMaterials(meshes.Count);

        StartCoroutine(DisplayTriangleByTriangle(meshes));
    }
    public void StartVisualizer(HashSet <MyVector2> points, HalfEdgeData2 triangleData)
    {
        controller = GetComponent <VisualizerController>();

        //Step 1. Triangulate the points with some algorithm. The result is a convex triangulation
        HashSet <Triangle2> triangles = _TriangulatePoints.VisibleEdgesTriangulation(points);

        //HashSet<Triangle2> triangles = _TriangulatePoints.TriangleSplitting(points);

        //Step 2. Change the data structure from triangle to half-edge to make it easier to flip edges
        triangleData = _TransformBetweenDataStructures.Triangle2ToHalfEdge2(triangles, triangleData);

        //Generate the visual triangles
        controller.GenerateTriangulationMesh(triangleData);

        //Step 3. Flip edges until we have a delaunay triangulation
        StartCoroutine(FlipEdges(triangleData));
    }
Esempio n. 9
0
        public override Expression Build(IEnumerable <Expression> arguments)
        {
            var source          = arguments.First();
            var parameterType   = source.Type.GetGenericArguments()[0];
            var valueParameter  = Expression.Parameter(typeof(object));
            var viewParameter   = Expression.Parameter(typeof(LineGraphVisualizer));
            var elementVariable = Expression.Variable(parameterType);

            Controller            = new VisualizerController();
            Controller.Capacity   = Capacity.GetValueOrDefault();
            Controller.SymbolType = SymbolType;
            Controller.LineWidth  = LineWidth;

            var selectedValues = GraphHelper.SelectDataPoints(elementVariable, ValueSelector, out Controller.ValueLabels);
            var addValuesBody  = Expression.Block(new[] { elementVariable },
                                                  Expression.Assign(elementVariable, Expression.Convert(valueParameter, parameterType)),
                                                  Expression.Call(viewParameter, nameof(LineGraphVisualizer.AddValues), null, selectedValues));

            Controller.AddValues = Expression.Lambda <Action <object, LineGraphVisualizer> >(addValuesBody, valueParameter, viewParameter).Compile();
            return(Expression.Call(typeof(LineGraphBuilder), nameof(Process), new[] { parameterType }, source));
        }
    public void StartVisualizer(HashSet <MyVector2> points, HalfEdgeData2 triangulationData)
    {
        controller = GetComponent <VisualizerController>();


        //Step 3. Establish the supertriangle
        //The report says that the supertriangle should be at (-100, 100) which is way
        //outside of the points which are in the range(0, 1)
        Triangle2 superTriangle = new Triangle2(new MyVector2(-100f, -100f), new MyVector2(100f, -100f), new MyVector2(0f, 100f));

        //Create the triangulation data with the only triangle we have
        HashSet <Triangle2> triangles = new HashSet <Triangle2>();

        triangles.Add(superTriangle);

        //Change to half-edge data structure
        _TransformBetweenDataStructures.Triangle2ToHalfEdge2(triangles, triangulationData);



        //Start the visualization
        StartCoroutine(InsertPoints(points, triangulationData, superTriangle));
    }
Esempio n. 11
0
 public void SetBoundVisualizer(VisualizerController controller, Visualizer visualizer)
 {
     BoundVisualizers[controller] = visualizer;
 }
Esempio n. 12
0
        // TODO: THis can all go away!

        public void ChildVisualizer(VisualizerController controller, Visualizer visualizer)
        {
            //ClearBoundVisualizer(controller);
            SetBoundVisualizer(controller, visualizer);
            ChildWithinBound(visualizer.transform);
        }