DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

Static assertion raised in SegmentFactory when using SaturatedSegmentation #1483

Closed nyorem closed 4 years ago

nyorem commented 4 years ago

Hi all,

I tried to use the SaturatedSegmentation class with a StandardDSS4Computer namely the following typedefs (for instance in lines 173-174 the convex-and-concave-parts example):

typedef StandardDSS4Computer<Iterator> RecognitionAlgorithm;
typedef SaturatedSegmentation<RecognitionAlgorithm> Segmentation;

and it raised a static assertion in SegmentFactory:

/path/to/DGtal/src/DGtal/geometry/curves/CSegmentFactory.h:98:56: error: static assertion failed: ( boost::is_same< T, Self >::value )
   98 |       BOOST_STATIC_ASSERT(( boost::is_same< T, Self >::value ));
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ 

Using an ArithmeticalDSSComputer<Iterator,Coordinate,4> for the RecognitionAlgorithm does not raise this error.

As far as I understand SaturatedSegmentation should work with any kind of SegmentComputer such as StandardDSS4Computer or am I wrong?

Thank you in advance.

rolanddenis commented 4 years ago

Hi Jocelyn and sorry for the delay :wink:

From what I understand from these classes, StandardDSS4Computer is just an alias to ArithmeticalDSSComputer with a adjacency 4. It has been implemented as a derived class whose Selftypedef does not match the actual class leading to the concept check error that you have.

While waiting for a fix, I suggest you to use the corresponding alias, that is the same line as in the original example:

typedef ArithmeticalDSSComputer<Iterator,Coordinate,4> RecognitionAlgorithm;

or if you prefer, to get the real type using the Selfor Supertypedef (the ugly solution):

typedef typename StandardDSS4Computer<Iterator>::Self RecognitionAlgorithm;
nyorem commented 4 years ago

No worries for the delay!

Thank you for your answer, I already used your first proposition to solve the issue but a real fix would be better :wink:

rolanddenis commented 4 years ago

Ongoing fix : #1491

rolanddenis commented 4 years ago

Should be fixed, I close the issue!

nyorem commented 4 years ago

Thanks!