Skip to content

[common] C++20 Concepts for ponca#293

Draft
BDoignies wants to merge 21 commits intoponcateam:masterfrom
BDoignies:Concepts
Draft

[common] C++20 Concepts for ponca#293
BDoignies wants to merge 21 commits intoponcateam:masterfrom
BDoignies:Concepts

Conversation

@BDoignies
Copy link
Copy Markdown
Contributor

Hi,

This PR serves as a base for introducing concepts in the library. Note that it depends on #219 but some commits will drop once rebase.

This first commit introduces:

  • A format for requires clause
  • An example concept for points. Note that due to PointBinding type, we can not check for return type, for write access or for a non const version.

I suggest to start concept by the prefix "Is" or "Provides" because of current Ponca terminology.

@BDoignies BDoignies self-assigned this Mar 24, 2026
@BDoignies BDoignies added the enhancement New feature or request label Mar 24, 2026
@BDoignies BDoignies added this to the Release v2.0 milestone Mar 24, 2026
@BDoignies BDoignies marked this pull request as draft March 24, 2026 17:32
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.20%. Comparing base (cfb0fcc) to head (6acec21).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   94.10%   94.20%   +0.10%     
==========================================
  Files          86       84       -2     
  Lines        3340     3315      -25     
  Branches      264      263       -1     
==========================================
- Hits         3143     3123      -20     
+ Misses        196      191       -5     
  Partials        1        1              
Files with missing lines Coverage Δ
Ponca/src/Fitting/algebraicSphere.h 96.61% <ø> (ø)
Ponca/src/Fitting/algebraicSphere.hpp 100.00% <ø> (ø)
Ponca/src/Fitting/basket.h 100.00% <ø> (ø)
Ponca/src/Fitting/basketUnit.h 96.96% <ø> (ø)
Ponca/src/Fitting/cnc.h 100.00% <ø> (ø)
Ponca/src/Fitting/covarianceFit.h 100.00% <ø> (ø)
Ponca/src/Fitting/covarianceFit.hpp 94.11% <ø> (ø)
Ponca/src/Fitting/covarianceLineFit.h 85.71% <ø> (ø)
Ponca/src/Fitting/covariancePlaneFit.h 100.00% <ø> (ø)
Ponca/src/Fitting/covariancePlaneFit.hpp 94.73% <ø> (ø)
... and 27 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BDoignies
Copy link
Copy Markdown
Contributor Author

Hi,

I added a few more concepts. There are things that we can not check with concept unfortunately.

For example, ProvidesMeanPosition should require barycenterLocal to be defined. However, this is intentionally protected so concept can not check this as this is not accessible.

We can try a work around using a subclass but I am not sure this is worth doing.

@BDoignies
Copy link
Copy Markdown
Contributor Author

Another conflict:

-> Ponca::Plane has an isApprox function inherited through 'Eigen::Hyperplane'
-> AlgebraicSphere requires an isApprox function from an AlgebraicSphere

Therefore, when a fitting is instantiated with both, one isApprox hides the other. In the case I found this, Planes::isApprox hides AlgebraicSphere::isApprox and fails the ProvidesAlgebraicSphere concept.

We can not trick the compiler beacause AlgebraicSphere::isApprox is templated on 'any' type, hence we can not use an empty initializer... Because there are overload (although hidden), we can not check for '&T::isApprox' pattern...

@BDoignies BDoignies force-pushed the Concepts branch 3 times, most recently from c054149 to 103d724 Compare March 27, 2026 11:14
@BDoignies
Copy link
Copy Markdown
Contributor Author

Hi,

Here are a few more concepts.

What's left:

  • Monge Patch: Not clear what its definition would be
  • HeightField: I do not have access to it's base. I can not write a concept that requires a derivation from it...
  • Test to verify all concepts were properly instantiated and that they fail when required
  • Add a macro to simplify requirements
  • static_assert in requirements clause wherever possible
  • Remove curvature.h. This should be in another PR though

Questions:

  • For Weingarten map what would be the proper cast name ? wiengartenMap is already taken by the function
  • covarianceFit base offers a lot more than its current definition. Should we add the function in the requirements ?

@BDoignies BDoignies force-pushed the Concepts branch 2 times, most recently from 20ce509 to 71e78d8 Compare March 31, 2026 08:19
@nmellado nmellado mentioned this pull request Apr 10, 2026
@nmellado nmellado force-pushed the Concepts branch 2 times, most recently from af31e98 to 290c267 Compare April 17, 2026 18:41
@nmellado nmellado force-pushed the Concepts branch 2 times, most recently from 747a620 to 3572481 Compare April 17, 2026 19:19
@nmellado
Copy link
Copy Markdown
Contributor

I gave it a go and modified the current proposition. I also modified the curvature estimator, as I believe it is an important feature.
I did not tried to solve the issues you mentioned in the comments for the missing concepts, will work on it later.
We also need to work on the documentation, I put some comments here and there, but it can definitely be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants