@@ -582,6 +582,7 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
582582 cout << " REFERENCE MAP FOR THE ICP:" << endl;
583583 refMapPt.insertionOptions .dumpToConsole ();
584584 refMapPt.renderOptions .color = mrpt::img::TColorf (.0f , .0f , 1 .0f );
585+ refMapPt.renderOptions .point_size = 3.0 ;
585586 }
586587 else
587588 {
@@ -602,6 +603,7 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
602603 CConfigFileMemory refCfg (string (edOptAlignMap->GetValue ().mb_str ()));
603604 newMapPt.insertionOptions .loadFromConfigFile (refCfg, " InsertionOptions" );
604605 newMapPt.renderOptions .color = mrpt::img::TColorf (1 .0f , .0f , .0f );
606+ newMapPt.renderOptions .point_size = 2.0 ;
605607
606608 cout << " NEW MAP (TO ALIGN) FOR THE ICP:" << endl;
607609 newMapPt.insertionOptions .dumpToConsole ();
@@ -613,8 +615,9 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
613615 insert_obs_into_map (obj_new, &newMapPt);
614616
615617 // Delete all existing draw layers:
616- m_gl_map_ref = refMap->getVisualization ();
617- m_gl_map_new = newMapPt.getVisualization ();
618+ *m_gl_map_ref = *refMap->getVisualization ();
619+ m_gl_map_new->clear ();
620+ m_gl_map_new->insert (newMapPt.getVisualization ());
618621
619622 auto gl_ellipse = mrpt::opengl::CEllipsoid2D::Create ();
620623 gl_ellipse->setQuantiles (3 .0f );
@@ -624,8 +627,8 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
624627 // Align:
625628 // --------------------------------------
626629 bool isAnimation = cbAnimate->GetValue ();
627- unsigned int maxSteps = icp.options .maxIterations ;
628- unsigned int curStep = isAnimation ? 0 : maxSteps;
630+ const unsigned int maxSteps = icp.options .maxIterations ;
631+ unsigned int curStep = isAnimation ? 1 : maxSteps;
629632 CPose2D estMean;
630633 CMatrixDouble33 estCov;
631634
@@ -639,13 +642,12 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
639642
640643 pbSteps->SetRange (maxSteps);
641644
642- while ( curStep <= maxSteps)
645+ for (; curStep <= maxSteps; curStep++ )
643646 {
644647 if (isAnimation)
645648 {
646649 txtStep->SetLabel ((format (" Step: %u / %u" , curStep, maxSteps).c_str ()));
647650 pbSteps->SetValue (curStep);
648- wxTheApp->Yield (); // Let the app. process messages
649651 }
650652
651653 icp.options .maxIterations = curStep;
@@ -672,7 +674,7 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
672674 cout << format (" Quality: %.04f\n " , icpInfo.quality );
673675
674676 // Already converged?
675- if (isAnimation && icpInfo.nIterations < (curStep - 3 ))
677+ if (isAnimation && static_cast < int >( icpInfo.nIterations ) < (static_cast < int >( curStep) - 3 ))
676678 {
677679 curStep = maxSteps;
678680 pbSteps->SetValue (maxSteps);
@@ -689,28 +691,23 @@ void CScanMatching::OnbtnICPClick(wxCommandEvent&)
689691 cout << " std(phi) = " << RAD2DEG (sqrt (estCov (2 , 2 ))) << " deg. " << endl;
690692
691693 cout << format (" Output PDF class is: %s\n " , poseEst->GetRuntimeClass ()->className );
692- if (poseEst-> GetRuntimeClass () == CLASS_ID ( CPosePDFSOG) )
694+ if (const auto SOG = std::dynamic_pointer_cast< CPosePDFSOG>(poseEst); SOG )
693695 {
694- CPosePDFSOG::Ptr SOG = std::dynamic_pointer_cast<CPosePDFSOG>(poseEst);
695- size_t i, n = SOG->size ();
696+ const size_t n = SOG->size ();
696697 cout << format (" # of gaussians in SOG: %i\n " , (int )n);
697- for (i = 0 ; i < n; i++)
698+ for (size_t i = 0 ; i < n; i++)
698699 {
699700 cout << format (" SOG[%02i]:w=%e mean=" , (int )i, SOG->get (i).log_w ) << SOG->get (i).mean
700701 << endl;
701702 }
702703 }
703704
704- // delete poseEst; poseEst=nullptr;
705-
706705 if (isAnimation)
707706 {
708- wxTheApp->Yield (); // Let the app. process messages
707+ wxTheApp->SafeYield ( this , true );
709708 ::wxMilliSleep (100 );
710709 }
711-
712- curStep++;
713- } // end while
710+ }
714711
715712 // End of wait cursor
716713 }
0 commit comments