Commit 59c40b49 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'clean-cppcheck' into 'master'

cppcheck fixes

See merge request !59
parents f1b89140 aa83f978
Pipeline #10567 passed with stage
in 4 minutes and 21 seconds
......@@ -5,3 +5,4 @@ build*
*.swp
.settings
cppcheck.log
......@@ -13,22 +13,14 @@ WARNING='\033[0;93m'
echo -e "${OUTPUT}"
echo "=============================================================================="
echo "Running cppcheck"
echo -n "Version: "
cppcheck --version
echo "=============================================================================="
echo -e "${NC}"
echo "Please Wait ..."
# Run cppcheck and output into file
cppcheck --enable=all . -I src -i Doc/ --force --suppress=missingIncludeSystem --quiet -Umin -Umax -UBMPOSTFIX -DOPENVOLUMEMESHDLLEXPORT="" &> cppcheck.log
echo -e "${OUTPUT}"
echo "=============================================================================="
echo "CPPCHECK Messages"
echo "=============================================================================="
echo -e "${NC}"
# Echo output to command line for simple analysis via gitlab
cat cppcheck.log
cppcheck --enable=all . -I src -i Doc/ --force --suppress=missingIncludeSystem --inline-suppr --quiet -Umin -Umax -UBMPOSTFIX -DOPENVOLUMEMESHDLLEXPORT="" 2>&1 | tee cppcheck.log
COUNT=$(wc -l < cppcheck.log )
......
......@@ -85,11 +85,11 @@ template<typename T, typename Entity>
class PropertyTT : public PropertyPtr<OpenVolumeMeshPropertyT<T>, Entity> {
public:
template<typename MeshT>
PropertyTT(MeshT *mesh, const std::string& _name, const T _def = T())
PropertyTT(MeshT *mesh, const std::string& _name, const T &_def = T())
: PropertyTT(std::move(mesh->template request_property<T, Entity>(_name, _def)))
{}
using PropertyHandleT = OpenVolumeMesh::PropHandleT<Entity>;
PropertyTT(const std::string& _name, const std::string& _internal_type_name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def = T());
PropertyTT(const std::string& _name, const std::string& _internal_type_name, ResourceManager& _resMan, PropertyHandleT _handle, const T &_def = T());
~PropertyTT() override = default;
BaseProperty* clone(ResourceManager &_resMan, OpenVolumeMeshHandle _handle) const override;
const std::string entityType() const override { return entityTypeName<Entity>(); }
......
......@@ -42,7 +42,7 @@
namespace OpenVolumeMesh {
template<typename T, typename Entity>
PropertyTT<T,Entity>::PropertyTT(const std::string& _name, const std::string& _internal_type_name, ResourceManager& _resMan, PropertyHandleT _handle, const T _def) :
PropertyTT<T,Entity>::PropertyTT(const std::string& _name, const std::string& _internal_type_name, ResourceManager& _resMan, PropertyHandleT _handle, const T &_def) :
PropertyPtr<OpenVolumeMeshPropertyT<T>, Entity>(new OpenVolumeMeshPropertyT<T>(_name, _internal_type_name, _def), _resMan, _handle) {
}
......
......@@ -468,6 +468,7 @@ CellHandle TopologyKernel::add_cell(const std::vector<HalfFaceHandle>& _halfface
//========================================================================================
/// Set the vertices of an edge
// cppcheck-suppress unusedFunction ; public interface
void TopologyKernel::set_edge(const EdgeHandle& _eh, const VertexHandle& _fromVertex, const VertexHandle& _toVertex) {
assert(_fromVertex.is_valid() && (size_t)_fromVertex.idx() < n_vertices() && !is_deleted(_fromVertex));
......@@ -502,6 +503,7 @@ void TopologyKernel::set_edge(const EdgeHandle& _eh, const VertexHandle& _fromVe
//========================================================================================
/// Set the half-edges of a face
// cppcheck-suppress unusedFunction ; public interface
void TopologyKernel::set_face(const FaceHandle& _fh, const std::vector<HalfEdgeHandle>& _hes) {
Face& f = face(_fh);
......@@ -542,6 +544,7 @@ void TopologyKernel::set_face(const FaceHandle& _fh, const std::vector<HalfEdgeH
//========================================================================================
/// Set the half-faces of a cell
// cppcheck-suppress unusedFunction ; public interface
void TopologyKernel::set_cell(const CellHandle& _ch, const std::vector<HalfFaceHandle>& _hfs) {
Cell& c = cell(_ch);
......@@ -1954,6 +1957,7 @@ void TopologyKernel::delete_multiple_cells(const std::vector<bool>& _tag) {
//========================================================================================
// cppcheck-suppress unusedFunction ; public interface
CellIter TopologyKernel::delete_cell_range(const CellIter& _first, const CellIter& _last) {
assert(_first >= cells_begin());
......
......@@ -184,6 +184,7 @@ bool FileManager::isHexahedralMesh(const std::string& _filename) const {
return true;
}
// cppcheck-suppress unusedFunction ; public interface
bool FileManager::isTetrahedralMesh(const std::string& _filename) const {
std::ifstream iff(_filename.c_str(), std::ios::in);
......
......@@ -121,7 +121,9 @@ class VectorT {
typename = typename std::enable_if<sizeof...(T) == DIM>::type,
typename = typename std::enable_if<
are_convertible_to<Scalar, T...>::value>::type>
constexpr VectorT(T... vs) : values_ { {static_cast<Scalar>(vs)...} } {
// cppcheck-suppress noExplicitConstructor ; only applies to unimportant DIM==1
constexpr VectorT(T... vs) : values_ { {static_cast<Scalar>(vs)...} }
{
static_assert(sizeof...(T) == DIM,
"Invalid number of components specified in constructor.");
static_assert(are_convertible_to<Scalar, T...>::value,
......@@ -176,7 +178,9 @@ class VectorT {
template<typename OtherScalar,
typename = typename std::enable_if<
std::is_convertible<OtherScalar, Scalar>::value>>
vector_type& operator=(const VectorT<OtherScalar, DIM>& _rhs) {
// cppcheck-suppress operatorEqRetRefThis ; false positive
vector_type& operator=(const VectorT<OtherScalar, DIM>& _rhs)
{
std::transform(_rhs.data(), _rhs.data() + DIM,
data(), [](OtherScalar rhs) {
return static_cast<Scalar>(std::move(rhs));
......
......@@ -235,10 +235,12 @@ HexVertexIter::HexVertexIter(const CellHandle& _ref_h,
BaseIter(_mesh, _ref_h, _max_laps) {
assert(_ref_h.is_valid());
assert(_mesh->cell(_ref_h).halffaces().size() == 6);
HexahedralMeshTopologyKernel::Cell cell = _mesh->cell(_ref_h);
assert(cell.halffaces().size() == 6);
// Get first half-face
HalfFaceHandle curHF = *_mesh->cell(_ref_h).halffaces().begin();
HalfFaceHandle curHF = *cell.halffaces().begin();
assert(curHF.is_valid());
// Get first half-edge
......
......@@ -32,14 +32,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Date$ *
* $LastChangedBy$ *
* *
\*===========================================================================*/
#include <set>
#include "TetrahedralMeshIterators.hh"
......@@ -58,10 +50,13 @@ TetVertexIter::TetVertexIter(const CellHandle& _ref_h,
BaseIter(_mesh, _ref_h, _max_laps) {
assert(_ref_h.is_valid());
assert(_mesh->cell(_ref_h).halffaces().size() == 4);
TetrahedralMeshTopologyKernel::Cell cell = _mesh->cell(_ref_h);
assert(cell.halffaces().size() == 4);
// Get first half-face
HalfFaceHandle curHF = *_mesh->cell(_ref_h).halffaces().begin();
HalfFaceHandle curHF = *cell.halffaces().begin();
assert(curHF.is_valid());
// Get first half-edge
......
......@@ -330,6 +330,7 @@ void TetrahedralMeshTopologyKernel::collapse_edge(HalfEdgeHandle _heh)
// swapPropertyElements(halfedge_props_begin(), halfedge_props_end(), source, destination);
//}
// cppcheck-suppress unusedFunction ; public interface
VertexHandle TetrahedralMeshTopologyKernel::collapse_edge(HalfEdgeHandle _heh)
{
bool deferred_deletion_tmp = deferred_deletion_enabled();
......@@ -355,10 +356,8 @@ VertexHandle TetrahedralMeshTopologyKernel::collapse_edge(HalfEdgeHandle _heh)
for (VertexCellIter vc_it = vc_iter(from_vh); vc_it.valid(); ++vc_it)
incidentCells.push_back(*vc_it);
for (unsigned int i = 0; i < incidentCells.size(); ++i)
for (const CellHandle &ch: incidentCells)
{
CellHandle ch = incidentCells[i];
if (collapsingCells.find(ch) != collapsingCells.end())
continue;
......@@ -366,9 +365,9 @@ VertexHandle TetrahedralMeshTopologyKernel::collapse_edge(HalfEdgeHandle _heh)
std::vector<HalfFaceHandle> newHalffaces;
for (unsigned int i = 0; i < 4; ++i)
for (unsigned int hf_idx = 0; hf_idx < 4; ++hf_idx)
{
Face hf = halfface(c.halffaces()[i]);
Face hf = halfface(c.halffaces()[hf_idx]);
std::vector<HalfEdgeHandle> newHalfedges;
for (unsigned int j = 0; j < 3; ++j)
......@@ -384,7 +383,7 @@ VertexHandle TetrahedralMeshTopologyKernel::collapse_edge(HalfEdgeHandle _heh)
HalfFaceHandle hfh = add_halfface(newHalfedges);
newHalffaces.push_back(hfh);
swap_halfface_properties(c.halffaces()[i], hfh);
swap_halfface_properties(c.halffaces()[hf_idx], hfh);
}
delete_cell(ch);
......@@ -422,6 +421,7 @@ VertexHandle TetrahedralMeshTopologyKernel::collapse_edge(HalfEdgeHandle _heh)
}
// cppcheck-suppress unusedFunction ; public interface
void TetrahedralMeshTopologyKernel::split_edge(HalfEdgeHandle _heh, VertexHandle _vh)
{
bool deferred_deletion_tmp = deferred_deletion_enabled();
......@@ -450,6 +450,7 @@ void TetrahedralMeshTopologyKernel::split_edge(HalfEdgeHandle _heh, VertexHandle
}
// cppcheck-suppress unusedFunction ; public interface
void TetrahedralMeshTopologyKernel::split_face(FaceHandle _fh, VertexHandle _vh)
{
bool deferred_deletion_tmp = deferred_deletion_enabled();
......@@ -562,6 +563,7 @@ std::vector<VertexHandle> TetrahedralMeshTopologyKernel::get_halfface_vertices(H
return std::vector<VertexHandle>();
}
// cppcheck-suppress unusedFunction ; public interface
std::vector<VertexHandle> TetrahedralMeshTopologyKernel::get_halfface_vertices(HalfFaceHandle hfh, HalfEdgeHandle heh) const
{
std::vector<VertexHandle> vertices;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment