Skip to content

Commit

Permalink
[SofaBaseTopology] Change callback names in TopologyData
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed Jun 11, 2021
1 parent 78cee81 commit 61f07e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class TopologyData : public sofa::core::topology::BaseTopologyData<VecT>
* This is only to specify a specific behevior/computation when removing an element from this container. Otherwise normal deletion is applyed.
* Parameters are @param Index of the element which is detroyed and @value_type value hold by this container.
*/
void applyDestroyFunction(std::function<void(Index, value_type&)> func) { m_DestroyFunction = func; }
void setDestructionCallback(std::function<void(Index, value_type&)> func) { p_onDestructionCallback = func; }

/** Method to add a callback when a element is created in this container. It will be called by @sa add method for example.
* This is only to specify a specific behevior/computation when adding an element in this container. Otherwise default constructor of the element is used.
Expand All @@ -124,10 +124,10 @@ class TopologyData : public sofa::core::topology::BaseTopologyData<VecT>
* @param List of ancestor indices.
* @param List of coefficient respect to the ancestor indices.
*/
void applyCreateFunction(std::function<void(Index, value_type&, const TopologyElementType&, const sofa::helper::vector< Index >&, const sofa::helper::vector< double >&)> func) { m_CreateFunction = func; }
void setCreationCallback(std::function<void(Index, value_type&, const TopologyElementType&, const sofa::helper::vector< Index >&, const sofa::helper::vector< double >&)> func) { p_onCreationCallback = func; }

std::function<void(Index, value_type&)> m_DestroyFunction;
std::function<void(Index, value_type&, const TopologyElementType&, const sofa::helper::vector< Index >&, const sofa::helper::vector< double >&)> m_CreateFunction;
std::function<void(Index, value_type&)> p_onDestructionCallback;
std::function<void(Index, value_type&, const TopologyElementType&, const sofa::helper::vector< Index >&, const sofa::helper::vector< double >&)> p_onCreationCallback;

////////////////////////////////////// DEPRECATED ///////////////////////////////////////////
SOFA_ATTRIBUTE_DISABLED("v21.06 (PR#2082)", "v21.06 (PR#2082)", "This method has been removed as it is not part of the new topology change design.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ void TopologyData <TopologyElementType, VecT>::remove(const sofa::helper::vector
this->m_topologyHandler->applyDestroyFunction(index[i], data[index[i]]);
}

if (m_DestroyFunction)
if (p_onDestructionCallback)
{
m_DestroyFunction(index[i], data[index[i]]);
p_onDestructionCallback(index[i], data[index[i]]);
}

this->swap(index[i], last);
Expand Down Expand Up @@ -258,9 +258,9 @@ void TopologyData <TopologyElementType, VecT>::add(const sofa::helper::vector<In
(ancestors.empty() || coefs.empty()) ? empty_vecdouble : coefs[i],
(ancestorElems.empty()) ? nullptr : &ancestorElems[i]);

if (m_CreateFunction)
if (p_onCreationCallback)
{
m_CreateFunction(Index(i0 + i), t, elems[i],
p_onCreationCallback(Index(i0 + i), t, elems[i],
(ancestors.empty() || coefs.empty()) ? empty_vecint : ancestors[i],
(ancestors.empty() || coefs.empty()) ? empty_vecdouble : coefs[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void TriangularBendingSprings<DataTypes>::init()
edgeInfo.linkToPointDataArray();
edgeInfo.linkToTriangleDataArray();

edgeInfo.applyCreateFunction([this](Index edgeIndex, EdgeInformation& ei,
edgeInfo.setCreationCallback([this](Index edgeIndex, EdgeInformation& ei,
const core::topology::BaseMeshTopology::Edge& edge,
const sofa::helper::vector< Index >& ancestors,
const sofa::helper::vector< double >& coefs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void TriangularFEMForceField<DataTypes>::init()
edgeInfo.createTopologyHandler(m_topology);
vertexInfo.createTopologyHandler(m_topology);

triangleInfo.applyCreateFunction([this](Index triangleIndex, TriangleInformation& triInfo,
triangleInfo.setCreationCallback([this](Index triangleIndex, TriangleInformation& triInfo,
const core::topology::BaseMeshTopology::Triangle& triangle,
const sofa::helper::vector< Index >& ancestors,
const sofa::helper::vector< double >& coefs)
Expand Down

0 comments on commit 61f07e6

Please sign in to comment.