diff --git a/Applications/FileIO/CsvInterface.cpp b/Applications/FileIO/CsvInterface.cpp index 62ee47902bdb17f6bb925f2d35ccc5ff463fb136..d3106ac4d0edea07ec861b351a060c4f2cfa884a 100644 --- a/Applications/FileIO/CsvInterface.cpp +++ b/Applications/FileIO/CsvInterface.cpp @@ -88,7 +88,7 @@ int CsvInterface::readPoints(std::string const& fname, char delim, continue; } it = fields.begin(); - std::array<double, 3> point; + std::array<double, 3> point{}; try { point[0] = std::stod(*it); point[1] = std::stod(*(++it)); @@ -189,7 +189,7 @@ int CsvInterface::readPoints(std::ifstream &in, char delim, continue; } - std::array<double, 3> point; + std::array<double, 3> point{}; it = fields.begin(); try { std::advance(it, column_advance[0]); diff --git a/Applications/FileIO/GMSInterface.cpp b/Applications/FileIO/GMSInterface.cpp index 032dce2872af0d58ea89301ee5fd97f786488267..71cab4a8c2e76a44a53cc72d6ca31fb0b269f2f5 100644 --- a/Applications/FileIO/GMSInterface.cpp +++ b/Applications/FileIO/GMSInterface.cpp @@ -90,10 +90,12 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, depth = pnt[2]; } else + { WARN( "GMSInterface::readBoreholeFromGMS(): Skipped layer " "'{:s}' in borehole '{:s}' because of thickness 0.0.", sName, cName); + } } else // add new borehole { @@ -317,8 +319,10 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string& filename) std::back_inserter(*opt_pv)); } else + { ERR("Ignoring Material IDs information (does not match number of " "elements)."); + } return new MeshLib::Mesh(mesh_name, nodes, elements, properties); } diff --git a/Applications/FileIO/GocadIO/CoordinateSystem.cpp b/Applications/FileIO/GocadIO/CoordinateSystem.cpp index 05e874daec8037a53b837a6a72c2ef2427a5673e..16a9899d7168391df4933ceaf18a5c69ec11e925 100644 --- a/Applications/FileIO/GocadIO/CoordinateSystem.cpp +++ b/Applications/FileIO/GocadIO/CoordinateSystem.cpp @@ -100,8 +100,10 @@ bool CoordinateSystem::parse(std::istream& in) return true; } else + { WARN("CoordinateSystem::parse() - Unknown keyword found: {:s}", line); + } } ERR ("Error: Unexpected end of file."); return false; diff --git a/Applications/FileIO/GocadIO/CoordinateSystem.h b/Applications/FileIO/GocadIO/CoordinateSystem.h index 2324eaa282480a9a8cd6625403e34b949c6b1dd8..27c016c0180754bcd05c6a4249847758610b0a71 100644 --- a/Applications/FileIO/GocadIO/CoordinateSystem.h +++ b/Applications/FileIO/GocadIO/CoordinateSystem.h @@ -30,7 +30,7 @@ public: std::string datum; std::string axis_name_u, axis_name_v, axis_name_w; std::string axis_unit_u, axis_unit_v, axis_unit_w; - ZPOSITIVE z_positive; + ZPOSITIVE z_positive = ZPOSITIVE::Elevation; }; std::ostream& operator<<(std::ostream& os, CoordinateSystem const& c); diff --git a/Applications/FileIO/GocadIO/GocadAsciiReader.cpp b/Applications/FileIO/GocadIO/GocadAsciiReader.cpp index a0f020830f49bd62a6db7019a65787063d911028..7969ebf6e9021f21f7d6a44e7014d1e902a03495 100644 --- a/Applications/FileIO/GocadIO/GocadAsciiReader.cpp +++ b/Applications/FileIO/GocadIO/GocadAsciiReader.cpp @@ -245,7 +245,7 @@ MeshLib::Node* createNode(std::stringstream& sstr) { std::string keyword; std::size_t id; - std::array<double, 3> data; + std::array<double, 3> data{}; sstr >> keyword >> id >> data[0] >> data[1] >> data[2]; return new MeshLib::Node(data, id); } @@ -352,9 +352,9 @@ bool parseLineSegments(std::ifstream& in, { std::stringstream sstr(line); std::string keyword; - std::array<std::size_t, 2> data; + std::array<std::size_t, 2> data{}; sstr >> keyword >> data[0] >> data[1]; - std::array<MeshLib::Node*, 2> elem_nodes; + std::array<MeshLib::Node*, 2> elem_nodes{}; for (std::size_t i = 0; i < 2; ++i) { auto const it = node_id_map.find(data[i]); @@ -443,9 +443,9 @@ bool parseElements(std::ifstream& in, { std::stringstream sstr(line); std::string keyword; - std::array<std::size_t, 3> data; + std::array<std::size_t, 3> data{}; sstr >> keyword >> data[0] >> data[1] >> data[2]; - std::array<MeshLib::Node*, 3> elem_nodes; + std::array<MeshLib::Node*, 3> elem_nodes{}; for (std::size_t i = 0; i < 3; ++i) { auto const it = node_id_map.find(data[i]); diff --git a/Applications/FileIO/GocadIO/GocadSGridReader.cpp b/Applications/FileIO/GocadIO/GocadSGridReader.cpp index 9b5d4f5f12e1c3d9be11537a8bba4bd92f748847..ca4c954b6052b587fcf36ed73b66d32959e477a3 100644 --- a/Applications/FileIO/GocadIO/GocadSGridReader.cpp +++ b/Applications/FileIO/GocadIO/GocadSGridReader.cpp @@ -346,11 +346,17 @@ void GocadSGridReader::parseFaceSet(std::string& line, std::istream& in) std::array<std::size_t, 3> const c( _index_calculator.getCoordsForID(id)); if (c[0] >= _index_calculator._x_dim - 1) + { ERR("****** i coord {:d} to big for id {:d}.", c[0], id); + } if (c[1] >= _index_calculator._y_dim - 1) + { ERR("****** j coord {:d} to big for id {:d}.", c[1], id); + } if (c[2] >= _index_calculator._z_dim - 1) + { ERR("****** k coord {:d} to big for id {:d}.", c[2], id); + } std::size_t const cell_id( _index_calculator.getCellIdx(c[0], c[1], c[2])); face_set_property._property_data[cell_id] = @@ -435,9 +441,11 @@ void GocadSGridReader::readNodesBinary() k++; } if (k != n * 3 && !in.eof()) + { ERR("Read different number of points. Expected {:d} floats, got " "{:d}.\n", n * 3, k); + } } void GocadSGridReader::mapRegionFlagsToCellProperties( @@ -540,9 +548,10 @@ std::vector<Bitset> GocadSGridReader::readRegionFlagsBinary() const result[k++] = readBits(in, regions.size()); } if (k != n && !in.eof()) + { ERR("Read different number of values. Expected {:d}, got {:d}.\n", n, k); - + } return result; } std::vector<MeshLib::Element*> GocadSGridReader::createElements( diff --git a/Applications/FileIO/Legacy/OGSIOVer4.cpp b/Applications/FileIO/Legacy/OGSIOVer4.cpp index bc7fa4b6b0e89377654dc4a590d79ac90100ddaf..d2db8d291d5b7afb0a375818bf3d77b7b080497f 100644 --- a/Applications/FileIO/Legacy/OGSIOVer4.cpp +++ b/Applications/FileIO/Legacy/OGSIOVer4.cpp @@ -101,10 +101,12 @@ std::string readPoints(std::istream &in, std::vector<GeoLib::Point*>* pnt_vec, std::size_t id_pos (line.find("$ID")); if (id_pos != std::string::npos) + { WARN( "readPoints(): found tag $ID - please use tag $NAME for " "reading point names in point {:d}.", cnt); + } cnt++; } getline(in, line); @@ -541,7 +543,9 @@ bool readGLIFileV4(const std::string& fname, ply_vec->size()); } else + { INFO("GeoLib::readGLIFile(): tag #POLYLINE not found."); + } if (!ply_vec->empty()) { diff --git a/Applications/FileIO/Legacy/createSurface.cpp b/Applications/FileIO/Legacy/createSurface.cpp index 8368168e46a6526b779f38a9202b84bbead44001..4e4c2ee81fdc60339949bdc36a8878fb05c07811 100644 --- a/Applications/FileIO/Legacy/createSurface.cpp +++ b/Applications/FileIO/Legacy/createSurface.cpp @@ -106,7 +106,9 @@ bool createSurface(GeoLib::Polyline const& ply, return false; } if (!(fs::remove(geo_file) && fs::remove(msh_file))) + { WARN("Could not remove temporary files in createSurface."); + } // convert the surface mesh into a geometric surface if (!MeshLib::convertMeshToGeo(*surface_mesh, geometries, diff --git a/Applications/FileIO/PetrelInterface.cpp b/Applications/FileIO/PetrelInterface.cpp index a4bc66044f4254e4d29569829dd995016be0e864..2198c58e64fdcf5e1a6807887c7936dcd3336efd 100644 --- a/Applications/FileIO/PetrelInterface.cpp +++ b/Applications/FileIO/PetrelInterface.cpp @@ -45,10 +45,12 @@ PetrelInterface::PetrelInterface(std::list<std::string> &sfc_fnames, in.close(); } else + { WARN( "PetrelInterface::PetrelInterface(): \tCould not open file " "{:s}.", it->c_str()); + } } for (std::list<std::string>::const_iterator it(well_path_fnames.begin()); it @@ -63,10 +65,12 @@ PetrelInterface::PetrelInterface(std::list<std::string> &sfc_fnames, in.close(); } else + { WARN( "PetrelInterface::PetrelInterface(): \tCould not open well " "path file {:s}.", it->c_str()); + } } // store data in GEOObject @@ -124,11 +128,14 @@ void PetrelInterface::readPetrelSurface(std::istream &in) idx++; } } - } else + } + else + { WARN( "PetrelInterface::readPetrelSurface(): problem reading petrel " "points from line\n'{:s}'.", line); + } } void PetrelInterface::readPetrelWellTrace(std::istream &in) diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index c117f81b0f9f54ac9abf160ef1a1ce62cbb6a44d..d138aae57fecb8be7761a41ec978da79b3bcd9cd 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -215,11 +215,15 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname, if (!ins_nodes || !ins_ele) { if (!ins_nodes) + { ERR("TetGenInterface::readTetGenMesh failed to open {:s}", nodes_fname); + } if (!ins_ele) + { ERR("TetGenInterface::readTetGenMesh failed to open {:s}", ele_fname); + } return nullptr; } @@ -591,8 +595,10 @@ bool TetGenInterface::writeTetGenSmesh(const std::string &file_name, return false; } if (surfaces==nullptr) + { WARN("No surfaces found for geometry {:s}. Writing points only.", geo_name); + } std::ofstream out( file_name.c_str(), std::ios::out ); out.precision(std::numeric_limits<double>::digits10); diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 973244a4307776fae32c6389661930f296259dae..0c90124691f7593295b6c897f0d4c0e78d128073 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -75,11 +75,15 @@ std::string date2string(double ddate) rest = rest % (y * 10000); auto m = static_cast<int>(std::floor(rest / 100.0)); if (m < 1 || m > 12) + { WARN("date2String(): month not in [1:12]."); + } rest = rest % (m * 100); int d = rest; if (d < 1 || d > 31) + { WARN("date2String(): day not in [1:31]."); + } std::string day = std::to_string(d); if (d < 10) @@ -116,10 +120,14 @@ int xmlDate2int(const std::string &s) { int d = atoi(s.substr(8,2).c_str()); if (d < 1 || d > 31) + { WARN("xmlDate2double(): day not in [1:31]."); + } int m = atoi(s.substr(5,2).c_str()); if (m < 1 || m > 12) + { WARN("xmlDate2double(): month not in [1:12]."); + } int y = atoi(s.substr(0,4).c_str()); return date2int(y, m, d); } diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h index 7240acef54c4e12f24603c4dfdcc6ddd080a94ce..4f47d5b1d0d3361e68c3e20764f43544d5ba5879 100644 --- a/BaseLib/FileTools.h +++ b/BaseLib/FileTools.h @@ -101,7 +101,9 @@ std::vector<T> readBinaryArray(std::string const& filename, std::size_t const n) result.size()); if (!in.eof()) + { ERR("EOF reached.\n"); + } return std::vector<T>(); } diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 10666050f2eae4607fafdd4518c3a8d91cef691e..d384c4e7a38c94f527aa067e35fb1a57c12305b2 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -49,7 +49,7 @@ public: template <typename InputIterator> Histogram(InputIterator first, InputIterator last, const int nr_bins = 16, const bool computeHistogram = true ) - : _data(first, last), _nr_bins(nr_bins) + : _data(first, last), _nr_bins(nr_bins), _dirty(true) { init(computeHistogram); } @@ -62,7 +62,7 @@ public: */ explicit Histogram(std::vector<T> data, const unsigned int nr_bins = 16, const bool computeHistogram = true) - : _data(std::move(data)), _nr_bins(nr_bins) + : _data(std::move(data)), _nr_bins(nr_bins), _dirty(true) { init(computeHistogram); } diff --git a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp index 95ed78d9f9450dcd09b6ca7bc4e6e838327535a1..702d446337bae7935d20bafe89baf1aa42d483b2 100644 --- a/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp +++ b/BaseLib/IO/XmlIO/Qt/XMLQtInterface.cpp @@ -125,7 +125,9 @@ bool XMLQtInterface::checkHash() const INFO("File is valid, hashfile written."); } else + { WARN("File is valid but could not write hashfile!"); + } return true; } } // namespace IO diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h index 8266d9efcae0f4c3fc5301249722b02bba6c6dc3..8e6c075ab67285ba97c159b22d2d5604413713a0 100644 --- a/GeoLib/Grid.h +++ b/GeoLib/Grid.h @@ -200,8 +200,10 @@ Grid<POINT>::Grid(InputIterator first, InputIterator last, _max_pnt[2] - _min_pnt[2]}}; // enlarge delta - for (auto & d : delta) + for (auto& d : delta) + { d = std::nextafter(d, std::numeric_limits<double>::max()); + } assert(n_pnts > 0); initNumberOfSteps(max_num_per_grid_cell, static_cast<std::size_t>(n_pnts), delta); @@ -375,7 +377,7 @@ template <typename POINT> template <typename T> std::array<std::size_t,3> Grid<POINT>::getGridCoords(T const& pnt) const { - std::array<std::size_t,3> coords; + std::array<std::size_t,3> coords{}; for (std::size_t k(0); k < 3; k++) { if (pnt[k] < _min_pnt[k]) @@ -405,7 +407,7 @@ template <typename P> std::array<double,6> Grid<POINT>::getPointCellBorderDistances(P const& p, std::array<std::size_t,3> const& coords) const { - std::array<double,6> dists; + std::array<double,6> dists{}; dists[0] = std::abs(p[2]-_min_pnt[2] + coords[2]*_step_sizes[2]); // bottom dists[5] = std::abs(p[2]-_min_pnt[2] + (coords[2]+1)*_step_sizes[2]); // top diff --git a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp index bf16c1ab19d7b58e3bec1909b3a814ede440f36e..a60c76464c12818046c3f9888362c032417ea8c4 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlGmlInterface.cpp @@ -431,12 +431,15 @@ bool XmlGmlInterface::write() } } else + { INFO("XmlGmlInterface::write(): Polyline vector is empty, no polylines written to file."); + } } } else + { INFO("XmlGmlInterface::write(): Polyline vector is empty, no polylines written to file."); - + } // SURFACES const GeoLib::SurfaceVec* sfc_vec (_geo_objs.getSurfaceVecObj(_exportName)); @@ -478,12 +481,15 @@ bool XmlGmlInterface::write() } } else + { INFO("XmlGmlInterface::write(): Surface vector is empty, no surfaces written to file."); + } } } else + { INFO("XmlGmlInterface::write(): Surface vector is empty, no surfaces written to file."); - + } std::string xml = doc.toString().toStdString(); _out << xml; diff --git a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp index ff493674190e846a203ee869fe42b14c07fd5426..fbb61d358df7254c0c5260add2eb2d15c29a6ba0 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp @@ -177,7 +177,9 @@ void XmlStnInterface::readStations( const QDomNode &stationsRoot, } } else + { WARN("XmlStnInterface::readStations(): Attribute missing in <station> tag."); + } station = station.nextSiblingElement(); } } @@ -216,13 +218,17 @@ void XmlStnInterface::readStratigraphy( const QDomNode &stratRoot, depth_check = depth; } else + { WARN( "XmlStnInterface::readStratigraphy(): Skipped layer '{:s}' " "in borehole '{:s}' because of thickness 0.0.", horizonName, borehole->getName()); + } } else + { WARN("XmlStnInterface::readStratigraphy(): Attribute missing in <horizon> tag."); + } horizon = horizon.nextSiblingElement(); } } diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index f1292ff47f25aeef2ac1409b1d0cce91f60391c1..3608426263bf7bac00d16d8fcac10e1fec638c53 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -111,8 +111,10 @@ PointVec::PointVec( } if (number_of_all_input_pnts > _data_vec->size()) + { WARN("PointVec::PointVec(): there are {:d} double points.", number_of_all_input_pnts - _data_vec->size()); + } correctNameIDMapping(); // create the inverse mapping diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index f8976916064158a6ed4aed9eec6d435519f4e146..3522fa12dc814d2835fb6b7c8d12da5c8def0cb5 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -378,7 +378,9 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & } } else + { ERR("Error in Polyline::contructPolylineFromSegments() - Line segments use different point vectors."); + } } if (!ply_found) diff --git a/GeoLib/Raster.cpp b/GeoLib/Raster.cpp index 7cdd4653a028405f54c7364d53184597aeff5835..7336958d5def40d875c52278044664ae7256d3fd 100644 --- a/GeoLib/Raster.cpp +++ b/GeoLib/Raster.cpp @@ -99,7 +99,7 @@ double Raster::interpolateValueAtPoint(MathLib::Point3d const& pnt) const std::array<int,4> const y_nb = {{ 0, 0, yShiftIdx, yShiftIdx }}; // get pixel values - std::array<double,4> pix_val; + std::array<double,4> pix_val{}; unsigned no_data_count (0); for (unsigned j=0; j<4; ++j) { diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index 4cf64928fb40347614cd9ea8871f7ecd34d08cb1..d39e280bc7919bef60f8b042e17469da3da6b9a4 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -33,8 +33,10 @@ SensorData::SensorData(std::vector<std::size_t> time_steps) { for (std::size_t i=1; i<time_steps.size(); i++) { - if (time_steps[i-1]>=time_steps[i]) + if (time_steps[i - 1] >= time_steps[i]) + { ERR("Error in SensorData() - Time series has no order!"); + } } } diff --git a/GeoLib/SurfaceGrid.h b/GeoLib/SurfaceGrid.h index 8106e6476b47faccf2272883bbbd35f0d821b673..9ddba3ffee272c5473a9b38bf74f862adb8d5e46 100644 --- a/GeoLib/SurfaceGrid.h +++ b/GeoLib/SurfaceGrid.h @@ -38,8 +38,8 @@ private: bool sortTriangleInGridCells(GeoLib::Triangle const*const triangle); boost::optional<std::array<std::size_t,3>> getGridCellCoordinates(MathLib::Point3d const& p) const; - std::array<double,3> _step_sizes; - std::array<double,3> _inverse_step_sizes; + std::array<double,3> _step_sizes{}; + std::array<double,3> _inverse_step_sizes{}; std::array<std::size_t,3> _n_steps; std::vector<std::vector<GeoLib::Triangle const*>> _triangles_in_grid_box; }; diff --git a/MeshLib/CoordinateSystem.h b/MeshLib/CoordinateSystem.h index 107d954a138975549bebaf639499d72926828041..8bad010138a3c5c6b856bb1928607215578a4cd9 100644 --- a/MeshLib/CoordinateSystem.h +++ b/MeshLib/CoordinateSystem.h @@ -55,9 +55,13 @@ public: /// get dimension size unsigned getDimension() const { if (hasZ()) + { return 3; + } if (hasY()) + { return 2; + } return 1; } diff --git a/MeshLib/Elements/HexRule20.cpp b/MeshLib/Elements/HexRule20.cpp index c854c0faa83d42d05eb81c22bad8aeffc33f9f6e..10eab7bf10ebc4f9ca10442cb344fd4fbaefa65b 100644 --- a/MeshLib/Elements/HexRule20.cpp +++ b/MeshLib/Elements/HexRule20.cpp @@ -48,7 +48,7 @@ const Element* HexRule20::getFace(const Element* e, unsigned i) { if (i < n_faces) { - std::array<Node*, 8> nodes; + std::array<Node*, 8> nodes{}; for (unsigned j = 0; j < 8; j++) { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); diff --git a/MeshLib/Elements/HexRule8.cpp b/MeshLib/Elements/HexRule8.cpp index 31526574a6527abc71ba0c4ff8dc1c0c1f2a72e3..98d26c6e101784d539677172becf4bf5f7ec107a 100644 --- a/MeshLib/Elements/HexRule8.cpp +++ b/MeshLib/Elements/HexRule8.cpp @@ -52,7 +52,7 @@ const Element* HexRule8::getFace(const Element* e, unsigned i) { if (i < n_faces) { - std::array<Node*, 4> nodes; + std::array<Node*, 4> nodes{}; for (unsigned j = 0; j < 4; j++) { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); diff --git a/MeshLib/Elements/TetRule10.cpp b/MeshLib/Elements/TetRule10.cpp index 1a75211da36bec9ab57451e622a4a0ee1af81416..3679ad84a8c0fcdf18a5b63b77e65e134c684bde 100644 --- a/MeshLib/Elements/TetRule10.cpp +++ b/MeshLib/Elements/TetRule10.cpp @@ -42,7 +42,7 @@ const Element* TetRule10::getFace(const Element* e, unsigned i) { if (i<n_faces) { - std::array<Node*,6> nodes; + std::array<Node*,6> nodes{}; for (unsigned j = 0; j < 6; j++) { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); diff --git a/MeshLib/Elements/TetRule4.cpp b/MeshLib/Elements/TetRule4.cpp index 26fa1a874971fdbc1856ea85bd8904cf34f172fb..4e6bfbe797c38ac2826c904f0d3eec01d5fd527c 100644 --- a/MeshLib/Elements/TetRule4.cpp +++ b/MeshLib/Elements/TetRule4.cpp @@ -44,7 +44,7 @@ const Element* TetRule4::getFace(const Element* e, unsigned i) { if (i<n_faces) { - std::array<Node*,3> nodes; + std::array<Node*,3> nodes{}; for (unsigned j = 0; j < 3; j++) { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); diff --git a/MeshLib/IO/VtkIO/VtuInterface-impl.h b/MeshLib/IO/VtkIO/VtuInterface-impl.h index 579c9f10afc1bde90c688432a6aec07003115d9b..61474590fa0a516da71caa9dc57abf3f1ddf6e50 100644 --- a/MeshLib/IO/VtkIO/VtuInterface-impl.h +++ b/MeshLib/IO/VtkIO/VtuInterface-impl.h @@ -49,14 +49,20 @@ bool VtuInterface::writeVTU(std::string const& file_name, vtkSource->Update(); vtuWriter->SetInputData(vtkSource->GetOutput()); - if(_use_compressor) + if (_use_compressor) + { vtuWriter->SetCompressorTypeToZLib(); + } else + { vtuWriter->SetCompressorTypeToNone(); + } vtuWriter->SetDataMode(_data_mode); if (_data_mode == vtkXMLWriter::Appended) + { vtuWriter->SetEncodeAppendedData(1); + } if (_data_mode == vtkXMLWriter::Ascii) { vtkSource->Update(); diff --git a/MeshLib/IO/VtkIO/VtuInterface.cpp b/MeshLib/IO/VtkIO/VtuInterface.cpp index 99a662822580b39d16bcacd90300456d20557e8b..e7c26b0eafcebccc3f08958093dbdb7d03730228 100644 --- a/MeshLib/IO/VtkIO/VtuInterface.cpp +++ b/MeshLib/IO/VtkIO/VtuInterface.cpp @@ -43,8 +43,10 @@ namespace IO VtuInterface::VtuInterface(const MeshLib::Mesh* mesh, int dataMode, bool compress) : _mesh(mesh), _data_mode(dataMode), _use_compressor(compress) { - if(_data_mode == vtkXMLWriter::Ascii && compress) + if (_data_mode == vtkXMLWriter::Ascii && compress) + { WARN("Ascii data cannot be compressed, ignoring compression flag."); + } } MeshLib::Mesh* VtuInterface::readVTUFile(std::string const &file_name) diff --git a/MeshLib/MeshEditing/ElementValueModification.h b/MeshLib/MeshEditing/ElementValueModification.h index f565ed4c1a2a28655524758bde537c1e54fd49fd..490deeb2ba700c3e186efbd2bb9dbbf341015783 100644 --- a/MeshLib/MeshEditing/ElementValueModification.h +++ b/MeshLib/MeshEditing/ElementValueModification.h @@ -66,7 +66,9 @@ private: } } if (!exists) + { value_mapping.push_back(value); + } } std::sort(value_mapping.begin(), value_mapping.end()); diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index c02e24e73592e91d06a5cc8ec0715b37d0c3391f..2570421137ae024ebff5e80d54d3c2129bb0bf89 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -117,8 +117,11 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, } new_material_vec->insert(new_material_vec->end(), n_new_elements, (*material_vec)[k]); - } else + } + else + { ERR ("Something is wrong, more unique nodes than actual nodes"); + } } this->resetNodeIDs(); @@ -833,7 +836,7 @@ unsigned MeshRevision::lutHexDiametralNode(unsigned id) const std::array<unsigned, 4> MeshRevision::lutHexCuttingQuadNodes(unsigned id1, unsigned id2) const { - std::array<unsigned,4> nodes; + std::array<unsigned,4> nodes{}; if (id1==0 && id2==1) { nodes[0]=3; nodes[1]=2; nodes[2]=5; nodes[3]=4; } else if (id1==1 && id2==2) { nodes[0]=0; nodes[1]=3; nodes[2]=6; nodes[3]=5; } else if (id1==2 && id2==3) { nodes[0]=1; nodes[1]=0; nodes[2]=7; nodes[3]=6; } diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.cpp b/MeshLib/MeshGenerators/MeshLayerMapper.cpp index 571b34811d83270b17f987d5c789dd0ae252a01f..726fc20d39c8697d03b59a0e4e70bcf122cae7a8 100644 --- a/MeshLib/MeshGenerators/MeshLayerMapper.cpp +++ b/MeshLib/MeshGenerators/MeshLayerMapper.cpp @@ -42,8 +42,10 @@ MeshLib::Mesh* MeshLayerMapper::createStaticLayers(MeshLib::Mesh const& mesh, st thickness.push_back(layer_thickness_vector[i]); } else + { WARN("Ignoring layer {:d} with thickness {:f}.", i, layer_thickness_vector[i]); + } } const std::size_t nLayers(thickness.size()); @@ -219,7 +221,7 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay } unsigned node_counter(3); unsigned missing_idx(0); - std::array<MeshLib::Node*, 6> new_elem_nodes; + std::array<MeshLib::Node*, 6> new_elem_nodes{}; for (unsigned j=0; j<3; ++j) { new_elem_nodes[j] = _nodes[_nodes[last_layer_node_offset + elem->getNodeIndex(j)]->getID()]; @@ -242,6 +244,7 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay _materials.push_back(layer_id); break; case 5: + { std::array<MeshLib::Node*, 5> pyramid_nodes; pyramid_nodes[0] = new_elem_nodes[pyramid_base[missing_idx][0]]; pyramid_nodes[1] = new_elem_nodes[pyramid_base[missing_idx][1]]; @@ -251,12 +254,15 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay _elements.push_back(new MeshLib::Pyramid(pyramid_nodes)); _materials.push_back(layer_id); break; + } case 4: + { std::array<MeshLib::Node*, 4> tet_nodes; std::copy(new_elem_nodes.begin(), new_elem_nodes.begin() + node_counter, tet_nodes.begin()); _elements.push_back(new MeshLib::Tet(tet_nodes)); _materials.push_back(layer_id); break; + } default: continue; } diff --git a/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp b/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp index 19e92bf2846f7765f33b0feda837273f6d8d47c3..806e8e5dece5ab1b4345d2f57808910998545aca 100644 --- a/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp @@ -31,7 +31,7 @@ std::unique_ptr<QuadraticElement> convertLinearToQuadratic( assert(n_base_nodes == e.getNumberOfBaseNodes()); // Copy base nodes of element to the quadratic element new nodes'. - std::array<MeshLib::Node*, n_all_nodes> nodes; + std::array<MeshLib::Node*, n_all_nodes> nodes{}; for (int i = 0; i < n_base_nodes; i++) { nodes[i] = const_cast<MeshLib::Node*>(e.getNode(i)); diff --git a/MeshLib/MeshGenerators/RasterToMesh.h b/MeshLib/MeshGenerators/RasterToMesh.h index bd8e582ea64c9acdefaa1e79c92d7e2faeb162b2..0d38b7440261cde0aee758bddb77ad0b2b9ef0cb 100644 --- a/MeshLib/MeshGenerators/RasterToMesh.h +++ b/MeshLib/MeshGenerators/RasterToMesh.h @@ -97,8 +97,11 @@ private: { auto val(static_cast<T>(img[idx + j])); prop_vec.push_back(val); - if (elem_type == MeshElemType::TRIANGLE || elem_type == MeshElemType::PRISM) + if (elem_type == MeshElemType::TRIANGLE || + elem_type == MeshElemType::PRISM) + { prop_vec.push_back(val); // because each pixel is represented by two cells + } } } } diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.h b/MeshLib/MeshGenerators/VtkMeshConverter.h index 266ab9bfdba461d48ff553c9a0865e1bfcc778db..f0d58beb133241b2f033ab8cc3caf3b1addc5451 100644 --- a/MeshLib/MeshGenerators/VtkMeshConverter.h +++ b/MeshLib/MeshGenerators/VtkMeshConverter.h @@ -79,7 +79,9 @@ private: for (std::size_t j = 0; j < imgWidth; j++) { if (!pix_vis[i * imgWidth + j]) + { continue; + } T val(static_cast<T>(pix_val[i * (imgWidth + 1) + j])); if (elem_type == MeshElemType::TRIANGLE) { @@ -87,7 +89,9 @@ private: prop_vec.push_back(val); } else if (elem_type == MeshElemType::QUAD) + { prop_vec.push_back(val); + } } } } diff --git a/MeshLib/MeshQuality/ElementSizeMetric.cpp b/MeshLib/MeshQuality/ElementSizeMetric.cpp index 52383aeeadeba4bdddc075577abee986f3a9247e..245b695b2ba89c9154440a06f22697d2c316fdb9 100644 --- a/MeshLib/MeshQuality/ElementSizeMetric.cpp +++ b/MeshLib/MeshQuality/ElementSizeMetric.cpp @@ -43,7 +43,9 @@ void ElementSizeMetric::calculateQuality() _min, _max); if (error_count > 0) + { WARN("Warning: {:d} elements with zero volume found.", error_count); + } } std::size_t ElementSizeMetric::calc1dQuality() diff --git a/MeshLib/MeshQuality/MeshValidation.cpp b/MeshLib/MeshQuality/MeshValidation.cpp index 8a0a29dd8aba48f76e896be6a14cc57325d3a3d6..56db3a14098ae2ae624def0df80bfdcf98c42bc6 100644 --- a/MeshLib/MeshQuality/MeshValidation.cpp +++ b/MeshLib/MeshQuality/MeshValidation.cpp @@ -104,13 +104,17 @@ std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib: for (std::size_t i = 0; i < nErrorCodes; ++i) { if (error_count[i]) + { INFO("{:d} elements found with {:s}.", error_count[i], ElementErrorCode::toString(flags[i])); + } } } else + { INFO ("No errors found."); + } return error_code_vector; } diff --git a/MeshLib/MeshSearch/ElementSearch.h b/MeshLib/MeshSearch/ElementSearch.h index f852681958af536750b04d5e68a8cec3a88e90ce..e958074b8b27e0db5f59d9154ec8c321e34baaa1 100644 --- a/MeshLib/MeshSearch/ElementSearch.h +++ b/MeshLib/MeshSearch/ElementSearch.h @@ -96,7 +96,9 @@ public: { if ((*pv)[i] < min_property_value || (*pv)[i] > max_property_value) + { matchedIDs.push_back(i); + } } } else @@ -105,7 +107,9 @@ public: { if ((*pv)[i] >= min_property_value && (*pv)[i] <= max_property_value) + { matchedIDs.push_back(i); + } } } updateUnion(matchedIDs); diff --git a/MeshLib/MeshSearch/MeshElementGrid.cpp b/MeshLib/MeshSearch/MeshElementGrid.cpp index e6f5479097ffbfbf69baee7630fe85f71ae0255e..fe0e69527661efba62d2854347223c5b4b50b4fa 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.cpp +++ b/MeshLib/MeshSearch/MeshElementGrid.cpp @@ -123,8 +123,8 @@ void MeshElementGrid::sortElementsInGridCells(MeshLib::Mesh const& sfc_mesh) bool MeshElementGrid::sortElementInGridCells(MeshLib::Element const& element) { - std::array<std::size_t,3> min; - std::array<std::size_t,3> max; + std::array<std::size_t,3> min{}; + std::array<std::size_t,3> max{}; std::pair<bool, std::array<std::size_t, 3>> c( getGridCellCoordinates(*(static_cast<MathLib::Point3d const*>(element.getNode(0))))); if (c.first) { @@ -183,7 +183,7 @@ std::pair<bool, std::array<std::size_t, 3>> MeshElementGrid::getGridCellCoordinates(MathLib::Point3d const& p) const { bool valid(true); - std::array<std::size_t, 3> coords; + std::array<std::size_t, 3> coords{}; for (std::size_t k(0); k<3; ++k) { const double d(p[k]-_aabb.getMinPoint()[k]); diff --git a/MeshLib/MeshSearch/MeshElementGrid.h b/MeshLib/MeshSearch/MeshElementGrid.h index 5887c4abc62e0821a7dafce4b8d6a3009d352a9c..4e80f6bef597efa00eeabb359ab8768e9628608d 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.h +++ b/MeshLib/MeshSearch/MeshElementGrid.h @@ -84,8 +84,8 @@ private: /// false. std::pair<bool, std::array<std::size_t,3>> getGridCellCoordinates(MathLib::Point3d const& p) const; - std::array<double,3> _step_sizes; - std::array<double,3> _inverse_step_sizes; + std::array<double,3> _step_sizes{}; + std::array<double,3> _inverse_step_sizes{}; std::array<std::size_t,3> _n_steps; std::vector<std::vector<MeshLib::Element const*>> _elements_in_grid_box; }; diff --git a/MeshLib/MeshSurfaceExtraction.cpp b/MeshLib/MeshSurfaceExtraction.cpp index bc60c273396d2d6a55a72c1b5893ea9dcfc0cf88..1478ec282b74a3e66e6e83d533e907835b9ff354 100644 --- a/MeshLib/MeshSurfaceExtraction.cpp +++ b/MeshLib/MeshSurfaceExtraction.cpp @@ -257,7 +257,9 @@ void MeshSurfaceExtraction::get2DSurfaceElements( const MathLib::Vector3& dir, double angle, unsigned mesh_dimension) { if (mesh_dimension < 2 || mesh_dimension > 3) + { ERR("Cannot handle meshes of dimension {:i}", mesh_dimension); + } bool const complete_surface = (MathLib::scalarProduct(dir, dir) == 0); diff --git a/MeshLib/Vtk/VtkMappedMeshSource.cpp b/MeshLib/Vtk/VtkMappedMeshSource.cpp index 692a087aae97cc2a248026275da007b8a6c221ff..fe485b9472a0b89e62cf1e60d55305cf60bcbd71 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.cpp +++ b/MeshLib/Vtk/VtkMappedMeshSource.cpp @@ -113,7 +113,7 @@ int VtkMappedMeshSource::RequestData(vtkInformation* /*request*/, } else if (cellType == VTK_QUADRATIC_WEDGE) { - std::array<vtkIdType, 15> ogs_nodeIds; + std::array<vtkIdType, 15> ogs_nodeIds{}; for (unsigned i = 0; i < 15; ++i) { ogs_nodeIds[i] = ptIds->GetId(i); diff --git a/MeshLib/Vtk/VtkMappedMeshSource.h b/MeshLib/Vtk/VtkMappedMeshSource.h index 45200cc578b492ac7ca16b5e0f66e5dc272eed9c..0de774ab34a9266582fea5d4c3a38b361475e951 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.h +++ b/MeshLib/Vtk/VtkMappedMeshSource.h @@ -82,7 +82,7 @@ private: bool addProperty(MeshLib::Properties const& properties, std::string const& prop_name) const; - const MeshLib::Mesh* _mesh; + const MeshLib::Mesh* _mesh{}; int NumberOfDimensions{0}; int NumberOfNodes{0}; diff --git a/Tests/MeshLib/TestElementConstants.cpp b/Tests/MeshLib/TestElementConstants.cpp index 0cd5385c5d271e16b7139caca83d757073f7a739..988b0d4315983cc0f351347fd45598e807dd193e 100644 --- a/Tests/MeshLib/TestElementConstants.cpp +++ b/Tests/MeshLib/TestElementConstants.cpp @@ -20,7 +20,7 @@ TEST(MeshLib, ElementConstantsQuad4) ASSERT_EQ(4u, Quad::n_all_nodes); ASSERT_EQ(4u, Quad::n_base_nodes); - std::array<Node*, 4> nodes; + std::array<Node*, 4> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(0.0, 1.0, 0.0); nodes[2] = new Node(1.0, 1.0, 0.0); @@ -43,7 +43,7 @@ TEST(MeshLib, ElementConstantsQuad8) ASSERT_EQ(8u, Quad8::n_all_nodes); ASSERT_EQ(4u, Quad8::n_base_nodes); - std::array<Node*, 8> nodes; + std::array<Node*, 8> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(0.0, 1.0, 0.0); nodes[2] = new Node(1.0, 1.0, 0.0); @@ -72,7 +72,7 @@ TEST(MeshLib, ElementConstantsQuad9) ASSERT_EQ(9u, Quad9::n_all_nodes); ASSERT_EQ(4u, Quad9::n_base_nodes); - std::array<Node*, 9> nodes; + std::array<Node*, 9> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(0.0, 1.0, 0.0); nodes[2] = new Node(1.0, 1.0, 0.0); @@ -102,7 +102,7 @@ TEST(MeshLib, ElementConstantsHex8) ASSERT_EQ(8u, Hex::n_all_nodes); ASSERT_EQ(8u, Hex::n_base_nodes); - std::array<Node*, 8> nodes; + std::array<Node*, 8> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(0.0, 1.0, 0.0); nodes[2] = new Node(1.0, 1.0, 0.0); @@ -129,7 +129,7 @@ TEST(MeshLib, ElementConstantsHex20) ASSERT_EQ(20u, Hex20::n_all_nodes); ASSERT_EQ( 8u, Hex20::n_base_nodes); - std::array<Node*, 20> nodes; + std::array<Node*, 20> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(1.0, 0.0, 0.0); nodes[2] = new Node(1.0, 1.0, 0.0); @@ -168,7 +168,7 @@ TEST(MeshLib, ElementConstantsTet4) ASSERT_EQ(4u, Tet::n_all_nodes); ASSERT_EQ(4u, Tet::n_base_nodes); - std::array<Node*, 4> nodes; + std::array<Node*, 4> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(1.0, 0.0, 0.0); nodes[2] = new Node(0.0, 1.0, 0.0); @@ -191,7 +191,7 @@ TEST(MeshLib, ElementConstantsTet10) ASSERT_EQ(10u, Tet10::n_all_nodes); ASSERT_EQ( 4u, Tet10::n_base_nodes); - std::array<Node*, 10> nodes; + std::array<Node*, 10> nodes{}; nodes[0] = new Node(0.0, 0.0, 0.0); nodes[1] = new Node(1.0, 0.0, 0.0); nodes[2] = new Node(0.0, 1.0, 0.0); diff --git a/Tests/MeshLib/TestPntInElement.cpp b/Tests/MeshLib/TestPntInElement.cpp index b3fd222bd4299716ef68ec32c27114f10b371b6a..48e86efef15272944b48885b122db2edf1fac5b9 100644 --- a/Tests/MeshLib/TestPntInElement.cpp +++ b/Tests/MeshLib/TestPntInElement.cpp @@ -109,7 +109,7 @@ TEST(IsPntInElement, Pyramid) { GeoLib::Point pnt; std::vector<MeshLib::Node*> nodes (createNodes()); - std::array<MeshLib::Node*, 5> pyr_nodes; + std::array<MeshLib::Node*, 5> pyr_nodes{}; std::copy(nodes.begin(), nodes.begin()+5, pyr_nodes.begin()); MeshLib::Pyramid pyr(pyr_nodes); @@ -144,7 +144,7 @@ TEST(IsPntInElement, Hex) { GeoLib::Point pnt; std::vector<MeshLib::Node*> nodes (createNodes()); - std::array<MeshLib::Node*, 8> hex_nodes; + std::array<MeshLib::Node*, 8> hex_nodes{}; std::copy(nodes.begin(), nodes.end(), hex_nodes.begin()); MeshLib::Hex hex(hex_nodes); diff --git a/Tests/MeshLib/TestTriLineMesh.cpp b/Tests/MeshLib/TestTriLineMesh.cpp index cba370d50ed81cc365421d84d7722aa7d67f685b..29ab4b79d8193f336fa7d920fd61d9116ded24b5 100644 --- a/Tests/MeshLib/TestTriLineMesh.cpp +++ b/Tests/MeshLib/TestTriLineMesh.cpp @@ -25,7 +25,7 @@ class MeshLibTriLineMesh : public ::testing::Test nodes.push_back(new MeshLib::Node(0, 1, 0)); nodes.push_back(new MeshLib::Node(1, 1, 0)); - std::array<MeshLib::Node*, 3> t_nodes; + std::array<MeshLib::Node*, 3> t_nodes{}; t_nodes[0] = nodes[0]; t_nodes[1] = nodes[1]; t_nodes[2] = nodes[2]; @@ -36,7 +36,7 @@ class MeshLibTriLineMesh : public ::testing::Test t_nodes[2] = nodes[2]; elements.push_back(new MeshLib::Tri(t_nodes)); - std::array<MeshLib::Node*, 2> l_nodes; + std::array<MeshLib::Node*, 2> l_nodes{}; l_nodes[0] = nodes[1]; l_nodes[1] = nodes[2]; elements.push_back(new MeshLib::Line(l_nodes));