smoothers/SM_PathSmoothingSuccessiveNodePair.cpp

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include "CollisionDetectors\CD_BasicStyle.h"
00003 #include "SM_PathSmoothingSuccessiveNodePair.h"
00004 
00005 //=============================================================================
00006 // Constructor
00007 //
00008 // Description: constructor
00009 //=============================================================================
00010 SM_PathSmoothingSuccessiveNodePair::SM_PathSmoothingSuccessiveNodePair()
00011         :
00012         SmootherBase()
00013 {
00014 }
00015 
00016 //=============================================================================
00017 // Destructor
00018 //
00019 // Description: destructor
00020 //=============================================================================
00021 SM_PathSmoothingSuccessiveNodePair::~SM_PathSmoothingSuccessiveNodePair()
00022 {
00023 }
00024 
00025 //===============================================================================
00026 // Smooth
00027 //
00028 // Description: performs the smoothing operation based on graph smoothing method
00029 //===============================================================================
00030 void SM_PathSmoothingSuccessiveNodePair::Smooth()
00031 {
00032         bool pathInterfering = true;
00033         int  i = 0, j = 0, size = 0;
00034         Configuration iNode;
00035         Configuration jNode;
00036 
00037         this->m_SmoothedPath.Clear();
00038         this->m_SmoothedPath.AppendPoint(this->m_PathToSmooth->GetPoint(0));
00039 
00040         size = this->m_PathToSmooth->Size();
00041         if (size == 2)
00042         {
00043                 this->m_SmoothedPath.AppendPoint(this->m_PathToSmooth->GetPoint(1));
00044                 return;
00045         }
00046 
00047         i = 0;
00048         while (i < size - 2 )
00049         {
00050                 iNode = this->m_PathToSmooth->GetPoint(i);
00051 
00052                 for (j = i + 2; j < size; j++)
00053                 {       
00054                         jNode = this->m_PathToSmooth->GetPoint(j);
00055                         pathInterfering = this->m_CollisionDetector->IsInterferingLinear(iNode,jNode);
00056                         
00057                         if (!pathInterfering && j == size - 1)
00058                         {
00059                                 this->m_SmoothedPath.AppendPoint(this->m_PathToSmooth->GetPoint(j));
00060                                 return;
00061                         }
00062                         else if (!pathInterfering)
00063                                 continue;
00064                         else
00065                         {
00066                                 this->m_SmoothedPath.AppendPoint(this->m_PathToSmooth->GetPoint(j-1));
00067                                 break;
00068                         }
00069                 } // end for
00070                 
00071                 i = j-1;
00072         } // end while
00073 
00074         assert( i == size - 2 && j == size - 1 );
00075         this->m_SmoothedPath.AppendPoint(this->m_PathToSmooth->GetPoint(j));
00076 }

Generated on Sat Apr 1 21:30:47 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO