示例#1
0
    internal virtual void SetBoundingBuffer(int index, IClusterObject obj, Matrix4x4 objTransMatrix, Transform root)
    {
        //Set cullBound
        Vector3 rootscale = root.lossyScale;

        renderCache.BoundingBuffer[index].position = new Vector3(objTransMatrix.m03, objTransMatrix.m13, objTransMatrix.m23) + obj.BoundOffset;
        //ignore gc
        float max = (rootscale.x * obj.LocalScale.x > rootscale.y * obj.LocalScale.y) ? rootscale.x * obj.LocalScale.x : rootscale.y * obj.LocalScale.y;

        renderCache.BoundingBuffer[index].radius = max * obj.BoundScale;
    }
示例#2
0
    /// <summary>
    /// override special object transform
    /// </summary>
    /// <param name="overrideObject"></param>
    /// <param name="root"></param>
    public virtual void ApplyOverrideTransform(int index, IClusterObject overrideObject, Transform root)
    {
        if (renderCache == null || renderCache.Count == 0)
        {
            return;
        }
        var objtrans = Matrix4x4.TRS(root.position, root.rotation, root.lossyScale) * Matrix4x4.TRS(overrideObject.LocalPostion, Quaternion.Euler(overrideObject.LocalRotation), overrideObject.LocalScale);

        SetBoundingBuffer(index, overrideObject, objtrans, root);
        renderCache.TRSmatrices.All[index] = objtrans;
    }
示例#3
0
        /// <summary>
        /// This method draws the centerlines/medians of the clusters. The more of the cluster streamlines are contained in the cluster, the thicker the median gets plotted.
        /// </summary>
        /// <param name="centerLines">A double array of the center lines of the clusters handed by matlab</param>
        /// <param name="percentCluster">The array contaning a percentage value for each cluster saying, how many of the clustered streamlines lie within the cluster</param>
        /// <param name="clusterObject">The object for the clustering (vectorfield, travel)</param>
        private void drawCenterLines(double[,] centerLines, double[] percentCluster, IClusterObject clusterObject)
        {
            List <Line>     cenLines        = Util.getLines(centerLines);
            List <Line>     transfCenLinse  = clusterObject.transformLines(cenLines);
            List <Polyline> polyCenterLines = Util.getPolyLinesWithPercentage(transfCenLinse, percentCluster, true);

            foreach (Polyline polCenter in polyCenterLines)
            {
                centerCanvas.Children.Add(polCenter);
                Canvas.SetTop(polCenter, 0);
                Canvas.SetLeft(polCenter, 0);
            }
        }
示例#4
0
        /// <summary>
        /// This method executes matlab codes and sets parameters for the clustering and starts the matlab script calculateVariabilityLines;
        /// </summary>
        /// <param name="clusterObject">The object for the clustering (vectorfield, travel)</param>
        private void executeMatlab(IClusterObject clusterObject)
        {
            clusterObject.executeMatlab(matlab);

            matlab.Execute("numBasis = " + numBasis + ";");
            matlab.Execute("numSamples = " + numSamples + ";");
            matlab.Execute("numClusters = " + numClusters + ";");
            matlab.Execute("splatSize = " + sizeSplats + ";");

            matlab.Execute(("convInter = " + conf + ";").Replace(',', '.'));
            matlab.Execute(("boundCoeff = " + boundaryCoeff + ";").Replace(',', '.'));

            matlab.Execute("calculateVariabilityLinesPar");
        }
示例#5
0
        /// <summary>
        /// This method calls the matlab code, hands over the data to matlab and stores the results. Afterwards the
        /// clusters and the centerlines/medians are plotted and the rectangles for the stackpanel showing, how many of
        /// the clustered streamlines are contained in the respective cluster.
        /// </summary>
        /// <param name="clusterObject">The object for the clustering (vectorfield, travel)</param>
        private void cluster(IClusterObject clusterObject)
        {
            clearClusterCanvas();

            lineCanvas.Children.Clear();
            barPanel.Children.Clear();

            executeMatlab(clusterObject);

            double[,] centerLines      = matlab.GetVariable("reconCenterLines", "base");
            double[,] percentCluster2D = matlab.GetVariable("percentCluster", "base");
            double[] percentCluster = Util.Make1Dimensional(percentCluster2D);

            drawClusters(percentCluster, clusterObject);

            drawCenterLines(centerLines, percentCluster, clusterObject);

            addRects(Util.getRects(numClusters, percentCluster, barPanel.ActualWidth, barPanel.ActualHeight));
        }
示例#6
0
        /// <summary>
        /// This method plotts the lines of each cluster in the respective transparent color.
        /// </summary>
        /// <param name="percentCluster">The array contaning a percentage value for each cluster saying, how many of the clustered streamlines lie within the cluster</param>
        /// <param name="clusterObject">The object for the clustering (vectorfield, travel)</param>
        private void drawClusters(double[] percentCluster, IClusterObject clusterObject)
        {
            for (int i = 1; i <= numClusters; i++)
            {
                double[,] clusterBoundary = matlab.GetVariable("boundary" + i, "base");

                List <Line> boundaryLine = Util.getLines(clusterBoundary);
                boundaryLine = clusterObject.transformLines(boundaryLine);

                Color color = Color.FromArgb(125,
                                             Util.colors[i - 1, 0],
                                             Util.colors[i - 1, 1],
                                             Util.colors[i - 1, 2]);

                List <Polyline> polyLines = Util.getPolyLines(boundaryLine, color, 2);
                polyLines.First().Fill    = new SolidColorBrush(color);

                clusterCanvas[i - 1].Children.Add(polyLines.First());
                Canvas.SetTop(polyLines.First(), 0);
                Canvas.SetLeft(polyLines.First(), 0);
            }
        }