Ejemplo n.º 1
0
        //------------------------------------------------------------------------------
        public void SimpleModelData(string[] surfacedata5)
        {
            surfacedata5[0] = "Models " + _Models.Count;

            int cyl = 0, sph = 0, ple = 0, cne = 0;

            foreach (ModelBase m1 in _Models)
            {
                if (m1.type() == ModelCylinder.stype())
                {
                    cyl++;
                }
                else if (m1.type() == ModelSphere.stype())
                {
                    sph++;
                }
                else if (m1.type() == ModelCone.stype())
                {
                    cne++;
                }
                else if (m1.type() == ModelPlane.stype())
                {
                    ple++;
                }
            }

            surfacedata5[1] = ModelPlane.stype() + ":" + ple;
            surfacedata5[2] = ModelSphere.stype() + ":" + sph;
            surfacedata5[3] = ModelCylinder.stype() + ":" + cyl;
            surfacedata5[4] = ModelCone.stype() + ":" + cne;
        }
Ejemplo n.º 2
0
        //------------------------------------------------------------------------------
        public void ModelData(out string[] surfacedata, ref int id)
        {
            ModelBase m = null;

            m = getModelID(id);
            if (m != null)
            {
                m.ModelData(out surfacedata);
                id = m.ID;
            }
            else
            {
                surfacedata    = new string[5];
                surfacedata[0] = "Models " + _Models.Count;

                int cyl = 0, sph = 0, ple = 0, cne = 0;
                foreach (ModelBase m1 in _Models)
                {
                    if (m1.type() == ModelCylinder.stype())
                    {
                        cyl++;
                    }
                    else if (m1.type() == ModelSphere.stype())
                    {
                        sph++;
                    }
                    else if (m1.type() == ModelCone.stype())
                    {
                        cne++;
                    }
                    else if (m1.type() == ModelPlane.stype())
                    {
                        ple++;
                    }
                }

                surfacedata[1] = ModelPlane.stype() + ":" + ple;
                surfacedata[2] = ModelSphere.stype() + ":" + sph;
                surfacedata[3] = ModelCylinder.stype() + ":" + cyl;
                surfacedata[4] = ModelCone.stype() + ":" + cne;
                id             = 0;
            }
        }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------------
        void Segment(ref List <Surface> SC, ref List <ModelBase> m)
        {
            if (leafCount > SurfaceController._MINNODESURF)
            {
                int trails = 1;

                ModelBase[] candidateLst = new ModelBase[4];
                ModelBase   TopModel     = null;

                int    nm      = 0; // number of models under test
                int    topsz   = 0;
                int    topflag = 0;
                int[]  contiq;
                int    topValidCount = 0;
                double prob          = 0.0d;

                while (
                    (prob < SurfaceController._RANSACPROB) &&
                    (Surface.RansacPEqN(trails, leafCount) < SurfaceController._RANSACPROB) &&
                    (trails < SurfaceController._RANSACPNUM)
                    )
                {
                    Vectors[] pts  = new Vectors[SurfaceController._MSSETSIZE];
                    Vectors[] ptsN = new Vectors[SurfaceController._MSSETSIZE];
                    for (int i = 0; i < SurfaceController._MSSETSIZE; i++)
                    {
                        int k = C.CONST.iRANDOM(0, leafCount - 1);
                        pts[i]  = _leafs[k].Sigma;
                        ptsN[i] = _leafs[k].Norm;
                    }

                    candidateLst[0] = new ModelPlane(pts, ptsN);
                    //candidateLst[0].Initialize() ;
                    if (candidateLst[0].Initialize())
                    {
                        // plane could fit the  data
                        nm++;
                    }
                    if (nm == 0)
                    {
                        // create other canidates
                        candidateLst[nm] = new ModelCylinder(pts, ptsN);
                        if (candidateLst[nm].Initialize())
                        {
                            nm++;
                        }
                        candidateLst[nm] = new ModelCone(pts, ptsN);
                        if (candidateLst[nm].Initialize())
                        {
                            nm++;
                        }
                        candidateLst[nm] = new ModelSphere(pts, ptsN);
                        if (candidateLst[nm].Initialize())
                        {
                            nm++;
                        }
                    }

                    // test models
                    while (nm > 0)
                    {
                        nm--;
                        int ValidCount = candidateLst[nm].Eval(_leafs);
                        if (ValidCount > SurfaceController._MINNODESURF)
                        {
                            if (ValidCount > topsz)
                            {
                                candidateLst[nm].refine(_leafs, true);
                                ValidCount = candidateLst[nm].Eval(_leafs);
                                FlagSubset(out contiq, null);
                                if (contiq[contiq[0]] > topsz)
                                {
                                    topValidCount = ValidCount;
                                    TopModel      = candidateLst[nm];
                                    topflag       = contiq[0];
                                    topsz         = contiq[topflag];
                                }
                            } //if ValidCount>topsz
                        }
                    }         //while nm > 0



                    trails++;

                    if (TopModel != null)
                    {
                        prob = TopModel.probabillity4(trails, topsz, topValidCount, this._leafs.Count);
                    }
                }// while nm > 0

                if (TopModel != null)
                {
                    // recompute largest subset
                    TopModel.Eval(Leafs);

                    FlagSubset(out contiq, null);
                    int flag = contiq[0];

                    split(flag, ref SC);

                    TopModel.refine(Leafs, false);
                    m.Add(TopModel);
                } // if TopModel
            }     // if leafscount> minsurf
        }