Beispiel #1
0
    void Start()
    {
        var cellPos = Vector <double> .Build.DenseOfArray(new double [] { 0, 0, 0 });

        var circlePos = Vector <double> .Build.DenseOfArray(new double [] { 2.5, 2.5, 2.5 });

        surface = new CircleSurface(2.4, circlePos, 0.01);
        cell    = Cell.Create(cellPos, size, surface, maxLevel);
        cell.EnumerateEdges((Cell[] edge, int dimensionMap) => {
            var a = edge[0].pointIndexToWorldPos(dimensionMap);
            var b = edge[0].pointIndexToWorldPos((int)Math.Pow(2, 3) - 1);

            var point = getEdgePoint(a, b, edge[0].getPoint(dimensionMap), edge[0].getPoint((int)Math.Pow(2, 3) - 1));
            var n     = surface.sampleDerivative(point);

            Debug.DrawRay(MakeUnityVector.GetVector(point), MakeUnityVector.GetVector(n), Color.red, 1000);
            Debug.DrawLine(MakeUnityVector.GetVector(a), MakeUnityVector.GetVector(b), Color.white, 1000);

            foreach (Cell cell in edge)
            {
                //cell.addEdge(point, n);
            }
        });

        /* cell.ForEach((Cell Cell) => {
         *      cell.SolveQEF();
         * }); */
        /* cell.EnumerateEdges((Cell[] edge, int dimensionMap) => {
         *      for(int i = 0; i < edge.Length; i++) {
         *              var a = edge[i].Point;
         *              var b = edge[(i + 1)%4].Point;
         *
         *              if(a == null || b == null) continue;
         *
         *              var A = MakeUnityVector.GetVector(a);
         *              var B = MakeUnityVector.GetVector(b);
         *
         *              //Debug.DrawLine(A, B, Color.black, 1000);
         *      }
         * }); */
    }
Beispiel #2
0
        private void ChartToCreate(String item)
        {
            List <String[]> originalData = ChartData();

            String[] dataPicker = new String[originalData.Count];

            for (int i = 0; i < originalData.Count; i++)
            {
                dataPicker[i] = originalData[i][1];
            }
            _customChart.ChartView.Chart.Series.RemoveAllSeries();

            var imageButton = ((((this.Children[0] as ContentPage).Content as ScrollView).Content as StackLayout).Children[1] as Grid).Children[2] as Button;

            switch (item)
            {
            case "AREA":
                Area area = new Area();
                area.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(area);
                _customChart.ImageSource = dataPicker[0];
                imageButton.ImageSource  = dataPicker[0];

                break;

                    #if !TEE_STD
            case "ARROW":
                Arrow arrow = new Arrow();
                arrow.FillSampleValues(10);
                _customChart.ChartView.Chart.Series.Add(arrow);
                _customChart.ImageSource = dataPicker[1];
                imageButton.ImageSource  = dataPicker[1];
                break;
#endif

            case "BAR":
                Bar bar = new Bar();
                bar.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(bar);
                _customChart.ImageSource = dataPicker[2];
                imageButton.ImageSource  = dataPicker[2];
                break;

                    #if !TEE_STD
            case "BARJOIN":
                BarJoin barjoin = new BarJoin();
                barjoin.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(barjoin);
                _customChart.ImageSource = dataPicker[3];
                imageButton.ImageSource  = dataPicker[3];
                break;

            case "BEZIER":
                Bezier bezier = new Bezier();
                bezier.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(bezier);
                _customChart.ImageSource = dataPicker[4];
                imageButton.ImageSource  = dataPicker[4];
                break;

            case "BOX":
                Box box = new Box();
                box.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(box);
                _customChart.ImageSource = dataPicker[5];
                imageButton.ImageSource  = dataPicker[5];
                break;
#endif
            case "BUBBLES":
                Bubble bubble = new Bubble();
                bubble.FillSampleValues(7);
                _customChart.ChartView.Chart.Series.Add(bubble);
                _customChart.ImageSource = dataPicker[6];
                imageButton.ImageSource  = dataPicker[6];
                break;

                    #if !TEE_STD
            case "CANDLE":
                Candle candle = new Candle();
                candle.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(candle);
                _customChart.ImageSource = dataPicker[7];
                imageButton.ImageSource  = dataPicker[7];
                break;

            case "CONTOUR":
                Contour countour = new Contour();
                countour.FillSampleValues(1);
                _customChart.ChartView.Chart.Series.Add(countour);
                _customChart.ImageSource = dataPicker[8];
                imageButton.ImageSource  = dataPicker[8];
                break;

            case "DARVAS":
                Darvas darvas = new Darvas();
                darvas.FillSampleValues(3);
                _customChart.ChartView.Chart.Series.Add(darvas);
                _customChart.ImageSource = dataPicker[9];
                imageButton.ImageSource  = dataPicker[9];
                break;
#endif
            case "DONUT":
                Donut donut = new Donut();
                donut.FillSampleValues(1);
                _customChart.ChartView.Chart.Series.Add(donut);
                _customChart.ImageSource = dataPicker[10];
                imageButton.ImageSource  = dataPicker[10];
                break;

                    #if !TEE_STD
            case "ERROR":
                Error error = new Error();
                error.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(error);
                _customChart.ImageSource = dataPicker[11];
                imageButton.ImageSource  = dataPicker[11];
                break;

            case "ERRORBAR":
                ErrorBar errorbar = new ErrorBar();
                errorbar.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(errorbar);
                _customChart.ImageSource = dataPicker[12];
                imageButton.ImageSource  = dataPicker[12];
                break;

            case "ERRORPOINT":
                ErrorPoint errorPoint = new ErrorPoint();
                errorPoint.FillSampleValues(7);
                _customChart.ChartView.Chart.Series.Add(errorPoint);
                _customChart.ImageSource = dataPicker[13];
                imageButton.ImageSource  = dataPicker[13];
                break;
#endif
            case "FASTLINE":
                FastLine fastLine = new FastLine();
                fastLine.FillSampleValues(2);
                _customChart.ChartView.Chart.Series.Add(fastLine);
                _customChart.ImageSource = dataPicker[14];
                imageButton.ImageSource  = dataPicker[14];
                break;

                    #if !TEE_STD
            case "HIGHLOW":
                HighLow highLow = new HighLow();
                highLow.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(highLow);
                _customChart.ImageSource = dataPicker[15];
                imageButton.ImageSource  = dataPicker[15];
                break;

            case "HISTOGRAM":
                Histogram histogram = new Histogram();
                histogram.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(histogram);
                _customChart.ImageSource = dataPicker[16];
                imageButton.ImageSource  = dataPicker[16];
                break;
#endif
            case "HORIZAREA":
                HorizArea horizArea = new HorizArea();
                horizArea.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizArea);
                _customChart.ImageSource = dataPicker[17];
                imageButton.ImageSource  = dataPicker[17];
                break;

            case "HORIZBAR":
                HorizBar horizBar = new HorizBar();
                horizBar.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizBar);
                _customChart.ImageSource = dataPicker[18];
                imageButton.ImageSource  = dataPicker[18];
                break;

            case "HORIZLINE":
                HorizLine horizLine = new HorizLine();
                horizLine.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(horizLine);
                _customChart.ImageSource = dataPicker[19];
                imageButton.ImageSource  = dataPicker[19];
                break;

                    #if !TEE_STD
            case "ISOSURFACE":
                IsoSurface isoSurface = new IsoSurface();
                isoSurface.FillSampleValues(10);
                _customChart.ChartView.Chart.Series.Add(isoSurface);
                _customChart.ImageSource = dataPicker[20];
                imageButton.ImageSource  = dataPicker[20];
                break;
#endif
            case "LINE":
                Line line = new Line();
                line.FillSampleValues(5);
                _customChart.ChartView.Chart.Series.Add(line);
                _customChart.ImageSource = dataPicker[21];
                imageButton.ImageSource  = dataPicker[21];
                break;

#if !TEE_STD
            case "LINEPOINT":
                LinePoint linePoint = new LinePoint();
                linePoint.FillSampleValues(6);
                _customChart.ChartView.Chart.Series.Add(linePoint);
                _customChart.ImageSource = dataPicker[22];
                imageButton.ImageSource  = dataPicker[22];
                break;
#endif
            case "PIE":
                Pie pie = new Pie();
                pie.FillSampleValues(4);
                _customChart.ChartView.Chart.Series.Add(pie);
                _customChart.ImageSource = dataPicker[23];
                imageButton.ImageSource  = dataPicker[23];
                break;

#if !TEE_STD
            case "SURFACE":
                Surface surface = new Surface();
                surface.FillSampleValues(10);
                //surface.
                _customChart.ChartView.Chart.Series.Add(surface);
                _customChart.ImageSource = dataPicker[24];
                imageButton.ImageSource  = dataPicker[24];
                break;

            case "TOWER":
                Tower tower = new Tower();
                tower.FillSampleValues(8);
                _customChart.ChartView.Chart.Series.Add(tower);
                _customChart.ImageSource = dataPicker[25];
                imageButton.ImageSource  = dataPicker[25];
                break;

            case "VOLUME":
                Volume volume = new Volume();
                volume.FillSampleValues(9);
                _customChart.ChartView.Chart.Series.Add(volume);
                _customChart.ImageSource = dataPicker[26];
                imageButton.ImageSource  = dataPicker[26];
                break;
#endif
            }

            _customChart.ChartView.Chart.Axes.Left.Automatic   = true;
            _customChart.ChartView.Chart.Axes.Bottom.Automatic = true;
        }
Beispiel #3
0
        public static List <IsoSurface> CalculateIsoSurface(this Mesh self, double numberOfSurfaces, int dataIndex)
        {
            double minOfData = self.GetMinimumBounds(dataIndex);
            double maxOfData = self.GetMaximumBounds(dataIndex);

            double            interval    = Mathf.SliceInterval(numberOfSurfaces, minOfData, maxOfData);
            List <IsoSurface> meshSurface = new List <IsoSurface>();

            if (interval == 0)
            {
                return(meshSurface);
            }

            for (double isoValue = minOfData + interval / 2; isoValue <= maxOfData; isoValue += interval)
            {
                IsoSurface finalSurface = new IsoSurface();
                foreach (Zone zone in self.Zones)
                {
                    foreach (Element element in zone.Elements)
                    {
                        double[] dataArray = new double[8];

                        for (int index = 0; index < element.VertInOrder.Length; index++)
                        {
                            uint vertex = element.VertInOrder[index];

                            dataArray[index] = (zone.Vertices[vertex].Data[dataIndex]);
                        }
                        byte caseNumber = ISOSurface.GetElementCase(dataArray, isoValue);

                        int[] caseEdges = ISOSurface.GetCaseEdges(caseNumber);
                        for (int i = 0; i < caseEdges.Length - 1; i += 3)
                        {
                            if (caseEdges[i] != -1 && caseEdges[i + 1] != -1 && caseEdges[i + 2] != -1)
                            {
                                Edge   firstEdge           = ISOSurface.GetEdgePoints(caseEdges[i]);
                                Point3 firstEdgeFinalPoint = firstEdge.GetIsoValuePoint(zone, element, isoValue,
                                                                                        dataIndex);

                                Edge   secondEdge           = ISOSurface.GetEdgePoints(caseEdges[i + 1]);
                                Point3 secondEdgeFinalPoint = secondEdge.GetIsoValuePoint(zone, element, isoValue,
                                                                                          dataIndex);

                                Edge   thirdEdge           = ISOSurface.GetEdgePoints(caseEdges[i + 2]);
                                Point3 thirdEdgeFinalPoint = thirdEdge.GetIsoValuePoint(zone, element, isoValue,
                                                                                        dataIndex);

                                IsoTriangle resultTriangle = new IsoTriangle(firstEdgeFinalPoint, secondEdgeFinalPoint,
                                                                             thirdEdgeFinalPoint)
                                {
                                    Color = ColorUtility.CalculateColor(isoValue, minOfData, maxOfData)
                                };

                                finalSurface.AddTriangle(resultTriangle);
                            }
                        }
                    }
                }
                meshSurface.Add(finalSurface);
            }
            return(meshSurface);
        }
Beispiel #4
0
    Cell(double originalSize, int level, int maxLevel, Vector <double> pos, IsoSurface surface, Cell parent)
    {
        this.originalSize = originalSize;
        this.level        = level;
        this.maxLevel     = maxLevel;
        this.pos          = pos;
        this.parent       = parent;

        size = originalSize / Math.Pow(2, level);

        points = new double[(int)Math.Pow(2, pos.Count)];

        int sign = 0;

        for (int i = 0; i < points.Length; i++)
        {
            var vector = posToVector(pointIndexToPos(i));
            points[i] = surface.sample(pos + vector);

            if (signed)
            {
                continue;
            }

            int thisSign = Math.Sign(points[i]);
            if (sign == 0)
            {
                sign = thisSign;
            }

            if (sign != thisSign)
            {
                setSigned();
            }

            sign = thisSign;
        }

        if (!signed)
        {
            if (parent != null)
            {
                if (parent.signed)
                {
                    return;
                }
            }
        }

        if (level == maxLevel)
        {
        }
        else
        {
            children = new Cell[points.Length];
            for (int i = 0; i < children.Length; i++)
            {
                var vector = posToVector(pointIndexToPos(i)) * 0.5;
                children[i] = new Cell(originalSize, level + 1, maxLevel, pos + vector, surface, this);
            }
        }
    }
Beispiel #5
0
 public static Cell Create(Vector <double> pos, double size, IsoSurface surface, int maxLevel)
 {
     return(new Cell(size, 1, maxLevel, pos, surface, null));
 }