Ejemplo n.º 1
0
        /// <summary>
        /// Draws the clusters.
        /// </summary>
        //private void panelCanvas_Paint(object sender, PaintEventArgs e)
        //{
        //    // constants defining drawing properties
        //    Pen penVertex = Pens.Blue;          // vertex color
        //    Pen penDifference = Pens.Black;
        //    Pen penLine = Pens.Blue;            // line color
        //    Brush brushFacility = Brushes.Red;  // facility color
        //    const float vertexRadius = 2.0f;    // vertex radius
        //    const float facilityRadius = 3.5f;  // facility radius

        //    int colorIndex = -1;
        //    KnownColor[] values = (KnownColor[])Enum.GetValues(typeof(KnownColor));

        //    bool drawXYplane = true;
        //    bool drawSpheres = false;

        //    // prepare a canvas to draw
        //    System.Drawing.Graphics gr = e.Graphics;
        //    gr.Clear(Color.White);
        //    // get panel (canvas) dimensions
        //    int width = e.ClipRectangle.Width;
        //    int height = e.ClipRectangle.Height;

        //    // compute scaling
        //    float scaleX = (float)width / (float)bBox.Width;
        //    float scaleY = (float)height / (float)bBox.Height;
        //    //float scaleZ = (float)height / (float)bBox.Depth;
        //    float scale = Math.Min(scaleX, scaleY) * 0.9f;
        //    //float scale = scaleX < scaleY ? scaleX : scaleY;
        //    //float scale = scaleX < scaleZ ? scaleX : scaleZ;
        //    float minX = (float)bBox.MinX - (float)bBox.Width * 0.05f;
        //    float minY = (float)bBox.MinY - (float)bBox.Height * 0.05f;
        //    //float minZ = (float)bBox.MinZ;
        //    float minYZ = minY;

        //    // font for writing vertex numbers etc.
        //    Font font = new Font(FontFamily.GenericSansSerif, 10);

        //    // check we have something to draw
        //    if (vertices == null)
        //        return;

        //    if ( showClusterGroups )
        //    {
        //        Brush fill = Brushes.LawnGreen;
        //        Pen pen = Pens.Black;

        //        //foreach (List<Vertex> convex in convexHull)
        //        //{
        //        //    PointF[] poly = new PointF[convex.Count];

        //        //    for (int i = 0; i < convex.Count; ++i)
        //        //    {
        //        //        Vertex v = convex[i];

        //        //        float vx = ((float)v.X - minX) * scale;
        //        //        float vy = height - ((float)(drawXYplane ? v.Y : v.Z) - minYZ) * scale;

        //        //        poly[i] = new PointF(vx, vy);
        //        //    }

        //        //    // gr.FillPolygon(fill, poly);
        //        //    gr.DrawPolygon(pen, poly);
        //        //}

        //        foreach (Facility f in facilities)
        //        {
        //            float fx = ((float)f.Coords[0] - minX) * scale;
        //            float fy = height - ((float)(drawXYplane ? f.Coords[1] : f.Coords[2]) - minYZ) * scale;

        //            // draw lines to facility vertices
        //            foreach (int vertexIndex in f.VertexIndices)
        //            {
        //                // get the vertex position
        //                Vertex vertPos = vertices[vertexIndex];
        //                float vx = ((float)vertPos.X - minX) * scale;
        //                float vy = height - ((float)(drawXYplane ? vertPos.Y : vertPos.Z) - minYZ) * scale;

        //                //float dx = ((float)vertPos[2]) * SCALE_DIFFERENCE;
        //                // float dy = ((float)vertPos[3]) * SCALE_DIFFERENCE;

        //                // check radius
        //                //if (vertPos.WeightedDistToFac > radius)
        //                //    radius = (float)vertPos.WeightedDistToFac;

        //                // draw line to the vertex
        //                gr.DrawLine(penLine, fx, fy, vx, vy);
        //                // draw the vertex
        //                gr.DrawEllipse(penVertex, vx - vertexRadius, vy - vertexRadius, 2 * vertexRadius, 2 * vertexRadius);

        //                // draw difference
        //                //gr.DrawLine(penDifference, vx - vertexRadius, vy - vertexRadius, vx - vertexRadius + dx, vy - vertexRadius + dy);

        //                // draw facility index
        //                //gr.DrawString(i.ToString(), font, Brushes.Black, vx, vy);
        //                // draw vertex index
        //                //gr.DrawString(vertexIndex.ToString(), font, Brushes.Black, vx, vy);
        //            }

        //            ++colorIndex;
        //            if (colorIndex >= brushes.Count)
        //            {
        //                colorIndex = 0;
        //            }

        //            gr.FillEllipse(brushes[colorIndex], fx - vertexRadius, fy - vertexRadius, 2 * vertexRadius, 2 * vertexRadius);
        //        }

        //    } else {

        //        // draw facilities with connected vertices
        //        for (int i = 0; i < vertices.Length; i++)
        //        {
        //            // draw bounding box information
        //            //string boxInfo = string.Format("{0:0.##}-{1:0.##}", facPos.bbox.MinX, facPos.bbox.MaxX);
        //            //gr.DrawString(boxInfo, font, Brushes.Black, fx, fy);

        //            Vertex vertex = vertices[i];

        //            if (showPoints)
        //            {
        //                // get the vertex position
        //                float vx = ((float)vertex.X - minX) * scale;
        //                float vy = height - ((float)(drawXYplane ? vertex.Y : vertex.Z) - minYZ) * scale;

        //                //float dx = ((float)vertex[2]) * SCALE_DIFFERENCE;
        //                //float dy = ((float)vertex[3]) * SCALE_DIFFERENCE;

        //                // draw the vertex
        //                gr.DrawEllipse(penVertex, vx - vertexRadius, vy - vertexRadius, 2 * vertexRadius, 2 * vertexRadius);

        //                // draw difference
        //                // gr.DrawLine(penDifference, vx - vertexRadius, vy - vertexRadius, vx - vertexRadius + dx, vy - vertexRadius + dy);
        //            }
        //            else if (vertex.IsFacility)
        //            {
        //                // get the facility position
        //                float fx = ((float)vertex.X - minX) * scale;
        //                float fy = height - ((float)(drawXYplane ? vertex.Y : vertex.Z) - minYZ) * scale;

        //                float radius = 0;

        //                // draw lines to facility vertices
        //                foreach (int vertexIndex in vertices[i].Facility.VertexIndices)
        //                {
        //                    // get the vertex position
        //                    Vertex vertPos = vertices[vertexIndex];
        //                    float vx = ((float)vertPos.X - minX) * scale;
        //                    float vy = height - ((float)(drawXYplane ? vertPos.Y : vertPos.Z) - minYZ) * scale;

        //                    //float dx = ((float)vertPos[2]) * SCALE_DIFFERENCE;
        //                    // float dy = ((float)vertPos[3]) * SCALE_DIFFERENCE;

        //                    // check radius
        //                    //if (vertPos.WeightedDistToFac > radius)
        //                    //    radius = (float)vertPos.WeightedDistToFac;

        //                    // draw line to the vertex
        //                    gr.DrawLine(penLine, fx, fy, vx, vy);
        //                    // draw the vertex
        //                    //gr.DrawEllipse(penVertex, vx - vertexRadius, vy - vertexRadius, 2 * vertexRadius, 2 * vertexRadius);

        //                    // draw difference
        //                    //gr.DrawLine(penDifference, vx - vertexRadius, vy - vertexRadius, vx - vertexRadius + dx, vy - vertexRadius + dy);

        //                    // draw facility index
        //                    //gr.DrawString(i.ToString(), font, Brushes.Black, vx, vy);
        //                    // draw vertex index
        //                    //gr.DrawString(vertexIndex.ToString(), font, Brushes.Black, vx, vy);
        //                }

        //                // draw the facility
        //                gr.FillEllipse(brushFacility, fx - facilityRadius, fy - facilityRadius,
        //                    2 * facilityRadius, 2 * facilityRadius);
        //                //gr.DrawString(facPos.facility.vertexIndex.ToString(), font, Brushes.Black, fx, fy);
        //                //gr.DrawString(radius.ToString(), font, Brushes.Magenta, fx, fy);

        //                if (drawSpheres)
        //                {
        //                    // draw the bounding sphere
        //                    radius *= scale;
        //                    gr.DrawEllipse(Pens.Black, fx - radius, fy - radius, 2 * radius, 2 * radius);
        //                }
        //            }
        //        }
        //    }

        //    font.Dispose();
        //}

        private void Main_Load_Click(object sender, EventArgs e)
        {
            if (Dialog_OpenFile.ShowDialog() == DialogResult.OK)
            {
                ClusterEngine.LoadData(Dialog_OpenFile.FileName);
                // bBox.AddVertices(vertices);

                // enable UI components
                showPoints                 = true;
                Menu_Cluster.Enabled       = true;
                Menu_ClusterSolver.Enabled = true;
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            ClusterEngine.LoadData(@"D:\__gDrive\__PHD\Input\PointCloud\Geo_Normals_Curveture_TRIANGLE\BILO59_5g\05CSMEstimator.txt");

            ClusterEngine.Cluster(@"D:\__gDrive\__PHD\Output\ArtefactDetection\Clustering_MeanShift\MeshLab\f005.xyz", 0.05, 0.05);
        }