42 template <
typename TIterator,
typename TInteger,
int connectivity>
43 template<
typename DSS,
typename Adapter>
49 const typename DSS::ConstIterator& i ) {
52 if ( aDSS.getRemainder(i) < (aDSS.getMu()) ) {
62 template <
typename TIterator,
typename TInteger,
int connectivity>
63 template<
typename DSS,
typename Adapter>
69 typename DSS::ConstIterator i,
82 if (adapter->firstLeaningPoint() != adapter->lastLeaningPoint()) {
83 myPolygon.push_back(adapter->lastLeaningPoint());
87 while (!currentDSS.isExtendableForward(i)) {
89 if ( currentDSS.retractForward() ) {
91 if (adapter->lastLeaningPoint() != myPolygon.back()) {
92 myPolygon.push_back(adapter->lastLeaningPoint());
103 if (adapter->firstLeaningPoint() != adapter->lastLeaningPoint()) {
104 myPolygon.pop_back();
108 while ( (i != end)&&(currentDSS.extendForward(i)) ) {
110 if (adapter->firstLeaningPoint() != myPolygon.back()) {
111 myPolygon.push_back(adapter->firstLeaningPoint());
119 if ( (isConvex)&&( currentDSS.getRemainder(i) <
120 (currentDSS.getMu()) ) ) {
125 }
else if ( (!isConvex)&&( currentDSS.getRemainder(i) >=
126 (currentDSS.getMu()+currentDSS.getOmega()) ) ) {
140 while (currentDSS.retractForward()) {
142 if (adapter->lastLeaningPoint() != myPolygon.back()) {
143 myPolygon.push_back(adapter->lastLeaningPoint());
150 template <
typename TIterator,
typename TInteger,
int connectivity>
153 const TIterator& itb,
159 template <
typename TIterator,
typename TInteger,
int connectivity>
162 const TIterator& itb,
163 const TIterator& ite,
165 : myFlagIsClosed( isClosed )
192 bool isConvexAtFront;
195 isConvexAtFront = initConvexityConcavity<DSSComputerInLoop,Adapter<DSSComputerInLoop> >
196 (*firstMS,adapterAtFront,front);
201 isConvexAtBack = initConvexityConcavity<DSSComputerInLoop,Adapter<DSSComputerInLoop> >
202 (*firstMS,adapterAtBack,back);
204 ASSERT(adapterAtFront);
205 ASSERT(adapterAtBack);
209 if (adapterAtFront->firstLeaningPoint() == adapterAtFront->lastLeaningPoint()) {
210 myPolygon.push_back(adapterAtFront->lastLeaningPoint());
215 if ( ( (isConvexAtFront)&&(isConvexAtBack) )
216 || ( (!isConvexAtFront)&&(!isConvexAtBack) ) ) {
217 leaningPoint = adapterAtFront->lastLeaningPoint();
219 leaningPoint = adapterAtBack->firstLeaningPoint();
223 }
while (*back != leaningPoint);
227 mainAlgorithm<DSSComputerInLoop,Adapter<DSSComputerInLoop> >
228 (*firstMS,adapterAtFront,isConvexAtFront,front,back);
230 ASSERT(adapterAtFront);
231 ASSERT(adapterAtBack);
237 myPolygon.pop_back();
244 std::list<Point> vTmpU, vTmpL;
257 if (longestDSS->
getUf() != vTmpU.back()) {
258 vTmpU.push_back(longestDSS->
getUf());
261 if (longestDSS->
getLf() != vTmpL.back()) {
262 vTmpL.push_back(longestDSS->
getLf());
272 isConvex = initConvexityConcavity<DSSComputer,Adapter<DSSComputer> >
273 (*longestDSS,adapter,i);
277 if (isConvex) myPolygon = vTmpU;
278 else myPolygon = vTmpL;
281 mainAlgorithm<DSSComputer,Adapter<DSSComputer> >
282 (*longestDSS,adapter,isConvex,i,ite);
304 template <
typename TIterator,
typename TInteger,
int connectivity>
313 template <
typename TIterator,
typename TInteger,
int connectivity>
321 template <
typename TIterator,
typename TInteger,
int connectivity>
326 return myPolygon.size();
330 template <
typename TIterator,
typename TInteger,
int connectivity>
331 template <
typename OutputIterator>
335 typename Polygon::const_iterator i = myPolygon.begin();
336 while ( i != myPolygon.end() ) {
342 template <
typename TIterator,
typename TInteger,
int connectivity>
343 template <
typename OutputIterator>
348 unsigned int n = (
unsigned int) myPolygon.size();
351 typename Polygon::const_iterator i = myPolygon.begin();
352 for ( ; i!= myPolygon.end() ; ++i) {
358 typename Polygon::const_iterator i, j, k;
359 i = myPolygon.begin();
363 if (myFlagIsClosed) {
366 *result++ = getRealPoint(myPolygon.back(),*i,*j);
368 while ( k != myPolygon.end() ) {
369 *result++ = getRealPoint(*i,*j,*k);
373 *result++ = getRealPoint(*i,*j,myPolygon.front());
378 *result++ =
RealPoint( myPolygon.front() );
380 while ( k != myPolygon.end() ) {
381 *result++ = getRealPoint(*i,*j,*k);
385 *result++ =
RealPoint( myPolygon.back() );
393 template <
typename TIterator,
typename TInteger,
int connectivity>
404 if ( (e1[0]*e2[1]-e1[1]*e2[0]) <= 0 ) {
407 if ( (quadrant(e1,1))&&(quadrant(e2,1)) ) {
409 }
else if ( (quadrant(e1,2))&&(quadrant(e2,2)) ) {
411 }
else if ( (quadrant(e1,3))&&(quadrant(e2,3)) ) {
413 }
else if ( (quadrant(e1,4))&&(quadrant(e2,4)) ) {
416 ASSERT(
false &&
"DGtal::FP<TIterator,TInteger,connectivity>::getRealPoint: not valid polygon" );
422 if ( (quadrant(e1,1))&&(quadrant(e2,1)) ) {
424 }
else if ( (quadrant(e1,2))&&(quadrant(e2,2)) ) {
426 }
else if ( (quadrant(e1,3))&&(quadrant(e2,3)) ) {
428 }
else if ( (quadrant(e1,4))&&(quadrant(e2,4)) ) {
431 ASSERT(
false &&
"DGtal::FP<TIterator,TInteger,connectivity>::getRealPoint: not valid polygon" );
439 template <
typename TIterator,
typename TInteger,
int connectivity>
446 return ( (v[0]>=0)&&(v[1]>=0) );
448 return ( (v[0]>=0)&&(v[1]<=0) );
450 return ( (v[0]<=0)&&(v[1]<=0) );
452 return ( (v[0]<=0)&&(v[1]>=0) );
455 "DGtal::FP<TIterator,TInteger,connectivity>::quadrant: quadrant number should be 0,1,2 or 3" );
463 template <
typename TIterator,
typename TInteger,
int connectivity>
472 template <
typename TIterator,
typename TInteger,
int connectivity>
477 out <<
"[FP]" << endl;
478 typename Polygon::const_iterator i = myPolygon.begin();
479 for ( ;i != myPolygon.end();++i)
481 out <<
"\t " << (*i) << endl;
483 out <<
"[end FP]" << endl;
493 template <
typename TIterator,
typename TInteger,
int connectivity>
499 object.selfDisplay( out );