@@ -45,7 +45,19 @@ class SOFA_CORE_API BaseConstraintSet : public virtual objectmodel::BaseObject
4545 BaseConstraintSet& operator =(const BaseConstraintSet& n) = delete ;
4646
4747public:
48- virtual void resetConstraint () {}
48+ /* *
49+ * !!! WARNING since v26.06 !!!
50+ *
51+ * The template method pattern has been applied to this part of the API.
52+ * This method calls the newly introduced method "doFunctionName" internally,
53+ * which is the method to override from now on.
54+ *
55+ **/
56+ virtual void resetConstraint () final
57+ {
58+ // TODO (SPRINT SED 2025): Component state mechanism
59+ doResetConstraint ();
60+ }
4961
5062 // / Set the id of the constraint (this id is build in the getConstraintViolation function)
5163 // /
@@ -55,39 +67,93 @@ class SOFA_CORE_API BaseConstraintSet : public virtual objectmodel::BaseObject
5567 d_constraintIndex.setValue (cId);
5668 }
5769
70+ /* *
71+ * !!! WARNING since v26.06 !!!
72+ *
73+ * The template method pattern has been applied to this part of the API.
74+ * This method calls the newly introduced method "doFunctionName" internally,
75+ * which is the method to override from now on.
76+ *
77+ **/
5878 // / Process geometrical data.
5979 // /
6080 // / This function is called by the CollisionVisitor, it can be used to process a collision detection specific for the constraint
61- virtual void processGeometricalData () {}
81+ virtual void processGeometricalData () final
82+ {
83+ // TODO (SPRINT SED 2025): Component state mechanism
84+ doProcessGeometricalData ();
85+ }
6286
87+ /* *
88+ * !!! WARNING since v26.06 !!!
89+ *
90+ * The template method pattern has been applied to this part of the API.
91+ * This method calls the newly introduced method "doFunctionName" internally,
92+ * which is the method to override from now on.
93+ *
94+ **/
6395 // / Construct the Jacobian Matrix
6496 // /
6597 // / \param cId is the result constraint sparse matrix Id
6698 // / \param cIndex is the index of the next constraint equation: when building the constraint matrix, you have to use this index, and then update it
6799 // / \param cParams defines the state vectors to use for positions and velocities. Also defines the order of the constraint (POS, VEL, ACC)
68- virtual void buildConstraintMatrix (const ConstraintParams* cParams, MultiMatrixDerivId cId, unsigned int &cIndex) = 0;
100+ virtual void buildConstraintMatrix (const ConstraintParams* cParams, MultiMatrixDerivId cId, unsigned int &cIndex) final
101+ {
102+ // TODO (SPRINT SED 2025): Component state mechanism
103+ doBuildConstraintMatrix (cParams, cId, cIndex);
104+ }
69105
106+ /* *
107+ * !!! WARNING since v26.06 !!!
108+ *
109+ * The template method pattern has been applied to this part of the API.
110+ * This method calls the newly introduced method "doFunctionName" internally,
111+ * which is the method to override from now on.
112+ *
113+ **/
70114 // / Construct the Constraint violations vector
71115 // /
72116 // / \param v is the result vector that contains the whole constraints violations
73117 // / \param cParams defines the state vectors to use for positions and velocities. Also defines the order of the constraint (POS, VEL, ACC)
74- virtual void getConstraintViolation (const ConstraintParams* cParams, linearalgebra::BaseVector *v)
118+ virtual void getConstraintViolation (const ConstraintParams* cParams, linearalgebra::BaseVector *v) final
75119 {
76- getConstraintViolation (cParams, v, d_constraintIndex.getValue ());
120+ // TODO (SPRINT SED 2025): Component state mechanism
121+ doGetConstraintViolation (cParams, v);
77122 }
78123
124+
125+ /* *
126+ * !!! WARNING since v26.06 !!!
127+ *
128+ * The template method pattern has been applied to this part of the API.
129+ * This method calls the newly introduced method "doFunctionName" internally,
130+ * which is the method to override from now on.
131+ *
132+ **/
79133 // / Construct the Constraint violations vector
80134 // /
81135 // / \param v is the result vector that contains the whole constraints violations
82136 // / \param cIndex is the index of the next constraint equation
83137 // / \param cParams defines the state vectors to use for positions and velocities. Also defines the order of the constraint (POS, VEL, ACC)
84- virtual void getConstraintViolation (const ConstraintParams* /* cParams*/ , linearalgebra::BaseVector * /* v*/ , unsigned int /* cIndex*/ ) {
85- dmsg_error () << " getConstraintViolation(const ConstraintParams* cParams, linearalgebra::BaseVector *v, const unsigned int cIndex) is not implemented while it should" ;
138+ virtual void getConstraintViolation (const ConstraintParams* /* cParams*/ , linearalgebra::BaseVector * /* v*/ , unsigned int /* cIndex*/ ) final
139+ {
140+
86141 }
87142
88143protected:
89-
144+ virtual void doResetConstraint () {}
145+ virtual void doProcessGeometricalData () {}
146+ virtual void doBuildConstraintMatrix (const ConstraintParams* cParams, MultiMatrixDerivId cId, unsigned int &cIndex) = 0;
147+ virtual void doGetConstraintViolation (const ConstraintParams* cParams, linearalgebra::BaseVector *v)
148+ {
149+ getConstraintViolation (cParams, v, d_constraintIndex.getValue ());
150+ }
151+ virtual void doGetConstraintViolation (const ConstraintParams* /* cParams*/ , linearalgebra::BaseVector * /* v*/ , unsigned int /* cIndex*/ )
152+ {
153+ dmsg_error () << " getConstraintViolation(const ConstraintParams* cParams, linearalgebra::BaseVector *v, const unsigned int cIndex) is not implemented while it should" ;
154+ }
90155 Data< int > group; // /< ID of the group containing this constraint. This ID is used to specify which constraints are solved by which solver, by specifying in each solver which groups of constraints it should handle.
156+
91157public:
92158 Data< sofa::Index > d_constraintIndex; // /< Constraint index (first index in the right hand term resolution vector)
93159
0 commit comments