diff --git a/src/App/Branding.cpp b/src/App/Branding.cpp index a8b8eca594..6f593022a6 100644 --- a/src/App/Branding.cpp +++ b/src/App/Branding.cpp @@ -78,8 +78,8 @@ Branding::XmlConfig Branding::getUserDefines() const if (!root.isNull()) { child = root.firstChildElement(); while (!child.isNull()) { - std::string name = (const char*)child.localName().toLatin1(); - std::string value = (const char*)child.text().toUtf8(); + std::string name = child.localName().toLatin1().constData(); + std::string value = child.text().toUtf8().constData(); if (std::find(filter.begin(), filter.end(), name) != filter.end()) cfg[name] = value; child = child.nextSiblingElement(); diff --git a/src/App/ComplexGeoData.cpp b/src/App/ComplexGeoData.cpp index dc490bed13..992e1e8324 100644 --- a/src/App/ComplexGeoData.cpp +++ b/src/App/ComplexGeoData.cpp @@ -40,12 +40,12 @@ TYPESYSTEM_SOURCE_ABSTRACT(Data::Segment , Base::BaseClass) TYPESYSTEM_SOURCE_ABSTRACT(Data::ComplexGeoData , Base::Persistence) -ComplexGeoData::ComplexGeoData(void) +ComplexGeoData::ComplexGeoData() :Tag(0) { } -ComplexGeoData::~ComplexGeoData(void) +ComplexGeoData::~ComplexGeoData() { } @@ -56,10 +56,10 @@ Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const std::string::size_type pos = element.find_first_of("0123456789"); if (pos != std::string::npos) { index = std::atoi(element.substr(pos).c_str()); - element = element.substr(0,pos); + element = element.substr(0, pos); } - return getSubElement(element.c_str(),index); + return getSubElement(element.c_str(), static_cast(index)); } void ComplexGeoData::applyTransform(const Base::Matrix4D& rclTrf) diff --git a/src/App/ComplexGeoData.h b/src/App/ComplexGeoData.h index 875e9b309b..d8fb8e7d46 100644 --- a/src/App/ComplexGeoData.h +++ b/src/App/ComplexGeoData.h @@ -68,7 +68,7 @@ public: }; /// Constructor - ComplexGeoData(void); + ComplexGeoData(); /// Destructor virtual ~ComplexGeoData(); @@ -78,7 +78,7 @@ public: * List of different subelement types * its NOT a list of the subelements itself */ - virtual std::vector getElementTypes(void) const=0; + virtual std::vector getElementTypes() const=0; virtual unsigned long countSubElements(const char* Type) const=0; /// get the subelement by type and number virtual Segment* getSubElement(const char* Type, unsigned long) const=0; @@ -122,7 +122,7 @@ public: * This method has to be handled by the child classes. * the actual placement and matrix is not part of this class. */ - virtual Base::Matrix4D getTransform(void) const = 0; + virtual Base::Matrix4D getTransform() const = 0; //@} /** @name Modification */ @@ -134,7 +134,7 @@ public: /** @name Getting basic geometric entities */ //@{ /// Get the bound box - virtual Base::BoundBox3d getBoundBox(void)const=0; + virtual Base::BoundBox3d getBoundBox()const=0; /** Get point from line object intersection */ virtual Base::Vector3d getPointFromLineIntersection( const Base::Vector3f& base, @@ -196,7 +196,9 @@ protected: /// from local to outside inline Base::Vector3d transformToOutside(const Base::Vector3f& vec) const { - return getTransform() * Base::Vector3d(vec.x,vec.y,vec.z); + return getTransform() * Base::Vector3d(static_cast(vec.x), + static_cast(vec.y), + static_cast(vec.z)); } /// from local to inside inline Base::Vector3f transformToInside(const Base::Vector3d& vec) const @@ -204,7 +206,9 @@ protected: Base::Matrix4D tmpM(getTransform()); tmpM.inverse(); Base::Vector3d tmp = tmpM * vec; - return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z); + return Base::Vector3f(static_cast(tmp.x), + static_cast(tmp.y), + static_cast(tmp.z)); } public: mutable long Tag; diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 30ffe02880..77bb6e15f2 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -171,8 +171,8 @@ public: bool isRemoving() const {return StatusBits.test(ObjectStatus::Remove);} /// return the status bits unsigned long getStatus() const {return StatusBits.to_ulong();} - bool testStatus(ObjectStatus pos) const {return StatusBits.test((size_t)pos);} - void setStatus(ObjectStatus pos, bool on) {StatusBits.set((size_t)pos, on);} + bool testStatus(ObjectStatus pos) const {return StatusBits.test(size_t(pos));} + void setStatus(ObjectStatus pos, bool on) {StatusBits.set(size_t(pos), on);} //@} int isExporting() const; diff --git a/src/App/Enumeration.cpp b/src/App/Enumeration.cpp index 4855bc34a8..dc4a73bbda 100644 --- a/src/App/Enumeration.cpp +++ b/src/App/Enumeration.cpp @@ -160,7 +160,7 @@ void Enumeration::setEnums(const std::vector &values) _EnumArray[i] = 0; // null termination // Other state variables - _maxVal = values.size() - 1; + _maxVal = static_cast(values.size() - 1); _ownEnumArray = true; if (_index < 0) _index = 0; diff --git a/src/App/Material.cpp b/src/App/Material.cpp index 64590868c6..89ce94badf 100644 --- a/src/App/Material.cpp +++ b/src/App/Material.cpp @@ -35,7 +35,7 @@ using namespace App; //=========================================================================== // Material //=========================================================================== -Material::Material(void) +Material::Material() { setType(STEEL); setType(USER_DEFINED); diff --git a/src/App/Material.h b/src/App/Material.h index 90d44b070b..18f1f9f470 100644 --- a/src/App/Material.h +++ b/src/App/Material.h @@ -25,7 +25,7 @@ #define APP_MATERIAL_H #ifdef __GNUC__ -# include +# include #endif #include @@ -100,10 +100,10 @@ public: */ uint32_t getPackedValue() const { - return ((uint32_t)(r*255.0f + 0.5f) << 24 | - (uint32_t)(g*255.0f + 0.5f) << 16 | - (uint32_t)(b*255.0f + 0.5f) << 8 | - (uint32_t)(a*255.0f + 0.5f)); + return (static_cast(r*255.0f + 0.5f) << 24 | + static_cast(g*255.0f + 0.5f) << 16 | + static_cast(b*255.0f + 0.5f) << 8 | + static_cast(a*255.0f + 0.5f)); } /** * creates FC Color from template type, e.g. Qt QColor @@ -116,8 +116,8 @@ public: * */ template - inline T asValue(void) const { - return(T(int(r*255.0),int(g*255.0),int(b*255.0))); + inline T asValue() const { + return(T(int(r*255.0f),int(g*255.0f),int(b*255.0f))); } /** * returns color as hex color "#RRGGBB" @@ -125,9 +125,9 @@ public: */ std::string asHexString() const { std::stringstream ss; - ss << "#" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << int(r*255.0) - << std::setw(2) << int(g*255.0) - << std::setw(2) << int(b*255.0); + ss << "#" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << int(r*255.0f) + << std::setw(2) << int(g*255.0f) + << std::setw(2) << int(b*255.0f); return ss.str(); } /** @@ -223,7 +223,7 @@ public: */ //@{ /** Sets the USER_DEFINED material type. The user must set the colors afterwards. */ - Material(void); + Material(); /** Defines the colors and shininess for the material \a MatName. If \a MatName isn't defined then USER_DEFINED is * set and the user must define the colors itself. */ diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 5c14e43bae..368eef20fb 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -64,7 +64,7 @@ PropertyFileIncluded::~PropertyFileIncluded() } } -void PropertyFileIncluded::aboutToSetValue(void) +void PropertyFileIncluded::aboutToSetValue() { // This is a trick to check in Copy() if it is called // directly from outside or by the Undo/Redo mechanism. @@ -78,7 +78,7 @@ void PropertyFileIncluded::aboutToSetValue(void) this->StatusBits.reset(10); } -std::string PropertyFileIncluded::getDocTransientPath(void) const +std::string PropertyFileIncluded::getDocTransientPath() const { std::string path; PropertyContainer *co = getContainer(); @@ -100,13 +100,13 @@ std::string PropertyFileIncluded::getUniqueFileName(const std::string& path, con return fi.filePath(); } -std::string PropertyFileIncluded::getExchangeTempFile(void) const +std::string PropertyFileIncluded::getExchangeTempFile() const { return Base::FileInfo::getTempFileName(Base::FileInfo (getValue()).fileName().c_str(), getDocTransientPath().c_str()); } -std::string PropertyFileIncluded::getOriginalFileName(void) const +std::string PropertyFileIncluded::getOriginalFileName() const { return _OriginalName; } @@ -232,14 +232,14 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName) } } -const char* PropertyFileIncluded::getValue(void) const +const char* PropertyFileIncluded::getValue() const { return _cValue.c_str(); } -PyObject *PropertyFileIncluded::getPyObject(void) +PyObject *PropertyFileIncluded::getPyObject() { - PyObject *p = PyUnicode_DecodeUTF8(_cValue.c_str(),_cValue.size(),0); + PyObject *p = PyUnicode_DecodeUTF8(_cValue.c_str(),_cValue.size(),nullptr); if (!p) { throw Base::UnicodeError("PropertyFileIncluded: UTF-8 conversion failure"); } @@ -249,7 +249,7 @@ PyObject *PropertyFileIncluded::getPyObject(void) namespace App { const char* getNameFromFile(PyObject* value) { - const char* string = 0; + const char* string = nullptr; PyObject *oname = PyObject_GetAttrString (value, "name"); if (oname) { if (PyUnicode_Check (oname)) { @@ -464,7 +464,7 @@ void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader) hasSetValue(); } -Property *PropertyFileIncluded::Copy(void) const +Property *PropertyFileIncluded::Copy() const { std::unique_ptr prop(new PropertyFileIncluded()); @@ -564,7 +564,7 @@ void PropertyFileIncluded::Paste(const Property &from) hasSetValue(); } -unsigned int PropertyFileIncluded::getMemSize (void) const +unsigned int PropertyFileIncluded::getMemSize () const { unsigned int mem = Property::getMemSize(); mem += _cValue.size(); diff --git a/src/App/PropertyFile.h b/src/App/PropertyFile.h index f512ae4522..97061023f4 100644 --- a/src/App/PropertyFile.h +++ b/src/App/PropertyFile.h @@ -44,10 +44,10 @@ class AppExport PropertyFile : public PropertyString TYPESYSTEM_HEADER(); public: - PropertyFile(void); + PropertyFile(); virtual ~PropertyFile(); - virtual const char* getEditorName(void) const + virtual const char* getEditorName() const { return "Gui::PropertyEditor::PropertyFileItem"; } virtual void setFilter(const std::string filter); @@ -76,15 +76,15 @@ class AppExport PropertyFileIncluded : public Property TYPESYSTEM_HEADER(); public: - PropertyFileIncluded(void); + PropertyFileIncluded(); virtual ~PropertyFileIncluded(); - void setValue(const char* sFile, const char* sName=0); - const char* getValue(void) const; + void setValue(const char* sFile, const char* sName=nullptr); + const char* getValue() const; - virtual const char* getEditorName(void) const + virtual const char* getEditorName() const { return "Gui::PropertyEditor::PropertyTransientFileItem"; } - virtual PyObject *getPyObject(void); + virtual PyObject *getPyObject(); virtual void setPyObject(PyObject *); virtual void Save (Base::Writer &writer) const; @@ -93,9 +93,9 @@ public: virtual void SaveDocFile (Base::Writer &writer) const; virtual void RestoreDocFile(Base::Reader &reader); - virtual Property *Copy(void) const; + virtual Property *Copy() const; virtual void Paste(const Property &from); - virtual unsigned int getMemSize (void) const; + virtual unsigned int getMemSize () const; virtual bool isSame(const Property &other) const { if (&other == this) @@ -111,16 +111,16 @@ public: * this file with setValue() is the fastest way to change * the File. */ - std::string getExchangeTempFile(void) const; - std::string getOriginalFileName(void) const; + std::string getExchangeTempFile() const; + std::string getOriginalFileName() const; bool isEmpty(void) const {return _cValue.empty();} protected: // get the transient path if the property is in a DocumentObject - std::string getDocTransientPath(void) const; + std::string getDocTransientPath() const; std::string getUniqueFileName(const std::string&, const std::string&) const; - void aboutToSetValue(void); + void aboutToSetValue(); protected: mutable std::string _cValue; diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp index 61d21f036f..403211ff1b 100644 --- a/src/App/PropertyUnits.cpp +++ b/src/App/PropertyUnits.cpp @@ -74,7 +74,7 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject *value) else if (PyFloat_Check(value)) quant = Quantity(PyFloat_AsDouble(value),_Unit); else if (PyLong_Check(value)) - quant = Quantity((double)PyLong_AsLong(value),_Unit); + quant = Quantity(double(PyLong_AsLong(value)),_Unit); else if (PyObject_TypeCheck(value, &(QuantityPy::Type))) { Base::QuantityPy *pcObject = static_cast(value); quant = *(pcObject->getQuantityPtr()); diff --git a/src/App/Range.cpp b/src/App/Range.cpp index ce5d360b34..7a0fb891e8 100644 --- a/src/App/Range.cpp +++ b/src/App/Range.cpp @@ -42,9 +42,9 @@ Range::Range(const char * range) std::string from; std::string to; - assert(range != NULL); + assert(range != nullptr); - if (strchr(range, ':') == NULL) { + if (strchr(range, ':') == nullptr) { from = range; to = range; } @@ -247,13 +247,13 @@ std::string App::CellAddress::toString(Cell cell) const if (_absCol && flags.testFlag(Cell::Absolute)) s << '$'; if (col() < 26) { - s << (char)('A' + col()); + s << static_cast('A' + col()); } else { int colnum = col() - 26; - s << (char)('A' + (colnum / 26)); - s << (char)('A' + (colnum % 26)); + s << static_cast('A' + (colnum / 26)); + s << static_cast('A' + (colnum % 26)); } } diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp index f0b45273c8..1413a419ac 100644 --- a/src/Base/FileInfo.cpp +++ b/src/Base/FileInfo.cpp @@ -66,9 +66,9 @@ using namespace Base; std::string ConvertFromWideString(const std::wstring& string) { int neededSize = WideCharToMultiByte(CP_UTF8, 0, string.c_str(), -1, 0, 0,0,0); - char * CharString = new char[neededSize]; + char * CharString = new char[static_cast(neededSize)]; WideCharToMultiByte(CP_UTF8, 0, string.c_str(), -1, CharString, neededSize,0,0); - std::string String((char*)CharString); + std::string String(CharString); delete [] CharString; CharString = NULL; return String; @@ -77,7 +77,7 @@ std::string ConvertFromWideString(const std::wstring& string) std::wstring ConvertToWideString(const std::string& string) { int neededSize = MultiByteToWideChar(CP_UTF8, 0, string.c_str(), -1, 0, 0); - wchar_t* wideCharString = new wchar_t[neededSize]; + wchar_t* wideCharString = new wchar_t[static_cast(neededSize)]; MultiByteToWideChar(CP_UTF8, 0, string.c_str(), -1, wideCharString, neededSize); std::wstring wideString(wideCharString); delete [] wideCharString; @@ -110,7 +110,7 @@ const std::string &FileInfo::getTempPath() wchar_t buf[MAX_PATH + 2]; GetTempPathW(MAX_PATH + 1,buf); int neededSize = WideCharToMultiByte(CP_UTF8, 0, buf, -1, 0, 0, 0, 0); - char* dest = new char[neededSize]; + char* dest = new char[static_cast(neededSize)]; WideCharToMultiByte(CP_UTF8, 0, buf, -1,dest, neededSize, 0, 0); tempPath = dest; delete [] dest; @@ -383,14 +383,15 @@ bool FileInfo::isDir () const return false; } return S_ISDIR(st.st_mode); -#endif +#else return false; +#endif } else return false; // TODO: Check for valid path name - return true; + //return true; } unsigned int FileInfo::size () const diff --git a/src/Base/FutureWatcherProgress.cpp b/src/Base/FutureWatcherProgress.cpp index 35573d37b9..c151cd8924 100644 --- a/src/Base/FutureWatcherProgress.cpp +++ b/src/Base/FutureWatcherProgress.cpp @@ -40,7 +40,7 @@ void FutureWatcherProgress::progressValueChanged(int v) { if (steps == 0) return; - unsigned int step = (100 * v) / steps; + unsigned int step = (100 * static_cast(v)) / steps; if (step > current) { current = step; seq.next(); diff --git a/src/Base/GeometryPyCXX.cpp b/src/Base/GeometryPyCXX.cpp index 151c043b00..5d6fafb789 100644 --- a/src/Base/GeometryPyCXX.cpp +++ b/src/Base/GeometryPyCXX.cpp @@ -127,7 +127,8 @@ Py::Object Vector2dPy::repr() Py::Float y(v.y); std::stringstream str; str << "Vector2 ("; - str << (std::string)x.repr() << ", "<< (std::string)y.repr(); + str << static_cast(x.repr()) << ", " + << static_cast(y.repr()); str << ")"; return Py::String(str.str()); diff --git a/src/Base/InputSource.cpp b/src/Base/InputSource.cpp index ef959b730d..da3f49af3a 100644 --- a/src/Base/InputSource.cpp +++ b/src/Base/InputSource.cpp @@ -89,28 +89,28 @@ unsigned int StdInputStream::readBytes( XMLByte* const toFill, const unsigned i #else XMLFilePos StdInputStream::curPos() const { - return stream.tellg(); + return static_cast(stream.tellg()); } -XMLSize_t StdInputStream::readBytes( XMLByte* const toFill, const XMLSize_t maxToRead ) +XMLSize_t StdInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxToRead) { // // Read up to the maximum bytes requested. We return the number // actually read. // - stream.read((char *)toFill,maxToRead); - XMLSize_t len = stream.gcount(); + stream.read(reinterpret_cast(toFill), static_cast(maxToRead)); + std::streamsize len = stream.gcount(); QTextCodec *codec = QTextCodec::codecForName("UTF-8"); - const QString text = codec->toUnicode((char *)toFill, len, &state); + const QString text = codec->toUnicode(reinterpret_cast(toFill), static_cast(len), &state); if (state.invalidChars > 0) { // In case invalid characters were found decode back to 'utf-8' and replace // them with '?' // First, Qt replaces invalid characters with '\0' (see ConvertInvalidToNull) // but Xerces doesn't like this because it handles this as termination. Thus, // we have to go through the array and replace '\0' with '?'. - XMLSize_t pos = 0; + std::streamsize pos = 0; QByteArray ba = codec->fromUnicode(text); for (int i=0; i(len); } #endif diff --git a/src/Base/PlacementPyImp.cpp b/src/Base/PlacementPyImp.cpp index 15789ae5e4..3ed96ad601 100644 --- a/src/Base/PlacementPyImp.cpp +++ b/src/Base/PlacementPyImp.cpp @@ -289,16 +289,16 @@ void PlacementPy::setRotation(Py::Object arg) { Py::Rotation rot; if (rot.accepts(arg.ptr())) { - getPlacementPtr()->setRotation((Base::Rotation)Py::Rotation(arg)); + getPlacementPtr()->setRotation(static_cast(Py::Rotation(arg))); return; } Py::Tuple tuple; if (tuple.accepts(arg.ptr())) { tuple = arg; - getPlacementPtr()->setRotation(Base::Rotation((double)Py::Float(tuple[0]), - (double)Py::Float(tuple[1]), - (double)Py::Float(tuple[2]), - (double)Py::Float(tuple[3]) + getPlacementPtr()->setRotation(Base::Rotation(static_cast(Py::Float(tuple[0])), + static_cast(Py::Float(tuple[1])), + static_cast(Py::Float(tuple[2])), + static_cast(Py::Float(tuple[3])) )); return; } diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index 9b8fe17663..b92aa8073e 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -438,12 +438,21 @@ double num_change(char* yytext,char dez_delim,char grp_delim) return ret_val; } +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + // error func void Quantity_yyerror(char *errorinfo) { throw Base::ParserError(errorinfo); } +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + // for VC9 (isatty and fileno not supported anymore) //#ifdef _MSC_VER diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp index a4354fe2ce..43d09240a5 100644 --- a/src/Base/QuantityPyImp.cpp +++ b/src/Base/QuantityPyImp.cpp @@ -115,8 +115,15 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/) int i8=0; PyErr_Clear(); // set by PyArg_ParseTuple() if (PyArg_ParseTuple(args, "|diiiiiiii", &f,&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8)) { - if (f != DOUBLE_MAX) { - *self = Quantity(f,Unit(i1,i2,i3,i4,i5,i6,i7,i8)); + if (f < DOUBLE_MAX) { + *self = Quantity(f,Unit{static_cast(i1), + static_cast(i2), + static_cast(i3), + static_cast(i4), + static_cast(i5), + static_cast(i6), + static_cast(i7), + static_cast(i8)}); } return 0; } @@ -218,8 +225,15 @@ PyObject* QuantityPy::getValueAs(PyObject *args) int i8=0; PyErr_Clear(); if (PyArg_ParseTuple(args, "d|iiiiiiii", &f,&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8)) { - if (f!=DOUBLE_MAX) { - quant = Quantity(f,Unit(i1,i2,i3,i4,i5,i6,i7,i8)); + if (f < DOUBLE_MAX) { + quant = Quantity(f,Unit{static_cast(i1), + static_cast(i2), + static_cast(i3), + static_cast(i4), + static_cast(i5), + static_cast(i6), + static_cast(i7), + static_cast(i8)}); } } } @@ -278,7 +292,7 @@ PyObject * QuantityPy::number_int_handler (PyObject *self) } QuantityPy* q = static_cast(self); - return PyLong_FromLong((long)q->getValue()); + return PyLong_FromLong(long(q->getValue())); } PyObject * QuantityPy::number_negative_handler (PyObject *self) diff --git a/src/Base/Rotation.cpp b/src/Base/Rotation.cpp index a3bb128e8b..2edd5bd5f1 100644 --- a/src/Base/Rotation.cpp +++ b/src/Base/Rotation.cpp @@ -515,7 +515,7 @@ Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdi auto dropPriority = [&order](int index){ - char tmp; + int tmp; if (index == 0){ tmp = order[0]; order[0] = order[1]; @@ -531,7 +531,7 @@ Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdi //pick up the strict direction Vector3d mainDir; for (int i = 0; i < 3; ++i){ - mainDir = *(dirs[order[0]]); + mainDir = *(dirs[size_t(order[0])]); if (mainDir.Length() > tol) break; else @@ -544,7 +544,7 @@ Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdi //pick up the 2nd priority direction, "hint" direction. Vector3d hintDir; for (int i = 0; i < 2; ++i){ - hintDir = *(dirs[order[1]]); + hintDir = *(dirs[size_t(order[1])]); if ((hintDir.Cross(mainDir)).Length() > tol) break; else diff --git a/src/Base/Tools.cpp b/src/Base/Tools.cpp index ad12e7d7cb..eee272bd9b 100644 --- a/src/Base/Tools.cpp +++ b/src/Base/Tools.cpp @@ -166,7 +166,7 @@ std::string Base::Tools::escapedUnicodeToUtf8(const std::string& s) Base::PyGILStateLocker lock; std::string string; - PyObject* unicode = PyUnicode_DecodeUnicodeEscape(s.c_str(), s.size(), "strict"); + PyObject* unicode = PyUnicode_DecodeUnicodeEscape(s.c_str(), static_cast(s.size()), "strict"); if (!unicode) return string; if (PyUnicode_Check(unicode)) { diff --git a/src/Base/Tools.h b/src/Base/Tools.h index be28e62183..79a21cf623 100644 --- a/src/Base/Tools.h +++ b/src/Base/Tools.h @@ -263,14 +263,19 @@ struct BaseExport Tools * @param s String to convert. * @return A std::string encoded as UTF-8. */ - static inline std::string toStdString(const QString& s) { QByteArray tmp = s.toUtf8(); return std::string(tmp.constData(), tmp.size()); } + static inline std::string toStdString(const QString& s) { + QByteArray tmp = s.toUtf8(); + return std::string(tmp.constData(), static_cast(tmp.size())); + } /** * @brief fromStdString Convert a std::string encoded as UTF-8 into a QString. * @param s std::string, expected to be UTF-8 encoded. * @return String represented as a QString. */ - static inline QString fromStdString(const std::string & s) { return QString::fromUtf8(s.c_str(), s.size()); } + static inline QString fromStdString(const std::string & s) { + return QString::fromUtf8(s.c_str(), static_cast(s.size())); + } }; diff --git a/src/Base/Tools2D.cpp b/src/Base/Tools2D.cpp index e988b9c19d..14ef848496 100644 --- a/src/Base/Tools2D.cpp +++ b/src/Base/Tools2D.cpp @@ -43,7 +43,7 @@ double Vector2d::GetAngle (const Vector2d &rclVect) const { fNum = (*this * rclVect) / fDivid; if (fNum < -1) - return F_PI; + return D_PI; else if (fNum > 1) return 0.0; @@ -186,11 +186,11 @@ bool Line2d::Intersect (const Line2d& rclLine, Vector2d &rclV) const if (fabs (clV2.x - clV1.x) > 1e-10) m1 = (clV2.y - clV1.y) / (clV2.x - clV1.x); else - m1 = FLOAT_MAX; + m1 = DOUBLE_MAX; if (fabs (rclLine.clV2.x - rclLine.clV1.x) > 1e-10) m2 = (rclLine.clV2.y - rclLine.clV1.y) / (rclLine.clV2.x - rclLine.clV1.x); else - m2 = FLOAT_MAX; + m2 = DOUBLE_MAX; if (m1 == m2) /****** RETURN ERR (parallel lines) *************/ return false; @@ -198,13 +198,13 @@ bool Line2d::Intersect (const Line2d& rclLine, Vector2d &rclV) const b2 = rclLine.clV1.y - m2 * rclLine.clV1.x; // calc intersection - if (m1 == FLOAT_MAX) + if (m1 == DOUBLE_MAX) { rclV.x = clV1.x; rclV.y = m2 * rclV.x + b2; } else - if (m2 == FLOAT_MAX) + if (m2 == DOUBLE_MAX) { rclV.x = rclLine.clV1.x; rclV.y = m1 * rclV.x + b1; diff --git a/src/Base/Tools2D.h b/src/Base/Tools2D.h index 752ee1a566..c503500660 100644 --- a/src/Base/Tools2D.h +++ b/src/Base/Tools2D.h @@ -176,8 +176,10 @@ public: // admin-interface inline size_t GetCtVectors () const; inline bool Add (const Vector2d &rclVct); - inline Vector2d& operator[] (size_t ulNdx) const; - inline Vector2d& At (size_t ulNdx) const; + inline const Vector2d& operator[] (size_t ulNdx) const; + inline const Vector2d& At (size_t ulNdx) const; + inline Vector2d& operator[] (size_t ulNdx); + inline Vector2d& At (size_t ulNdx); inline bool Delete (size_t ulNdx); inline void DeleteAll (); @@ -200,7 +202,7 @@ inline Vector2d::Vector2d() } inline Vector2d::Vector2d(float x, float y) -: x(x), y(y) +: x(double(x)), y(double(y)) { } @@ -410,7 +412,8 @@ inline bool Polygon2d::Delete (size_t ulNdx) { if ( ulNdx < _aclVct.size() ) { - std::vector::iterator it = _aclVct.begin() + ulNdx; + std::vector::iterator it = _aclVct.begin(); + std::advance(it, ulNdx); _aclVct.erase ( it ); return true; } @@ -418,16 +421,27 @@ inline bool Polygon2d::Delete (size_t ulNdx) return false; } -inline Vector2d& Polygon2d::operator[] (size_t ulNdx) const +inline const Vector2d& Polygon2d::operator[] (size_t ulNdx) const { - return (Vector2d&) _aclVct[ulNdx]; + return _aclVct[ulNdx]; } -inline Vector2d& Polygon2d::At (size_t ulNdx) const +inline const Vector2d& Polygon2d::At (size_t ulNdx) const { - return (Vector2d&) _aclVct[ulNdx]; + return _aclVct.at(ulNdx); } +inline Vector2d& Polygon2d::operator[] (size_t ulNdx) +{ + return _aclVct[ulNdx]; +} + +inline Vector2d& Polygon2d::At (size_t ulNdx) +{ + return _aclVct.at(ulNdx); +} + + inline Line2d::Line2d (const Line2d &rclLine) : clV1 (rclLine.clV1), clV2 (rclLine.clV2) diff --git a/src/Base/Type.cpp b/src/Base/Type.cpp index 6922d49088..dd97820655 100644 --- a/src/Base/Type.cpp +++ b/src/Base/Type.cpp @@ -142,7 +142,7 @@ Type Type::badType() const Type Type::createType(const Type parent, const char *name, instantiationMethod method) { Type newType; - newType.index = Type::typedata.size(); + newType.index = static_cast(Type::typedata.size()); TypeData * typeData = new TypeData(name, newType, parent,method); Type::typedata.push_back(typeData); @@ -232,7 +232,7 @@ int Type::getAllDerivedFrom(const Type type, std::vector & List) int Type::getNumTypes() { - return typedata.size(); + return static_cast(typedata.size()); } Type Type::getTypeIfDerivedFrom(const char* name , const Type parent, bool bLoadModule) diff --git a/src/Base/Unit.cpp b/src/Base/Unit.cpp index d67a26522d..596e072dd1 100644 --- a/src/Base/Unit.cpp +++ b/src/Base/Unit.cpp @@ -65,14 +65,14 @@ Unit::Unit(int8_t Length, int8_t Angle) { checkRange("unit", - (int32_t)Length, - (int32_t)Mass, - (int32_t)Time, - (int32_t)ElectricCurrent, - (int32_t)ThermodynamicTemperature, - (int32_t)AmountOfSubstance, - (int32_t)LuminousIntensity, - (int32_t)Angle); + Length, + Mass, + Time, + ElectricCurrent, + ThermodynamicTemperature, + AmountOfSubstance, + LuminousIntensity, + Angle); Sig.Length = Length; Sig.Mass = Mass; @@ -122,14 +122,14 @@ Unit::Unit(const QString& expr) Unit Unit::pow(signed char exp) const { checkRange("pow()", - (int32_t)Sig.Length * (int32_t)exp, - (int32_t)Sig.Mass * (int32_t)exp, - (int32_t)Sig.Time * (int32_t)exp, - (int32_t)Sig.ElectricCurrent * (int32_t)exp, - (int32_t)Sig.ThermodynamicTemperature * (int32_t)exp, - (int32_t)Sig.AmountOfSubstance * (int32_t)exp, - (int32_t)Sig.LuminousIntensity * (int32_t)exp, - (int32_t)Sig.Angle * (int32_t)exp); + Sig.Length * exp, + Sig.Mass * exp, + Sig.Time * exp, + Sig.ElectricCurrent * exp, + Sig.ThermodynamicTemperature * exp, + Sig.AmountOfSubstance * exp, + Sig.LuminousIntensity * exp, + Sig.Angle * exp); Unit result; result.Sig.Length = Sig.Length * exp; @@ -172,14 +172,14 @@ bool Unit::operator ==(const Unit& that) const Unit Unit::operator *(const Unit &right) const { checkRange("* operator", - (int32_t)Sig.Length + (int32_t)right.Sig.Length, - (int32_t)Sig.Mass + (int32_t)right.Sig.Mass, - (int32_t)Sig.Time + (int32_t)right.Sig.Time, - (int32_t)Sig.ElectricCurrent + (int32_t)right.Sig.ElectricCurrent, - (int32_t)Sig.ThermodynamicTemperature + (int32_t)right.Sig.ThermodynamicTemperature, - (int32_t)Sig.AmountOfSubstance + (int32_t)right.Sig.AmountOfSubstance, - (int32_t)Sig.LuminousIntensity + (int32_t)right.Sig.LuminousIntensity, - (int32_t)Sig.Angle + (int32_t)right.Sig.Angle); + Sig.Length +right.Sig.Length, + Sig.Mass + right.Sig.Mass, + Sig.Time + right.Sig.Time, + Sig.ElectricCurrent + right.Sig.ElectricCurrent, + Sig.ThermodynamicTemperature + right.Sig.ThermodynamicTemperature, + Sig.AmountOfSubstance + right.Sig.AmountOfSubstance, + Sig.LuminousIntensity + right.Sig.LuminousIntensity, + Sig.Angle + right.Sig.Angle); Unit result; result.Sig.Length = Sig.Length + right.Sig.Length; @@ -197,14 +197,14 @@ Unit Unit::operator *(const Unit &right) const Unit Unit::operator /(const Unit &right) const { checkRange("/ operator", - (int32_t)Sig.Length - (int32_t)right.Sig.Length, - (int32_t)Sig.Mass - (int32_t)right.Sig.Mass, - (int32_t)Sig.Time - (int32_t)right.Sig.Time, - (int32_t)Sig.ElectricCurrent - (int32_t)right.Sig.ElectricCurrent, - (int32_t)Sig.ThermodynamicTemperature - (int32_t)right.Sig.ThermodynamicTemperature, - (int32_t)Sig.AmountOfSubstance - (int32_t)right.Sig.AmountOfSubstance, - (int32_t)Sig.LuminousIntensity - (int32_t)right.Sig.LuminousIntensity, - (int32_t)Sig.Angle - (int32_t)right.Sig.Angle); + Sig.Length - right.Sig.Length, + Sig.Mass - right.Sig.Mass, + Sig.Time - right.Sig.Time, + Sig.ElectricCurrent - right.Sig.ElectricCurrent, + Sig.ThermodynamicTemperature - right.Sig.ThermodynamicTemperature, + Sig.AmountOfSubstance - right.Sig.AmountOfSubstance, + Sig.LuminousIntensity - right.Sig.LuminousIntensity, + Sig.Angle - right.Sig.Angle); Unit result; result.Sig.Length = Sig.Length - right.Sig.Length; diff --git a/src/Base/UnitsApiPy.cpp b/src/Base/UnitsApiPy.cpp index e391c1fb5b..7951e22b92 100644 --- a/src/Base/UnitsApiPy.cpp +++ b/src/Base/UnitsApiPy.cpp @@ -140,7 +140,7 @@ PyObject* UnitsApi::sSetSchema(PyObject * /*self*/, PyObject *args) PyErr_SetString(PyExc_ValueError, "invalid schema value"); return nullptr; } - setSchema((UnitSystem)index); + setSchema(static_cast(index)); } Py_Return; } diff --git a/src/Base/UnitsSchema.cpp b/src/Base/UnitsSchema.cpp index 25b6ec5b7c..df551bc83f 100644 --- a/src/Base/UnitsSchema.cpp +++ b/src/Base/UnitsSchema.cpp @@ -40,7 +40,7 @@ QString UnitsSchema::toLocale(const Base::Quantity& quant, double factor, const QLocale Lc; const QuantityFormat& format = quant.getFormat(); if (format.option != QuantityFormat::None) { - uint opt = static_cast(format.option); + int opt = format.option; Lc.setNumberOptions(static_cast(opt)); } diff --git a/src/Base/UnitsSchemaImperial1.cpp b/src/Base/UnitsSchemaImperial1.cpp index 3cd062fe4d..02a3a3f370 100644 --- a/src/Base/UnitsSchemaImperial1.cpp +++ b/src/Base/UnitsSchemaImperial1.cpp @@ -235,18 +235,18 @@ QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity &quant, doub minden = quant.getFormat().getDenominator(); // Compute and round the total number of fractional units - ntot = (int)std::round(totalInches * (double)minden); + ntot = static_cast(std::round(totalInches * static_cast(minden))); // If this is zero, nothing to do but return if( ntot==0 ) return QString::fromLatin1("0"); // Compute the whole number of feet and remaining units - feet = (int)std::floor(ntot / (12*minden)); + feet = static_cast(std::floor(ntot / (12*minden))); ntot = ntot - 12*minden*feet; // Compute the remaining number of whole inches - inches = (int)std::floor(ntot/minden); + inches = static_cast(std::floor(ntot/minden)); // Lastly the fractional quantities num = ntot - inches*minden; @@ -387,9 +387,9 @@ QString UnitsSchemaImperialCivil::schemaTranslate(const Base::Quantity& quant, d // double wholeSeconds = std::floor(rawSeconds); // double remainSeconds = rawSeconds - wholeSeconds; - int outDeg = (int) wholeDegrees; - int outMin = (int) wholeMinutes; - int outSec = (int) std::round(rawSeconds); + int outDeg = static_cast(wholeDegrees); + int outMin = static_cast(wholeMinutes); + int outSec = static_cast(std::round(rawSeconds)); std::stringstream output; output << outDeg << degreeString.toUtf8().constData(); diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index c79d5920d4..9e52fab521 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -47,7 +47,9 @@ std::string VectorPy::representation() const Py::Float z(ptr->z); std::stringstream str; str << "Vector ("; - str << (std::string)x.repr() << ", "<< (std::string)y.repr() << ", "<< (std::string)z.repr(); + str << static_cast(x.repr()) << ", " + << static_cast(y.repr()) << ", " + << static_cast(z.repr()); str << ")"; return str.str(); @@ -192,8 +194,10 @@ PyObject * VectorPy::sequence_item (PyObject *self, Py_ssize_t index) return nullptr; } + unsigned short pos = index % 3; + Base::Vector3d a = static_cast(self)->value(); - return Py_BuildValue("d", a[index]); + return Py_BuildValue("d", a[pos]); } int VectorPy::sequence_ass_item(PyObject *self, Py_ssize_t index, PyObject *value) @@ -207,9 +211,11 @@ int VectorPy::sequence_ass_item(PyObject *self, Py_ssize_t index, PyObject *valu return -1; } + unsigned short pos = index % 3; + if (PyNumber_Check(value)) { VectorPy::PointerType ptr = static_cast(self)->getVectorPtr(); - (*ptr)[index] = PyFloat_AsDouble(value); + (*ptr)[pos] = PyFloat_AsDouble(value); } else { PyErr_SetString(PyExc_ValueError, "value must be float"); @@ -255,11 +261,11 @@ PyObject * VectorPy::mapping_subscript(PyObject *self, PyObject *item) } else if (PyObject_TypeCheck(self, &(VectorPy::Type))) { Base::Vector3d v = static_cast(self) ->value(); - Py::Tuple xyz(slicelength); + Py::Tuple xyz(static_cast(slicelength)); - for (cur = start, i = 0; i < slicelength; - cur += step, i++) { - xyz.setItem(i, Py::Float(v[cur])); + for (cur = start, i = 0; i < slicelength; cur += step, i++) { + unsigned short pos = cur % 3; + xyz.setItem(static_cast(i), Py::Float(v[pos])); } return Py::new_reference_to(xyz); @@ -622,7 +628,7 @@ void VectorPy::setLength(Py::Float arg) throw Py::RuntimeError(std::string("Cannot set length of null vector")); } - double val = (double)arg/len; + double val = static_cast(arg)/len; ptr->x *= val; ptr->y *= val; ptr->z *= val; @@ -637,7 +643,7 @@ Py::Float VectorPy::getx() const void VectorPy::setx(Py::Float arg) { VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); - ptr->x = (double)arg; + ptr->x = static_cast(arg); } Py::Float VectorPy::gety() const @@ -649,7 +655,7 @@ Py::Float VectorPy::gety() const void VectorPy::sety(Py::Float arg) { VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); - ptr->y = (double)arg; + ptr->y = static_cast(arg); } Py::Float VectorPy::getz() const @@ -661,7 +667,7 @@ Py::Float VectorPy::getz() const void VectorPy::setz(Py::Float arg) { VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); - ptr->z = (double)arg; + ptr->z = static_cast(arg); } PyObject *VectorPy::getCustomAttributes(const char* /*attr*/) const @@ -693,7 +699,7 @@ PyObject * VectorPy::number_divide_handler (PyObject* self, PyObject* other) Base::Vector3d vec = static_cast(self) ->value(); double div = PyFloat_AsDouble(other); - if (div == 0) { + if (div == 0.0) { PyErr_Format(PyExc_ZeroDivisionError, "'%s' division by zero", Py_TYPE(self)->tp_name); return nullptr; diff --git a/src/Mod/Mesh/App/Core/Visitor.h b/src/Mod/Mesh/App/Core/Visitor.h index f410d9a56f..fc793db5a7 100644 --- a/src/Mod/Mesh/App/Core/Visitor.h +++ b/src/Mod/Mesh/App/Core/Visitor.h @@ -24,7 +24,8 @@ #ifndef VISITOR_H #define VISITOR_H -#include "Definitions.h" +#include +#include #include namespace MeshCore { @@ -32,6 +33,7 @@ namespace MeshCore { class MeshFacet; class MeshKernel; class MeshFacetVisitor; +class MeshPoint; class PlaneFit; /**