diff --git a/Sofa/Component/Collision/Detection/Intersection/src/sofa/component/collision/detection/intersection/LocalMinDistance.cpp b/Sofa/Component/Collision/Detection/Intersection/src/sofa/component/collision/detection/intersection/LocalMinDistance.cpp index d17d4c0f095..b27302c66b4 100644 --- a/Sofa/Component/Collision/Detection/Intersection/src/sofa/component/collision/detection/intersection/LocalMinDistance.cpp +++ b/Sofa/Component/Collision/Detection/Intersection/src/sofa/component/collision/detection/intersection/LocalMinDistance.cpp @@ -1236,7 +1236,7 @@ bool LocalMinDistance::testValidity(Point &p, const Vec3 &PQ) const { /// validity test with nMean, except if bothSide const PointCollisionModel *pM = p.getCollisionModel(); - const bool bothSide_computation = pM->bothSide.getValue(); + const bool bothSide_computation = pM->d_bothSide.getValue(); nMean.normalize(); if (dot(nMean, PQ) < -d_angleCone.getValue() * PQ.norm() && !bothSide_computation) { @@ -1268,7 +1268,7 @@ bool LocalMinDistance::testValidity(Line &l, const Vec3 &PQ) const return true; const LineCollisionModel *lM = l.getCollisionModel(); - const bool bothSide_computation = lM->bothSide.getValue(); + const bool bothSide_computation = lM->d_bothSide.getValue(); Vec3 n1; diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.h b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.h index 3db8be5336f..88c52c250a9 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.h +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.h @@ -141,7 +141,11 @@ public : int getLineFlags(sofa::Index i); - Data bothSide; ///< to activate collision on both-side of the both side of the line model (when surface normals are defined on these lines) + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data bothSide; + + + Data d_bothSide; ///< to activate collision on both-side of the both side of the line model (when surface normals are defined on these lines) /// Pre-construction check method called by ObjectFactory. /// Check that DataTypes matches the MechanicalState. @@ -164,7 +168,11 @@ public : void computeBBox(const core::ExecParams* params, bool onlyVisible) override; - Data m_displayFreePosition; ///< Display Collision Model Points free position(in green) + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data m_displayFreePosition; + + + Data d_displayFreePosition; ///< Display Collision Model Points free position(in green) /// Link to be set to the topology container in the component graph. SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.inl b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.inl index b281e9650ed..6682e0caf0e 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.inl +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/LineModel.inl @@ -37,12 +37,15 @@ using core::topology::BaseMeshTopology; template LineCollisionModel::LineCollisionModel() - : bothSide(initData(&bothSide, false, "bothSide", "activate collision on both side of the line model (when surface normals are defined on these lines)") ) - , m_displayFreePosition(initData(&m_displayFreePosition, false, "displayFreePosition", "Display Collision Model Points free position(in green)") ) + : d_bothSide(initData(&d_bothSide, false, "bothSide", "activate collision on both side of the line model (when surface normals are defined on these lines)") ) + , d_displayFreePosition(initData(&d_displayFreePosition, false, "displayFreePosition", "Display Collision Model Points free position(in green)") ) , l_topology(initLink("topology", "link to the topology container")) , mstate(nullptr), topology(nullptr), meshRevision(-1) { enum_type = LINE_TYPE; + + bothSide.setParent(&d_bothSide); + m_displayFreePosition.setParent(&d_displayFreePosition); } @@ -330,7 +333,7 @@ void LineCollisionModel::draw(const core::visual::VisualParams* vpara const auto c = getColor4f(); vparams->drawTool()->drawLines(points, 1, sofa::type::RGBAColor(c[0], c[1], c[2], c[3])); - if (m_displayFreePosition.getValue()) + if (d_displayFreePosition.getValue()) { std::vector< type::Vec3 > pointsFree; for (sofa::Size i=0; i bothSide; ///< to activate collision on both side of the point model (when surface normals are defined on these points) + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data bothSide; + + + Data d_bothSide; ///< to activate collision on both side of the point model (when surface normals are defined on these points) /// Pre-construction check method called by ObjectFactory. /// Check that DataTypes matches the MechanicalState. @@ -129,11 +133,17 @@ class PointCollisionModel : public core::CollisionModel core::behavior::MechanicalState* mstate; - Data computeNormals; ///< activate computation of normal vectors (required for some collision detection algorithms) + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data computeNormals; + + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data m_displayFreePosition; + + Data d_computeNormals; ///< activate computation of normal vectors (required for some collision detection algorithms) VecDeriv normals; - Data m_displayFreePosition; ///< Display Collision Model Points free position(in green) + Data d_displayFreePosition; ///< Display Collision Model Points free position(in green) /// Link to be set to the topology container in the component graph. SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/PointModel.inl b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/PointModel.inl index b7012ed673c..8e079bdb165 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/PointModel.inl +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/PointModel.inl @@ -34,13 +34,17 @@ namespace sofa::component::collision::geometry template PointCollisionModel::PointCollisionModel() - : bothSide(initData(&bothSide, false, "bothSide", "activate collision on both side of the point model (when surface normals are defined on these points)") ) + : d_bothSide(initData(&d_bothSide, false, "bothSide", "activate collision on both side of the point model (when surface normals are defined on these points)") ) , mstate(nullptr) - , computeNormals( initData(&computeNormals, false, "computeNormals", "activate computation of normal vectors (required for some collision detection algorithms)") ) - , m_displayFreePosition(initData(&m_displayFreePosition, false, "displayFreePosition", "Display Collision Model Points free position(in green)") ) + , d_computeNormals(initData(&d_computeNormals, false, "computeNormals", "activate computation of normal vectors (required for some collision detection algorithms)") ) + , d_displayFreePosition(initData(&d_displayFreePosition, false, "displayFreePosition", "Display Collision Model Points free position(in green)") ) , l_topology(initLink("topology", "link to the topology container")) { enum_type = POINT_TYPE; + + bothSide.setParent(&d_bothSide); + computeNormals.setParent(&d_computeNormals); + m_displayFreePosition.setParent(&d_displayFreePosition); } template @@ -69,7 +73,7 @@ void PointCollisionModel::init() const int npoints = mstate->getSize(); resize(npoints); - if (computeNormals.getValue()) updateNormals(); + if (d_computeNormals.getValue()) updateNormals(); } @@ -125,7 +129,7 @@ void PointCollisionModel::computeBoundingTree(int maxDepth) if (updated) cubeModel->resize(0); if (!isMoving() && !cubeModel->empty() && !updated) return; // No need to recompute BBox if immobile - if (computeNormals.getValue()) updateNormals(); + if (d_computeNormals.getValue()) updateNormals(); cubeModel->resize(size); if (!empty()) @@ -155,7 +159,7 @@ void PointCollisionModel::computeContinuousBoundingTree(SReal dt, int } if (!isMoving() && !cubeModel->empty() && !updated) return; // No need to recompute BBox if immobile - if (computeNormals.getValue()) updateNormals(); + if (d_computeNormals.getValue()) updateNormals(); type::Vec3 minElem, maxElem; @@ -362,7 +366,7 @@ void PointCollisionModel::draw(const core::visual::VisualParams* vpar vparams->drawTool()->drawPoints(pointsP, 3, sofa::type::RGBAColor(c[0], c[1], c[2], c[3])); vparams->drawTool()->drawLines(pointsL, 1, sofa::type::RGBAColor(c[0], c[1], c[2], c[3])); - if (m_displayFreePosition.getValue()) + if (d_displayFreePosition.getValue()) { std::vector< type::Vec3 > pointsPFree; diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.cpp b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.cpp index 2887dace5e2..ca64b229a2f 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.cpp +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.cpp @@ -37,9 +37,10 @@ using namespace sofa::type; using namespace sofa::defaulttype; RayCollisionModel::RayCollisionModel(SReal length) - : defaultLength(initData(&defaultLength, length, "", "TODO")) + : d_defaultLength(initData(&d_defaultLength, length, "defaultLength", "The default length for all rays in this collision model")) { this->contactResponse.setValue("RayContact"); // use RayContact response class + defaultLength.setParent(&d_defaultLength); } void RayCollisionModel::resize(sofa::Size size) @@ -50,7 +51,7 @@ void RayCollisionModel::resize(sofa::Size size) { length.reserve(size); while (length.size() < size) - length.push_back(defaultLength.getValue()); + length.push_back(d_defaultLength.getValue()); direction.reserve(size); while (direction.size() < size) direction.push_back(Vec3()); diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.h b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.h index fe3271718a3..b598ffe74eb 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.h +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/RayModel.h @@ -93,7 +93,13 @@ class SOFA_COMPONENT_COLLISION_GEOMETRY_API RayCollisionModel : public core::Col sofa::type::vector length; sofa::type::vector direction; - Data defaultLength; ///< TODO + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data defaultLength; + + + + + Data d_defaultLength; std::set contacts; core::behavior::MechanicalState* mstate; diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.h b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.h index c5a7497a702..069194c0372 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.h +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.h @@ -116,7 +116,7 @@ class SphereCollisionModel : public core::CollisionModel core::behavior::MechanicalState* getMechanicalState() { return mstate; } - const VecReal& getR() const { return this->radius.getValue(); } + const VecReal& getR() const { return this->d_radius.getValue(); } Real getRadius(const sofa::Index i) const; @@ -158,9 +158,14 @@ class SphereCollisionModel : public core::CollisionModel return obj; } - //TODO(dmarchal) guideline de sofa. - Data< VecReal > radius; ///< Radius of each sphere - Data< SReal > defaultRadius; ///< Default Radius + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data< VecReal > radius; + + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data defaultRadius; + + Data< VecReal > d_radius; ///< Radius of each sphere + Data< SReal > d_defaultRadius; ///< Default Radius Data< bool > d_showImpostors; ///< Draw spheres as impostors instead of "real" spheres diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.inl b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.inl index becb7feb1f9..975f2897c88 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.inl +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/SphereModel.inl @@ -33,18 +33,21 @@ namespace sofa::component::collision::geometry template SphereCollisionModel::SphereCollisionModel() - : radius(initData(&radius, "listRadius","Radius of each sphere")) - , defaultRadius(initData(&defaultRadius,(SReal)(1.0), "radius","Default Radius")) + : d_radius(initData(&d_radius, "listRadius", "Radius of each sphere")) + , d_defaultRadius(initData(&d_defaultRadius, (SReal)(1.0), "radius", "Default Radius")) , d_showImpostors(initData(&d_showImpostors, true, "showImpostors", "Draw spheres as impostors instead of \"real\" spheres")) , mstate(nullptr) { enum_type = SPHERE_TYPE; + + radius.setParent(&d_radius); + defaultRadius.setParent(&d_defaultRadius); } template SphereCollisionModel::SphereCollisionModel(core::behavior::MechanicalState* _mstate ) - : radius(initData(&radius, "listRadius","Radius of each sphere")) - , defaultRadius(initData(&defaultRadius,(SReal)(1.0), "radius","Default Radius. (default=1.0)")) + : d_radius(initData(&d_radius, "listRadius", "Radius of each sphere")) + , d_defaultRadius(initData(&d_defaultRadius, (SReal)(1.0), "radius", "Default Radius. (default=1.0)")) , d_showImpostors(initData(&d_showImpostors, true, "showImpostors", "Draw spheres as impostors instead of \"real\" spheres")) , mstate(_mstate) { @@ -57,13 +60,13 @@ void SphereCollisionModel::resize(sofa::Size size) { this->core::CollisionModel::resize(size); - helper::WriteAccessor< Data > r = radius; + helper::WriteAccessor< Data > r = d_radius; if (r.size() < size) { r.reserve(size); while (r.size() < size) - r.push_back((Real)defaultRadius.getValue()); + r.push_back((Real)d_defaultRadius.getValue()); } else { @@ -249,10 +252,10 @@ void SphereCollisionModel::computeContinuousBoundingTree(SReal dt, in template typename SphereCollisionModel::Real SphereCollisionModel::getRadius(const sofa::Index i) const { - if(i < this->radius.getValue().size()) - return radius.getValue()[i]; + if(i < this->d_radius.getValue().size()) + return d_radius.getValue()[i]; else - return (Real) defaultRadius.getValue(); + return (Real) d_defaultRadius.getValue(); } template diff --git a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/config.h.in b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/config.h.in index 5168625a495..42ec7bfd3e0 100644 --- a/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/config.h.in +++ b/Sofa/Component/Collision/Geometry/src/sofa/component/collision/geometry/config.h.in @@ -36,3 +36,11 @@ namespace sofa::component::collision::geometry constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; } // namespace sofa::component::collision::geometry + +#ifdef SOFA_BUILD_SOFA_COMPONENT_COLLISION_GEOMETRY +#define SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() +#else +#define SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() \ + SOFA_ATTRIBUTE_DEPRECATED("v24.06", "v24.12", \ + "Data renamed according to the guidelines") +#endif diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.h index 2b76051b1fe..e372f8ad399 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.h @@ -71,7 +71,11 @@ class BarycentricStickContact : public core::collision::Contact void setInteractionTags(MechanicalState1* mstate1, MechanicalState2* mstate2); public: - Data f_keepAlive; ///< set to true to keep this contact alive even after collisions are no longer detected + + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data f_keepAlive; + + Data d_keepAlive; ///< set to true to keep this contact alive even after collisions are no longer detected void cleanup() override; @@ -84,10 +88,10 @@ class BarycentricStickContact : public core::collision::Contact void removeResponse() override; /// Return true if this contact should be kept alive, even if objects are no longer in collision - bool keepAlive() override { return f_keepAlive.getValue(); } + bool keepAlive() override { return d_keepAlive.getValue(); } /// Control the keepAlive flag of the contact. - void setKeepAlive(bool val) override { f_keepAlive.setValue(val); } + void setKeepAlive(bool val) override { d_keepAlive.setValue(val); } void draw(const core::visual::VisualParams* vparams) override; }; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.inl index 4cecc1b9e9f..079881ad23e 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/BarycentricStickContact.inl @@ -30,10 +30,12 @@ namespace sofa::component::collision::response::contact template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes > BarycentricStickContact::BarycentricStickContact(CollisionModel1* model1, CollisionModel2* model2, Intersection* intersectionMethod) : model1(model1), model2(model2), intersectionMethod(intersectionMethod), ff(nullptr), parent(nullptr) - , f_keepAlive(initData(&f_keepAlive, true, "keepAlive", "set to true to keep this contact alive even after collisions are no longer detected")) + , d_keepAlive(initData(&d_keepAlive, true, "keepAlive", "set to true to keep this contact alive even after collisions are no longer detected")) { mapper1.setCollisionModel(model1); mapper2.setCollisionModel(model2); + + f_keepAlive.setParent(&d_keepAlive); } template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes > diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp index c31ea4aef72..c5a7c8fd9b3 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.cpp @@ -36,9 +36,11 @@ int CollisionResponseClass = core::RegisterObject("Default class to create react ; CollisionResponse::CollisionResponse() - : response(initData(&response, "response", "contact response class")) - , responseParams(initData(&responseParams, "responseParams", "contact response parameters (syntax: name1=value1&name2=value2&...)")) + : d_response(initData(&d_response, "response", "contact response class")) + , d_responseParams(initData(&d_responseParams, "responseParams", "contact response parameters (syntax: name1=value1&name2=value2&...)")) { + response.setParent(&d_response); + responseParams.setParent(&d_responseParams); } sofa::helper::OptionsGroup CollisionResponse::initializeResponseOptions(sofa::core::objectmodel::BaseContext *context) @@ -70,9 +72,9 @@ sofa::helper::OptionsGroup CollisionResponse::initializeResponseOptions(sofa::co void CollisionResponse::init() { Inherit1::init(); - if (response.getValue().size() == 0) + if (d_response.getValue().size() == 0) { - response.setValue(initializeResponseOptions(getContext())); + d_response.setValue(initializeResponseOptions(getContext())); } } @@ -96,17 +98,17 @@ void CollisionResponse::reset() void CollisionResponse::setDefaultResponseType(const std::string &responseT) { - if (response.getValue().size() == 0) + if (d_response.getValue().size() == 0) { const type::vector listResponse(1,responseT); const sofa::helper::OptionsGroup responseOptions(listResponse); - response.setValue(responseOptions); + d_response.setValue(responseOptions); } else { - sofa::helper::OptionsGroup* options = response.beginEdit(); + sofa::helper::OptionsGroup* options = d_response.beginEdit(); options->setSelectedItem(responseT); - response.endEdit(); + d_response.endEdit(); } } @@ -287,8 +289,8 @@ void CollisionResponse::setNumberOfContacts() const std::string CollisionResponse::getContactResponse(core::CollisionModel* model1, core::CollisionModel* model2) { - std::string responseUsed = response.getValue().getSelectedItem(); - const std::string params = responseParams.getValue(); + std::string responseUsed = d_response.getValue().getSelectedItem(); + const std::string params = d_responseParams.getValue(); if (!params.empty()) { responseUsed += '?'; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.h index bd61f1a91c0..d133ad96c48 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/CollisionResponse.h @@ -36,8 +36,15 @@ class SOFA_COMPONENT_COLLISION_RESPONSE_CONTACT_API CollisionResponse : public c public : SOFA_CLASS(CollisionResponse,sofa::core::collision::ContactManager); - Data response; ///< contact response class - Data responseParams; ///< contact response parameters (syntax: name1=value1 Data responseParams;name2=value2 Data responseParams;...) + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data response; + + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data responseParams; + + + Data d_response; ///< contact response class + Data d_responseParams; ///< contact response parameters (syntax: name1=value1 Data responseParams;name2=value2 Data responseParams;...) /// outputsVec fixes the reproducibility problems by storing contacts in the collision detection saved order /// if not given, it is still working but with eventual reproducibility problems @@ -53,7 +60,7 @@ public : { context->addObject(obj); sofa::helper::OptionsGroup options = initializeResponseOptions(context); - obj->response.setValue(options); + obj->d_response.setValue(options); } if (arg) @@ -98,7 +105,7 @@ public : void setDefaultResponseType(const std::string &responseT); - std::string getDefaultResponseType() const { return response.getValue().getSelectedItem(); } + std::string getDefaultResponseType() const { return d_response.getValue().getSelectedItem(); } protected: typedef sofa::helper::map_ptr_stable_compare< diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h index a50fc209383..8bb87d02af8 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h @@ -63,8 +63,14 @@ class FrictionContact : public core::collision::Contact, public ContactIdentifie constraint::lagrangian::model::UnilateralLagrangianConstraint::SPtr m_constraint; core::objectmodel::BaseContext* parent; - Data mu; ///< friction coefficient (0 for frictionless contacts) - Data tol; ///< tolerance for the constraints resolution (0 for default tolerance) + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data mu; + + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data tol; + + Data d_mu; ///< friction coefficient (0 for frictionless contacts) + Data d_tol; ///< tolerance for the constraints resolution (0 for default tolerance) std::vector< sofa::core::collision::DetectionOutput* > contacts; std::vector< std::pair< std::pair, double > > mappedContacts; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl index d0d093e4db1..5d2c755a2e6 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl @@ -46,8 +46,8 @@ FrictionContact::FrictionCo , intersectionMethod(intersectionMethod) , m_constraint(nullptr) , parent(nullptr) - , mu (initData(&mu, 0.8, "mu", "friction coefficient (0 for frictionless contacts)")) - , tol (initData(&tol, 0.0, "tol", "tolerance for the constraints resolution (0 for default tolerance)")) + , d_mu (initData(&d_mu, 0.8, "mu", "friction coefficient (0 for frictionless contacts)")) + , d_tol (initData(&d_tol, 0.0, "tol", "tolerance for the constraints resolution (0 for default tolerance)")) { selfCollision = ((core::CollisionModel*)model1 == (core::CollisionModel*)model2); mapper1.setCollisionModel(model1); @@ -55,6 +55,9 @@ FrictionContact::FrictionCo contacts.clear(); mappedContacts.clear(); + mu.setParent(&d_mu); + tol.setParent(&d_tol); + } template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes > @@ -147,7 +150,7 @@ void FrictionContact::activ m_constraint = sofa::core::objectmodel::New >(mmodel1, mmodel2); m_constraint->setName( getName() ); setInteractionTags(mmodel1, mmodel2); - m_constraint->setCustomTolerance( tol.getValue() ); + m_constraint->setCustomTolerance(d_tol.getValue() ); } int size = contacts.size(); @@ -204,7 +207,7 @@ void FrictionContact::creat { activateMappers(); - const double mu_ = this->mu.getValue(); + const double mu_ = this->d_mu.getValue(); // Checks if friction is considered if ( mu_ < 0.0 ) msg_error() << "mu has to take positive values"; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp index bad0827f8b6..ea4471db851 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.cpp @@ -34,11 +34,12 @@ int RuleBasedContactManagerClass = core::RegisterObject("Create different respon RuleBasedContactManager::RuleBasedContactManager() : d_variables(initData(&d_variables, "variables", "Define a list of variables to be used inside the rules")) - , rules(initData(&rules, "rules", "Ordered list of rules, each with a triplet of strings.\n" + , d_rules(initData(&d_rules, "rules", "Ordered list of rules, each with a triplet of strings.\n" "The first two define either the name of the collision model, its group number, or * meaning any model.\n" "The last string define the response algorithm to use for contacts matched by this rule.\n" "Rules are applied in the order they are specified. If none match a given contact, the default response is used.\n")) { + rules.setParent(&d_rules); } RuleBasedContactManager::~RuleBasedContactManager() @@ -123,7 +124,7 @@ std::string RuleBasedContactManager::getContactResponse(core::CollisionModel* mo if (!response1.empty()) return response1; else if (!response2.empty()) return response2; - const type::vector& rulesValue = rules.getValue(); + const type::vector& rulesValue = d_rules.getValue(); for (const auto& rule : rulesValue) { if (rule.match(model1, model2) || rule.match(model2, model1)) diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.h index a12e758299a..7eb9af931d0 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/RuleBasedContactManager.h @@ -102,9 +102,16 @@ class SOFA_COMPONENT_COLLISION_RESPONSE_CONTACT_API RuleBasedContactManager : pu } }; - Data< std::string > d_variables; ///< Define a list of variables to be used inside the rules + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() Data< type::vector > rules; + + + + + Data< std::string > d_variables; ///< Define a list of variables to be used inside the rules + Data< type::vector > d_rules; + virtual std::string getContactResponse(core::CollisionModel* model1, core::CollisionModel* model2) override; void createVariableData ( std::string variable ); diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h index f51e5f20b53..2561f48507e 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h @@ -70,13 +70,17 @@ class StickContactConstraint : public core::collision::Contact, public ContactId ~StickContactConstraint() override; public: - Data f_keepAlive; ///< set to true to keep this contact alive even after collisions are no longer detected + SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() + Data f_keepAlive; + + + Data d_keepAlive; ///< set to true to keep this contact alive even after collisions are no longer detected /// Return true if this contact should be kept alive, even if objects are no longer in collision - bool keepAlive() override { return f_keepAlive.getValue(); } + bool keepAlive() override { return d_keepAlive.getValue(); } /// Control the keepAlive flag of the contact. - void setKeepAlive(bool val) override { f_keepAlive.setValue(val); } + void setKeepAlive(bool val) override { d_keepAlive.setValue(val); } void cleanup() override; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl index 49ad5f0e91a..aa1d5ee4e6a 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl @@ -44,11 +44,12 @@ StickContactConstraint::StickContactConstrain , intersectionMethod(intersectionMethod) , m_constraint(nullptr) , parent(nullptr) - , f_keepAlive(initData(&f_keepAlive, true, "keepAlive", "set to true to keep this contact alive even after collisions are no longer detected")) + , d_keepAlive(initData(&d_keepAlive, true, "keepAlive", "set to true to keep this contact alive even after collisions are no longer detected")) { mapper1.setCollisionModel(model1); mapper2.setCollisionModel(model2); this->f_printLog.setValue(true); + f_keepAlive.setParent(&d_keepAlive); } template < class TCollisionModel1, class TCollisionModel2 > diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/config.h.in b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/config.h.in index 8452734db98..a93215437bc 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/config.h.in +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/config.h.in @@ -36,3 +36,11 @@ namespace sofa::component::collision::response::contact constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; } // namespace sofa::component::collision::response::contact + +#ifdef SOFA_BUILD_SOFA_COMPONENT_COLLISION_RESPONSE_CONTACT +#define SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() +#else +#define SOFA_ATTRIBUTE_DEPRECATED__RENAME_DATA() \ + SOFA_ATTRIBUTE_DEPRECATED("v24.06", "v24.12", \ + "Data renamed according to the guidelines") +#endif diff --git a/Sofa/Component/Collision/Testing/src/sofa/component/collision/testing/SpherePrimitiveCreator.h b/Sofa/Component/Collision/Testing/src/sofa/component/collision/testing/SpherePrimitiveCreator.h index 9c6f6027259..6f392d05780 100644 --- a/Sofa/Component/Collision/Testing/src/sofa/component/collision/testing/SpherePrimitiveCreator.h +++ b/Sofa/Component/Collision/Testing/src/sofa/component/collision/testing/SpherePrimitiveCreator.h @@ -103,11 +103,11 @@ inline sofa::component::collision::geometry::SphereCollisionModelinit(); - sofa::component::collision::geometry::SphereCollisionModel::VecReal& vecRad = *(sphereCollisionModel->radius.beginEdit()); + sofa::component::collision::geometry::SphereCollisionModel::VecReal& vecRad = *(sphereCollisionModel->d_radius.beginEdit()); vecRad[0] = radius; - sphereCollisionModel->radius.endEdit(); + sphereCollisionModel->d_radius.endEdit(); return sphereCollisionModel; } @@ -146,11 +146,11 @@ inline sofa::component::collision::geometry::SphereCollisionModelinit(); - sofa::component::collision::geometry::SphereCollisionModel::VecReal& vecRad = *(sphereCollisionModel->radius.beginEdit()); + sofa::component::collision::geometry::SphereCollisionModel::VecReal& vecRad = *(sphereCollisionModel->d_radius.beginEdit()); vecRad[0] = radius; - sphereCollisionModel->radius.endEdit(); + sphereCollisionModel->d_radius.endEdit(); return sphereCollisionModel; } diff --git a/Sofa/framework/Helper/src/sofa/helper/LCPcalc.cpp b/Sofa/framework/Helper/src/sofa/helper/LCPcalc.cpp index 7718fbb677a..a010443751e 100644 --- a/Sofa/framework/Helper/src/sofa/helper/LCPcalc.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/LCPcalc.cpp @@ -778,7 +778,7 @@ struct listSortAscending Classe - NLCP {dim , dfree, W , f - void NLCPSolve( int numIteration, const SReal &tol, bool convergenceTest) + void NLCPSolve( int numIteration, const SReal &d_tol, bool convergenceTest) } diff --git a/applications/projects/SceneChecking/src/SceneChecking/SceneCheckCollisionResponse.cpp b/applications/projects/SceneChecking/src/SceneChecking/SceneCheckCollisionResponse.cpp index 3c9d09441db..c867b289e0f 100644 --- a/applications/projects/SceneChecking/src/SceneChecking/SceneCheckCollisionResponse.cpp +++ b/applications/projects/SceneChecking/src/SceneChecking/SceneCheckCollisionResponse.cpp @@ -68,7 +68,7 @@ void SceneCheckCollisionResponse::doCheckOn(Node* node) } else { - const std::string response = contactManager[0]->response.getValue().getSelectedItem(); + const std::string response = contactManager[0]->d_response.getValue().getSelectedItem(); /// If StickContactConstraint is chosen, make sure the scene includes a FreeMotionAnimationLoop and a GenericConstraintSolver (specifically) if ( response == "StickContactConstraint" )