Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sofa/framework/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ endif()
## Windows-specific
if(WIN32)
list(APPEND SOFACONFIG_COMPILE_OPTIONS "/W4")
# MSVC warning suppressions
list(APPEND SOFACONFIG_COMPILE_OPTIONS "/wd4589") # Constructor of abstract class ignores initializer for virtual base class

list(APPEND SOFACONFIG_COMPILE_OPTIONS "-D_USE_MATH_DEFINES")
list(APPEND SOFACONFIG_COMPILE_OPTIONS "-D_CRT_SECURE_NO_WARNINGS")
list(APPEND SOFACONFIG_COMPILE_OPTIONS "-D_CRT_NONSTDC_NO_DEPRECATE")
Expand Down
2 changes: 1 addition & 1 deletion Sofa/framework/Core/src/sofa/core/CollisionElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BaseCollisionElementIterator
/// Constructor.
/// This constructor should be used in case a vector of indices is used.
BaseCollisionElementIterator(VIterator vit, VIterator vitend)
: index(-1), it(vit), itend(vitend)
: index(static_cast<Index>(-1)), it(vit), itend(vitend)
{
if (it != itend) index = *it;
}
Expand Down
2 changes: 1 addition & 1 deletion Sofa/framework/Core/src/sofa/core/ComponentLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace sofa::core
std::string caseInsensitive(const std::string &text)
{
std::string result; result.resize(text.size());
for (unsigned int i=0; i<text.size(); ++i) result[i] = toupper(text[i]);
for (unsigned int i=0; i<text.size(); ++i) result[i] = static_cast<char>(toupper(text[i]));
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Core/src/sofa/core/DataTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void DataTrackerDDGNode::cleanDirty(const core::ExecParams*)

void DataTrackerDDGNode::updateAllInputsIfDirty()
{
const DDGLinkContainer& inputs = DDGNode::getInputs();
for(const auto input : inputs)
const DDGLinkContainer& ddgInputs = DDGNode::getInputs();
for(const auto input : ddgInputs)
{
static_cast<core::objectmodel::BaseData*>(input)->updateIfDirty();
}
Expand Down
1 change: 0 additions & 1 deletion Sofa/framework/Core/src/sofa/core/Mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace sofa::core
{

using namespace sofa::defaulttype;
using namespace core;

template class SOFA_CORE_API Mapping< sofa::defaulttype::Vec1Types, sofa::defaulttype::Vec1Types >;
template class SOFA_CORE_API Mapping< sofa::defaulttype::Vec1Types, sofa::defaulttype::Vec2Types >;
Expand Down
52 changes: 26 additions & 26 deletions Sofa/framework/Core/src/sofa/core/Mapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ sofa::linearalgebra::BaseMatrix* Mapping<In,Out>::createMappedMatrix(const behav
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)
State<In>* from = this->fromModel.get();
State<Out>* to = this->toModel.get();
if(from && to)
{
OutDataVecCoord* out = outPos[toModel].write();
const InDataVecCoord* in = inPos[fromModel].read();
OutDataVecCoord* out = outPos[to].write();
const InDataVecCoord* in = inPos[from].read();
if(out && in)
{
this->apply(mparams, *out, *in);
Expand All @@ -151,12 +151,12 @@ void Mapping<In,Out>::apply(const MechanicalParams* mparams, MultiVecCoordId out
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)
State<In>* from = this->fromModel.get();
State<Out>* to = this->toModel.get();
if(from && to)
{
OutDataVecDeriv* out = outVel[toModel].write();
const InDataVecDeriv* in = inVel[fromModel].read();
OutDataVecDeriv* out = outVel[to].write();
const InDataVecDeriv* in = inVel[from].read();
if(out && in)
{
this->applyJ(mparams, *out, *in);
Expand All @@ -167,12 +167,12 @@ void Mapping<In,Out>::applyJ(const MechanicalParams* mparams, MultiVecDerivId ou
template <class In, class Out>
void Mapping<In,Out>::applyJT(const MechanicalParams *mparams, MultiVecDerivId inForce, ConstMultiVecDerivId outForce)
{
State<In>* fromModel = this->fromModel.get();
State<Out>* toModel = this->toModel.get();
if(fromModel && toModel)
State<In>* from = this->fromModel.get();
State<Out>* to = this->toModel.get();
if(from && to)
{
InDataVecDeriv* out = inForce[fromModel].write();
const OutDataVecDeriv* in = outForce[toModel].read();
InDataVecDeriv* out = inForce[from].write();
const OutDataVecDeriv* in = outForce[to].read();
if(out && in)
{
this->applyJT(mparams, *out, *in);
Expand All @@ -184,12 +184,12 @@ void Mapping<In,Out>::applyJT(const MechanicalParams *mparams, MultiVecDerivId i
template <class In, class Out>
void Mapping<In,Out>::applyJT(const ConstraintParams* cparams, MultiMatrixDerivId inConst, ConstMultiMatrixDerivId outConst )
{
State<In>* fromModel = this->fromModel.get();
State<Out>* toModel = this->toModel.get();
if(fromModel && toModel)
State<In>* from = this->fromModel.get();
State<Out>* to = this->toModel.get();
if(from && to)
{
InDataMatrixDeriv* out = inConst[fromModel].write();
const OutDataMatrixDeriv* in = outConst[toModel].read();
InDataMatrixDeriv* out = inConst[from].write();
const OutDataMatrixDeriv* in = outConst[to].read();
if(out && in)
{
this->applyJT(cparams, *out, *in);
Expand All @@ -208,13 +208,13 @@ void Mapping<In,Out>::applyDJT(const MechanicalParams* /*mparams */ , MultiVecDe
template <class In, class Out>
void Mapping<In,Out>::computeAccFromMapping(const MechanicalParams* mparams, MultiVecDerivId outAcc, ConstMultiVecDerivId inVel, ConstMultiVecDerivId inAcc )
{
State<In>* fromModel = this->fromModel.get();
State<Out>* toModel = this->toModel.get();
if(fromModel && toModel)
State<In>* from = this->fromModel.get();
State<Out>* to = this->toModel.get();
if(from && to)
{
OutDataVecDeriv* out = outAcc[toModel].write();
const InDataVecDeriv* inV = inVel[fromModel].read();
const InDataVecDeriv* inA = inAcc[fromModel].read();
OutDataVecDeriv* out = outAcc[to].write();
const InDataVecDeriv* inV = inVel[from].read();
const InDataVecDeriv* inA = inAcc[from].read();
if(out && inV && inA)
this->computeAccFromMapping(mparams, *out, *inV, *inA);
}
Expand Down
6 changes: 3 additions & 3 deletions Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void ObjectFactory::dump(std::ostream& out)
if (!entry->aliases.empty())
{
out << " aliases :";
for (std::set<std::string>::iterator myit = entry->aliases.begin(), itend = entry->aliases.end(); myit != itend; ++myit)
for (std::set<std::string>::iterator myit = entry->aliases.begin(), aliasesEnd = entry->aliases.end(); myit != aliasesEnd; ++myit)
out << " " << *myit;
out << "\n";
}
Expand Down Expand Up @@ -573,7 +573,7 @@ void ObjectFactory::dumpXML(std::ostream& out)
const ClassEntry::SPtr entry = it->second;
if (entry->className != it->first) continue;
out << "<class name=\"" << xmlencode(entry->className) <<"\">\n";
for (std::set<std::string>::iterator myit = entry->aliases.begin(), itend = entry->aliases.end(); myit != itend; ++myit)
for (std::set<std::string>::iterator myit = entry->aliases.begin(), aliasesEnd = entry->aliases.end(); myit != aliasesEnd; ++myit)
out << "<alias>" << xmlencode(*myit) << "</alias>\n";
if (!entry->description.empty())
out << "<description>"<<entry->description<<"</description>\n";
Expand Down Expand Up @@ -607,7 +607,7 @@ void ObjectFactory::dumpHTML(std::ostream& out)
if (!entry->aliases.empty())
{
out << "<li>Aliases:<i>";
for (std::set<std::string>::iterator myit = entry->aliases.begin(), itend = entry->aliases.end(); myit != itend; ++myit)
for (std::set<std::string>::iterator myit = entry->aliases.begin(), aliasesEnd = entry->aliases.end(); myit != aliasesEnd; ++myit)
out << " " << xmlencode(*myit);
out << "</i></li>\n";
}
Expand Down
6 changes: 3 additions & 3 deletions Sofa/framework/Core/src/sofa/core/SofaLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void SofaLibrary::build( const std::vector< std::string >& examples)
if (creatorEntry != entries[i]->creatorMap.end())
{
const objectmodel::BaseClass* baseClass = creatorEntry->second->getClass();
std::vector<std::string> categories;
CategoryLibrary::getCategories(baseClass, categories);
for (std::vector<std::string>::iterator it = categories.begin(); it != categories.end(); ++it)
std::vector<std::string> categoriesVec;
CategoryLibrary::getCategories(baseClass, categoriesVec);
for (std::vector<std::string>::iterator it = categoriesVec.begin(); it != categoriesVec.end(); ++it)
{
mainCategories.insert((*it));
inventory.insert(std::make_pair((*it), entries[i]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void DefaultMultiMatrixAccessor::clear()
{
globalDim = 0;
for (auto it = realStateOffsets.begin(), itend = realStateOffsets.end(); it != itend; ++it)
it->second = -1;
it->second = static_cast<decltype(it->second)>(-1);

for (std::map< const sofa::core::behavior::BaseMechanicalState*, linearalgebra::BaseMatrix* >::iterator it = mappedMatrices.begin(), itend = mappedMatrices.end(); it != itend; ++it)
if (it->second != nullptr) delete it->second;
Expand Down
18 changes: 9 additions & 9 deletions Sofa/framework/Core/src/sofa/core/collision/Intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ helper::TypeInfo IntersectorMap::getType(core::CollisionModel* model)
if (it == castMap.end())
{
helper::TypeInfo t2 = t;
for (std::set<const objectmodel::ClassInfo* >::iterator it = classes.begin(); it != classes.end(); ++it)
for (std::set<const objectmodel::ClassInfo* >::iterator ci = classes.begin(); ci != classes.end(); ++ci)
{
if ((*it)->isInstance(model))
if ((*ci)->isInstance(model))
{
t2 = (*it)->type();
t2 = (*ci)->type();
break;
}
}
Expand Down Expand Up @@ -76,14 +76,14 @@ ElementIntersector* IntersectorMap::get(core::CollisionModel* model1, core::Coll


std::stringstream tmp;
for(InternalMap::const_iterator it = intersectorsMap.begin(), itEnd = intersectorsMap.end(); it != itEnd; ++it)
for(InternalMap::const_iterator it2 = intersectorsMap.begin(), itEnd = intersectorsMap.end(); it2 != itEnd; ++it2)
{
helper::TypeInfo t1 = it->first.first;
helper::TypeInfo t2 = it->first.second;
helper::TypeInfo t1_tmp = it2->first.first;
helper::TypeInfo t2_tmp = it2->first.second;
tmp << " "
<< gettypename(t1) << "-"
<< gettypename(t2);
const ElementIntersector* i = it->second;
<< gettypename(t1_tmp) << "-"
<< gettypename(t2_tmp);
const ElementIntersector* i = it2->second;
if (!i)
tmp << " nullptr";
else
Expand Down
1 change: 0 additions & 1 deletion Sofa/framework/Core/src/sofa/core/loader/VoxelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace sofa::core::loader
{

using namespace sofa::defaulttype;
using namespace sofa::core::loader;

VoxelLoader::VoxelLoader()
:BaseLoader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ const BaseComponent::VecSlaves& BaseComponent::getSlaves() const
return l_slaves.getValue();
}

BaseComponent* BaseComponent::getSlave(const std::string& name) const
BaseComponent* BaseComponent::getSlave(const std::string& slaveName) const
{
for (auto slave : l_slaves)
{
if (slave.get() && slave->getName() == name)
if (slave.get() && slave->getName() == slaveName)
return slave.get();
}
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Core/src/sofa/core/objectmodel/BaseLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ bool BaseLink::read( const std::string& str )

/// Add the detected objects that are not already present to the container of this Link
clear();
for (const auto& [base, path] : entries)
for (const auto& [base, linkPath] : entries)
{
ok = add(base, path) && ok;
ok = add(base, linkPath) && ok;
}
return ok;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int BaseObjectDescription::getAttributeAsInt(const std::string& attr, const int

const char* attrstr=it->second.c_str();
char* end=nullptr;
const int retval = strtol(attrstr, &end, 10);
const int retval = static_cast<int>(strtol(attrstr, &end, 10));

/// It is important to check that the attribute was totally parsed to report
/// message to users because a silent error is the worse thing that can happen in UX.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ void TopologySubsetData <ElementType, VecT>::add(sofa::Size nbElements,
helper::WriteOnlyAccessor<Data<container_type> > data = this;

// first resize the subsetData. value will be applied in the loop using callbacks
const Size size = data.size();
data.resize(size + nbElements);
const Size size = static_cast<Size>(data.size());
data.resize(size + static_cast<Size>(nbElements));


if (this->p_onCreationCallback)
Expand All @@ -129,7 +129,7 @@ void TopologySubsetData <ElementType, VecT>::add(sofa::Size nbElements,
value_type& t = data[id];

// update map if needed
addPostProcess(LastDataId + i + 1);
addPostProcess(LastDataId + static_cast<sofa::Index>(i) + 1);

this->p_onCreationCallback(id, t, elems[i],
(ancestors.empty() || coefs.empty()) ? s_empty_ancestors : ancestors[i],
Expand All @@ -154,7 +154,7 @@ void TopologySubsetData <ElementType, VecT>::add(const sofa::type::vector<Index>
{
SOFA_UNUSED(ancestorElems);

const sofa::Size nbElements = index.size();
const sofa::Size nbElements = static_cast<sofa::Size>(index.size());
this->add(nbElements, elems, ancestors, coefs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int TypeInfoRegistry::AllocateNewTypeId(const std::type_info& nfo)
const std::string name = sofa::helper::NameDecoder::decodeTypeName(nfo);
const std::string typeName = sofa::helper::NameDecoder::decodeTypeName(nfo);
typeinfos.push_back(new NameOnlyTypeInfo(name, typeName));
return typeinfos.size()-1;
return static_cast<int>(typeinfos.size()-1);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ class SOFA_DEFAULTTYPE_API NameOnlyTypeInfo : public AbstractTypeInfo
/// and those six elements are conceptually numbered from 0 to 5. This is
/// relevant only if FixedSize() is true. I FixedSize() is false,
/// the return value will be equivalent to the one of byteSize()
sofa::Size size() const override {return -1;}
sofa::Size size() const override {return static_cast<sofa::Size>(-1);}
/// The size in bytes of the ValueType
/// For example, the size of a fixed_array<fixed_array<int, 2>, 3>` is 4 on most systems,
/// as it is the byte size of the smallest dimension in the array (int -> 32bit)
sofa::Size byteSize() const override {return -1;}
sofa::Size byteSize() const override {return static_cast<sofa::Size>(-1);}

/// The size of \a data, in number of iterable elements
/// (For containers, that'll be the number of elements in the 1st dimension).
/// For example, with type == `
sofa::Size size(const void* /*data*/) const override {return -1;}
sofa::Size size(const void* /*data*/) const override {return static_cast<sofa::Size>(-1);}
/// Resize \a data to \a size elements, if relevant.

/// But resizing is not always relevant, for example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ class SOFA_DEFAULTTYPE_API NoTypeInfo : public AbstractTypeInfo
/// and those six elements are conceptually numbered from 0 to 5. This is
/// relevant only if FixedSize() is true. I FixedSize() is false,
/// the return value will be equivalent to the one of byteSize()
sofa::Size size() const override {return -1;}
sofa::Size size() const override {return static_cast<sofa::Size>(-1);}
/// The size in bytes of the ValueType
/// For example, the size of a fixed_array<fixed_array<int, 2>, 3>` is 4 on most systems,
/// as it is the byte size of the smallest dimension in the array (int -> 32bit)
sofa::Size byteSize() const override {return -1;}
sofa::Size byteSize() const override {return static_cast<sofa::Size>(-1);}

/// The size of \a data, in number of iterable elements
/// (For containers, that'll be the number of elements in the 1st dimension).
/// For example, with type == `
sofa::Size size(const void* /*data*/) const override {return -1;}
sofa::Size size(const void* /*data*/) const override {return static_cast<sofa::Size>(-1);}
/// Resize \a data to \a size elements, if relevant.

/// But resizing is not always relevant, for example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct FixedArrayTypeInfo
{
if constexpr (!FixedSize)
{
size /= data.size();
size /= static_cast<sofa::Size>(data.size());
for (sofa::Size i = 0; i < data.size(); ++i)
{
if (!BaseTypeInfo::setSize(data[(sofa::Size)i], size))
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Helper/src/sofa/helper/AdvancedTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ void TimerData::print()
AdvancedTimer::outputType AdvancedTimer::convertOutputType(std::string type)
{
std::for_each(type.begin(), type.end(), [](char& c) {
c = std::tolower(static_cast<unsigned char>(c)); } );
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c))); } );

if(type.compare("json") == 0)
return JSON;
Expand Down Expand Up @@ -1087,7 +1087,7 @@ std::string getTime(ctime_t t, int niter=1)
double strToDouble(std::string const &stringToConvert, std::size_t const precision)
{
std::stringstream convertingStream;
convertingStream << std::setprecision(precision) << std::fixed << stringToConvert << std::endl;
convertingStream << std::setprecision(static_cast<int>(precision)) << std::fixed << stringToConvert << std::endl;

double answer;
convertingStream >> answer;
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Helper/src/sofa/helper/DiffLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ std::vector<std::tuple<std::string, SReal>> SOFA_HELPER_API getClosestMatch(cons
class Tuple
{
public:
Tuple(float ratio_, std::string value_)
Tuple(SReal ratio_, std::string value_)
: ratio(ratio_), value(std::move(value_)) {}

float ratio;
SReal ratio;
std::string value;
};
auto cmp = [](const Tuple& left, Tuple& right) { return left.ratio < right.ratio; };
Expand Down
Loading
Loading