Open alxbilger opened 1 week ago
The unit tests fail because lambdas on BaseForceField
are not called on BaseInteractionForceField
, which is the case in old visitors.
[ci-build][with-all-tests]
@sofa-framework/reviewers your opinion is needed.
While working on the visitor definition, Alex proposes two alternative methods: the creation of classical SOFA visitors or a new implementation of the original visitor design pattern. It is a known pattern, slightly more verbous but the implementation follows modern C++ format (accept combined with lambda). A second version of these modern visitors is presented (see MechanicalOperations.cpp) with a function e.g. makeMechanicalVisitor
. This might lead to code duplication.
Objective is to improve the visitor readability at first sight. This work is done with the objective to apply visitors on a "mapping-based graph".
We thought @JeremieA you could have an interesting point of view about this.
This PR makes several suggestions, and should not be considered as is for a merge. A choice on the implementations must be made.
void accept(TopDownVisitor& visitor)
) https://refactoring.guru/design-patterns/visitor/cpp/example. It is a new implementation of the visitors, independent from the old visitors.makeMechanicalVisitor
.MechanicalOperations
uses a mix of old fashion visitors, and new visitors. The file must be reviewed as an example of usage.Example of the new visitors:
Example of the old visitors:
Pros:
Cons:
TODO with the new visitors:
BaseForceField
andBaseInteractionForceField
BaseMechanicalVisitor
and old visitorsThe question is: which implementation of the visitors do we keep?
Future work: Implement this kind of "visitor" for the mapping graph
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if