2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @file FMMPointFunctors.ih
19 * @author Tristan Roussillon (\c
20 * tristan.roussillon@liris.cnrs.fr ) Laboratoire d'InfoRmatique en
21 * Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS,
27 * @brief Implementation of inline methods defined in FMMPointFunctors.h
29 * This file is part of the DGtal library.
33//////////////////////////////////////////////////////////////////////////////
35//////////////////////////////////////////////////////////////////////////////
37///////////////////////////////////////////////////////////////////////////////
38// Helper functions defined in the compilation unit (anonymous namespace)
39// see operator() below
42 //comparator in absolute value
43 template <typename Value>
44 bool absComparator(const Value& i, const Value& j)
46 return ( std::abs(static_cast<double>(i)) < std::abs(static_cast<double>(j)) );
49 //pair second member comparator in absolute value
50 template <typename Pair>
51 bool secondAbsComparator(const Pair& i, const Pair& j)
53 return absComparator( i.second, j.second );
58///////////////////////////////////////////////////////////////////////////////
59// IMPLEMENTATION of inline methods.
60///////////////////////////////////////////////////////////////////////////////
62///////////////////////////////////////////////////////////////////////////////
63//-----------------------------------------------------------------------------
64template <typename TImage, typename TSet>
66DGtal::L2FirstOrderLocalDistance<TImage,TSet>::L2FirstOrderLocalDistance
67 (Image& aImg, TSet& aSet): myImgPtr(&aImg), mySetPtr(&aSet)
73//-----------------------------------------------------------------------------
74template <typename TImage, typename TSet>
76DGtal::L2FirstOrderLocalDistance<TImage,TSet>::L2FirstOrderLocalDistance
77 (const L2FirstOrderLocalDistance& other): myImgPtr(other.myImgPtr), mySetPtr(other.mySetPtr)
83//-----------------------------------------------------------------------------
84template <typename TImage, typename TSet>
86DGtal::L2FirstOrderLocalDistance<TImage,TSet>&
87DGtal::L2FirstOrderLocalDistance<TImage,TSet>::operator=
88 (const L2FirstOrderLocalDistance& other)
92 myImgPtr = other.myImgPtr;
93 mySetPtr = other.mySetPtr;
100//-----------------------------------------------------------------------------
101template <typename TImage, typename TSet>
103DGtal::L2FirstOrderLocalDistance<TImage,TSet>::~L2FirstOrderLocalDistance
108//-----------------------------------------------------------------------------
109template <typename TImage, typename TSet>
111typename DGtal::L2FirstOrderLocalDistance<TImage, TSet>::Value
112DGtal::L2FirstOrderLocalDistance<TImage, TSet>::operator()
113 (const Point& aPoint)
118 v.reserve(Point::dimension);
121 Point neighbor1 = aPoint;
122 Point neighbor2 = aPoint;
124 typename Point::Iterator it1 = neighbor1.begin();
125 typename Point::Iterator it2 = neighbor2.begin();
126 typename Point::ConstIterator it = aPoint.begin();
127 typename Point::ConstIterator itEnd = aPoint.end();
128 for ( ; it != itEnd; ++it, ++it1, ++it2)
129 {//for each dimension
131 typename Point::Coordinate c = *it;
136 Value d = 0, d1 = 0, d2 = 0;
137 bool flag1 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor1, d1 );
138 bool flag2 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor2, d2 );
139 if ( flag1 || flag2 )
141 if ( flag1 && flag2 )
142 { //take the minimal value
143 if (std::abs(d1) < std::abs(d2))
158 } //end for each dimension
160 //computation of the new value
161 return this->compute(v);
165//-----------------------------------------------------------------------------
166template <typename TImage, typename TSet>
168typename DGtal::L2FirstOrderLocalDistance<TImage, TSet>::Value
169DGtal::L2FirstOrderLocalDistance<TImage, TSet>::compute
170(Values& aValueList) const
172 ASSERT(aValueList.size() > 0);
174 if ( aValueList.size() == 1 )
176 Value d = aValueList.back();
177 if (d >= 0) return d + 1.0;
182 //function computation
183 typename Values::iterator itMax =
184 std::max_element( aValueList.begin(), aValueList.end(), absComparator<Value> );
185 if ( gradientNorm( *itMax, aValueList ) > 1 )
187 aValueList.erase( itMax );
188 return this->compute(aValueList);
196 for (typename Values::iterator it = aValueList.begin();
197 it != aValueList.end(); ++it)
202 b -= static_cast<double>(2*d);
203 c += static_cast<double>(d*d);
207 double disc = b*b - 4*a*c;
211 return static_cast<Value>( ( -b + std::sqrt(disc) ) / (2*a) );
213 return static_cast<Value>( ( -b - std::sqrt(disc) ) / (2*a) );
219//-----------------------------------------------------------------------------
220template <typename TImage, typename TSet>
222typename DGtal::L2FirstOrderLocalDistance<TImage, TSet>::Value
223DGtal::L2FirstOrderLocalDistance<TImage, TSet>
224::gradientNorm(const Value& aValue, const Values& aValueList) const
227 for (typename Values::const_iterator it = aValueList.begin();
228 it != aValueList.end(); ++it)
230 Value d = (aValue - *it);
236//-----------------------------------------------------------------------------
237template <typename TImage, typename TSet>
240DGtal::L2FirstOrderLocalDistance<TImage, TSet>
241::selfDisplay ( std::ostream & out ) const
246///////////////////////////////////////////////////////////////////////////////
247//-----------------------------------------------------------------------------
248template <typename TImage, typename TSet>
250DGtal::L2SecondOrderLocalDistance<TImage,TSet>::L2SecondOrderLocalDistance
251 (Image& aImg, TSet& aSet): myImgPtr(&aImg), mySetPtr(&aSet)
257//-----------------------------------------------------------------------------
258template <typename TImage, typename TSet>
260DGtal::L2SecondOrderLocalDistance<TImage,TSet>::L2SecondOrderLocalDistance
261 (const L2SecondOrderLocalDistance& other): myImgPtr(other.myImgPtr), mySetPtr(other.mySetPtr)
267//-----------------------------------------------------------------------------
268template <typename TImage, typename TSet>
270DGtal::L2SecondOrderLocalDistance<TImage,TSet>&
271DGtal::L2SecondOrderLocalDistance<TImage,TSet>::operator=
272 (const L2SecondOrderLocalDistance& other)
276 myImgPtr = other.myImgPtr;
277 mySetPtr = other.mySetPtr;
284//-----------------------------------------------------------------------------
285template <typename TImage, typename TSet>
287DGtal::L2SecondOrderLocalDistance<TImage,TSet>::~L2SecondOrderLocalDistance
292//-----------------------------------------------------------------------------
293template <typename TImage, typename TSet>
295typename DGtal::L2SecondOrderLocalDistance<TImage, TSet>::Value
296DGtal::L2SecondOrderLocalDistance<TImage, TSet>::operator()
297 (const Point& aPoint)
302 l.reserve(Point::dimension);
305 Point neighbor1 = aPoint;
306 Point neighbor2 = aPoint;
308 typename Point::Iterator it1 = neighbor1.begin();
309 typename Point::Iterator it2 = neighbor2.begin();
310 typename Point::ConstIterator it = aPoint.begin();
311 typename Point::ConstIterator itEnd = aPoint.end();
312 for ( ; it != itEnd; ++it, ++it1, ++it2)
313 {//for each dimension
315 typename Point::Coordinate c = *it;
321 Value d = 0, d1 = 0, d2 = 0;
322 bool flag1 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor1, d1 );
323 bool flag2 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor2, d2 );
324 if ( flag1 || flag2 )
329 Value d12 = 0, d22 = 0;
330 bool flag12 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor1, d12 );
331 bool flag22 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor2, d22 );
333 if ( flag1 && flag2 )
336 if ( flag12 && flag22 )
337 { //take the minimal value
338 d1 = getValue( d1, d12 );
339 d2 = getValue( d2, d22 );
340 if (std::abs(d1) < std::abs(d2))
347 { //like first-order accurate case
348 //take the minimal value
349 if (std::abs(d1) < std::abs(d2))
356 else //if not flag1 AND flag2 both true
363 d1 = getValue( d1, d12 );
375 d2 = getValue( d2, d22 );
382 l.push_back( CoeffValue( coeff, d ) );
384 } //end if flag1 or flag2
388 } //end for each dimension
390 //computation of the new value
391 return this->compute(l);
395//-----------------------------------------------------------------------------
396template <typename TImage, typename TSet>
398typename DGtal::L2SecondOrderLocalDistance<TImage, TSet>::Value
399DGtal::L2SecondOrderLocalDistance<TImage, TSet>::compute
402 ASSERT(aList.size() > 0);
404 if ( aList.size() == 1 )
406 CoeffValue pair = aList.back();
407 if (pair.second >= 0)
408 return ( (pair.second + 1.0)/(pair.first) );
410 return ( (pair.second - 1.0)/(pair.first) );
418 for (typename List::iterator it = aList.begin();
419 it != aList.end(); ++it)
421 double coeff = it->first;
422 Value v = it->second;
425 b -= 2 * coeff * static_cast<double>(v);
426 c += static_cast<double>(v*v);
430 double disc = b*b - 4*a*c;
434 return static_cast<Value>( ( -b + std::sqrt(disc) ) / (2*a) );
436 return static_cast<Value>( ( -b - std::sqrt(disc) ) / (2*a) );
440//-----------------------------------------------------------------------------
441template <typename TImage, typename TSet>
443typename DGtal::L2SecondOrderLocalDistance<TImage, TSet>::Value
444DGtal::L2SecondOrderLocalDistance<TImage, TSet>
445::getValue(const Value& aValue1, const Value& aValue2) const
447 return (2.0*aValue1 - aValue2/2.0);
450//-----------------------------------------------------------------------------
451template <typename TImage, typename TSet>
454DGtal::L2SecondOrderLocalDistance<TImage, TSet>
455::selfDisplay ( std::ostream & out ) const
460///////////////////////////////////////////////////////////////////////////////
461//-----------------------------------------------------------------------------
462template <typename TImage, typename TSet>
464DGtal::LInfLocalDistance<TImage,TSet>::LInfLocalDistance
465 (Image& aImg, TSet& aSet): myImgPtr(&aImg), mySetPtr(&aSet)
471//-----------------------------------------------------------------------------
472template <typename TImage, typename TSet>
474DGtal::LInfLocalDistance<TImage,TSet>::LInfLocalDistance
475 (const LInfLocalDistance& other): myImgPtr(other.myImgPtr), mySetPtr(other.mySetPtr)
481//-----------------------------------------------------------------------------
482template <typename TImage, typename TSet>
484DGtal::LInfLocalDistance<TImage,TSet>&
485DGtal::LInfLocalDistance<TImage,TSet>::operator=
486 (const LInfLocalDistance& other)
490 myImgPtr = other.myImgPtr;
491 mySetPtr = other.mySetPtr;
498//-----------------------------------------------------------------------------
499template <typename TImage, typename TSet>
501DGtal::LInfLocalDistance<TImage,TSet>::~LInfLocalDistance
505//-----------------------------------------------------------------------------
506template <typename TImage, typename TSet>
508typename DGtal::LInfLocalDistance<TImage, TSet>::Value
509DGtal::LInfLocalDistance<TImage, TSet>::operator()
510 (const Point& aPoint)
515 v.reserve(Point::dimension);
518 Point neighbor1 = aPoint;
519 Point neighbor2 = aPoint;
521 typename Point::Iterator it1 = neighbor1.begin();
522 typename Point::Iterator it2 = neighbor2.begin();
523 typename Point::ConstIterator it = aPoint.begin();
524 typename Point::ConstIterator itEnd = aPoint.end();
525 for ( ; it != itEnd; ++it, ++it1, ++it2)
526 {//for each dimension
528 typename Point::Coordinate c = *it;
533 Value d = 0, d1 = 0, d2 = 0;
534 bool flag1 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor1, d1 );
535 bool flag2 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor2, d2 );
536 if ( flag1 || flag2 )
538 if ( flag1 && flag2 )
539 { //take the minimal value
540 if (std::abs(d1) < std::abs(d2))
556 } //end for each dimension
558 //computation of the new value
559 return this->compute(v);
563//-----------------------------------------------------------------------------
564template <typename TImage, typename TSet>
566typename DGtal::LInfLocalDistance<TImage, TSet>::Value
567DGtal::LInfLocalDistance<TImage, TSet>::compute
568(Values& aValueList) const
571 ASSERT(aValueList.size() > 0);
573 if ( aValueList.size() == 1 )
575 Value d = aValueList.back();
582 typename Values::iterator it =
583 std::max_element( aValueList.begin(), aValueList.end(), absComparator<Value> );
588//-----------------------------------------------------------------------------
589template <typename TImage, typename TSet>
592DGtal::LInfLocalDistance<TImage, TSet>
593::selfDisplay ( std::ostream & out ) const
598///////////////////////////////////////////////////////////////////////////////
599//-----------------------------------------------------------------------------
600template <typename TImage, typename TSet>
602DGtal::L1LocalDistance<TImage,TSet>::L1LocalDistance
603 (Image& aImg, TSet& aSet): myImgPtr(&aImg), mySetPtr(&aSet)
609//-----------------------------------------------------------------------------
610template <typename TImage, typename TSet>
612DGtal::L1LocalDistance<TImage,TSet>::L1LocalDistance
613 (const L1LocalDistance& other): myImgPtr(other.myImgPtr), mySetPtr(other.mySetPtr)
619//-----------------------------------------------------------------------------
620template <typename TImage, typename TSet>
622DGtal::L1LocalDistance<TImage,TSet>&
623DGtal::L1LocalDistance<TImage,TSet>::operator=
624 (const L1LocalDistance& other)
628 myImgPtr = other.myImgPtr;
629 mySetPtr = other.mySetPtr;
636//-----------------------------------------------------------------------------
637template <typename TImage, typename TSet>
639DGtal::L1LocalDistance<TImage,TSet>::~L1LocalDistance
643//-----------------------------------------------------------------------------
644template <typename TImage, typename TSet>
646typename DGtal::L1LocalDistance<TImage, TSet>::Value
647DGtal::L1LocalDistance<TImage, TSet>::operator()
648 (const Point& aPoint)
653 v.reserve(2*Point::dimension);
656 Point neighbor1 = aPoint;
657 Point neighbor2 = aPoint;
659 typename Point::Iterator it1 = neighbor1.begin();
660 typename Point::Iterator it2 = neighbor2.begin();
661 typename Point::ConstIterator it = aPoint.begin();
662 typename Point::ConstIterator itEnd = aPoint.end();
663 for ( ; it != itEnd; ++it, ++it1, ++it2)
664 {//for each dimension
666 typename Point::Coordinate c = *it;
671 Value d1 = 0, d2 = 0;
672 bool flag1 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor1, d1 );
673 bool flag2 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor2, d2 );
674 if (flag1) v.push_back( d1 );
675 if (flag2) v.push_back( d2 );
679 } //end for each dimension
681 //computation of the new value
682 return this->compute(v);
686//-----------------------------------------------------------------------------
687template <typename TImage, typename TSet>
689typename DGtal::L1LocalDistance<TImage, TSet>::Value
690DGtal::L1LocalDistance<TImage, TSet>::compute
691(Values& aValueList) const
693 ASSERT(aValueList.size() > 0);
695 //min (in absolute values)
696 typename Values::iterator it =
697 std::min_element( aValueList.begin(), aValueList.end(), absComparator<Value> );
707//-----------------------------------------------------------------------------
708template <typename TImage, typename TSet>
711DGtal::L1LocalDistance<TImage, TSet>
712::selfDisplay ( std::ostream & out ) const
717///////////////////////////////////////////////////////////////////////////////
719///////////////////////////////////////////////////////////////////////////////
720///////////////////////////////////////////////////////////////////////////////
721// Helper classes defined in the compilation unit (anonymous namespace)
722// see operator() below
726 template<bool complementToOne>
727 struct ValueBetween0And1
729 template<typename Value>
730 static Value get(const Value& v)
732 ASSERT( (v>=0)&&(v<=1) );
738 struct ValueBetween0And1<true>
740 template<typename Value>
741 static Value get(const Value& v)
743 ASSERT( (v>=0)&&(v<=1) );
749///////////////////////////////////////////////////////////////////////////////
750//-----------------------------------------------------------------------------
751template <typename TKSpace, typename TMap, bool isIndirect>
753DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>
754::L2FirstOrderLocalDistanceFromCells
755 ( ConstAlias<KSpace> aK, Map& aMap): myKSpace(&aK), myMap(&aMap)
759//-----------------------------------------------------------------------------
760template <typename TKSpace, typename TMap, bool isIndirect>
762DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>
763::L2FirstOrderLocalDistanceFromCells
764 (const L2FirstOrderLocalDistanceFromCells& other)
765: myKSpace(other.myKSpace), myMap(other.myMap)
769//-----------------------------------------------------------------------------
770template <typename TKSpace, typename TMap, bool isIndirect>
772DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>&
773DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>
775 (const L2FirstOrderLocalDistanceFromCells& other)
780 myKSpace = other.myKSpace;
785//-----------------------------------------------------------------------------
786template <typename TKSpace, typename TMap, bool isIndirect>
788DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>
789::~L2FirstOrderLocalDistanceFromCells
794//-----------------------------------------------------------------------------
795template <typename TKSpace, typename TMap, bool isIndirect>
797typename DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>::Value
798DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>::operator()
799 (const Point& aPoint)
804 v.reserve(Point::dimension);
806 Cell spel = myKSpace->uSpel( aPoint );
807 for ( typename KSpace::DirIterator q = myKSpace->uDirs( spel );
809 { //for each dimension
810 const DGtal::Dimension dir = *q;
812 /// for the direct orientation
813 Cell surfel1 = myKSpace->uIncident( spel, dir, true );
814 ASSERT( myKSpace->uDim( surfel1 ) == (KSpace::dimension - 1) );
816 /// for the indirect orientation
817 Cell surfel2 = myKSpace->uIncident( spel, dir, false );
818 ASSERT( myKSpace->uDim( surfel2 ) == (KSpace::dimension - 1) );
822 typename Map::iterator it1 = myMap->find( surfel1 );
823 typename Map::iterator it2 = myMap->find( surfel2 );
824 bool flag1 = ( it1 != myMap->end() );
825 bool flag2 = ( it2 != myMap->end() );
826 if ( flag1 || flag2 )
828 if ( flag1 && flag2 )
829 { //take the minimal value
830 ASSERT( (it1->second >= 0)&&(it1->second <= 1) );
831 ASSERT( (it2->second >= 0)&&(it2->second <= 1) );
832 if (it1->second < it2->second)
833 d = ValueBetween0And1<isIndirect>
834 ::get( it1->second );
836 d = ValueBetween0And1<isIndirect>
837 ::get( it2->second );
842 ASSERT( (it1->second >= 0)&&(it1->second <= 1) );
843 d = ValueBetween0And1<isIndirect>
844 ::get( it1->second );
848 ASSERT( (it2->second >= 0)&&(it2->second <= 1) );
849 d = ValueBetween0And1<isIndirect>
850 ::get( it2->second );
854 if (d == 0) return 0;
859 } //end for each dimension
861 //computation of the new value
862 return this->compute(v);
866//-----------------------------------------------------------------------------
867template <typename TKSpace, typename TMap, bool isIndirect>
869typename DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>::Value
870DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap,isIndirect>::compute
871(Values& aValueList) const
873 ASSERT(aValueList.size() > 0);
875 if ( aValueList.size() == 1 )
877 return aValueList.back();
883 for (typename Values::iterator it = aValueList.begin();
884 it != aValueList.end(); ++it)
887 a += ( 1.0 / static_cast<double>( d*d ) );
890 return static_cast<Value>( std::sqrt(a) / a );
894//-----------------------------------------------------------------------------
895template <typename TKSpace, typename TMap, bool isIndirect>
898DGtal::L2FirstOrderLocalDistanceFromCells<TKSpace,TMap, isIndirect>
899::selfDisplay ( std::ostream & out ) const
904///////////////////////////////////////////////////////////////////////////////
905//-----------------------------------------------------------------------------
906template <typename TDistanceImage, typename TSet, typename TSpeedFunctor>
908DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>::SpeedExtrapolator
909(const DistanceImage& aDistImg, const Set& aSet, SpeedFunctor& aSpeedFunc)
910 : myDistImgPtr(&aDistImg), mySetPtr(&aSet), mySpeedFuncPtr(&aSpeedFunc)
912 ASSERT( myDistImgPtr );
914 ASSERT( mySpeedFuncPtr );
917//-----------------------------------------------------------------------------
918template <typename TDistanceImage, typename TSet, typename TSpeedFunctor>
920DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>::SpeedExtrapolator
921 (const SpeedExtrapolator& other)
922 : myDistImgPtr(other.myDistImgPtr), mySetPtr(other.mySetPtr), mySpeedFuncPtr(other.mySpeedFuncPtr)
924 ASSERT( myDistImgPtr );
926 ASSERT( mySpeedFuncPtr );
929//-----------------------------------------------------------------------------
930template <typename TDistanceImage, typename TSet, typename TSpeedFunctor>
932DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>&
933DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>::operator=
934 (const SpeedExtrapolator& other)
938 myDistImgPtr = other.myDistImgPtr;
939 mySetPtr = other.mySetPtr;
940 mySpeedFuncPtr = other.mySpeedFuncPtr;
941 ASSERT( myDistImgPtr );
943 ASSERT( mySpeedFuncPtr );
948//-----------------------------------------------------------------------------
949template <typename TDistanceImage, typename TSet, typename TSpeedFunctor>
951DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>::~SpeedExtrapolator
956//-----------------------------------------------------------------------------
957template <typename TDistanceImage, typename TSet, typename TSpeedFunctor>
959typename DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>::Value
960DGtal::SpeedExtrapolator<TDistanceImage,TSet,TSpeedFunctor>::operator()
961 (const Point& aPoint)
965 Value num = 0.0, den = 0;
967 //two 1-neighbors for one dimension
968 Point neighbor1 = aPoint;
969 Point neighbor2 = aPoint;
971 typename Point::Iterator it1 = neighbor1.begin();
972 typename Point::Iterator it2 = neighbor2.begin();
973 typename Point::ConstIterator it = aPoint.begin();
974 typename Point::ConstIterator itEnd = aPoint.end();
975 for ( ; it != itEnd; ++it, ++it1, ++it2)
976 {//for each dimension
978 typename Point::Coordinate c = *it;
982 bool flag = findAndGetValue( *myDistImgPtr, *mySetPtr, aPoint, d );
983 ASSERT( flag ); boost::ignore_unused_variable_warning( flag );
988 //neighboring speed value
990 //neighboring distance values
991 DistanceValue d0 = 0, d1 = 0, d2 = 0;
992 bool flag1 = findAndGetValue( *myDistImgPtr, *mySetPtr, neighbor1, d1 );
993 bool flag2 = findAndGetValue( *myDistImgPtr, *mySetPtr, neighbor2, d2 );
994 if ( flag1 || flag2 )
996 if ( flag1 && flag2 )
997 { //take the minimal value
998 if (std::abs(d1) < std::abs(d2))
1001 s = (*mySpeedFuncPtr)( neighbor1 );
1006 s = (*mySpeedFuncPtr)( neighbor2 );
1013 s = (*mySpeedFuncPtr)( neighbor1 );
1018 s = (*mySpeedFuncPtr)( neighbor2 );
1022 Value diff = static_cast<Value>(d - d0);
1023 num += ( s * diff );
1029 } //end for each dimension
1031 //computation of the new value