Home › Forum › SOFA › Programming with SOFA › [SOLVED] after sofa debug mode build, load BeamAdapter file, vector access failure
Tagged: SOFA_2106, Windows_10
- This topic has 1 reply, 1 voice, and was last updated 3 years ago by Tum Zhang.
-
AuthorPosts
-
30 November 2021 at 09:47 #20869Tum ZhangBlocked
Dear SOFAs,
I build sofa by debug mode, when loading BeamAdapter “3instruments_collis.scn” file and start animate, I got vector access failure, but when I build sofa by release mode, the sce file running well without any failures, the failure comes from below apply and applyJ functions upstream to failure operator[], could anybody help to check the BeamAdapter for help?/// Read-only random access
const_reference operator[](Size n) const
{
if constexpr (sofa::type::isEnabledVectorAccessChecking)
{
if (n >= this->size())
vector_access_failure(this, this->size(), n, typeid(T));
}
return std::vector<T>::operator[](n);template <class In, class Out>
void Mapping<In,Out>::apply(const MechanicalParams* mparams, MultiVecCoordId outPos, ConstMultiVecCoordId inPos)
{
State<In>* fromModel = this->fromModel.get();
State<Out>* toModel = this->toModel.get();
if(fromModel && toModel)
{
OutDataVecCoord* out = outPos[toModel].write();
const InDataVecCoord* in = inPos[fromModel].read();
if((out) && (in))
{
this->apply(mparams, *out, *in);
}
}
}// Mapping::applytemplate<class DataTypes>
int BeamInterpolation<DataTypes>::getNodeIndices(unsigned int edgeInList,
unsigned int &node0Idx,
unsigned int &node1Idx )
{
if (m_topologyEdges==nullptr)
{
msg_error() <<“This object does not have edge topology defined (computation halted). ” ;
return -1;
}/// 1. Get the indices of element and nodes
ElementID e = d_edgeList.getValue()[edgeInList] ;
BaseMeshTopology::Edge edge= (*m_topologyEdges)[e];
node0Idx = edge[0];
node1Idx = edge[1];
return 1;
}template <class In, class Out>
void Mapping<In,Out>::applyJ(const MechanicalParams* mparams, MultiVecDerivId outVel, ConstMultiVecDerivId inVel)
{
State<In>* fromModel = this->fromModel.get();
State<Out>* toModel = this->toModel.get();
if(fromModel && toModel)
{
OutDataVecDeriv* out = outVel[toModel].write();
const InDataVecDeriv* in = inVel[fromModel].read();
if(out && in)
{
this->applyJ(mparams, *out, *in);
}
}
}// Mapping::applyJ2 December 2021 at 07:28 #21047Tum ZhangBlockedfinally, I found the cause, it is due to the initial positions of the three primitives(coil,cath,guide) not aligned which results in the debug vector access failure.
-
AuthorPosts
- You must be logged in to reply to this topic.