private void InitializeRigidParameterMap()
        {
            if (RegistrationParametersRigid.ParamMapToUse == null)
            {
                using (RigidRegistration reg = new RigidRegistration(RegistrationParametersRigid))
                {
                    RegistrationParametersRigid.ParamMapToUse = reg.GetParameterMap();
                }

                if (RegistrationParametersRigid.ParamMapToUse == null)
                {
                    RegistrationParametersRigid.ParamMapToUse = RegistrationUtils.GetDefaultParameterMap(RegistrationParametersRigid.RegistrationDefaultParams);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Starts a nonrigid registration.
        /// </summary>
        /// <param name="sender">The sender of an event.</param>
        /// <param name="e">Event arguments.</param>
        private void toolsRegistrationNonrigidMenuItem_Click(object sender, EventArgs e)
        {
            NonrigidSettingsForm nonrigidSettingsForm = new NonrigidSettingsForm(this.model3DBean.ModelListBean);

            nonrigidSettingsForm.ShowDialog(this);

            if (nonrigidSettingsForm.DialogResult == DialogResult.OK)
            {
                this.statusProgressBar.Visible = true;
                this.statusLabel.Text          = "Registration task is in progress.";

                for (int i = 0; i < nonrigidSettingsForm.SourceModels.Count; i++)
                {
                    for (int j = 0; j < nonrigidSettingsForm.TargetModels.Count; j++)
                    {
                        BackgroundWorker worker = new BackgroundWorker();
                        worker.RunWorkerCompleted += this.ReportTaskCompleted;
                        worker.DoWork             += (obj, args) =>
                        {
                            NonrigidArgs nonrigidArgs = (NonrigidArgs)args.Argument;

                            FileReader  fileReader  = new FileReader();
                            Model3DData sourceModel = fileReader.ReadModel(nonrigidArgs.SourceModel.EditPath);
                            Model3DData targetModel = fileReader.ReadModel(nonrigidArgs.TargetModel.EditPath);

                            List <Vector <float> > sourceVertexBuffer = sourceModel.GetVertices();
                            List <Vector <float> > targetVertexBuffer = targetModel.GetVertices();

                            RigidRegistration    rigidRegistration    = new RigidRegistration(new KdTreeMapping(), nonrigidArgs.NumberOfIterations);
                            NonrigidRegistration nonrigidRegistration = new NonrigidRegistration(rigidRegistration);
                            sourceVertexBuffer = nonrigidRegistration.ComputeRegistration(sourceVertexBuffer, targetVertexBuffer);

                            sourceModel.SetVertices(sourceVertexBuffer);
                            ObjFileWriter fileWriter = new ObjFileWriter(nonrigidArgs.SourceModel.EditPath);
                            fileWriter.WriteModel(sourceModel.Model);
                            fileWriter.Close();

                            nonrigidArgs.SourceModel.Changed  = true;
                            nonrigidArgs.SourceModel.Exported = false;
                        };

                        worker.RunWorkerAsync(new NonrigidArgs(nonrigidSettingsForm.SourceModels[i], nonrigidSettingsForm.TargetModels[j], nonrigidSettingsForm.MaxIterations));
                    }
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NonrigidRegistration"/> class and sets a rigid registration which will be used during a nonrigid algorithm.
 /// </summary>
 /// <param name="rigidRegistration">The rigid registration.</param>
 public NonrigidRegistration(RigidRegistration rigidRegistration)
 {
     this.rigidRegistration = rigidRegistration;
 }