diff --git a/Code/Common/otbLabelObjectToPolygonFunctor.h b/Code/Common/otbLabelObjectToPolygonFunctor.h index daf4d5bfa889ba09deb5b4b8b7d32f11e250f51c..1cbcf57c7d9b9d42dc135abfdaf383166086bc99 100644 --- a/Code/Common/otbLabelObjectToPolygonFunctor.h +++ b/Code/Common/otbLabelObjectToPolygonFunctor.h @@ -66,7 +66,7 @@ public: * \param labelObject the label object to vectorize * \return The vectorized label object as a polygon. */ - inline PolygonPointerType operator()(const LabelObjectType * labelObject); + inline PolygonType * operator()(const LabelObjectType * labelObject); private: /// Internal structures @@ -109,6 +109,8 @@ private: /// Walk right to update the finite states machine. inline void WalkRight(unsigned int line,const IndexType & startPoint, const IndexType & endPoint, PolygonType * polygon, const StateType state); + PolygonPointerType m_Polygon; + // Internal structure to store runs RunsPerLineVectorType m_InternalDataSet; diff --git a/Code/Common/otbLabelObjectToPolygonFunctor.txx b/Code/Common/otbLabelObjectToPolygonFunctor.txx index 15db73b77a9d7d8c8aa647781ae57151db63656e..8b735998dcece8cfaab1096bc1ace3b8f9d369a0 100644 --- a/Code/Common/otbLabelObjectToPolygonFunctor.txx +++ b/Code/Common/otbLabelObjectToPolygonFunctor.txx @@ -43,7 +43,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> template<class TLabelObject, class TPolygon> inline typename LabelObjectToPolygonFunctor<TLabelObject,TPolygon> -::PolygonPointerType +::PolygonType * LabelObjectToPolygonFunctor<TLabelObject,TPolygon> ::operator()(const LabelObjectType * labelObject) { @@ -52,7 +52,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_PositionFlag = LEFT_END; m_InternalDataSet.clear(); - PolygonPointerType polygon = PolygonType::New(); + m_Polygon = PolygonType::New(); // Get the internal container LineContainerType lcontainer = labelObject->GetLineContainer(); @@ -118,7 +118,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = secondCandidateRun; m_CurrentState = DOWN_RIGHT; m_PositionFlag = LEFT_END; - WalkRight(m_CurrentLine-1,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine-1,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } else @@ -128,7 +128,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = firstCandidateRun; m_CurrentState = UP_RIGHT; m_PositionFlag = RIGHT_END; - WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } @@ -141,7 +141,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> // Up-Left Case m_CurrentState = UP_LEFT; m_PositionFlag = RIGHT_END; - WalkLeft(m_CurrentLine,m_CurrentPoint,RightEnd(secondCandidateRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine,m_CurrentPoint,RightEnd(secondCandidateRun),m_Polygon, m_CurrentState); m_CurrentLine--; m_CurrentRun = secondCandidateRun; } @@ -150,7 +150,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> // Down-Left case m_CurrentState = DOWN_LEFT; m_PositionFlag = LEFT_END; - WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } break; @@ -171,7 +171,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = secondCandidateRun; m_CurrentState = UP_LEFT; m_PositionFlag = RIGHT_END; - WalkLeft(m_CurrentLine+1,m_CurrentPoint,RightEnd(m_CurrentRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine+1,m_CurrentPoint,RightEnd(m_CurrentRun),m_Polygon, m_CurrentState); } else { @@ -180,7 +180,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = firstCandidateRun; m_CurrentState = DOWN_LEFT; m_PositionFlag = LEFT_END; - WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } @@ -195,7 +195,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentLine++; m_CurrentState = DOWN_RIGHT; m_PositionFlag = LEFT_END; - WalkRight(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } else @@ -203,7 +203,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> // Up-Right case m_CurrentState = UP_RIGHT; m_PositionFlag = RIGHT_END; - WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } @@ -223,7 +223,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentState = UP_LEFT; m_PositionFlag = RIGHT_END; m_CurrentRun = secondCandidateRun; - WalkLeft(m_CurrentLine+1,m_CurrentPoint,RightEnd(m_CurrentRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine+1,m_CurrentPoint,RightEnd(m_CurrentRun),m_Polygon, m_CurrentState); } else @@ -233,7 +233,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = firstCandidateRun; m_CurrentState = DOWN_LEFT; m_PositionFlag = LEFT_END; - WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } @@ -248,14 +248,14 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = secondCandidateRun; m_CurrentState = DOWN_RIGHT; m_PositionFlag = LEFT_END; - WalkRight(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } else { // Up-Right case m_CurrentState = UP_RIGHT; m_PositionFlag = RIGHT_END; - WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } @@ -275,7 +275,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = secondCandidateRun; m_CurrentState = DOWN_RIGHT; m_PositionFlag = LEFT_END; - WalkRight(m_CurrentLine-1,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine-1,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } else @@ -285,7 +285,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> m_CurrentRun = firstCandidateRun; m_CurrentState = UP_RIGHT; m_PositionFlag = RIGHT_END; - WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),polygon, m_CurrentState); + WalkRight(m_CurrentLine,m_CurrentPoint,RightEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } else @@ -297,7 +297,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> // Up-Left case m_CurrentState = UP_LEFT; m_PositionFlag = RIGHT_END; - WalkLeft(m_CurrentLine,m_CurrentPoint,RightEnd(secondCandidateRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine,m_CurrentPoint,RightEnd(secondCandidateRun),m_Polygon, m_CurrentState); m_CurrentLine--; m_CurrentRun = secondCandidateRun; @@ -307,7 +307,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> // Down-Left case m_CurrentState = DOWN_LEFT; m_PositionFlag = LEFT_END; - WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),polygon, m_CurrentState); + WalkLeft(m_CurrentLine,m_CurrentPoint,LeftEnd(m_CurrentRun),m_Polygon, m_CurrentState); } } @@ -317,7 +317,7 @@ LabelObjectToPolygonFunctor<TLabelObject,TPolygon> goesOn = m_CurrentPoint != m_StartingPoint; } - return polygon; + return m_Polygon; } template<class TLabelObject, class TPolygon>