From 32bcbda23244986dad01b7cfcf6950a8501ea3f2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 30 Aug 2015 11:48:26 +0200 Subject: [PATCH] + fix various warnings --- src/Mod/Sketcher/App/Sketch.cpp | 9 +-- src/Mod/Sketcher/App/SketchObject.cpp | 45 +++--------- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 1 - src/Mod/Sketcher/App/planegcs/Constraints.cpp | 4 +- src/Mod/Sketcher/App/planegcs/GCS.cpp | 73 ++++++++++++------- src/Mod/Spreadsheet/App/Cell.cpp | 3 +- src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp | 2 +- 7 files changed, 64 insertions(+), 73 deletions(-) diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index edce1bbd2..02a555903 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -886,6 +886,8 @@ int Sketch::addConstraint(const Constraint *constraint) case EllipseFocus2: rtn = addInternalAlignmentEllipseFocus2(constraint->First,constraint->Second); break; + default: + break; } break; case SnellsLaw: @@ -1233,8 +1235,6 @@ int Sketch::addTangentConstraint(int geoId1, int geoId2) return ConstraintsCounter; } } else if (Geoms[geoId1].type == Ellipse) { - GCS::Ellipse &e = Ellipses[Geoms[geoId1].index]; - if (Geoms[geoId2].type == Circle) { Base::Console().Error("Direct tangency constraint between circle and ellipse is not supported. Use tangent-via-point instead."); return -1; @@ -1748,7 +1748,6 @@ int Sketch::addSnellsLawConstraint(int geoIdRay1, PointPos posRay1, return -1; } GCS::Point &p1 = Points[pointId1]; - GCS::Point &p2 = Points[pointId2]; // add the parameters (refractive indexes) // n1 uses the place hold by n2divn1, so that is retrivable in updateNonDrivingConstraints @@ -2097,10 +2096,10 @@ int Sketch::solve(void) isFine = true; } - int ret; + int ret = -1; bool valid_solution; std::string solvername; - int defaultsoltype; + int defaultsoltype = -1; if(isInitMove){ solvername = "DogLeg"; // DogLeg is used for dragging (same as before) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index febccb020..f729739fb 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -615,7 +615,7 @@ int SketchObject::addConstraints(const std::vector &ConstraintList //test if tangent constraints have been added; AutoLockTangency. std::vector< Constraint * > tbd;//list of temporary copies that need to be deleted - for(int i = newVals.size()-ConstraintList.size(); iType == Tangent || newVals[i]->Type == Perpendicular ){ Constraint *constNew = newVals[i]->clone(); AutoLockTangencyAndPerpty(constNew); @@ -627,7 +627,7 @@ int SketchObject::addConstraints(const std::vector &ConstraintList this->Constraints.setValues(newVals); //clean up - delete temporary copies of constraints that were made to affect the constraints - for(int i=0; i &vals = Constraints.getValues(); for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); @@ -1641,19 +1636,15 @@ int SketchObject::ExposeInternalGeometry(int GeoId) switch((*it)->AlignmentType){ case Sketcher::EllipseMajorDiameter: major=true; - majorelementindex=(*it)->First; break; case Sketcher::EllipseMinorDiameter: minor=true; - minorelementindex=(*it)->First; break; case Sketcher::EllipseFocus1: focus1=true; - focus1elementindex=(*it)->First; break; case Sketcher::EllipseFocus2: focus2=true; - focus2elementindex=(*it)->First; break; default: return -1; @@ -1794,12 +1785,7 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId) const Part::Geometry *geo = getGeometry(GeoId); // Only for supported types if(geo->getTypeId() == Part::GeomEllipse::getClassTypeId() || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { - // First we search what has to be deleted - bool major=false; - bool minor=false; - bool focus1=false; - bool focus2=false; - + int majorelementindex=-1; int minorelementindex=-1; int focus1elementindex=-1; @@ -1813,19 +1799,15 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId) { switch((*it)->AlignmentType){ case Sketcher::EllipseMajorDiameter: - major=true; majorelementindex=(*it)->First; break; case Sketcher::EllipseMinorDiameter: - minor=true; minorelementindex=(*it)->First; break; case Sketcher::EllipseFocus1: - focus1=true; focus1elementindex=(*it)->First; break; case Sketcher::EllipseFocus2: - focus2=true; focus2elementindex=(*it)->First; break; default: @@ -1840,8 +1822,6 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId) int focus1constraints=0; int focus2constraints=0; - int decrgeo=0; - for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) { @@ -2224,7 +2204,6 @@ void SketchObject::rebuildExternalGeometry(void) //gp_Dir normal = e.Axis().Direction(); gp_Dir normal = gp_Dir(0,0,1); - gp_Dir xdir = e.XAxis().Direction(); gp_Ax2 xdirref(p, normal); if (P1.SquareDistance(P2) < Precision::Confusion()) { @@ -2521,9 +2500,6 @@ bool SketchObject::evaluateConstraints() const void SketchObject::validateConstraints() { - int intGeoCount = getHighestCurveIndex() + 1; - int extGeoCount = getExternalGeometryCount(); - std::vector geometry = getCompleteGeometry(); const std::vector& constraints = Constraints.getValues(); @@ -2624,7 +2600,7 @@ double SketchObject::calculateConstraintError(int ConstrId) GeoIdList.push_back(cstr->Third); //add only necessary geometry to the sketch - for(int i=0; igetGeometry(g)); @@ -2724,7 +2700,7 @@ void SketchObject::getGeoVertexIndex(int VertexId, int &GeoId, PointPos &PosId) int SketchObject::getVertexIndexGeoPos(int GeoId, PointPos PosId) const { - for(int i=0;i tbd;//list of temporary Constraint copies that need to be deleted later - for(int i = 0; iType == Tangent || newVals[i]->Type == Perpendicular ){ //create a constraint copy, affect it, replace the pointer cntToBeAffected++; @@ -2768,7 +2744,7 @@ int SketchObject::changeConstraintsLocking(bool bLock) this->Constraints.setValues(newVals); //clean up - delete temporary copies of constraints that were made to affect the constraints - for(int i=0; i &vals = this->Constraints.getValues(); @@ -2794,7 +2769,7 @@ int SketchObject::port_reversedExternalArcs(bool justAnalyze) std::vector< Constraint * > tbd;//list of temporary Constraint copies that need to be deleted later - for(int ic = 0; icgetSketchObjectPtr(); if (this->getSketchObjectPtr()->getDriving(constrid, driving)) { PyErr_SetString(PyExc_ValueError, "Invalid constraint id"); return 0; diff --git a/src/Mod/Sketcher/App/planegcs/Constraints.cpp b/src/Mod/Sketcher/App/planegcs/Constraints.cpp index 28c5c5755..59e4f5ea7 100644 --- a/src/Mod/Sketcher/App/planegcs/Constraints.cpp +++ b/src/Mod/Sketcher/App/planegcs/Constraints.cpp @@ -87,7 +87,7 @@ double Constraint::maxStep(MAP_pD_D &dir, double lim) int Constraint::findParamInPvec(double *param) { int ret = -1; - for( int i=0 ; i Gra // System System::System() -: plist(0), clist(0), - c2p(), p2c(), - subSystems(0), subSystemsAux(0), - reference(0), - hasUnknowns(false), hasDiagnosis(false), isInit(false), - maxIter(100), maxIterRedundant(100), - sketchSizeMultiplier(true), sketchSizeMultiplierRedundant(true), - convergence(1e-10), convergenceRedundant(1e-10), - qrAlgorithm(EigenSparseQR), debugMode(Minimal), - LM_eps(1E-10), LM_eps1(1E-80), LM_tau(1E-3), - DL_tolg(1E-80), DL_tolx(1E-80), DL_tolf(1E-10), - LM_epsRedundant(1E-10), LM_eps1Redundant(1E-80), LM_tauRedundant(1E-3), - DL_tolgRedundant(1E-80), DL_tolxRedundant(1E-80), DL_tolfRedundant(1E-10), - qrpivotThreshold(1E-13) + : plist(0) + , clist(0) + , c2p() + , p2c() + , subSystems(0) + , subSystemsAux(0) + , reference(0) + , hasUnknowns(false) + , hasDiagnosis(false) + , isInit(false) + , maxIter(100) + , maxIterRedundant(100) + , sketchSizeMultiplier(true) + , sketchSizeMultiplierRedundant(true) + , convergence(1e-10) + , convergenceRedundant(1e-10) + , qrAlgorithm(EigenSparseQR) + , qrpivotThreshold(1E-13) + , debugMode(Minimal) + , LM_eps(1E-10) + , LM_eps1(1E-80) + , LM_tau(1E-3) + , DL_tolg(1E-80) + , DL_tolx(1E-80) + , DL_tolf(1E-10) + , LM_epsRedundant(1E-10) + , LM_eps1Redundant(1E-80) + , LM_tauRedundant(1E-3) + , DL_tolgRedundant(1E-80) + , DL_tolxRedundant(1E-80) + , DL_tolfRedundant(1E-10) { // currently Eigen only supports multithreading for multiplications // There is no appreciable gain from using more threads @@ -877,7 +894,7 @@ double System::calculateConstraintErrorByTag(int tagId) void System::rescaleConstraint(int id, double coeff) { - if (id >= clist.size() || id < 0) + if (id >= static_cast(clist.size()) || id < 0) return; if (clist[id]) clist[id]->rescale(coeff); @@ -999,7 +1016,7 @@ void System::initSolution(Algorithm alg) // calculates subSystems and subSystemsAux from clists, plists and reductionmaps clearSubSystems(); - for (int cid=0; cid < clists.size(); cid++) { + for (std::size_t cid=0; cid < clists.size(); cid++) { std::vector clist0, clist1; for (std::vector::const_iterator constr=clists[cid].begin(); constr != clists[cid].end(); ++constr) { @@ -1830,9 +1847,9 @@ int System::diagnose(Algorithm alg) #endif Eigen::MatrixXd R; - int paramsNum; - int constrNum; - int rank; + int paramsNum = 0; + int constrNum = 0; + int rank = 0; Eigen::FullPivHouseholderQR qrJT; if(qrAlgorithm==EigenDenseQR){ @@ -1940,7 +1957,7 @@ int System::diagnose(Algorithm alg) for (int j=rank; j < constrNum; j++) { for (int row=0; row < rank; row++) { if (fabs(R(row,j)) > 1e-10) { - int origCol; + int origCol = 0; if(qrAlgorithm==EigenDenseQR) origCol=qrJT.colsPermutation().indices()[row]; @@ -1952,7 +1969,7 @@ int System::diagnose(Algorithm alg) conflictGroups[j-rank].push_back(clist[origCol]); } } - int origCol; + int origCol = 0; if(qrAlgorithm==EigenDenseQR) origCol=qrJT.colsPermutation().indices()[j]; @@ -1972,9 +1989,9 @@ int System::diagnose(Algorithm alg) SET_I satisfiedGroups; while (1) { std::map< Constraint *, SET_I > conflictingMap; - for (int i=0; i < conflictGroups.size(); i++) { + for (std::size_t i=0; i < conflictGroups.size(); i++) { if (satisfiedGroups.count(i) == 0) { - for (int j=0; j < conflictGroups[i].size(); j++) { + for (std::size_t j=0; j < conflictGroups[i].size(); j++) { Constraint *constr = conflictGroups[i][j]; if (constr->getTag() != 0) // exclude constraints tagged with zero conflictingMap[constr].insert(i); @@ -1988,8 +2005,8 @@ int System::diagnose(Algorithm alg) Constraint *mostPopular = NULL; for (std::map< Constraint *, SET_I >::const_iterator it=conflictingMap.begin(); it != conflictingMap.end(); it++) { - if (it->second.size() > maxPopularity || - (it->second.size() == maxPopularity && mostPopular && + if (static_cast(it->second.size()) > maxPopularity || + (static_cast(it->second.size()) == maxPopularity && mostPopular && it->first->getTag() > mostPopular->getTag())) { mostPopular = it->first; maxPopularity = it->second.size(); @@ -2049,7 +2066,7 @@ int System::diagnose(Algorithm alg) conflictGroups.clear(); for (int i=conflictGroupsOrig.size()-1; i >= 0; i--) { bool isRedundant = false; - for (int j=0; j < conflictGroupsOrig[i].size(); j++) { + for (std::size_t j=0; j < conflictGroupsOrig[i].size(); j++) { if (redundant.count(conflictGroupsOrig[i][j]) > 0) { isRedundant = true; break; @@ -2065,8 +2082,8 @@ int System::diagnose(Algorithm alg) // simplified output of conflicting tags SET_I conflictingTagsSet; - for (int i=0; i < conflictGroups.size(); i++) { - for (int j=0; j < conflictGroups[i].size(); j++) { + for (std::size_t i=0; i < conflictGroups.size(); i++) { + for (std::size_t j=0; j < conflictGroups[i].size(); j++) { conflictingTagsSet.insert(conflictGroups[i][j]->getTag()); } } diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index 3496bd2bb..cf0ffd26d 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -187,7 +187,8 @@ bool Cell::getStringContent(std::string & s) const s = static_cast(expression)->getText(); char * end; errno = 0; - strtod(s.c_str(), &end); + double d = strtod(s.c_str(), &end); + (void)d; // fix gcc warning if (!*end && errno == 0) s = "'" + s; } diff --git a/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp b/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp index be32e03dc..5bb793cec 100644 --- a/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp +++ b/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp @@ -897,7 +897,7 @@ void ColorPickerPopup::regenerateGrid() */ void ColorPickerPopup::getColorFromDialog() { - bool ok; + //bool ok; //QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget()); QColor col = QColorDialog::getColor(lastSel,parentWidget(),0,QColorDialog::ShowAlphaChannel); if (!col.isValid())