diff --git a/src/Base/MatrixPy.xml b/src/Base/MatrixPy.xml index f59db854ae..4f06bf99fa 100644 --- a/src/Base/MatrixPy.xml +++ b/src/Base/MatrixPy.xml @@ -97,28 +97,28 @@ if it's not a scale matrix. tol : float - + nullify() -> None Make this the null matrix. - + isNull() -> bool Check if this is the null matrix. - + unity() -> None Make this matrix to unity (4D identity matrix). - + isUnity() -> bool @@ -185,7 +185,7 @@ index : int vector : Base.Vector - + diagonal() -> Base.Vector @@ -252,34 +252,34 @@ Compute the transformed vector using the matrix. vector : Base.Vector - + invert() -> None Compute the inverse matrix in-place, if possible. - + inverse() -> Base.Matrix Compute the inverse matrix, if possible. - + transpose() -> None Transpose the matrix in-place. - + transposed() -> Base.Matrix Returns a transposed copy of this matrix. - + determinant() -> float @@ -309,7 +309,7 @@ dim : int Dimension parameter must be in the range [1,4]. - + analyze() -> str diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index 9cf794d37a..505b77ab3e 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -352,11 +352,8 @@ PyObject* MatrixPy::hasScale(PyObject * args) return Py::new_reference_to(mod.callMemberFunction("ScaleType", Py::TupleN(Py::Int(static_cast(type))))); } -PyObject* MatrixPy::nullify(PyObject * args) +PyObject* MatrixPy::nullify() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { getMatrixPtr()->nullify(); Py_Return; @@ -364,11 +361,8 @@ PyObject* MatrixPy::nullify(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::isNull(PyObject * args) +PyObject* MatrixPy::isNull() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { bool ok = getMatrixPtr()->isNull(); return Py::new_reference_to(Py::Boolean(ok)); @@ -376,11 +370,8 @@ PyObject* MatrixPy::isNull(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::unity(PyObject * args) +PyObject* MatrixPy::unity() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { getMatrixPtr()->setToUnity(); Py_Return; @@ -388,11 +379,8 @@ PyObject* MatrixPy::unity(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::isUnity(PyObject * args) +PyObject* MatrixPy::isUnity() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { bool ok = getMatrixPtr()->isUnity(); return Py::new_reference_to(Py::Boolean(ok)); @@ -487,11 +475,8 @@ PyObject* MatrixPy::setRow(PyObject * args) Py_Return; } -PyObject* MatrixPy::diagonal(PyObject * args) +PyObject* MatrixPy::diagonal() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - Matrix4D* mat = getMatrixPtr(); Base::Vector3d v = mat->diagonal(); return Py::new_reference_to(Py::Vector(v)); @@ -628,11 +613,8 @@ PyObject* MatrixPy::multVec(PyObject * args) return new VectorPy(new Vector3d(vec)); } -PyObject* MatrixPy::invert(PyObject * args) +PyObject* MatrixPy::invert() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) { getMatrixPtr()->inverseGauss(); @@ -646,11 +628,8 @@ PyObject* MatrixPy::invert(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::inverse(PyObject * args) +PyObject* MatrixPy::inverse() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) { Base::Matrix4D m = *getMatrixPtr(); @@ -665,11 +644,8 @@ PyObject* MatrixPy::inverse(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::determinant(PyObject * args) +PyObject* MatrixPy::determinant() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - return PyFloat_FromDouble(getMatrixPtr()->determinant()); } @@ -741,11 +717,8 @@ PyObject* MatrixPy::isOrthogonal(PyObject * args) return Py::new_reference_to(Py::Float(ok ? mult : 0.0)); } -PyObject* MatrixPy::transposed(PyObject * args) +PyObject* MatrixPy::transposed() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { Base::Matrix4D m = *getMatrixPtr(); m.transpose(); @@ -754,11 +727,8 @@ PyObject* MatrixPy::transposed(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::transpose(PyObject * args) +PyObject* MatrixPy::transpose() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { getMatrixPtr()->transpose(); Py_Return; @@ -766,11 +736,8 @@ PyObject* MatrixPy::transpose(PyObject * args) PY_CATCH; } -PyObject* MatrixPy::analyze(PyObject * args) +PyObject* MatrixPy::analyze() { - if (!PyArg_ParseTuple(args, "")) - return nullptr; - PY_TRY { std::string type = getMatrixPtr()->analyse(); return PyUnicode_FromString(type.c_str()); diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 16169537f8..248ea7ac4e 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -833,8 +833,6 @@ SET(View3D_CPP_SRCS View3DPy.cpp View3DViewerPy.cpp NaviCube.cpp - NavigationAnimator.cpp - NavigationAnimation.cpp ) SET(View3D_SRCS ${View3D_CPP_SRCS} @@ -857,8 +855,6 @@ SET(View3D_SRCS CoinRiftWidget.h View3DViewerPy.h NaviCube.h - NavigationAnimator.h - NavigationAnimation.h ) SOURCE_GROUP("View3D" FILES ${View3D_SRCS}) diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 49c9fe0301..89ca6dcd0f 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -4009,6 +4009,7 @@ namespace Gui { void CreateViewStdCommands() { + // NOLINTBEGIN CommandManager &rcCmdMgr = Application::Instance->commandManager(); // views @@ -4085,8 +4086,6 @@ void CreateViewStdCommands() rcCmdMgr.addCommand(new CmdViewMeasureClearAll()); rcCmdMgr.addCommand(new CmdViewMeasureToggleAll()); rcCmdMgr.addCommand(new StdCmdSelBoundingBox()); - rcCmdMgr.addCommand(new StdCmdSelBack()); - rcCmdMgr.addCommand(new StdCmdSelForward()); rcCmdMgr.addCommand(new StdCmdTreeViewActions()); auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); @@ -4094,6 +4093,7 @@ void CreateViewStdCommands() hGrp->SetASCII("GestureRollFwdCommand","Std_SelForward"); if(hGrp->GetASCII("GestureRollBackCommand").empty()) hGrp->SetASCII("GestureRollBackCommand","Std_SelBack"); + // NOLINTEND } } // namespace Gui diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp index e3c67c141c..5dadc25a0c 100644 --- a/src/Gui/DemoMode.cpp +++ b/src/Gui/DemoMode.cpp @@ -91,7 +91,7 @@ void DemoMode::reset() view->getViewer()->stopAnimating(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/View"); - hGrp->Notify("UseNavigationAnimations"); + hGrp->Notify("UseAutoRotation"); } void DemoMode::accept() @@ -265,6 +265,7 @@ void DemoMode::onAutoPlay() Gui::View3DInventor* view = activeView(); if (view && !view->getViewer()->isAnimating()) { ui->playButton->setChecked(true); + startAnimation(view); } } @@ -272,9 +273,8 @@ void DemoMode::startAnimation(Gui::View3DInventor* view) { if (!view->getViewer()->isAnimationEnabled()) view->getViewer()->setAnimationEnabled(true); - - view->getViewer()->startSpinningAnimation(getDirection(view), - getSpeed(ui->speedSlider->value())); + view->getViewer()->startAnimating(getDirection(view), + getSpeed(ui->speedSlider->value())); } void DemoMode::onTimerCheckToggled(bool on) diff --git a/src/Gui/NavigationAnimation.cpp b/src/Gui/NavigationAnimation.cpp deleted file mode 100644 index 5f62366054..0000000000 --- a/src/Gui/NavigationAnimation.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later -/**************************************************************************** - * * - * Copyright (c) 2023 Bas Ruigrok (Rexbas) * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - ***************************************************************************/ - -#include "PreCompiled.h" -#include "NavigationAnimation.h" -#include - -using namespace Gui; - -NavigationAnimation::NavigationAnimation(NavigationStyle* navigation) - : navigation(navigation), started(false) -{} - -void NavigationAnimation::startAnimation(QAbstractAnimation::DeletionPolicy policy) -{ - started = true; - QAbstractAnimation::start(policy); -} - -void NavigationAnimation::updateCurrentValue(const QVariant& value) -{ - if (!started) { - return; - } - update(value); -} - -void NavigationAnimation::stopAnimation() -{ - QAbstractAnimation::stop(); -} - -FixedTimeAnimation::FixedTimeAnimation(NavigationStyle* navigation, const SbRotation& orientation, - const SbVec3f& rotationCenter, const SbVec3f& translation, - int duration) - : NavigationAnimation(navigation) - , targetOrientation(orientation) - , targetTranslation(translation) - , rotationCenter(rotationCenter) -{ - setDuration(duration); - setStartValue(0.0); - setEndValue(duration * 1.0); -} - -void FixedTimeAnimation::initialize() -{ - prevAngle = 0; - prevTranslation = SbVec3f(0, 0, 0); - - // Find an axis and angle to rotate from the camera orientation to the target orientation using post-multiplication - SbVec3f rotationAxisPost; - float angle; - SbRotation(navigation->getCamera()->orientation.getValue().inverse() * targetOrientation).getValue(rotationAxisPost, angle); - if (angle > M_PI) { - angle -= 2 * M_PI; - } - - // Convert post-multiplication axis to a pre-multiplication axis - navigation->getCamera()->orientation.getValue().inverse().multVec(rotationAxisPost, rotationAxis); - - angularVelocity = angle / duration(); - linearVelocity = targetTranslation / duration(); -} - -/** - * @param value The elapsed time - */ -void FixedTimeAnimation::update(const QVariant& value) -{ - float angle = value.toFloat() * angularVelocity; - SbVec3f translation = value.toFloat() * linearVelocity; - - SbRotation rotation(rotationAxis, angle - prevAngle); - - navigation->reorientCamera(navigation->getCamera(), rotation, rotationCenter); - navigation->getCamera()->position = navigation->getCamera()->position.getValue() + translation - prevTranslation; - - prevAngle = angle; - prevTranslation = translation; -} - -/** - * @param navigation The navigation style - * @param axis The rotation axis in screen coordinates - * @param velocity The angular velocity in radians per second - */ -SpinningAnimation::SpinningAnimation(NavigationStyle* navigation, const SbVec3f& axis, - float velocity) - : NavigationAnimation(navigation) - , rotationAxis(axis) -{ - setDuration((2 * M_PI / velocity) * 1000.0); - setStartValue(0.0); - setEndValue(2 * M_PI); - setLoopCount(-1); -} - -void SpinningAnimation::initialize() -{ - prevAngle = 0; - - navigation->setViewing(true); - navigation->setViewingMode(NavigationStyle::SPINNING); -} - -/** - * @param value The angle in radians - */ -void SpinningAnimation::update(const QVariant& value) -{ - SbRotation deltaRotation = SbRotation(rotationAxis, value.toFloat() - prevAngle); - navigation->reorientCamera(navigation->getCamera(), deltaRotation); - - prevAngle = value.toFloat(); -} - -void SpinningAnimation::stopAnimation() -{ - NavigationAnimation::stopAnimation(); - if (navigation->getViewingMode() != NavigationStyle::SPINNING) { - return; - } - navigation->setViewingMode(navigation->isViewing() ? NavigationStyle::IDLE : NavigationStyle::INTERACT); -} diff --git a/src/Gui/NavigationAnimation.h b/src/Gui/NavigationAnimation.h deleted file mode 100644 index 0488db5ed6..0000000000 --- a/src/Gui/NavigationAnimation.h +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later -/**************************************************************************** - * * - * Copyright (c) 2023 Bas Ruigrok (Rexbas) * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - ***************************************************************************/ - -#ifndef GUI_NAVIGATIONANIMATION_H -#define GUI_NAVIGATIONANIMATION_H - -#include "NavigationStyle.h" -#include -#include -#include - -namespace Gui -{ - -class GuiExport NavigationAnimation : protected QVariantAnimation -{ -public: - explicit NavigationAnimation(NavigationStyle* navigation); - -protected: - NavigationStyle* navigation; - - virtual void initialize() = 0; - virtual void update(const QVariant& value) = 0; - virtual void stopAnimation(); - -private: - bool started; - - void startAnimation(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped); - void updateCurrentValue(const QVariant& value) override; - - friend class NavigationAnimator; -}; - -class GuiExport FixedTimeAnimation : public NavigationAnimation -{ -public: - explicit FixedTimeAnimation(NavigationStyle* navigation, const SbRotation& orientation, - const SbVec3f& rotationCenter, const SbVec3f& translation, - int duration); - -private: - float angularVelocity; // [rad/ms] - SbVec3f linearVelocity; // [/ms] - - SbRotation targetOrientation; - SbVec3f targetTranslation; - - float prevAngle; - SbVec3f prevTranslation; - - SbVec3f rotationCenter; - SbVec3f rotationAxis; - - void initialize() override; - void update(const QVariant& value) override; -}; - -class GuiExport SpinningAnimation : public NavigationAnimation -{ -public: - explicit SpinningAnimation(NavigationStyle* navigation, const SbVec3f& axis, float velocity); - -private: - SbVec3f rotationAxis; - float prevAngle; - - void initialize() override; - void update(const QVariant& value) override; - void stopAnimation() override; -}; - -} // namespace Gui - -#endif // GUI_NAVIGATIONANIMATION_H diff --git a/src/Gui/NavigationAnimator.cpp b/src/Gui/NavigationAnimator.cpp deleted file mode 100644 index 0060952746..0000000000 --- a/src/Gui/NavigationAnimator.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later -/**************************************************************************** - * * - * Copyright (c) 2023 Bas Ruigrok (Rexbas) * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - ***************************************************************************/ - -#include "PreCompiled.h" -#include "NavigationAnimator.h" -#include "NavigationAnimation.h" -#include - -using namespace Gui; - -NavigationAnimator::NavigationAnimator() - : activeAnimation(nullptr) -{} - -NavigationAnimator::~NavigationAnimator() -{ - stop(); -} - -/** - * @brief Start an animation - * - * @param animation The animation to start - */ -void NavigationAnimator::start(const std::shared_ptr& animation) -{ - stop(); - activeAnimation = animation; - activeAnimation->initialize(); - - connect(activeAnimation.get(), &NavigationAnimation::finished, this, &NavigationAnimator::reset); - activeAnimation->startAnimation(); -} - -/** - * @brief Start an animation and wait for it to finish - * - * @param animation The animation to start - * @return True if the animation finished, false if interrupted - */ -bool NavigationAnimator::startAndWait(const std::shared_ptr& animation) -{ - stop(); - bool finished = true; - QEventLoop loop; - loop.connect(animation.get(), &NavigationAnimation::finished, - [&loop, &finished, &animation]() { // clazy:exclude=lambda-in-connect - if (animation->state() == QAbstractAnimation::State::Running) { - finished = false; - } - - loop.quit(); - }); - start(animation); - loop.exec(); - return finished; -} - -/** - * @brief Stops an active animation - */ -void NavigationAnimator::stop() -{ - if (activeAnimation != nullptr && activeAnimation->state() != QAbstractAnimation::State::Stopped) { - Q_EMIT activeAnimation->finished(); - } -} - -/** - * @brief Stops the animation and releases ownership of the animation - * - * Is called when the animation finished() signal is received which is triggered when the animation - * is finished or when the animation is interrupted by NavigationAnimator::stop() - */ -void NavigationAnimator::reset() { - activeAnimation->started = false; - activeAnimation->stopAnimation(); - activeAnimation.reset(); -} diff --git a/src/Gui/NavigationAnimator.h b/src/Gui/NavigationAnimator.h deleted file mode 100644 index d3d654560f..0000000000 --- a/src/Gui/NavigationAnimator.h +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later -/**************************************************************************** - * * - * Copyright (c) 2023 Bas Ruigrok (Rexbas) * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - ***************************************************************************/ - -#ifndef GUI_NAVIGATIONANIMATOR_H -#define GUI_NAVIGATIONANIMATOR_H - -#include "NavigationStyle.h" -#include -#include - -namespace Gui -{ - -class NavigationAnimation; - -class GuiExport NavigationAnimator : public QObject -{ - Q_OBJECT -public: - NavigationAnimator(); - ~NavigationAnimator(); - void start(const std::shared_ptr& animation); - bool startAndWait(const std::shared_ptr& animation); - void stop(); - -private Q_SLOTS: - void reset(); - -private: - std::shared_ptr activeAnimation; -}; - -} // namespace Gui - -#endif // GUI_NAVIGATIONANIMATOR_H diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 54e799ae0b..e3490ead43 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -45,13 +45,40 @@ #include "Application.h" #include "MenuManager.h" #include "MouseSelection.h" -#include "NavigationAnimator.h" -#include "NavigationAnimation.h" #include "SoMouseWheelEvent.h" #include "View3DInventorViewer.h" + using namespace Gui; +namespace Gui { +struct NavigationStyleP { + int animationsteps; + int animationdelta; + SbVec3f focal1, focal2; + SbVec3f rotationCenter; + SbBool rotationCenterFound; + NavigationStyle::RotationCenterModes rotationCenterMode; + SbRotation endRotation; + SoTimerSensor * animsensor; + float sensitivity; + SbBool resetcursorpos; + + NavigationStyleP() + { + this->animationsteps = 0; + this->animationdelta = 0; + this->animsensor = nullptr; + this->sensitivity = 2.0f; + this->resetcursorpos = false; + this->rotationCenterFound = false; + this->rotationCenterMode = NavigationStyle::RotationCenterMode::ScenePointAtCursor | + NavigationStyle::RotationCenterMode::FocalPointAtCursor; + } + static void viewAnimationCB(void * data, SoSensor * sensor); +}; +} + class FCSphereSheetProjector : public SbSphereSheetProjector { using inherited = SbSphereSheetProjector; @@ -157,19 +184,25 @@ const Base::Type& NavigationStyleEvent::style() const return t; } +#define PRIVATE(ptr) (ptr->pimpl) +#define PUBLIC(ptr) (ptr->pub) + TYPESYSTEM_SOURCE_ABSTRACT(Gui::NavigationStyle,Base::BaseClass) NavigationStyle::NavigationStyle() : viewer(nullptr), mouseSelection(nullptr) { - this->rotationCenterMode = NavigationStyle::RotationCenterMode::ScenePointAtCursor - | NavigationStyle::RotationCenterMode::FocalPointAtCursor; + PRIVATE(this) = new NavigationStyleP(); + PRIVATE(this)->animsensor = new SoTimerSensor(NavigationStyleP::viewAnimationCB, this); initialize(); } NavigationStyle::~NavigationStyle() { finalize(); - delete this->animator; + if (PRIVATE(this)->animsensor->isScheduled()) + PRIVATE(this)->animsensor->unschedule(); + delete PRIVATE(this)->animsensor; + delete PRIVATE(this); } NavigationStyle& NavigationStyle::operator = (const NavigationStyle& ns) @@ -189,15 +222,12 @@ void NavigationStyle::setViewer(View3DInventorViewer* view) void NavigationStyle::initialize() { - this->animator = new NavigationAnimator(); - - this->sensitivity = 2.0f; - this->resetcursorpos = false; this->currentmode = NavigationStyle::IDLE; + this->prevRedrawTime = SbTime::getTimeOfDay(); this->spinanimatingallowed = true; this->spinsamplecounter = 0; this->spinincrement = SbRotation::identity(); - this->rotationCenterFound = false; + this->spinRotation.setValue(SbVec3f(0, 0, -1), 0); // FIXME: use a smaller sphere than the default one to have a larger // area close to the borders that gives us "z-axis rotation"? @@ -323,71 +353,171 @@ SbBool NavigationStyle::lookAtPoint(const SbVec2s screenpos) SbVec3f hitpoint; hitpoint = picked->getPoint(); - this->rotationCenterFound = false; - translateCamera(hitpoint - getFocalPoint()); + lookAtPoint(hitpoint); return true; } -SoCamera* NavigationStyle::getCamera() const +void NavigationStyle::lookAtPoint(const SbVec3f& pos) { - return this->viewer->getCamera(); + SoCamera* cam = viewer->getSoRenderManager()->getCamera(); + if (!cam) + return; + PRIVATE(this)->rotationCenterFound = false; + + // Find global coordinates of focal point. + SbVec3f direction; + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + PRIVATE(this)->focal1 = cam->position.getValue() + + cam->focalDistance.getValue() * direction; + PRIVATE(this)->focal2 = pos; + + // avoid to interfere with spinning (fixes #3101462) + if (this->isAnimating()) + this->stopAnimating(); + + if (PRIVATE(this)->animsensor->isScheduled()) { + PRIVATE(this)->animsensor->unschedule(); + this->interactiveCountDec(); + } + + if (isAnimationEnabled()) { + SbRotation cam_rot = cam->orientation.getValue(); + // get the amount of movement + SbVec3f dir1 = direction, dir2; + dir2 = pos - cam->position.getValue(); + dir2.normalize(); + SbRotation rot(dir1, dir2); + float val = 0.5f*(1.0f + dir1.dot(dir2)); // value in range [0,1] + int div = (int)(val * 20.0f); + int steps = 20-div; // do it with max. 20 steps + + // check whether a movement is required + if (steps > 0) { + PRIVATE(this)->endRotation = cam_rot; + this->spinRotation = cam_rot; + PRIVATE(this)->animationsteps = 5; + PRIVATE(this)->animationdelta = std::max(100/steps, 5); + PRIVATE(this)->animsensor->setBaseTime(SbTime::getTimeOfDay()); + PRIVATE(this)->animsensor->schedule(); + this->interactiveCountInc(); + } + else { + // set to the given position + SbVec3f direction; + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->position = pos - cam->focalDistance.getValue() * direction; + } + } + else { + // set to the given position + SbVec3f direction; + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->position = pos - cam->focalDistance.getValue() * direction; + } } -void NavigationStyle::setCameraOrientation(const SbRotation& orientation, SbBool moveToCenter) +void NavigationStyle::setCameraOrientation(const SbRotation& rot, SbBool moveToCenter) { - SoCamera* camera = getCamera(); - if (!camera) + SoCamera* cam = viewer->getSoRenderManager()->getCamera(); + if (!cam) return; - animator->stop(); - - SbVec3f focalPoint = getFocalPoint(); - SbVec3f translation(0, 0, 0); - + // Find global coordinates of focal point. + SbVec3f direction; + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + PRIVATE(this)->focal1 = cam->position.getValue() + + cam->focalDistance.getValue() * direction; + PRIVATE(this)->focal2 = PRIVATE(this)->focal1; if (moveToCenter) { SoGetBoundingBoxAction action(viewer->getSoRenderManager()->getViewportRegion()); action.apply(viewer->getSceneGraph()); SbBox3f box = action.getBoundingBox(); if (!box.isEmpty()) { - translation = box.getCenter() - focalPoint; + rot.multVec(SbVec3f(0, 0, -1), direction); + //float s = (this->focal1 - box.getCenter()).dot(direction); + //this->focal2 = box.getCenter() + s * direction; + // setting the center of the overall bounding box as the future focal point + // seems to be a satisfactory solution + PRIVATE(this)->focal2 = box.getCenter(); } } - // Start an animation or set the pose directly + // avoid to interfere with spinning (fixes #3101462) + if (this->isAnimating()) + this->stopAnimating(); + + if (PRIVATE(this)->animsensor->isScheduled()) { + PRIVATE(this)->animsensor->unschedule(); + this->interactiveCountDec(); + } + if (isAnimationEnabled()) { - viewer->startAnimation(orientation, focalPoint, translation); + // get the amount of movement + SbVec3f dir1, dir2; + SbRotation cam_rot = cam->orientation.getValue(); + cam_rot.multVec(SbVec3f(0, 0, -1), dir1); + rot.multVec(SbVec3f(0, 0, -1), dir2); + float val = 0.5f*(1.0f + dir1.dot(dir2)); // value in range [0,1] + int div = (int)(val * 20.0f); + int steps = 20-div; // do it with max. 20 steps + + // check whether a movement is required + if (steps > 0) { + PRIVATE(this)->endRotation = rot; // this is the final camera orientation + this->spinRotation = cam_rot; + PRIVATE(this)->animationsteps = 5; + PRIVATE(this)->animationdelta = std::max(100/steps, 5); + PRIVATE(this)->animsensor->setBaseTime(SbTime::getTimeOfDay()); + PRIVATE(this)->animsensor->schedule(); + this->interactiveCountInc(); + } + else { + // due to possible round-off errors make sure that the + // exact orientation is set + cam->orientation.setValue(rot); + cam->position = PRIVATE(this)->focal2 - cam->focalDistance.getValue() * direction; + } } else { - // Distance from rotation center to camera position in camera coordinate system - SbVec3f rotationCenterDistanceCam = camera->focalDistance.getValue() * SbVec3f(0, 0, 1); - - // Set to the given orientation - camera->orientation = orientation; - - // Distance from rotation center to new camera position in global coordinate system - SbVec3f newRotationCenterDistance; - camera->orientation.getValue().multVec(rotationCenterDistanceCam, newRotationCenterDistance); - - // Reposition camera so the rotation center stays in the same place - // Optionally add translation to move to center - camera->position = focalPoint + newRotationCenterDistance + translation; + // set to the given rotation + cam->orientation.setValue(rot); + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->position = PRIVATE(this)->focal2 - cam->focalDistance.getValue() * direction; } } -void NavigationStyle::translateCamera(const SbVec3f& translation) +void NavigationStyleP::viewAnimationCB(void * data, SoSensor * sensor) { - SoCamera* camera = getCamera(); - if (!camera) - return; + Q_UNUSED(sensor); + auto that = static_cast(data); + if (PRIVATE(that)->animationsteps > 0) { + // here the camera rotates from the current rotation to a given + // rotation (e.g. the standard views). To get this movement animated + // we calculate an interpolated rotation and update the view after + // each step + float step = std::min((float)PRIVATE(that)->animationsteps/100.0f, 1.0f); + SbRotation slerp = SbRotation::slerp(that->spinRotation, PRIVATE(that)->endRotation, step); + SbVec3f focalpoint = (1.0f-step)*PRIVATE(that)->focal1 + step*PRIVATE(that)->focal2; + SoCamera* cam = that->viewer->getSoRenderManager()->getCamera(); + if (!cam) // no camera + return; - animator->stop(); + SbVec3f direction; + cam->orientation.setValue(slerp); + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->position = focalpoint - cam->focalDistance.getValue() * direction; - // Start an animation or set the pose directly - if (isAnimationEnabled()) { - viewer->startAnimation(camera->orientation.getValue(), SbVec3f(0, 0, 0), translation); - } - else { - camera->position = camera->position.getValue() + translation; + PRIVATE(that)->animationsteps += PRIVATE(that)->animationdelta; + if (PRIVATE(that)->animationsteps > 100) { + // now we have reached the end of the movement + PRIVATE(that)->animationsteps=0; + PRIVATE(that)->animsensor->unschedule(); + that->interactiveCountDec(); + // set to the actual given rotation + cam->orientation.setValue(PRIVATE(that)->endRotation); + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->position = PRIVATE(that)->focal2 - cam->focalDistance.getValue() * direction; + } } } @@ -474,41 +604,29 @@ void NavigationStyle::viewAll() } } -/** Rotate the camera by the given amount, then reposition it so we're still pointing at the same - * focal point +/** Rotate the camera by the given amount, then reposition it so we're + * still pointing at the same focal point. */ -void NavigationStyle::reorientCamera(SoCamera* camera, const SbRotation& rotation) +void NavigationStyle::reorientCamera(SoCamera * cam, const SbRotation & rot) { - reorientCamera(camera, rotation, getFocalPoint()); -} - -/** Rotate the camera by the given amount, then reposition it so the rotation center stays in the - * same place - */ -void NavigationStyle::reorientCamera(SoCamera* camera, const SbRotation& rotation, const SbVec3f& rotationCenter) -{ - if (!camera) { + if (!cam) return; - } - // Distance from rotation center to camera position in camera coordinate system - SbVec3f rotationCenterDistanceCam; - camera->orientation.getValue().inverse().multVec(camera->position.getValue() - rotationCenter, rotationCenterDistanceCam); - - // Set new orientation value by accumulating the new rotation - camera->orientation = rotation * camera->orientation.getValue(); + // Find global coordinates of focal point. + SbVec3f direction; + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + SbVec3f focalpoint = cam->position.getValue() + + cam->focalDistance.getValue() * direction; + // Set new orientation value by accumulating the new rotation. + cam->orientation = rot * cam->orientation.getValue(); // Fix issue with near clipping in orthogonal view - if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())) { - camera->focalDistance = static_cast(camera)->height; + if (cam->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())) { + cam->focalDistance = static_cast(cam)->height; } - - // Distance from rotation center to new camera position in global coordinate system - SbVec3f newRotationCenterDistance; - camera->orientation.getValue().multVec(rotationCenterDistanceCam, newRotationCenterDistance); - - // Reposition camera so the rotation center stays in the same place - camera->position = rotationCenter + newRotationCenterDistance; + // Reposition camera so we are still pointing at the same old focal point. + cam->orientation.getValue().multVec(SbVec3f(0, 0, -1), direction); + cam->position = focalpoint - cam->focalDistance.getValue() * direction; } void NavigationStyle::panCamera(SoCamera * cam, float aspectratio, const SbPlane & panplane, @@ -566,7 +684,7 @@ void NavigationStyle::panToCenter(const SbPlane & pplane, const SbVec2f & currpo const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); float ratio = vp.getViewportAspectRatio(); panCamera(viewer->getSoRenderManager()->getCamera(), ratio, pplane, SbVec2f(0.5,0.5), currpos); - this->rotationCenterFound = false; + PRIVATE(this)->rotationCenterFound = false; } /** Dependent on the camera type this will either shrink or expand the @@ -577,9 +695,6 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue) { if (!cam) // can happen for empty scenegraph return; - - animator->stop(); - SoType t = cam->getTypeId(); SbName tname = t.getName(); @@ -747,14 +862,14 @@ void NavigationStyle::doRotate(SoCamera * camera, float angle, const SbVec2f& po SbVec3f NavigationStyle::getRotationCenter(SbBool& found) const { - found = this->rotationCenterFound; - return this->rotationCenter; + found = PRIVATE(this)->rotationCenterFound; + return PRIVATE(this)->rotationCenter; } void NavigationStyle::setRotationCenter(const SbVec3f& cnt) { - this->rotationCenter = cnt; - this->rotationCenterFound = true; + PRIVATE(this)->rotationCenter = cnt; + PRIVATE(this)->rotationCenterFound = true; } SbVec3f NavigationStyle::getFocalPoint() const @@ -786,8 +901,8 @@ void NavigationStyle::spin(const SbVec2f & pointerpos) lastpos[0] = float(this->log.position[1][0]) / float(std::max((int)(glsize[0]-1), 1)); lastpos[1] = float(this->log.position[1][1]) / float(std::max((int)(glsize[1]-1), 1)); - if (this->rotationCenterMode && this->rotationCenterFound) { - SbVec3f hitpoint = this->rotationCenter; + if (PRIVATE(this)->rotationCenterMode && PRIVATE(this)->rotationCenterFound) { + SbVec3f hitpoint = PRIVATE(this)->rotationCenter; // set to the given position SbVec3f direction; @@ -814,7 +929,7 @@ void NavigationStyle::spin(const SbVec2f & pointerpos) r.invert(); this->reorientCamera(viewer->getSoRenderManager()->getCamera(), r); - if (this->rotationCenterMode && this->rotationCenterFound) { + if (PRIVATE(this)->rotationCenterMode && PRIVATE(this)->rotationCenterFound) { float ratio = vp.getViewportAspectRatio(); SbViewVolume vv = viewer->getSoRenderManager()->getCamera()->getViewVolume(vp.getViewportAspectRatio()); SbPlane panplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue()); @@ -900,7 +1015,7 @@ SbBool NavigationStyle::doSpin() float radians; rot.getValue(axis, radians); if ((radians > 0.01f) && (deltatime < 0.300)) { - viewer->startSpinningAnimation(axis, radians * 5); + this->spinRotation = rot; return true; } } @@ -915,14 +1030,14 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev) this->localPos = ev->getPosition(); // mode is WindowCenter - if (!this->rotationCenterMode) { + if (!PRIVATE(this)->rotationCenterMode) { setRotationCenter(getFocalPoint()); } //Option to get point on model (slow) or always on focal plane (fast) // // mode is ScenePointAtCursor to get exact point if possible - if (this->rotationCenterMode & NavigationStyle::RotationCenterMode::ScenePointAtCursor) { + if (PRIVATE(this)->rotationCenterMode & NavigationStyle::RotationCenterMode::ScenePointAtCursor) { SoRayPickAction rpaction(viewer->getSoRenderManager()->getViewportRegion()); rpaction.setPoint(this->localPos); rpaction.setRadius(viewer->getPickRadius()); @@ -936,7 +1051,7 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev) } // mode is FocalPointAtCursor or a ScenePointAtCursor failed - if (this->rotationCenterMode & NavigationStyle::RotationCenterMode::FocalPointAtCursor) { + if (PRIVATE(this)->rotationCenterMode & NavigationStyle::RotationCenterMode::FocalPointAtCursor) { // get the intersection point of the ray and the focal plane const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); float ratio = vp.getViewportAspectRatio(); @@ -957,7 +1072,7 @@ void NavigationStyle::saveCursorPosition(const SoEvent * const ev) } // mode is BoundingBoxCenter or a ScenePointAtCursor failed - if (this->rotationCenterMode & NavigationStyle::RotationCenterMode::BoundingBoxCenter) { + if (PRIVATE(this)->rotationCenterMode & NavigationStyle::RotationCenterMode::BoundingBoxCenter) { const SbViewportRegion & vp = viewer->getSoRenderManager()->getViewportRegion(); float ratio = vp.getViewportAspectRatio(); @@ -1013,6 +1128,20 @@ void NavigationStyle::moveCursorPosition() } } +void NavigationStyle::updateAnimation() +{ + SbTime now = SbTime::getTimeOfDay(); + double secs = now.getValue() - prevRedrawTime.getValue(); + this->prevRedrawTime = now; + + if (this->isAnimating()) { + // here the camera rotates around a fix axis + SbRotation deltaRotation = this->spinRotation; + deltaRotation.scaleAngle(secs * 5.0); + this->reorientCamera(viewer->getSoRenderManager()->getCamera(), deltaRotation); + } +} + void NavigationStyle::redraw() { if (mouseSelection) @@ -1039,7 +1168,7 @@ void NavigationStyle::setAnimationEnabled(const SbBool enable) { this->spinanimatingallowed = enable; - if (!enable && this->isAnimating()) { animator->stop(); } + if (!enable && this->isAnimating()) { this->stopAnimating(); } } /*! @@ -1062,29 +1191,52 @@ SbBool NavigationStyle::isAnimating() const return this->currentmode == NavigationStyle::SPINNING; } -NavigationAnimator* NavigationStyle::getAnimator() const +/*! + * Starts programmatically the viewer in animation mode. The given axis direction + * is always in screen coordinates, not in world coordinates. + */ +void NavigationStyle::startAnimating(const SbVec3f& axis, float velocity) { - return this->animator; + if (!isAnimationEnabled()) + return; + + this->prevRedrawTime = SbTime::getTimeOfDay(); + this->spinincrement = SbRotation::identity(); + SbRotation rot; + rot.setValue(axis, velocity); + + this->setViewing(true); + this->setViewingMode(NavigationStyle::SPINNING); + this->spinRotation = rot; +} + +void NavigationStyle::stopAnimating() +{ + if (this->currentmode != NavigationStyle::SPINNING) { + return; + } + this->setViewingMode(this->isViewing() ? + NavigationStyle::IDLE : NavigationStyle::INTERACT); } void NavigationStyle::setSensitivity(float val) { - this->sensitivity = val; + PRIVATE(this)->sensitivity = val; } float NavigationStyle::getSensitivity() const { - return this->sensitivity; + return PRIVATE(this)->sensitivity; } void NavigationStyle::setResetCursorPosition(SbBool on) { - this->resetcursorpos = on; + PRIVATE(this)->resetcursorpos = on; } SbBool NavigationStyle::isResetCursorPosition() const { - return this->resetcursorpos; + return PRIVATE(this)->resetcursorpos; } void NavigationStyle::setZoomInverted(SbBool on) @@ -1114,12 +1266,12 @@ SbBool NavigationStyle::isZoomAtCursor() const void NavigationStyle::setRotationCenterMode(NavigationStyle::RotationCenterModes mode) { - this->rotationCenterMode = mode; + PRIVATE(this)->rotationCenterMode = mode; } NavigationStyle::RotationCenterModes NavigationStyle::getRotationCenterMode() const { - return this->rotationCenterMode; + return PRIVATE(this)->rotationCenterMode; } void NavigationStyle::startSelection(AbstractMouseSelection* mouse) @@ -1263,7 +1415,6 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode) case DRAGGING: // Set up initial projection point for the projector object when // first starting a drag operation. - animator->stop(); viewer->showRotationCenter(true); this->spinprojector->project(this->lastmouseposition); this->interactiveCountInc(); @@ -1277,18 +1428,15 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode) break; case PANNING: - animator->stop(); pan(viewer->getSoRenderManager()->getCamera()); this->interactiveCountInc(); break; case ZOOMING: - animator->stop(); this->interactiveCountInc(); break; case BOXZOOM: - animator->stop(); this->interactiveCountInc(); break; diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 1bcdef2854..cbc6204a9a 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -52,7 +52,6 @@ class SbSphereSheetProjector; namespace Gui { class View3DInventorViewer; -class NavigationAnimator; class AbstractMouseSelection; /** @@ -123,8 +122,9 @@ public: void setAnimationEnabled(const SbBool enable); SbBool isAnimationEnabled() const; + void startAnimating(const SbVec3f& axis, float velocity); + void stopAnimating(); SbBool isAnimating() const; - NavigationAnimator* getAnimator() const; void setSensitivity(float); float getSensitivity() const; @@ -144,14 +144,11 @@ public: void setRotationCenter(const SbVec3f& cnt); SbVec3f getFocalPoint() const; + void updateAnimation(); void redraw(); - SoCamera* getCamera() const; - void setCameraOrientation(const SbRotation& orientation, SbBool moveToCenter = false); - void translateCamera(const SbVec3f& translation); - void reorientCamera(SoCamera* camera, const SbRotation& rotation); - void reorientCamera(SoCamera* camera, const SbRotation& rotation, const SbVec3f& rotationCenter); - + void setCameraOrientation(const SbRotation& rot, SbBool moveTocenter=false); + void lookAtPoint(const SbVec3f&); void boxZoom(const SbBox2s& box); virtual void viewAll(); @@ -176,9 +173,6 @@ public: void setOrbitStyle(OrbitStyle style); OrbitStyle getOrbitStyle() const; - SbBool isViewing() const; - void setViewing(SbBool); - SbVec3f getRotationCenter(SbBool&) const; protected: @@ -189,12 +183,15 @@ protected: void interactiveCountDec(); int getInteractiveCount() const; + SbBool isViewing() const; + void setViewing(SbBool); SbBool isSeekMode() const; void setSeekMode(SbBool enable); SbBool seekToPoint(const SbVec2s screenpos); void seekToPoint(const SbVec3f& scenepos); SbBool lookAtPoint(const SbVec2s screenpos); + void reorientCamera(SoCamera * camera, const SbRotation & rot); void panCamera(SoCamera * camera, float vpaspect, const SbPlane & panplane, @@ -236,13 +233,13 @@ protected: } log; View3DInventorViewer* viewer{nullptr}; - NavigationAnimator* animator; ViewerMode currentmode; SoMouseButtonEvent mouseDownConsumedEvent; SbVec2f lastmouseposition; SbVec2s globalPos; SbVec2s localPos; SbPlane panningplane; + SbTime prevRedrawTime; SbTime centerTime; SbBool lockrecenter; SbBool menuenabled; @@ -264,17 +261,13 @@ protected: SbBool spinanimatingallowed; int spinsamplecounter; SbRotation spinincrement; + SbRotation spinRotation; SbSphereSheetProjector * spinprojector; //@} private: - friend class NavigationAnimator; - - SbVec3f rotationCenter; - SbBool rotationCenterFound; - NavigationStyle::RotationCenterModes rotationCenterMode; - float sensitivity; - SbBool resetcursorpos; + struct NavigationStyleP* pimpl; + friend struct NavigationStyleP; }; /** Sub-classes of this class appear in the preference dialog where users can diff --git a/src/Gui/PreferencePackTemplates/View.cfg b/src/Gui/PreferencePackTemplates/View.cfg index 708b9b9498..6ad815c14c 100644 --- a/src/Gui/PreferencePackTemplates/View.cfg +++ b/src/Gui/PreferencePackTemplates/View.cfg @@ -32,8 +32,7 @@ - - + diff --git a/src/Gui/PreferencePages/DlgSettingsNavigation.cpp b/src/Gui/PreferencePages/DlgSettingsNavigation.cpp index af4c8372aa..55ff7a0a66 100644 --- a/src/Gui/PreferencePages/DlgSettingsNavigation.cpp +++ b/src/Gui/PreferencePages/DlgSettingsNavigation.cpp @@ -58,6 +58,7 @@ DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent) { ui->setupUi(this); ui->naviCubeBaseColor->setAllowTransparency(true); + ui->rotationCenterColor->setAllowTransparency(true); retranslate(); } @@ -84,10 +85,10 @@ void DlgSettingsNavigation::saveSettings() ui->checkBoxZoomAtCursor->onSave(); ui->checkBoxInvertZoom->onSave(); ui->checkBoxDisableTilt->onSave(); - ui->checkBoxShowRotationCenter->onSave(); + ui->rotationCenterSize->onSave(); + ui->rotationCenterColor->onSave(); ui->spinBoxZoomStep->onSave(); - ui->checkBoxNavigationAnimations->onSave(); - ui->spinBoxAnimationDuration->onSave(); + ui->checkBoxUseAutoRotation->onSave(); ui->qspinNewDocScale->onSave(); ui->prefStepByTurn->onSave(); ui->naviCubeCorner->onSave(); @@ -98,6 +99,9 @@ void DlgSettingsNavigation::saveSettings() bool showNaviCube = ui->groupBoxNaviCube->isChecked(); hGrp->SetBool("ShowNaviCube", showNaviCube); + bool showRotationCenter = ui->groupBoxRotationCenter->isChecked(); + hGrp->SetBool("ShowRotationCenter", showRotationCenter); + QVariant camera = ui->comboNewDocView->itemData(ui->comboNewDocView->currentIndex(), Qt::UserRole); hGrp->SetASCII("NewDocumentCameraOrientation", (const char*)camera.toByteArray()); @@ -111,7 +115,7 @@ void DlgSettingsNavigation::saveSettings() hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/NaviCube"); if (ui->naviCubeFontName->currentIndex()) { - hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); + hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); } else { hGrp->RemoveASCII("FontString"); } @@ -122,10 +126,10 @@ void DlgSettingsNavigation::loadSettings() ui->checkBoxZoomAtCursor->onRestore(); ui->checkBoxInvertZoom->onRestore(); ui->checkBoxDisableTilt->onRestore(); - ui->checkBoxShowRotationCenter->onRestore(); + ui->rotationCenterSize->onRestore(); + ui->rotationCenterColor->onRestore(); ui->spinBoxZoomStep->onRestore(); - ui->checkBoxNavigationAnimations->onRestore(); - ui->spinBoxAnimationDuration->onRestore(); + ui->checkBoxUseAutoRotation->onRestore(); ui->qspinNewDocScale->onRestore(); ui->prefStepByTurn->onRestore(); ui->naviCubeCorner->onRestore(); @@ -149,6 +153,9 @@ void DlgSettingsNavigation::loadSettings() bool showNaviCube = hGrp->GetBool("ShowNaviCube", true); ui->groupBoxNaviCube->setChecked(showNaviCube); + bool showRotationCenter = hGrp->GetBool("ShowRotationCenter", true); + ui->groupBoxRotationCenter->setChecked(showRotationCenter); + ui->comboNewDocView->addItem(tr("Isometric"), QByteArray("Isometric")); ui->comboNewDocView->addItem(tr("Dimetric"), QByteArray("Dimetric")); ui->comboNewDocView->addItem(tr("Trimetric"), QByteArray("Trimetric")); @@ -184,7 +191,7 @@ void DlgSettingsNavigation::loadSettings() QStringList familyNames = QFontDatabase::families(QFontDatabase::Any); #endif ui->naviCubeFontName->addItems(familyNames); - + hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/NaviCube"); int indexFamilyNames = familyNames.indexOf( diff --git a/src/Gui/PreferencePages/DlgSettingsNavigation.ui b/src/Gui/PreferencePages/DlgSettingsNavigation.ui index c107e57cf2..6ccab19a45 100644 --- a/src/Gui/PreferencePages/DlgSettingsNavigation.ui +++ b/src/Gui/PreferencePages/DlgSettingsNavigation.ui @@ -6,8 +6,8 @@ 0 0 - 432 - 423 + 484 + 586 @@ -229,6 +229,99 @@ + + + + Rotation center indicator + + + true + + + + + + Sphere size + + + + + + + Color and transparency + + + + + + + + 60 + 16777215 + + + + The size of the rotation center indicator + + + 1 + + + 1.0 + + + 100.0 + + + 0.5 + + + 5.0 + + + RotationCenterSize + + + View + + + + + + + The color of the rotation center indicator + + + + 255 + 0 + 0 + + + + RotationCenterColor + + + View + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -473,91 +566,27 @@ The value is the diameter of the sphere to fit on the screen. - + true - Enable navigation animations + Enable animated rotations - Enable navigation animations + Enable animation - true + false - UseNavigationAnimations + UseAutoRotation View - - - - Duration of navigation animations that have a fixed duration - - - Animation duration - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - 60 - 16777215 - - - - The duration of navigation animations in milliseconds - - - 100 - - - 10000 - - - 50 - - - 250 - - - AnimationDuration - - - View - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 10 - 20 - - - - - - @@ -580,7 +609,7 @@ The value is the diameter of the sphere to fit on the screen. - Zoom step + Zoom step Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -679,25 +708,6 @@ Mouse tilting is not disabled by this setting. - - - - Show the rotation center when dragging. - - - Enable rotation center indication - - - true - - - ShowRotationCenter - - - View - - - diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index d5636d75f5..ee2a800766 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -118,8 +118,6 @@ #include "ViewProvider.h" #include "ViewProviderDocumentObject.h" #include "ViewProviderLink.h" -#include "NavigationAnimator.h" -#include "NavigationAnimation.h" FC_LOG_LEVEL_INIT("3DViewer",true,true) @@ -204,8 +202,8 @@ while the progress bar is running. class Gui::ViewerEventFilter : public QObject { public: - ViewerEventFilter() {} - ~ViewerEventFilter() override {} + ViewerEventFilter() = default; + ~ViewerEventFilter() override = default; bool eventFilter(QObject* obj, QEvent* event) override { // Bug #0000607: Some mice also support horizontal scrolling which however might @@ -247,8 +245,8 @@ public: class SpaceNavigatorDevice : public Quarter::InputDevice { public: - SpaceNavigatorDevice() {} - ~SpaceNavigatorDevice() override {} + SpaceNavigatorDevice() = default; + ~SpaceNavigatorDevice() override = default; const SoEvent* translateEvent(QEvent* event) override { if (event->type() == Spaceball::MotionEvent::MotionEventType) { @@ -1319,6 +1317,17 @@ void View3DInventorViewer::showRotationCenter(bool show) } if (!rotationCenterGroup) { + float size = App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View") + ->GetFloat("RotationCenterSize", 5.0); + + unsigned long rotationCenterColor = + App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View") + ->GetUnsigned("RotationCenterColor", 4278190131); + + QColor color = App::Color::fromPackedRGBA(rotationCenterColor); + rotationCenterGroup = new SoSkipBoundingGroup(); auto sphere = new SoSphere(); @@ -1334,8 +1343,8 @@ void View3DInventorViewer::showRotationCenter(bool show) complexity->value = 1; auto material = new SoMaterial(); - material->emissiveColor = SbColor(1, 0, 0); - material->transparency = 0.8F; + material->emissiveColor = SbColor(color.redF(), color.greenF(), color.blueF()); + material->transparency = 1.0F - color.alphaF(); auto translation = new SoTranslation(); translation->translation.setValue(center); @@ -1347,7 +1356,7 @@ void View3DInventorViewer::showRotationCenter(bool show) auto scaledSphere = new SoShapeScale(); scaledSphere->setPart("shape", annotation); - scaledSphere->scaleFactor = 4.0; + scaledSphere->scaleFactor = size; rotationCenterGroup->addChild(translation); rotationCenterGroup->addChild(hidden); @@ -2237,6 +2246,8 @@ void View3DInventorViewer::renderScene() drawSingleBackground(col); glra->apply(this->backgroundroot); + navigation->updateAnimation(); + if (!this->shading) { state->push(); SoLightModelElement::set(state, selectionRoot, SoLightModelElement::BASE_COLOR); @@ -2754,9 +2765,9 @@ void View3DInventorViewer::pubSeekToPoint(const SbVec3f& pos) this->seekToPoint(pos); } -void View3DInventorViewer::setCameraOrientation(const SbRotation& orientation, SbBool moveToCenter) +void View3DInventorViewer::setCameraOrientation(const SbRotation& rot, SbBool moveTocenter) { - navigation->setCameraOrientation(orientation, moveToCenter); + navigation->setCameraOrientation(rot, moveTocenter); } void View3DInventorViewer::setCameraType(SoType t) @@ -2777,19 +2788,54 @@ void View3DInventorViewer::setCameraType(SoType t) } } -void View3DInventorViewer::moveCameraTo(const SbRotation& orientation, const SbVec3f& position) +namespace Gui { + class CameraAnimation : public QVariantAnimation + { + SoCamera* camera; + SbRotation startRot, endRot; + SbVec3f startPos, endPos; + + public: + CameraAnimation(SoCamera* camera, const SbRotation& rot, const SbVec3f& pos) + : camera(camera), endRot(rot), endPos(pos) + { + startPos = camera->position.getValue(); + startRot = camera->orientation.getValue(); + } + ~CameraAnimation() override = default; + protected: + void updateCurrentValue(const QVariant & value) override + { + int steps = endValue().toInt(); + int curr = value.toInt(); + + float s = static_cast(curr)/static_cast(steps); + SbVec3f curpos = startPos * (1.0f-s) + endPos * s; + SbRotation currot = SbRotation::slerp(startRot, endRot, s); + camera->orientation.setValue(currot); + camera->position.setValue(curpos); + } + }; +} + +void View3DInventorViewer::moveCameraTo(const SbRotation& rot, const SbVec3f& pos, int steps, int ms) { - SoCamera* camera = getCamera(); - if (!camera) + SoCamera* cam = this->getSoRenderManager()->getCamera(); + if (!cam) return; - if (isAnimationEnabled()) { - startAnimation( - orientation, camera->position.getValue(), position - camera->position.getValue(), true); - } + CameraAnimation anim(cam, rot, pos); + anim.setDuration(Base::clamp(ms,0,5000)); + anim.setStartValue(static_cast(0)); + anim.setEndValue(steps); - camera->orientation.setValue(orientation); - camera->position.setValue(position); + QEventLoop loop; + QObject::connect(&anim, &CameraAnimation::finished, &loop, &QEventLoop::quit); + anim.start(); + loop.exec(QEventLoop::ExcludeUserInputEvents); + + cam->orientation.setValue(rot); + cam->position.setValue(pos); } void View3DInventorViewer::animatedViewAll(int steps, int ms) @@ -3071,49 +3117,18 @@ SbBool View3DInventorViewer::isAnimating() const return navigation->isAnimating(); } -/** - * @brief Change the camera pose with an animation - * - * @param orientation The new orientation - * @param rotationCenter The rotation center - * @param translation An additional translation on top of the translation caused by the rotation around the rotation center +/*! + * Starts programmatically the viewer in animation mode. The given axis direction + * is always in screen coordinates, not in world coordinates. */ -void View3DInventorViewer::startAnimation(const SbRotation& orientation, - const SbVec3f& rotationCenter, const SbVec3f& translation, bool wait) +void View3DInventorViewer::startAnimating(const SbVec3f& axis, float velocity) { - // Currently starts a FixedTimeAnimation. If there is going to be an additional animation like - // FixedVelocityAnimation, check the animation type from a parameter and start the right animation - - int duration = App::GetApplication() - .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View") - ->GetInt("AnimationDuration", 250); - - auto animation = std::make_shared( - navigation, orientation, rotationCenter, translation, duration); - - if (wait) { - navigation->getAnimator()->startAndWait(animation); - } - else { - navigation->getAnimator()->start(animation); - } -} - -/** - * @brief Start an infinite spin animation - * - * @param axis The rotation axis in screen coordinates - * @param velocity The angular velocity in radians per second - */ -void View3DInventorViewer::startSpinningAnimation(const SbVec3f& axis, float velocity) -{ - auto animation = std::make_shared(navigation, axis, velocity); - navigation->getAnimator()->start(animation); + navigation->startAnimating(axis, velocity); } void View3DInventorViewer::stopAnimating() { - navigation->getAnimator()->stop(); + navigation->stopAnimating(); } void View3DInventorViewer::setPopupMenuEnabled(const SbBool on) diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 85441f11b8..0f0edfb429 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -164,9 +164,7 @@ public: void setPopupMenuEnabled(const SbBool on); SbBool isPopupMenuEnabled() const; - void startAnimation(const SbRotation& orientation, const SbVec3f& rotationCenter, - const SbVec3f& translation, bool wait = false); - void startSpinningAnimation(const SbVec3f& axis, float velocity); + void startAnimating(const SbVec3f& axis, float velocity); void stopAnimating(); SbBool isAnimating() const; @@ -375,9 +373,9 @@ public: * \a true the reorientation is animated, otherwise its directly * set. */ - void setCameraOrientation(const SbRotation& orientation, SbBool moveToCenter = false); + void setCameraOrientation(const SbRotation& rot, SbBool moveTocenter=false); void setCameraType(SoType t) override; - void moveCameraTo(const SbRotation& orientation, const SbVec3f& position); + void moveCameraTo(const SbRotation& rot, const SbVec3f& pos, int steps, int ms); /** * Zooms the viewport to the size of the bounding box. */ diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 7e36f8b4a3..92f407bbab 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -777,8 +777,10 @@ Py::Object View3DInventorPy::getCameraOrientation() Py::Object View3DInventorPy::viewPosition(const Py::Tuple& args) { - PyObject* p = nullptr; - if (!PyArg_ParseTuple(args.ptr(), "|O!", &Base::PlacementPy::Type, &p)) + PyObject* p=nullptr; + int steps = 20; + int ms = 30; + if (!PyArg_ParseTuple(args.ptr(), "|O!ii",&Base::PlacementPy::Type,&p,&steps,&ms)) throw Py::Exception(); if (p) { @@ -789,7 +791,7 @@ Py::Object View3DInventorPy::viewPosition(const Py::Tuple& args) rot.getValue(q0,q1,q2,q3); getView3DIventorPtr()->getViewer()->moveCameraTo( SbRotation((float)q0, (float)q1, (float)q2, (float)q3), - SbVec3f((float)pos.x, (float)pos.y, (float)pos.z)); + SbVec3f((float)pos.x, (float)pos.y, (float)pos.z), steps, ms); } SoCamera* cam = getView3DIventorPtr()->getViewer()->getSoRenderManager()->getCamera(); @@ -808,11 +810,11 @@ Py::Object View3DInventorPy::viewPosition(const Py::Tuple& args) Py::Object View3DInventorPy::startAnimating(const Py::Tuple& args) { - float x, y, z; + float x,y,z; float velocity; - if (!PyArg_ParseTuple(args.ptr(), "ffff", &x, &y, &z, &velocity)) + if (!PyArg_ParseTuple(args.ptr(), "ffff", &x,&y,&z,&velocity)) throw Py::Exception(); - getView3DIventorPtr()->getViewer()->startSpinningAnimation(SbVec3f(x, y, z), velocity); + getView3DIventorPtr()->getViewer()->startAnimating(SbVec3f(x,y,z),velocity); return Py::None(); } diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index 449302fffb..f16e5e5acb 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -74,7 +74,7 @@ void View3DSettings::applySettings() OnChange(*hGrp,"CornerCoordSystem"); OnChange(*hGrp,"CornerCoordSystemSize"); OnChange(*hGrp,"ShowAxisCross"); - OnChange(*hGrp,"UseNavigationAnimations"); + OnChange(*hGrp,"UseAutoRotation"); OnChange(*hGrp,"Gradient"); OnChange(*hGrp,"RadialGradient"); OnChange(*hGrp,"BackgroundColor"); @@ -287,9 +287,9 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M _viewer->setAxisCross(rGrp.GetBool("ShowAxisCross", false)); } } - else if (strcmp(Reason,"UseNavigationAnimations") == 0) { + else if (strcmp(Reason,"UseAutoRotation") == 0) { for (auto _viewer : _viewers) { - _viewer->setAnimationEnabled(rGrp.GetBool("UseNavigationAnimations", true)); + _viewer->setAnimationEnabled(rGrp.GetBool("UseAutoRotation", false)); } } else if (strcmp(Reason,"Gradient") == 0 || strcmp(Reason,"RadialGradient") == 0) { diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index 8e6177dfc1..c2c340eaef 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -281,6 +281,7 @@ def getSVG(source, linewidth=1, lineColor=(0.0, 0.0, 0.0), fontsize=1, + linespacing=None, showFill=False, fillColor=(1.0, 1.0, 1.0), techdraw=False, @@ -504,6 +505,7 @@ def getSVG(source, scale=scale, linewidth=svgSymbolLineWidth, fontsize=fontsize, + linespacing=linespacing, direction=direction, color=lineColor, techdraw=techdraw, @@ -526,6 +528,7 @@ def getSVG(source, scale=scale, linewidth=svgSymbolLineWidth, fontsize=fontsize, + linespacing=linespacing, direction=direction, color=lineColor, techdraw=techdraw, @@ -558,6 +561,7 @@ def getSVG(source, scale=scale, linewidth=svgSymbolLineWidth, fontsize=fontsize, + linespacing=linespacing, fillstyle="none", direction=direction, color=lineColor, diff --git a/src/Mod/Draft/draftobjects/shapestring.py b/src/Mod/Draft/draftobjects/shapestring.py index 41ada164f7..b5c7300ec3 100644 --- a/src/Mod/Draft/draftobjects/shapestring.py +++ b/src/Mod/Draft/draftobjects/shapestring.py @@ -164,11 +164,6 @@ class ShapeString(DraftObject): if obj.ScaleToSize: ss_shape.scale(obj.Size / cap_height) cap_height = obj.Size - just_vec = self.justification_vector(ss_shape, - cap_height, - obj.Justification, - obj.JustificationReference, - obj.KeepLeftMargin) if obj.ObliqueAngle: if -80 <= obj.ObliqueAngle <= 80: mtx = App.Matrix() @@ -177,6 +172,11 @@ class ShapeString(DraftObject): else: wrn = translate("draft", "ShapeString: oblique angle must be in the -80 to +80 degree range") + "\n" App.Console.PrintWarning(wrn) + just_vec = self.justification_vector(ss_shape, + cap_height, + obj.Justification, + obj.JustificationReference, + obj.KeepLeftMargin) shapes = ss_shape.SubShapes for shape in shapes: shape.translate(just_vec) @@ -194,7 +194,7 @@ class ShapeString(DraftObject): self.props_changed_store(prop) def justification_vector(self, ss_shape, cap_height, just, just_ref, keep_left_margin): # ss_shape is a compound - box = ss_shape.BoundBox + box = ss_shape.optimalBoundingBox() if keep_left_margin is True and "Left" in just: vec = App.Vector(0, 0, 0) else: diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index 6d98e7e9e3..344ace35e0 100644 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -324,7 +324,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const root->insertItem(item, solve); solve->setCommand("&Solve"); *solve << "FEM_SolverCalculixCxxtools" - << "FEM_SolverCalculiX" << "FEM_SolverElmer" << "FEM_SolverMystran" << "FEM_SolverZ88" diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index 9733d6122a..9f366f6bb7 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -27,12 +27,6 @@ #include #endif -#include "Core/Approximation.h" -#include "Core/Evaluation.h" -#include "Core/Iterator.h" -#include "Core/MeshIO.h" -#include "Core/MeshKernel.h" -#include "WildMagic4/Wm4ContBox3.h" #include #include #include @@ -41,6 +35,12 @@ #include #include #include +#include "Core/Approximation.h" +#include "Core/Evaluation.h" +#include "Core/Iterator.h" +#include "Core/MeshIO.h" +#include "Core/MeshKernel.h" +#include "WildMagic4/Wm4ContBox3.h" #include "Exporter.h" #include "Importer.h" @@ -139,7 +139,7 @@ private: } Py::Object read(const Py::Tuple& args) { - char* Name; + char* Name {}; if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name)) { throw Py::Exception(); } @@ -152,7 +152,7 @@ private: } Py::Object open(const Py::Tuple& args) { - char* Name; + char* Name {}; if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name)) { throw Py::Exception(); } @@ -170,7 +170,7 @@ private: } Py::Object importer(const Py::Tuple& args) { - char* Name; + char* Name {}; char* DocName = nullptr; if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName)) { throw Py::Exception(); @@ -199,8 +199,8 @@ private: Py::Object exporter(const Py::Tuple& args, const Py::Dict& keywds) { - PyObject* objects; - char* fileNamePy; + PyObject* objects {}; + char* fileNamePy {}; // If tolerance is specified via python interface, use that. // If not, use the preference, if that exists, else default to 0.1mm. @@ -292,7 +292,7 @@ private: Py::Object show(const Py::Tuple& args) { - PyObject* pcObj; + PyObject* pcObj {}; char* name = "Mesh"; if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(MeshPy::Type), &pcObj, &name)) { throw Py::Exception(); @@ -334,7 +334,7 @@ private: } PyErr_Clear(); - PyObject* box; + PyObject* box {}; if (PyArg_ParseTuple(args.ptr(), "O!", &Base::BoundBoxPy::Type, &box)) { Py::BoundingBox bbox(box, false); mesh = MeshObject::createCube(bbox.getValue()); @@ -468,7 +468,7 @@ private: } Py::Object calculateEigenTransform(const Py::Tuple& args) { - PyObject* input; + PyObject* input {}; if (!PyArg_ParseTuple(args.ptr(), "O", &input)) { throw Py::Exception(); @@ -513,7 +513,7 @@ private: } Py::Object polynomialFit(const Py::Tuple& args) { - PyObject* input; + PyObject* input {}; if (!PyArg_ParseTuple(args.ptr(), "O", &input)) { throw Py::Exception(); @@ -543,7 +543,7 @@ private: dict.setItem(Py::String("Sigma"), Py::Float(fit)); // coefficients - double a, b, c, d, e, f; + double a {}, b {}, c {}, d {}, e {}, f {}; polyFit.GetCoefficients(a, b, c, d, e, f); Py::Tuple p(6); p.setItem(0, Py::Float(a)); @@ -564,11 +564,11 @@ private: } dict.setItem(Py::String("Residuals"), r); - return dict; + return dict; // NOLINT } Py::Object minimumVolumeOrientedBox(const Py::Tuple& args) { - PyObject* input; + PyObject* input {}; if (!PyArg_ParseTuple(args.ptr(), "O", &input)) { throw Py::Exception(); @@ -626,7 +626,7 @@ private: result.setItem(5, Py::Float(mobox.Extent[1])); result.setItem(6, Py::Float(mobox.Extent[2])); - return result; + return result; // NOLINT } }; diff --git a/src/Mod/Mesh/App/Core/Algorithm.cpp b/src/Mod/Mesh/App/Core/Algorithm.cpp index 36f2cccb64..52dbb2d5d4 100644 --- a/src/Mod/Mesh/App/Core/Algorithm.cpp +++ b/src/Mod/Mesh/App/Core/Algorithm.cpp @@ -51,7 +51,7 @@ bool MeshAlgorithm::IsVertexVisible(const Base::Vector3f& rcVertex, Base::Vector3f cDirection = rcVertex - rcView; float fDistance = cDirection.Length(); Base::Vector3f cIntsct; - FacetIndex uInd; + FacetIndex uInd {}; // search for the nearest facet to rcView in direction to rcVertex if (NearestFacetOnRay(rcView, cDirection, /*1.2f*fDistance,*/ rclGrid, cIntsct, uInd)) { @@ -265,8 +265,8 @@ bool MeshAlgorithm::FirstFacetToVertex(const Base::Vector3f& rPt, else { // if not then check the distance to the border of the triangle Base::Vector3f res; - float fDist; - unsigned short uSide; + float fDist {}; + unsigned short uSide {}; cFacet.ProjectPointToPlane(rPt, res); cFacet.NearestEdgeToPoint(res, fDist, uSide); if (fDist < fEps) { @@ -405,7 +405,7 @@ void MeshAlgorithm::GetFacetBorders(const std::vector& raulInd, } // search for edges in the unsorted list - PointIndex ulFirst, ulLast; + PointIndex ulFirst {}, ulLast {}; std::list clBorder; ulFirst = aclEdges.begin()->first; ulLast = aclEdges.begin()->second; @@ -1187,7 +1187,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, MeshFacetIterator clIter(_rclMesh, 0); Base::Vector3f clPt2d; Base::Vector3f clGravityOfFacet; - bool bNoPointInside; + bool bNoPointInside {}; // Cache current view projection matrix since calls to Coin's projection are expensive Base::ViewProjMatrix fixedProj(pclProj->getComposedProjectionMatrix()); // Precompute the polygon's bounding box @@ -1614,7 +1614,7 @@ bool MeshAlgorithm::ConnectLines(std::list>& openEdges, std::list& boundary) const; -protected: +private: const MeshKernel& _rclMesh; /**< The mesh kernel. */ }; @@ -424,6 +424,10 @@ class MeshExport MeshCollector public: MeshCollector() = default; virtual ~MeshCollector() = default; + MeshCollector(const MeshCollector&) = default; + MeshCollector(MeshCollector&&) = default; + MeshCollector& operator=(const MeshCollector&) = default; + MeshCollector& operator=(MeshCollector&&) = default; virtual void Append(const MeshCore::MeshKernel&, FacetIndex index) = 0; }; @@ -435,7 +439,7 @@ public: {} void Append(const MeshCore::MeshKernel& kernel, FacetIndex index) override { - PointIndex ulP1, ulP2, ulP3; + PointIndex ulP1 {}, ulP2 {}, ulP3 {}; kernel.GetFacetPoints(index, ulP1, ulP2, ulP3); indices.push_back(ulP1); indices.push_back(ulP2); @@ -499,7 +503,7 @@ protected: std::set& visit, MeshCollector& collect) const; -protected: +private: const MeshKernel& _rclMesh; /**< The mesh kernel. */ std::vector> _map; }; @@ -528,7 +532,7 @@ public: /// Returns an array of common facets of the passed facet indexes. std::vector GetIndices(FacetIndex, FacetIndex) const; -protected: +private: const MeshKernel& _rclMesh; /**< The mesh kernel. */ std::vector> _map; }; @@ -557,7 +561,7 @@ public: void AddNeighbour(PointIndex, PointIndex); void RemoveNeighbour(PointIndex, PointIndex); -protected: +private: const MeshKernel& _rclMesh; /**< The mesh kernel. */ std::vector> _map; }; @@ -582,7 +586,7 @@ public: void Rebuild(); const std::pair& operator[](const MeshEdge&) const; -protected: +private: class EdgeOrder { public: @@ -630,7 +634,7 @@ public: return _norm; } -protected: +private: const MeshKernel& _rclMesh; /**< The mesh kernel. */ std::vector _norm; }; diff --git a/src/Mod/Mesh/App/Core/Approximation.cpp b/src/Mod/Mesh/App/Core/Approximation.cpp index ad204d493a..b986c2eeb5 100644 --- a/src/Mod/Mesh/App/Core/Approximation.cpp +++ b/src/Mod/Mesh/App/Core/Approximation.cpp @@ -146,8 +146,15 @@ float PlaneFit::Fit() return FLOAT_MAX; } - double sxx, sxy, sxz, syy, syz, szz, mx, my, mz; - sxx = sxy = sxz = syy = syz = szz = mx = my = mz = 0.0; + double sxx {0.0}; + double sxy {0.0}; + double sxz {0.0}; + double syy {0.0}; + double syz {0.0}; + double szz {0.0}; + double mx {0.0}; + double my {0.0}; + double mz {0.0}; for (const auto& vPoint : _vPoints) { sxx += double(vPoint.x * vPoint.x); @@ -356,9 +363,9 @@ float PlaneFit::GetSignedStdDeviation() const return FLOAT_MAX; } - float fSumXi = 0.0f, fSumXi2 = 0.0f, fMean = 0.0f, fDist = 0.0f; + float fSumXi = 0.0F, fSumXi2 = 0.0F, fMean = 0.0F, fDist = 0.0F; float fMinDist = FLOAT_MAX; - float fFactor; + float fFactor = 0.0F; float ulPtCt = float(CountPoints()); Base::Vector3f clGravity, clPt; @@ -1036,8 +1043,7 @@ struct LMCylinderFunctor // 'fjac' has dimensions m x n // It will contain the jacobian of the errors, calculated numerically in this case. - double epsilon; - epsilon = 1e-5; + const double epsilon = 1e-5; for (int i = 0; i < x.size(); i++) { Eigen::VectorXd xPlus(x); @@ -1122,8 +1128,12 @@ Base::Vector3f CylinderFit::GetInitialAxisFromNormals(const std::vector>& rcPts) const; + Approximation(const Approximation&) = default; + Approximation(Approximation&&) = default; + Approximation& operator=(const Approximation&) = default; + Approximation& operator=(Approximation&&) = default; + protected: // NOLINTBEGIN std::list _vPoints; /**< Holds the points for the fit algorithm. */ @@ -387,7 +392,7 @@ public: std::vector toBezier(double umin = 0.0, double umax = 1.0, double vmin = 0.0, double vmax = 1.0) const; -protected: +private: double PolynomFit(); double _fCoeff[10]; /**< Ziel der Koeffizienten aus dem Fit */ }; @@ -437,7 +442,7 @@ public: */ void GetBounding(Base::Vector3f& bottom, Base::Vector3f& top) const; -protected: +private: Base::Vector3f _vBase; /**< Base vector of the cylinder. */ Base::Vector3f _vAxis; /**< Axis of the cylinder. */ float _fRadius {0}; /**< Radius of the cylinder. */ @@ -474,7 +479,7 @@ public: */ void ProjectToSphere(); -protected: +private: Base::Vector3f _vCenter; /**< Center of the sphere. */ float _fRadius {0}; /**< Radius of the cylinder. */ }; @@ -498,11 +503,19 @@ public: * @param pKoef Pointer to the quadric coefficients * (double [10]) */ + // NOLINTBEGIN explicit FunctionContainer(const double* pKoef) { Assign(pKoef); pImplSurf = new Wm4::QuadricSurface(dKoeff); } + // NOLINTEND + + FunctionContainer(const FunctionContainer&) = delete; + FunctionContainer(FunctionContainer&&) = delete; + FunctionContainer& operator=(const FunctionContainer&) = delete; + FunctionContainer& operator=(FunctionContainer&&) = delete; + /** * Apply quadric coefficients * @param pKoef Pointer to the quadric coefficients @@ -676,7 +689,7 @@ public: return (2.0 * dKoeff[6]); } -protected: +private: double dKoeff[10]; /**< Coefficients of quadric */ Wm4::ImplicitSurface* pImplSurf; /**< Access to the WildMagic library */ @@ -695,7 +708,7 @@ public: float Fit() override; float Value(float x, float y) const; -protected: +private: float _fCoeff[9]; }; diff --git a/src/Mod/Mesh/App/Core/Builder.h b/src/Mod/Mesh/App/Core/Builder.h index 02da3e5663..e9ab351bb8 100644 --- a/src/Mod/Mesh/App/Core/Builder.h +++ b/src/Mod/Mesh/App/Core/Builder.h @@ -70,8 +70,8 @@ private: FacetIndex facetIdx; Edge(PointIndex p1, PointIndex p2, FacetIndex idx) + : facetIdx {idx} { - facetIdx = idx; if (p1 > p2) { pt1 = p2; pt2 = p1; @@ -117,6 +117,11 @@ public: explicit MeshBuilder(MeshKernel& rclM); ~MeshBuilder(); + MeshBuilder(const MeshBuilder&) = delete; + MeshBuilder(MeshBuilder&&) = delete; + MeshBuilder& operator=(const MeshBuilder&) = delete; + MeshBuilder& operator=(MeshBuilder&&) = delete; + /** * Set the tolerance for the comparison of points. Normally you don't need to set the tolerance. */ @@ -198,6 +203,11 @@ public: explicit MeshFastBuilder(MeshKernel& rclM); ~MeshFastBuilder(); + MeshFastBuilder(const MeshFastBuilder&) = delete; + MeshFastBuilder(MeshFastBuilder&&) = delete; + MeshFastBuilder& operator=(const MeshFastBuilder&) = delete; + MeshFastBuilder& operator=(MeshFastBuilder&&) = delete; + /** Initializes the class. Must be done before adding facets * @param ctFacets count of facets. */ diff --git a/src/Mod/Mesh/App/Core/Curvature.cpp b/src/Mod/Mesh/App/Core/Curvature.cpp index d60463f040..8c36fed6ce 100644 --- a/src/Mod/Mesh/App/Core/Curvature.cpp +++ b/src/Mod/Mesh/App/Core/Curvature.cpp @@ -59,11 +59,11 @@ MeshCurvature::MeshCurvature(const MeshKernel& kernel) std::generate(mySegment.begin(), mySegment.end(), Base::iotaGen(0)); } -MeshCurvature::MeshCurvature(const MeshKernel& kernel, const std::vector& segm) +MeshCurvature::MeshCurvature(const MeshKernel& kernel, std::vector segm) : myKernel(kernel) , myMinPoints(20) , myRadius(0.5f) - , mySegment(segm) + , mySegment(std::move(segm)) {} void MeshCurvature::ComputePerFace(bool parallel) @@ -357,7 +357,7 @@ public: {} void Append(const MeshCore::MeshKernel& kernel, FacetIndex index) override { - PointIndex ulP1, ulP2, ulP3; + PointIndex ulP1 {}, ulP2 {}, ulP3 {}; kernel.GetFacetPoints(index, ulP1, ulP2, ulP3); indices.insert(ulP1); indices.insert(ulP2); @@ -411,13 +411,13 @@ CurvatureInfo FacetCurvature::Compute(FacetIndex index) const fitPoints.push_back(verts[it] - face_gravity); } - float fMin, fMax; + float fMin {}, fMax {}; if (fitPoints.size() >= myMinPoints) { SurfaceFit surf_fit; surf_fit.AddPoints(fitPoints); surf_fit.Fit(); rkNormal = surf_fit.GetNormal(); - double dMin, dMax, dDistance; + double dMin {}, dMax {}, dDistance {}; if (surf_fit.GetCurvatureInfo(0.0, 0.0, 0.0, dMin, dMax, rkDir1, rkDir0, dDistance)) { fMin = (float)dMin; fMax = (float)dMax; diff --git a/src/Mod/Mesh/App/Core/Curvature.h b/src/Mod/Mesh/App/Core/Curvature.h index 9f724d1491..1e96135103 100644 --- a/src/Mod/Mesh/App/Core/Curvature.h +++ b/src/Mod/Mesh/App/Core/Curvature.h @@ -60,7 +60,7 @@ class MeshExport MeshCurvature { public: explicit MeshCurvature(const MeshKernel& kernel); - MeshCurvature(const MeshKernel& kernel, const std::vector& segm); + MeshCurvature(const MeshKernel& kernel, std::vector segm); float GetRadius() const { return myRadius; diff --git a/src/Mod/Mesh/App/Core/CylinderFit.cpp b/src/Mod/Mesh/App/Core/CylinderFit.cpp index 194ef85306..7a20d73bbb 100644 --- a/src/Mod/Mesh/App/Core/CylinderFit.cpp +++ b/src/Mod/Mesh/App/Core/CylinderFit.cpp @@ -291,7 +291,7 @@ float CylinderFit::Fit() // solL: Yc, Zc, M, N, R // solM: Xc, Zc, L, N, R // solN: Xc, Yc, L, M, R - SolutionD solDir; + SolutionD solDir {}; findBestSolDirection(solDir); // Initialise some matrices and vectors @@ -300,7 +300,7 @@ float CylinderFit::Fit() Eigen::VectorXd atpl(5); // Iteration loop... - double sigma0; + double sigma0 {}; bool cont = true; while (cont && (_numIter < _maxIter)) { ++_numIter; @@ -327,7 +327,7 @@ float CylinderFit::Fit() // Before updating the unknowns, compute the residuals and sigma0 and check the residual // convergence - bool vConverged; + bool vConverged {}; if (!computeResiduals(solDir, x, residuals, sigma0, _vConvLimit, vConverged)) { return FLOAT_MAX; } @@ -465,8 +465,8 @@ void CylinderFit::setupNormalEquationMatrices(SolutionD solDir, // For each point, setup the observation equation coefficients and add their // contribution into the normal equation matrices - double a[5], b[3]; - double f0, qw; + double a[5] {}, b[3] {}; + double f0 {}, qw {}; std::vector::const_iterator vIt = residuals.begin(); std::list::const_iterator cIt; for (cIt = _vPoints.begin(); cIt != _vPoints.end(); ++cIt, ++vIt) { @@ -523,11 +523,12 @@ void CylinderFit::setupObservation(SolutionD solDir, b[2] = 2.0 * (dz - _vAxis.x * _vAxis.z * dx - _vAxis.y * _vAxis.z * dy - _vAxis.z * _vAxis.z * dz); + double ddxdl {}, ddydl {}, ddzdl {}; + double ddxdm {}, ddydm {}, ddzdm {}; + double ddxdn {}, ddydn {}, ddzdn {}; + // partials of the parameters switch (solDir) { - double ddxdl, ddydl, ddzdl; - double ddxdm, ddydm, ddzdm; - double ddxdn, ddydn, ddzdn; case solL: // order of parameters: Yc, Zc, M, N, R ddxdm = -2.0 * _vAxis.y * dx00 + (_vAxis.x - _vAxis.y * _vAxis.y / _vAxis.x) * dy00 @@ -645,8 +646,8 @@ bool CylinderFit::computeResiduals(SolutionD solDir, vConverged = true; int nPtsUsed = 0; sigma0 = 0.0; - double a[5], b[3]; - double f0, qw; + double a[5] {}, b[3] {}; + double f0 {}, qw {}; // double maxdVx = 0.0; // double maxdVy = 0.0; // double maxdVz = 0.0; @@ -747,7 +748,7 @@ bool CylinderFit::updateParameters(SolutionD solDir, const Eigen::VectorXd& x) } // Update the dependent axis direction parameter - double l2, m2, n2; + double l2 {}, m2 {}, n2 {}; switch (solDir) { case solL: l2 = 1.0 - _vAxis.y * _vAxis.y - _vAxis.z * _vAxis.z; diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index 9f00419996..b01895a624 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -283,7 +283,7 @@ struct MeshFacet_Less { bool operator()(const FaceIterator& x, const FaceIterator& y) const { - PointIndex tmp; + PointIndex tmp {}; PointIndex x0 = x->_aulPoints[0]; PointIndex x1 = x->_aulPoints[1]; PointIndex x2 = x->_aulPoints[2]; diff --git a/src/Mod/Mesh/App/Core/Degeneration.h b/src/Mod/Mesh/App/Core/Degeneration.h index 0baf629930..6477002c98 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.h +++ b/src/Mod/Mesh/App/Core/Degeneration.h @@ -584,7 +584,7 @@ public: {} bool Evaluate() override; -protected: +private: std::vector& _facets; }; diff --git a/src/Mod/Mesh/App/Core/Elements.cpp b/src/Mod/Mesh/App/Core/Elements.cpp index 4f04abe768..068801c94f 100644 --- a/src/Mod/Mesh/App/Core/Elements.cpp +++ b/src/Mod/Mesh/App/Core/Elements.cpp @@ -55,7 +55,7 @@ PointIndex MeshPointArray::Get(const MeshPoint& rclPoint) PointIndex MeshPointArray::GetOrAddIndex(const MeshPoint& rclPoint) { - PointIndex ulIndex; + PointIndex ulIndex {}; if ((ulIndex = Get(rclPoint)) == POINT_INDEX_MAX) { push_back(rclPoint); @@ -111,7 +111,7 @@ MeshFacetArray::MeshFacetArray(MeshFacetArray&& ary) = default; void MeshFacetArray::Erase(_TIterator pIter) { - FacetIndex i, *pulN; + FacetIndex i {}, *pulN {}; _TIterator pPass, pEnd; FacetIndex ulInd = pIter - begin(); erase(pIter); @@ -494,7 +494,7 @@ bool MeshGeomFacet::IsPointOf(const Base::Vector3f& rclPoint, float fDistance) c // force internal normal to be computed if not done yet Base::Vector3f clNorm(GetNormal()), clProjPt(rclPoint), clEdge; Base::Vector3f clP0(_aclPoints[0]), clP1(_aclPoints[1]), clP2(_aclPoints[2]); - float fLP, fLE; + float fLP {}, fLE {}; clNorm.Normalize(); clProjPt.ProjectToPlane(_aclPoints[0], clNorm); @@ -616,8 +616,8 @@ void MeshGeomFacet::ProjectFacetToPlane(MeshGeomFacet& rclFacet) const void MeshGeomFacet::Enlarge(float fDist) { Base::Vector3f clM, clU, clV, clPNew[3]; - float fA, fD; - PointIndex i, ulP1, ulP2, ulP3; + float fA {}, fD {}; + PointIndex i {}, ulP1 {}, ulP2 {}, ulP3 {}; for (i = 0; i < 3; i++) { ulP1 = i; @@ -683,7 +683,7 @@ bool MeshGeomFacet::IsDegenerated(float epsilon) const bool MeshGeomFacet::IsDeformed(float fCosOfMinAngle, float fCosOfMaxAngle) const { - float fCosAngle; + float fCosAngle {}; Base::Vector3f u, v; for (int i = 0; i < 3; i++) { @@ -1047,8 +1047,10 @@ void MeshGeomFacet::SubSample(float fStep, std::vector& rclPoint float fDetABC = bx * cy; - for (float px = (fStep / 2.0f); px < fLenAB; px += fStep) { - for (float py = (fStep / 2.0f); py < cy; py += fStep) { + for (float px = (fStep / 2.0f); px < fLenAB; px += fStep) // NOLINT + { + for (float py = (fStep / 2.0f); py < cy; py += fStep) // NOLINT + { float u = (bx * cy + cx * py - px * cy - bx * py) / fDetABC; float v = (px * cy - cx * py) / fDetABC; float w = (bx * py) / fDetABC; @@ -1146,9 +1148,9 @@ int MeshGeomFacet::IntersectWithFacet(const MeshGeomFacet& rclFacet, return 0; } - float V[3][3], U[3][3]; + float V[3][3] {}, U[3][3] {}; int coplanar = 0; - float isectpt1[3], isectpt2[3]; + float isectpt1[3] {}, isectpt2[3] {}; for (int i = 0; i < 3; i++) { V[i][0] = _aclPoints[i].x; @@ -1313,7 +1315,7 @@ float MeshGeomFacet::CenterOfCircumCircle(Base::Vector3f& rclCenter) const unsigned short MeshGeomFacet::NearestEdgeToPoint(const Base::Vector3f& rclPt) const { - unsigned short usSide; + unsigned short usSide {}; const Base::Vector3f& rcP1 = _aclPoints[0]; const Base::Vector3f& rcP2 = _aclPoints[1]; @@ -1543,7 +1545,7 @@ float MeshGeomFacet::MinimumAngle() const bool MeshGeomFacet::IsPointOfSphere(const Base::Vector3f& rP) const { - float radius; + float radius {}; Base::Vector3f center; radius = CenterOfCircumCircle(center); radius *= radius; @@ -1554,7 +1556,7 @@ bool MeshGeomFacet::IsPointOfSphere(const Base::Vector3f& rP) const bool MeshGeomFacet::IsPointOfSphere(const MeshGeomFacet& rFacet) const { - float radius; + float radius {}; Base::Vector3f center; radius = CenterOfCircumCircle(center); radius *= radius; @@ -1575,7 +1577,7 @@ float MeshGeomFacet::AspectRatio() const Base::Vector3f d1 = _aclPoints[1] - _aclPoints[2]; Base::Vector3f d2 = _aclPoints[2] - _aclPoints[0]; - float l2, maxl2 = d0.Sqr(); + float l2 {}, maxl2 = d0.Sqr(); if ((l2 = d1.Sqr()) > maxl2) { maxl2 = l2; } diff --git a/src/Mod/Mesh/App/Core/Elements.h b/src/Mod/Mesh/App/Core/Elements.h index dfd349a81b..32994a3a5c 100644 --- a/src/Mod/Mesh/App/Core/Elements.h +++ b/src/Mod/Mesh/App/Core/Elements.h @@ -665,14 +665,16 @@ public: */ bool IsCoplanar(const MeshGeomFacet& facet) const; -protected: +private: mutable Base::Vector3f _clNormal; /**< Normal of the facet. */ mutable bool _bNormalCalculated; /**< True if the normal is already calculated. */ public: + // NOLINTBEGIN Base::Vector3f _aclPoints[3]; /**< Geometric corner points. */ unsigned char _ucFlag; /**< Flag property */ unsigned long _ulProp; /**< Free usable property. */ + // NOLINTEND }; using TMeshPointArray = std::vector; @@ -993,7 +995,7 @@ inline bool MeshGeomFacet::IntersectWithPlane(const Base::Vector3f& rclBase, && (bD0 == (_aclPoints[2].DistanceToPlane(rclBase, rclNormal) > 0.0f))); } -inline MeshFacet::MeshFacet() +inline MeshFacet::MeshFacet() // NOLINT : _ucFlag(0) , _ulProp(0) { @@ -1009,15 +1011,9 @@ inline MeshFacet::MeshFacet(PointIndex p1, FacetIndex n3) : _ucFlag(0) , _ulProp(0) -{ - _aulPoints[0] = p1; - _aulPoints[1] = p2; - _aulPoints[2] = p3; - - _aulNeighbours[0] = n1; - _aulNeighbours[1] = n2; - _aulNeighbours[2] = n3; -} + , _aulPoints {p1, p2, p3} + , _aulNeighbours {n1, n2, n3} +{} void MeshFacet::SetVertices(PointIndex p1, PointIndex p2, PointIndex p3) { @@ -1191,7 +1187,7 @@ inline unsigned short MeshFacet::Side(PointIndex ulP0, PointIndex ulP1) const inline unsigned short MeshFacet::Side(const MeshFacet& rFace) const { - unsigned short side; + unsigned short side {}; for (int i = 0; i < 3; i++) { side = Side(rFace._aulPoints[i], rFace._aulPoints[(i + 1) % 3]); if (side != USHRT_MAX) { diff --git a/src/Mod/Mesh/App/Core/Evaluation.cpp b/src/Mod/Mesh/App/Core/Evaluation.cpp index 707c712ceb..5397320bef 100644 --- a/src/Mod/Mesh/App/Core/Evaluation.cpp +++ b/src/Mod/Mesh/App/Core/Evaluation.cpp @@ -184,7 +184,7 @@ unsigned long MeshEvalOrientation::HasFalsePositives(const std::vector MeshEvalOrientation::GetIndices() const { - FacetIndex ulStartFacet, ulVisited; + FacetIndex ulStartFacet {}, ulVisited {}; if (_rclMesh.CountFacets() == 0) { return {}; @@ -346,7 +346,7 @@ bool MeshEvalTopology::Evaluate() Base::SequencerLauncher seq("Checking topology...", rclFAry.size()); for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { - Edge_Index item; + Edge_Index item {}; item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.f = pI - rclFAry.begin(); @@ -485,7 +485,7 @@ bool MeshEvalPointManifolds::Evaluate() const std::set& nf = vf_it[index]; const std::set& np = vv_it[index]; - std::set::size_type sp, sf; + std::set::size_type sp {}, sf {}; sp = np.size(); sf = nf.size(); // for an inner point the number of adjacent points is equal to the number of shared faces @@ -607,7 +607,7 @@ bool MeshEvalSelfIntersection::Evaluate() MeshFacetGrid cMeshFacetGrid(_rclMesh); const MeshFacetArray& rFaces = _rclMesh.GetFacets(); MeshGridIterator clGridIter(cMeshFacetGrid); - unsigned long ulGridX, ulGridY, ulGridZ; + unsigned long ulGridX {}, ulGridY {}, ulGridZ {}; cMeshFacetGrid.GetCtGrids(ulGridX, ulGridY, ulGridZ); MeshFacetIterator cMFI(_rclMesh); @@ -713,7 +713,7 @@ void MeshEvalSelfIntersection::GetIntersections( MeshFacetGrid cMeshFacetGrid(_rclMesh); const MeshFacetArray& rFaces = _rclMesh.GetFacets(); MeshGridIterator clGridIter(cMeshFacetGrid); - unsigned long ulGridX, ulGridY, ulGridZ; + unsigned long ulGridX {}, ulGridY {}, ulGridZ {}; cMeshFacetGrid.GetCtGrids(ulGridX, ulGridY, ulGridZ); MeshFacetIterator cMFI(_rclMesh); @@ -838,7 +838,7 @@ bool MeshEvalNeighbourhood::Evaluate() Base::SequencerLauncher seq("Checking indices...", rclFAry.size()); for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { - Edge_Index item; + Edge_Index item {}; item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.f = pI - rclFAry.begin(); @@ -905,7 +905,7 @@ std::vector MeshEvalNeighbourhood::GetIndices() const Base::SequencerLauncher seq("Checking indices...", rclFAry.size()); for (pI = rclFAry.begin(); pI != rclFAry.end(); ++pI) { for (int i = 0; i < 3; i++) { - Edge_Index item; + Edge_Index item {}; item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.f = pI - rclFAry.begin(); @@ -981,7 +981,7 @@ void MeshKernel::RebuildNeighbours(FacetIndex index) MeshFacetArray::_TConstIterator pB = this->_aclFacetArray.begin(); for (pI = pB + index; pI != this->_aclFacetArray.end(); ++pI) { for (int i = 0; i < 3; i++) { - Edge_Index item; + Edge_Index item {}; item.p0 = std::min(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.p1 = std::max(pI->_aulPoints[i], pI->_aulPoints[(i + 1) % 3]); item.f = pI - pB; @@ -1111,7 +1111,7 @@ bool MeshEigensystem::Evaluate() float xmin = 0.0f, xmax = 0.0f, ymin = 0.0f, ymax = 0.0f, zmin = 0.0f, zmax = 0.0f; Base::Vector3f clVect, clProj; - float fH; + float fH {}; const MeshPointArray& aclPoints = _rclMesh.GetPoints(); for (const auto& it : aclPoints) { @@ -1192,8 +1192,7 @@ void MeshEigensystem::CalculateLocalSystem() _cW = planeFit.GetNormal(); // set the sign for the vectors - float fSumU, fSumV, fSumW; - fSumU = fSumV = fSumW = 0.0f; + float fSumU {0.0F}, fSumV {0.0F}, fSumW {0.0F}; for (it = aclPoints.begin(); it != aclPoints.end(); ++it) { float fU = _cU * (*it - _cC); float fV = _cV * (*it - _cC); diff --git a/src/Mod/Mesh/App/Core/Evaluation.h b/src/Mod/Mesh/App/Core/Evaluation.h index 366e152e8f..a9456ed938 100644 --- a/src/Mod/Mesh/App/Core/Evaluation.h +++ b/src/Mod/Mesh/App/Core/Evaluation.h @@ -50,6 +50,11 @@ public: {} virtual ~MeshEvaluation() = default; + MeshEvaluation(const MeshEvaluation&) = delete; + MeshEvaluation(MeshEvaluation&&) = delete; + MeshEvaluation& operator=(const MeshEvaluation&) = delete; + MeshEvaluation& operator=(MeshEvaluation&&) = delete; + /** * Evaluates the mesh kernel with respect to certain criteria. Must be reimplemented by every * subclass. This pure virtual function returns false if the mesh kernel is invalid according @@ -58,6 +63,7 @@ public: virtual bool Evaluate() = 0; protected: + // NOLINTNEXTLINE const MeshKernel& _rclMesh; /**< Mesh kernel */ }; @@ -78,6 +84,11 @@ public: {} virtual ~MeshValidation() = default; + MeshValidation(const MeshValidation&) = delete; + MeshValidation(MeshValidation&&) = delete; + MeshValidation& operator=(const MeshValidation&) = delete; + MeshValidation& operator=(MeshValidation&&) = delete; + /** * This function attempts to change the mesh kernel to be valid according to the checked * criterion: True is returned if the errors could be fixed, false otherwise. @@ -85,6 +96,7 @@ public: virtual bool Fixup() = 0; protected: + // NOLINTNEXTLINE MeshKernel& _rclMesh; /**< Mesh kernel */ }; @@ -207,8 +219,10 @@ public: } protected: + // NOLINTBEGIN std::vector> nonManifoldList; std::list> nonManifoldFacets; + // NOLINTEND }; /** @@ -229,7 +243,7 @@ public: return deletedFaces; } -protected: +private: std::vector deletedFaces; const std::list>& nonManifoldList; }; @@ -264,7 +278,7 @@ public: return static_cast(nonManifoldPoints.size()); } -protected: +private: std::vector nonManifoldPoints; std::list> facetsOfNonManifoldPoints; }; @@ -300,7 +314,7 @@ public: {} bool Fixup() override; -protected: +private: const std::vector>& _raclManifoldList; }; diff --git a/src/Mod/Mesh/App/Core/Grid.cpp b/src/Mod/Mesh/App/Core/Grid.cpp index 0ad39efa4e..3f58ee2c84 100644 --- a/src/Mod/Mesh/App/Core/Grid.cpp +++ b/src/Mod/Mesh/App/Core/Grid.cpp @@ -101,8 +101,6 @@ void MeshGrid::InitGrid() { assert(_pclMesh); - unsigned long i, j; - // Calculate grid length if not initialised // if ((_ulCtGridsX == 0) || (_ulCtGridsY == 0) || (_ulCtGridsZ == 0)) { @@ -139,9 +137,9 @@ void MeshGrid::InitGrid() // Create data structure _aulGrid.clear(); _aulGrid.resize(_ulCtGridsX); - for (i = 0; i < _ulCtGridsX; i++) { + for (unsigned long i = 0; i < _ulCtGridsX; i++) { _aulGrid[i].resize(_ulCtGridsY); - for (j = 0; j < _ulCtGridsY; j++) { + for (unsigned long j = 0; j < _ulCtGridsY; j++) { _aulGrid[i][j].resize(_ulCtGridsZ); } } @@ -151,7 +149,7 @@ unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, std::vector& raulElements, bool bDelDoubles) const { - unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; + unsigned long ulMinX {}, ulMinY {}, ulMinZ {}, ulMaxX {}, ulMaxY {}, ulMaxZ {}; raulElements.clear(); @@ -159,9 +157,9 @@ unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, Position(Base::Vector3f(rclBB.MinX, rclBB.MinY, rclBB.MinZ), ulMinX, ulMinY, ulMinZ); Position(Base::Vector3f(rclBB.MaxX, rclBB.MaxY, rclBB.MaxZ), ulMaxX, ulMaxY, ulMaxZ); - for (i = ulMinX; i <= ulMaxX; i++) { - for (j = ulMinY; j <= ulMaxY; j++) { - for (k = ulMinZ; k <= ulMaxZ; k++) { + for (auto i = ulMinX; i <= ulMaxX; i++) { + for (auto j = ulMinY; j <= ulMaxY; j++) { + for (auto k = ulMinZ; k <= ulMaxZ; k++) { raulElements.insert(raulElements.end(), _aulGrid[i][j][k].begin(), _aulGrid[i][j][k].end()); @@ -185,7 +183,7 @@ unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, float fMaxDist, bool bDelDoubles) const { - unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; + unsigned long ulMinX {}, ulMinY {}, ulMinZ {}, ulMaxX {}, ulMaxY {}, ulMaxZ {}; float fGridDiag = GetBoundBox(0, 0, 0).CalcDiagonalLength(); float fMinDistP2 = (fGridDiag * fGridDiag) + (fMaxDist * fMaxDist); @@ -195,9 +193,9 @@ unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, Position(Base::Vector3f(rclBB.MinX, rclBB.MinY, rclBB.MinZ), ulMinX, ulMinY, ulMinZ); Position(Base::Vector3f(rclBB.MaxX, rclBB.MaxY, rclBB.MaxZ), ulMaxX, ulMaxY, ulMaxZ); - for (i = ulMinX; i <= ulMaxX; i++) { - for (j = ulMinY; j <= ulMaxY; j++) { - for (k = ulMinZ; k <= ulMaxZ; k++) { + for (auto i = ulMinX; i <= ulMaxX; i++) { + for (auto j = ulMinY; j <= ulMaxY; j++) { + for (auto k = ulMinZ; k <= ulMaxZ; k++) { if (Base::DistanceP2(GetBoundBox(i, j, k).GetCenter(), rclOrg) < fMinDistP2) { raulElements.insert(raulElements.end(), _aulGrid[i][j][k].begin(), @@ -220,7 +218,7 @@ unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, std::set& raulElements) const { - unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; + unsigned long ulMinX {}, ulMinY {}, ulMinZ {}, ulMaxX {}, ulMaxY {}, ulMaxZ {}; raulElements.clear(); @@ -228,9 +226,9 @@ unsigned long MeshGrid::Inside(const Base::BoundBox3f& rclBB, Position(Base::Vector3f(rclBB.MinX, rclBB.MinY, rclBB.MinZ), ulMinX, ulMinY, ulMinZ); Position(Base::Vector3f(rclBB.MaxX, rclBB.MaxY, rclBB.MaxZ), ulMaxX, ulMaxY, ulMaxZ); - for (i = ulMinX; i <= ulMaxX; i++) { - for (j = ulMinY; j <= ulMaxY; j++) { - for (k = ulMinZ; k <= ulMaxZ; k++) { + for (auto i = ulMinX; i <= ulMaxX; i++) { + for (auto j = ulMinY; j <= ulMaxY; j++) { + for (auto k = ulMinZ; k <= ulMaxZ; k++) { raulElements.insert(_aulGrid[i][j][k].begin(), _aulGrid[i][j][k].end()); } } @@ -302,7 +300,7 @@ void MeshGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMaxGr float fVolume = fLenX * fLenY * fLenZ; if (fVolume > 0.0f) { - float fVolElem; + float fVolElem {}; if (_ulCtElements > (ulMaxGrids * ulCtGrid)) { fVolElem = (fLenX * fLenY * fLenZ) / float(ulMaxGrids * ulCtGrid); } @@ -316,7 +314,7 @@ void MeshGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMaxGr else { // Planar bounding box float fArea = fLenX * fLenY + fLenX * fLenZ + fLenY * fLenZ; - float fAreaElem; + float fAreaElem {}; if (_ulCtElements > (ulMaxGrids * ulCtGrid)) { fAreaElem = fArea / float(ulMaxGrids * ulCtGrid); } @@ -499,7 +497,7 @@ void MeshGrid::SearchNearestFromPoint(const Base::Vector3f& rclPt, Base::BoundBox3f clBB = GetBoundBox(); if (clBB.IsInBox(rclPt)) { // Point lies within - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; Position(rclPt, ulX, ulY, ulZ); // int nX = ulX, nY = ulY, nZ = ulZ; unsigned long ulMaxLevel = @@ -605,11 +603,9 @@ void MeshGrid::GetHull(unsigned long ulX, int nY2 = std::min(int(_ulCtGridsY) - 1, int(ulY) + int(ulDistance)); int nZ2 = std::min(int(_ulCtGridsZ) - 1, int(ulZ) + int(ulDistance)); - int i, j; - // top plane - for (i = nX1; i <= nX2; i++) { - for (j = nY1; j <= nY2; j++) { + for (int i = nX1; i <= nX2; i++) { + for (int j = nY1; j <= nY2; j++) { GetElements(static_cast(i), static_cast(j), static_cast(nZ1), @@ -617,8 +613,8 @@ void MeshGrid::GetHull(unsigned long ulX, } } // bottom plane - for (i = nX1; i <= nX2; i++) { - for (j = nY1; j <= nY2; j++) { + for (int i = nX1; i <= nX2; i++) { + for (int j = nY1; j <= nY2; j++) { GetElements(static_cast(i), static_cast(j), static_cast(nZ2), @@ -626,8 +622,8 @@ void MeshGrid::GetHull(unsigned long ulX, } } // left plane - for (i = nY1; i <= nY2; i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = nY1; i <= nY2; i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(static_cast(nX1), static_cast(i), static_cast(j), @@ -635,8 +631,8 @@ void MeshGrid::GetHull(unsigned long ulX, } } // right plane - for (i = nY1; i <= nY2; i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = nY1; i <= nY2; i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(static_cast(nX2), static_cast(i), static_cast(j), @@ -644,8 +640,8 @@ void MeshGrid::GetHull(unsigned long ulX, } } // front plane - for (i = (nX1 + 1); i <= (nX2 - 1); i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = (nX1 + 1); i <= (nX2 - 1); i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(static_cast(i), static_cast(nY1), static_cast(j), @@ -653,8 +649,8 @@ void MeshGrid::GetHull(unsigned long ulX, } } // back plane - for (i = (nX1 + 1); i <= (nX2 - 1); i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = (nX1 + 1); i <= (nX2 - 1); i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { GetElements(static_cast(i), static_cast(nY2), static_cast(j), @@ -680,7 +676,7 @@ unsigned long MeshGrid::GetElements(unsigned long ulX, unsigned long MeshGrid::GetElements(const Base::Vector3f& rclPoint, std::vector& aulFacets) const { - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; if (!CheckPosition(rclPoint, ulX, ulY, ulZ)) { return 0; } @@ -724,7 +720,7 @@ bool MeshGrid::GetPositionToIndex(unsigned long id, MeshFacetGrid::MeshFacetGrid(const MeshKernel& rclM) : MeshGrid(rclM) { - RebuildGrid(); + MeshFacetGrid::RebuildGrid(); } MeshFacetGrid::MeshFacetGrid(const MeshKernel& rclM, int iCtGridPerAxis) @@ -820,7 +816,7 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint(const Base::Vector3f& rclPt) Base::BoundBox3f clBB = GetBoundBox(); if (clBB.IsInBox(rclPt)) { // Point lies within - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; Position(rclPt, ulX, ulY, ulZ); float fMinGridDist = std::min(std::min(_fGridLenX, _fGridLenY), _fGridLenZ); unsigned long ulDistance = 0; @@ -938,7 +934,7 @@ unsigned long MeshFacetGrid::SearchNearestFromPoint(const Base::Vector3f& rclPt, Inside(clBB, aulFacets, rclPt, fMaxSearchArea, true); for (ElementIndex facet : aulFacets) { - float fDist; + float fDist {}; if (clFTool.Distance(rclPt, facet, fMinDist, fDist)) { fMinDist = fDist; @@ -964,11 +960,9 @@ void MeshFacetGrid::SearchNearestFacetInHull(unsigned long ulX, int nY2 = std::min(int(_ulCtGridsY) - 1, int(ulY) + int(ulDistance)); int nZ2 = std::min(int(_ulCtGridsZ) - 1, int(ulZ) + int(ulDistance)); - int i, j; - // top plane - for (i = nX1; i <= nX2; i++) { - for (j = nY1; j <= nY2; j++) { + for (int i = nX1; i <= nX2; i++) { + for (int j = nY1; j <= nY2; j++) { SearchNearestFacetInGrid(static_cast(i), static_cast(j), static_cast(nZ1), @@ -978,8 +972,8 @@ void MeshFacetGrid::SearchNearestFacetInHull(unsigned long ulX, } } // bottom plane - for (i = nX1; i <= nX2; i++) { - for (j = nY1; j <= nY2; j++) { + for (int i = nX1; i <= nX2; i++) { + for (int j = nY1; j <= nY2; j++) { SearchNearestFacetInGrid(static_cast(i), static_cast(j), static_cast(nZ2), @@ -989,8 +983,8 @@ void MeshFacetGrid::SearchNearestFacetInHull(unsigned long ulX, } } // left plane - for (i = nY1; i <= nY2; i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = nY1; i <= nY2; i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { SearchNearestFacetInGrid(static_cast(nX1), static_cast(i), static_cast(j), @@ -1000,8 +994,8 @@ void MeshFacetGrid::SearchNearestFacetInHull(unsigned long ulX, } } // right plane - for (i = nY1; i <= nY2; i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = nY1; i <= nY2; i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { SearchNearestFacetInGrid(static_cast(nX2), static_cast(i), static_cast(j), @@ -1011,8 +1005,8 @@ void MeshFacetGrid::SearchNearestFacetInHull(unsigned long ulX, } } // front plane - for (i = (nX1 + 1); i <= (nX2 - 1); i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = (nX1 + 1); i <= (nX2 - 1); i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { SearchNearestFacetInGrid(static_cast(i), static_cast(nY1), static_cast(j), @@ -1022,8 +1016,8 @@ void MeshFacetGrid::SearchNearestFacetInHull(unsigned long ulX, } } // back plane - for (i = (nX1 + 1); i <= (nX2 - 1); i++) { - for (j = (nZ1 + 1); j <= (nZ2 - 1); j++) { + for (int i = (nX1 + 1); i <= (nX2 - 1); i++) { + for (int j = (nZ1 + 1); j <= (nZ2 - 1); j++) { SearchNearestFacetInGrid(static_cast(i), static_cast(nY2), static_cast(j), @@ -1056,7 +1050,7 @@ void MeshFacetGrid::SearchNearestFacetInGrid(unsigned long ulX, MeshPointGrid::MeshPointGrid(const MeshKernel& rclM) : MeshGrid(rclM) { - RebuildGrid(); + MeshPointGrid::RebuildGrid(); } MeshPointGrid::MeshPointGrid() @@ -1090,7 +1084,7 @@ MeshPointGrid::MeshPointGrid(const MeshKernel& rclM, float fGridLen) void MeshPointGrid::AddPoint(const MeshPoint& rclPt, ElementIndex ulPtIndex, float fEpsilon) { (void)fEpsilon; - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; Pos(Base::Vector3f(rclPt.x, rclPt.y, rclPt.z), ulX, ulY, ulZ); if ((ulX < _ulCtGridsX) && (ulY < _ulCtGridsY) && (ulZ < _ulCtGridsZ)) { _aulGrid[ulX][ulY][ulZ].insert(ulPtIndex); @@ -1172,7 +1166,7 @@ void MeshPointGrid::Pos(const Base::Vector3f& rclPoint, unsigned long MeshPointGrid::FindElements(const Base::Vector3f& rclPoint, std::set& aulElements) const { - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; Pos(rclPoint, ulX, ulY, ulZ); // check if the given point is inside the grid structure diff --git a/src/Mod/Mesh/App/Core/Grid.h b/src/Mod/Mesh/App/Core/Grid.h index ab9ebd5be9..631b3f8c30 100644 --- a/src/Mod/Mesh/App/Core/Grid.h +++ b/src/Mod/Mesh/App/Core/Grid.h @@ -61,6 +61,10 @@ protected: explicit MeshGrid(const MeshKernel& rclM); /// Construction MeshGrid(); + MeshGrid(const MeshGrid&) = default; + MeshGrid(MeshGrid&&) = default; + MeshGrid& operator=(const MeshGrid&) = default; + MeshGrid& operator=(MeshGrid&&) = default; //@} public: @@ -195,6 +199,7 @@ protected: virtual unsigned long HasElements() const = 0; protected: + // NOLINTBEGIN std::vector>>> _aulGrid; /**< Grid data structure. */ const MeshKernel* _pclMesh; /**< The mesh kernel. */ @@ -208,6 +213,7 @@ protected: float _fMinX; /**< Grid null position in x. */ float _fMinY; /**< Grid null position in y. */ float _fMinZ; /**< Grid null position in z. */ + // NOLINTEND // friends friend class MeshGridIterator; @@ -234,8 +240,12 @@ public: MeshFacetGrid(const MeshKernel& rclM, int iCtGridPerAxis); /// Construction MeshFacetGrid(const MeshKernel& rclM, float fGridLen); + MeshFacetGrid(const MeshFacetGrid&) = default; + MeshFacetGrid(MeshFacetGrid&&) = default; /// Destruction ~MeshFacetGrid() override = default; + MeshFacetGrid& operator=(const MeshFacetGrid&) = default; + MeshFacetGrid& operator=(MeshFacetGrid&&) = default; //@} /** @name Search */ @@ -314,8 +324,12 @@ public: MeshPointGrid(const MeshKernel& rclM, float fGridLen); /// Construction MeshPointGrid(const MeshKernel& rclM, unsigned long ulX, unsigned long ulY, unsigned long ulZ); + MeshPointGrid(const MeshPointGrid&) = default; + MeshPointGrid(MeshPointGrid&&) = default; /// Destruction ~MeshPointGrid() override = default; + MeshPointGrid& operator=(const MeshPointGrid&) = default; + MeshPointGrid& operator=(MeshPointGrid&&) = default; //@} /** Finds all points that lie in the same grid as the point \a rclPoint. */ @@ -427,6 +441,12 @@ public: } protected: + const MeshGrid& GetGrid() const + { + return _rclGrid; + } + +private: const MeshGrid& _rclGrid; /**< The mesh kernel. */ unsigned long _ulX {0}; /**< Number of grids in x. */ unsigned long _ulY {0}; /**< Number of grids in y. */ @@ -439,11 +459,10 @@ protected: struct GridElement { GridElement(unsigned long x, unsigned long y, unsigned long z) - { - this->x = x; - this->y = y; - this->z = z; - } + : x(x) + , y(y) + , z(z) + {} bool operator<(const GridElement& pos) const { if (x == pos.x) { @@ -470,7 +489,7 @@ protected: inline Base::BoundBox3f MeshGrid::GetBoundBox(unsigned long ulX, unsigned long ulY, unsigned long ulZ) const { - float fX, fY, fZ; + float fX {}, fY {}, fZ {}; fX = _fMinX + (float(ulX) * _fGridLenX); fY = _fMinY + (float(ulY) * _fGridLenY); @@ -558,9 +577,9 @@ inline void MeshFacetGrid::AddFacet(const MeshGeomFacet& rclFacet, ElementIndex ulFacetIndex, float /*fEpsilon*/) { - unsigned long ulX, ulY, ulZ; + unsigned long ulX {}, ulY {}, ulZ {}; - unsigned long ulX1, ulY1, ulZ1, ulX2, ulY2, ulZ2; + unsigned long ulX1 {}, ulY1 {}, ulZ1 {}, ulX2 {}, ulY2 {}, ulZ2 {}; Base::BoundBox3f clBB; diff --git a/src/Mod/Mesh/App/Core/Helpers.h b/src/Mod/Mesh/App/Core/Helpers.h index 0e7ab2f5bc..ac5e94c48e 100644 --- a/src/Mod/Mesh/App/Core/Helpers.h +++ b/src/Mod/Mesh/App/Core/Helpers.h @@ -50,7 +50,7 @@ struct MeshExport MeshHelpPoint } MeshPoint _clPt; - FacetIndex _ulInd; + FacetIndex _ulInd {FACET_INDEX_MAX}; }; /** @@ -170,7 +170,7 @@ inline bool MeshHelpBuilderEdge::operator!=(const MeshHelpBuilderEdge& rclObj) c inline void MeshEdgeBuilder::Add(PointIndex ulInd1, PointIndex ulInd2, FacetIndex ulSide, FacetIndex ulFInd) { - MeshHelpBuilderEdge clObj; + MeshHelpBuilderEdge clObj {}; clObj.Set(ulInd1, ulInd2, ulSide, ulFInd); push_back(clObj); } diff --git a/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp b/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp index 706442f87c..1cc2d45ef9 100644 --- a/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp +++ b/src/Mod/Mesh/App/Core/IO/ReaderOBJ.cpp @@ -74,7 +74,7 @@ bool ReaderOBJ::Load(std::istream& str) MeshFacetArray meshFacets; std::string line; - float fX, fY, fZ; + float fX {}, fY {}, fZ {}; int i1 = 1, i2 = 1, i3 = 1, i4 = 1; MeshFacet item; diff --git a/src/Mod/Mesh/App/Core/IO/WriterOBJ.cpp b/src/Mod/Mesh/App/Core/IO/WriterOBJ.cpp index 6ae501772b..73908022bb 100644 --- a/src/Mod/Mesh/App/Core/IO/WriterOBJ.cpp +++ b/src/Mod/Mesh/App/Core/IO/WriterOBJ.cpp @@ -153,7 +153,7 @@ bool WriterOBJ::Save(std::ostream& out) } // Export normals MeshFacetIterator clIter(_kernel), clEnd(_kernel); - const MeshGeomFacet* pclFacet; + const MeshGeomFacet* pclFacet {}; clIter.Begin(); clEnd.End(); diff --git a/src/Mod/Mesh/App/Core/Info.cpp b/src/Mod/Mesh/App/Core/Info.cpp index 2269f567b5..1bde0af7a6 100644 --- a/src/Mod/Mesh/App/Core/Info.cpp +++ b/src/Mod/Mesh/App/Core/Info.cpp @@ -41,7 +41,7 @@ MeshInfo::MeshInfo(const MeshKernel& rclM) std::ostream& MeshInfo::GeneralInformation(std::ostream& rclStream) const { - unsigned long ulCtPt, ulCtEd, ulCtFc; + unsigned long ulCtPt {}, ulCtEd {}, ulCtFc {}; ulCtPt = _rclMesh.CountPoints(); ulCtFc = _rclMesh.CountFacets(); ulCtEd = _rclMesh.CountEdges(); @@ -126,7 +126,7 @@ std::ostream& MeshInfo::DetailedEdgeInfo(std::ostream& rclStream) const std::ostream& MeshInfo::DetailedFacetInfo(std::ostream& rclStream) const { // print facets - unsigned long i, j; + unsigned long i {}, j {}; rclStream << _rclMesh.CountFacets() << " Faces:" << std::endl; MeshFacetIterator pFIter(_rclMesh), pFEnd(_rclMesh); pFIter.Begin(); @@ -163,7 +163,7 @@ std::ostream& MeshInfo::DetailedInformation(std::ostream& rclStream) const std::ostream& MeshInfo::InternalPointInfo(std::ostream& rclStream) const { // print points - unsigned long i; + unsigned long i {}; rclStream << _rclMesh.CountPoints() << " Points:" << std::endl; MeshPointIterator pPIter(_rclMesh), pPEnd(_rclMesh); pPIter.Begin(); @@ -190,7 +190,7 @@ std::ostream& MeshInfo::InternalPointInfo(std::ostream& rclStream) const std::ostream& MeshInfo::InternalFacetInfo(std::ostream& rclStream) const { // print facets - unsigned long i; + unsigned long i {}; rclStream << _rclMesh.CountFacets() << " Faces:" << std::endl; const MeshFacetArray& rFacets = _rclMesh.GetFacets(); diff --git a/src/Mod/Mesh/App/Core/Info.h b/src/Mod/Mesh/App/Core/Info.h index 930c89a54e..9789596f8d 100644 --- a/src/Mod/Mesh/App/Core/Info.h +++ b/src/Mod/Mesh/App/Core/Info.h @@ -79,11 +79,15 @@ protected: std::ostream& InternalFacetInfo(std::ostream& rclStream) const; -protected: +private: const MeshKernel& _rclMesh; // const reference to mesh data structure public: MeshInfo() = delete; // not accessible default constructor + MeshInfo(const MeshInfo&) = delete; + MeshInfo(MeshInfo&&) = delete; + MeshInfo& operator=(const MeshInfo&) = delete; + MeshInfo& operator=(MeshInfo&&) = delete; }; diff --git a/src/Mod/Mesh/App/Core/Iterator.h b/src/Mod/Mesh/App/Core/Iterator.h index ec10a72bdd..607c861c6b 100644 --- a/src/Mod/Mesh/App/Core/Iterator.h +++ b/src/Mod/Mesh/App/Core/Iterator.h @@ -57,6 +57,8 @@ public: inline MeshFacetIterator(const MeshKernel& rclM, FacetIndex ulPos); /// construction inline MeshFacetIterator(const MeshFacetIterator& rclI); + inline MeshFacetIterator(MeshFacetIterator&& rclI); + ~MeshFacetIterator() = default; //@} /** @name Transformation */ @@ -105,6 +107,7 @@ public: } /// Assignment. inline MeshFacetIterator& operator=(const MeshFacetIterator& rpI); + inline MeshFacetIterator& operator=(MeshFacetIterator&& rpI); /// Compares if this iterator points to a lower element than the other one. bool operator<(const MeshFacetIterator& rclI) const { @@ -205,7 +208,7 @@ public: protected: inline const MeshGeomFacet& Dereference(); -protected: +private: const MeshKernel& _rclMesh; const MeshFacetArray& _rclFAry; const MeshPointArray& _rclPAry; @@ -230,6 +233,8 @@ public: inline explicit MeshPointIterator(const MeshKernel& rclM); inline MeshPointIterator(const MeshKernel& rclM, PointIndex ulPos); inline MeshPointIterator(const MeshPointIterator& rclI); + inline MeshPointIterator(MeshPointIterator&& rclI); + ~MeshPointIterator() = default; //@} /** @name Transformation */ @@ -266,6 +271,7 @@ public: } /// Assignment. inline MeshPointIterator& operator=(const MeshPointIterator& rpI); + inline MeshPointIterator& operator=(MeshPointIterator&& rpI); /// Compares if this iterator points to a lower element than the other one. bool operator<(const MeshPointIterator& rclI) const { @@ -345,10 +351,10 @@ public: } //@} -protected: +private: inline const MeshPoint& Dereference() const; -protected: +private: const MeshKernel& _rclMesh; const MeshPointArray& _rclPAry; mutable MeshPoint _clPoint; @@ -376,22 +382,22 @@ public: return _clIter != _rclFAry.end(); } - Base::Vector3f _afPoints[3]; + Base::Vector3f _afPoints[3]; // NOLINT -protected: - const MeshKernel& _rclMesh; +private: const MeshFacetArray& _rclFAry; const MeshPointArray& _rclPAry; MeshFacetArray::_TConstIterator _clIter; public: MeshFastFacetIterator(const MeshFastFacetIterator&) = delete; + MeshFastFacetIterator(MeshFastFacetIterator&&) = delete; void operator=(const MeshFastFacetIterator&) = delete; + void operator=(MeshFastFacetIterator&&) = delete; }; inline MeshFastFacetIterator::MeshFastFacetIterator(const MeshKernel& rclM) - : _rclMesh(rclM) - , _rclFAry(rclM._aclFacetArray) + : _rclFAry(rclM._aclFacetArray) , _rclPAry(rclM._aclPointArray) , _clIter(_rclFAry.begin()) {} @@ -430,6 +436,15 @@ inline MeshFacetIterator::MeshFacetIterator(const MeshFacetIterator& rclI) , _clTrf(rclI._clTrf) {} +inline MeshFacetIterator::MeshFacetIterator(MeshFacetIterator&& rclI) + : _rclMesh(rclI._rclMesh) + , _rclFAry(rclI._rclFAry) + , _rclPAry(rclI._rclPAry) + , _clIter(rclI._clIter) + , _bApply(rclI._bApply) + , _clTrf(rclI._clTrf) +{} + inline void MeshFacetIterator::Transform(const Base::Matrix4D& rclTrf) { _clTrf = rclTrf; @@ -477,6 +492,14 @@ inline MeshFacetIterator& MeshFacetIterator::operator=(const MeshFacetIterator& return *this; } +inline MeshFacetIterator& MeshFacetIterator::operator=(MeshFacetIterator&& rpI) +{ + _clIter = rpI._clIter; + _bApply = rpI._bApply; + _clTrf = rpI._clTrf; + return *this; +} + inline unsigned long MeshFacetIterator::GetProperty() const { return _clIter->_ulProp; @@ -542,6 +565,14 @@ inline MeshPointIterator::MeshPointIterator(const MeshPointIterator& rclI) , _clTrf(rclI._clTrf) {} +inline MeshPointIterator::MeshPointIterator(MeshPointIterator&& rclI) + : _rclMesh(rclI._rclMesh) + , _rclPAry(rclI._rclPAry) + , _clIter(rclI._clIter) + , _bApply(rclI._bApply) + , _clTrf(rclI._clTrf) +{} + inline void MeshPointIterator::Transform(const Base::Matrix4D& rclTrf) { _clTrf = rclTrf; @@ -580,6 +611,14 @@ inline MeshPointIterator& MeshPointIterator::operator=(const MeshPointIterator& return *this; } +inline MeshPointIterator& MeshPointIterator::operator=(MeshPointIterator&& rpI) +{ + _clIter = rpI._clIter; + _bApply = rpI._bApply; + _clTrf = rpI._clTrf; + return *this; +} + } // namespace MeshCore diff --git a/src/Mod/Mesh/App/Core/KDTree.h b/src/Mod/Mesh/App/Core/KDTree.h index 4116cf6915..41dec24dd9 100644 --- a/src/Mod/Mesh/App/Core/KDTree.h +++ b/src/Mod/Mesh/App/Core/KDTree.h @@ -51,13 +51,14 @@ public: PointIndex FindExact(const Base::Vector3f& p) const; void FindInRange(const Base::Vector3f&, float, std::vector&) const; + MeshKDTree(const MeshKDTree&) = delete; + MeshKDTree(MeshKDTree&&) = delete; + void operator=(const MeshKDTree&) = delete; + void operator=(MeshKDTree&&) = delete; + private: class Private; Private* d; - -public: - MeshKDTree(const MeshKDTree&) = delete; - void operator=(const MeshKDTree&) = delete; }; } // namespace MeshCore diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index 9f3319e2ad..81eb43b674 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -297,7 +297,7 @@ bool MeshInput::LoadSTL(std::istream& rstrIn) return false; } buf->pubseekoff(80, std::ios::beg, std::ios::in); - uint32_t ulCt, ulBytes = 50; + uint32_t ulCt {}, ulBytes = 50; rstrIn.read((char*)&ulCt, sizeof(ulCt)); // if we have a binary STL with a single triangle we can only read-in 50 bytes if (ulCt > 1) { @@ -393,7 +393,7 @@ bool MeshInput::LoadSMF(std::istream& rstrIn) MeshFacetArray meshFacets; std::string line; - float fX, fY, fZ; + float fX {}, fY {}, fZ {}; int i1 = 1, i2 = 1, i3 = 1; MeshFacet item; @@ -510,7 +510,7 @@ bool MeshInput::LoadOFF(std::istream& rstrIn) continue; // empty line } - float fX, fY, fZ; + float fX {}, fY {}, fZ {}; str >> fX >> std::ws >> fY >> std::ws >> fZ; if (str) { meshPoints.push_back(MeshPoint(Base::Vector3f(fX, fY, fZ))); @@ -519,7 +519,7 @@ bool MeshInput::LoadOFF(std::istream& rstrIn) if (colorPerVertex) { std::size_t pos = std::size_t(str.tellg()); if (line.size() > pos) { - float r, g, b, a; + float r {}, g {}, b {}, a {}; str >> std::ws >> r >> std::ws >> g >> std::ws >> b; if (str) { str >> std::ws >> a; @@ -552,7 +552,7 @@ bool MeshInput::LoadOFF(std::istream& rstrIn) if (str.eof()) { continue; // empty line } - int count, index; + int count {}, index {}; str >> count; if (count >= 3) { std::vector faces; @@ -572,7 +572,7 @@ bool MeshInput::LoadOFF(std::istream& rstrIn) std::size_t pos = std::size_t(str.tellg()); if (line.size() > pos) { - float r, g, b, a; + float r {}, g {}, b {}, a {}; str >> std::ws >> r >> std::ws >> g >> std::ws >> b; if (str) { str >> std::ws >> a; @@ -704,7 +704,7 @@ bool MeshInput::LoadPLY(std::istream& inp) str >> kw; if (kw == "format") { std::string format_string, version; - char space_format_string, space_format_version; + char space_format_string {}, space_format_version {}; str >> space_format_string >> std::ws >> format_string >> space_format_version >> std::ws >> version; if (/*!str || !str.eof() ||*/ @@ -731,8 +731,8 @@ bool MeshInput::LoadPLY(std::istream& inp) } else if (kw == "element") { std::string name; - std::size_t count; - char space_element_name, space_name_count; + std::size_t count {}; + char space_element_name {}, space_name_count {}; str >> space_element_name >> std::ws >> name >> space_name_count >> std::ws >> count; if (/*!str || !str.eof() ||*/ !std::isspace(space_element_name) || !std::isspace(space_name_count)) { @@ -754,11 +754,11 @@ bool MeshInput::LoadPLY(std::istream& inp) } else if (kw == "property") { std::string type, name; - char space; + char space {}; if (element == "vertex") { str >> space >> std::ws >> type >> space >> std::ws >> name >> std::ws; - Ply::Number number; + Ply::Number number {}; if (type == "char" || type == "int8") { number = int8; } @@ -803,7 +803,7 @@ bool MeshInput::LoadPLY(std::istream& inp) str >> name; } if (name != "vertex_indices" && name != "vertex_index") { - Number number; + Number number {}; if (type == "char" || type == "int8") { number = int8; } @@ -930,7 +930,7 @@ bool MeshInput::LoadPLY(std::istream& inp) case int16: case int32: { if (boost::regex_search(line, what, rx_s)) { - int v; + int v {}; v = boost::lexical_cast(what[1]); prop_values[it.first] = static_cast(v); line = line.substr(what[0].length()); @@ -943,7 +943,7 @@ bool MeshInput::LoadPLY(std::istream& inp) case uint16: case uint32: { if (boost::regex_search(line, what, rx_u)) { - int v; + int v {}; v = boost::lexical_cast(what[1]); prop_values[it.first] = static_cast(v); line = line.substr(what[0].length()); @@ -955,7 +955,7 @@ bool MeshInput::LoadPLY(std::istream& inp) case float32: case float64: { if (boost::regex_search(line, what, rx_d)) { - double v; + double v {}; v = boost::lexical_cast(what[1]); prop_values[it.first] = static_cast(v); line = line.substr(what[0].length()); @@ -983,7 +983,7 @@ bool MeshInput::LoadPLY(std::istream& inp) } } - int f1, f2, f3; + int f1 {}, f2 {}, f3 {}; for (std::size_t i = 0; i < f_count && std::getline(inp, line); i++) { if (boost::regex_search(line, what, rx_f)) { f1 = boost::lexical_cast(what[1]); @@ -1009,42 +1009,42 @@ bool MeshInput::LoadPLY(std::istream& inp) for (const auto& it : vertex_props) { switch (it.second) { case int8: { - int8_t v; + int8_t v {}; is >> v; prop_values[it.first] = static_cast(v); } break; case uint8: { - uint8_t v; + uint8_t v {}; is >> v; prop_values[it.first] = static_cast(v); } break; case int16: { - int16_t v; + int16_t v {}; is >> v; prop_values[it.first] = static_cast(v); } break; case uint16: { - uint16_t v; + uint16_t v {}; is >> v; prop_values[it.first] = static_cast(v); } break; case int32: { - int32_t v; + int32_t v {}; is >> v; prop_values[it.first] = static_cast(v); } break; case uint32: { - uint32_t v; + uint32_t v {}; is >> v; prop_values[it.first] = static_cast(v); } break; case float32: { - float v; + float v {}; is >> v; prop_values[it.first] = v; } break; case float64: { - double v; + double v {}; is >> v; prop_values[it.first] = static_cast(v); } break; @@ -1067,8 +1067,8 @@ bool MeshInput::LoadPLY(std::istream& inp) } } - unsigned char n; - uint32_t f1, f2, f3; + unsigned char n {}; + uint32_t f1 {}, f2 {}, f3 {}; for (std::size_t i = 0; i < f_count; i++) { is >> n; if (n == 3) { @@ -1079,39 +1079,39 @@ bool MeshInput::LoadPLY(std::istream& inp) for (auto it : face_props) { switch (it) { case int8: { - int8_t v; + int8_t v {}; is >> v; } break; case uint8: { - uint8_t v; + uint8_t v {}; is >> v; } break; case int16: { - int16_t v; + int16_t v {}; is >> v; } break; case uint16: { - uint16_t v; + uint16_t v {}; is >> v; } break; case int32: { - int32_t v; + int32_t v {}; is >> v; } break; case uint32: { - uint32_t v; + uint32_t v {}; is >> v; } break; case float32: { is >> n; - float v; + float v {}; for (unsigned char j = 0; j < n; j++) { is >> v; } } break; case float64: { is >> n; - double v; + double v {}; for (unsigned char j = 0; j < n; j++) { is >> v; } @@ -1151,7 +1151,7 @@ bool MeshInput::LoadMeshNode(std::istream& rstrIn) MeshFacetArray meshFacets; std::string line; - float fX, fY, fZ; + float fX {}, fY {}, fZ {}; unsigned int i1 = 1, i2 = 1, i3 = 1; MeshGeomFacet clFacet; @@ -1206,8 +1206,8 @@ bool MeshInput::LoadAsciiSTL(std::istream& rstrIn) boost::cmatch what; std::string line; - float fX, fY, fZ; - unsigned long ulVertexCt, ulFacetCt = 0; + float fX {}, fY {}, fZ {}; + unsigned long ulVertexCt {}, ulFacetCt {}; MeshGeomFacet clFacet; if (!rstrIn || rstrIn.bad()) { @@ -1296,7 +1296,7 @@ bool MeshInput::LoadBinarySTL(std::istream& rstrIn) std::streamoff ulSize = 0; std::streambuf* buf = rstrIn.rdbuf(); if (buf) { - std::streamoff ulCurr; + std::streamoff ulCurr {}; ulCurr = buf->pubseekoff(0, std::ios::cur, std::ios::in); ulSize = buf->pubseekoff(0, std::ios::end, std::ios::in); buf->pubseekoff(ulCurr, std::ios::beg, std::ios::in); @@ -1461,7 +1461,7 @@ bool MeshInput::LoadNastran(std::istream& rstrIn) MeshPointArray vVertices; MeshFacetArray vTriangle; - int index; + int index {}; std::map mNode; std::map mTria; std::map mQuad; @@ -2055,7 +2055,7 @@ bool MeshOutput::SaveAsciiSTL(std::ostream& rstrOut) const { MeshFacetIterator clIter(_rclMesh), clEnd(_rclMesh); clIter.Transform(this->_transform); - const MeshGeomFacet* pclFacet; + const MeshGeomFacet* pclFacet {}; if (!rstrOut || rstrOut.bad() || _rclMesh.CountFacets() == 0) { return false; @@ -2104,9 +2104,9 @@ bool MeshOutput::SaveBinarySTL(std::ostream& rstrOut) const { MeshFacetIterator clIter(_rclMesh), clEnd(_rclMesh); clIter.Transform(this->_transform); - const MeshGeomFacet* pclFacet; - uint32_t i; - uint16_t usAtt; + const MeshGeomFacet* pclFacet {}; + uint32_t i {}; + uint16_t usAtt {}; char szInfo[81]; if (!rstrOut || rstrOut.bad() /*|| _rclMesh.CountFacets() == 0*/) { @@ -2290,7 +2290,7 @@ bool MeshOutput::SaveAsymptote(std::ostream& out) const } std::size_t index = 0; - const MeshGeomFacet* pclFacet; + const MeshGeomFacet* pclFacet {}; while (clIter < clEnd) { pclFacet = &(*clIter); @@ -2468,7 +2468,7 @@ bool MeshOutput::SaveBinaryPLY(std::ostream& out) const } } unsigned char n = 3; - int f1, f2, f3; + int f1 {}, f2 {}, f3 {}; for (std::size_t i = 0; i < f_count; i++) { const MeshFacet& f = rFacets[i]; f1 = (int)f._aulPoints[0]; @@ -2543,7 +2543,7 @@ bool MeshOutput::SaveAsciiPLY(std::ostream& out) const } unsigned int n = 3; - int f1, f2, f3; + int f1 {}, f2 {}, f3 {}; for (std::size_t i = 0; i < f_count; i++) { const MeshFacet& f = rFacets[i]; f1 = (int)f._aulPoints[0]; @@ -2923,7 +2923,7 @@ bool MeshOutput::SaveX3DContent(std::ostream& out, bool exportViewpoints) const const Base::Vector3d& v = p.getPosition(); const Base::Rotation& r = p.getRotation(); Base::Vector3d axis; - double angle; + double angle {}; r.getValue(axis, angle); out << " supportedMeshFormats(); static MeshIO::Format getFormat(const char* FileName); -protected: +private: MeshKernel& _rclMesh; /**< reference to mesh data structure */ Material* _material; std::vector _groupNames; @@ -256,7 +256,7 @@ protected: /** Writes an X3D file. */ bool SaveX3DContent(std::ostream& rstrOut, bool exportViewpoints) const; -protected: +private: const MeshKernel& _rclMesh; /**< reference to mesh data structure */ const Material* _material; Base::Matrix4D _transform; diff --git a/src/Mod/Mesh/App/Core/MeshKernel.cpp b/src/Mod/Mesh/App/Core/MeshKernel.cpp index f760c75ad0..312cadca0d 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.cpp +++ b/src/Mod/Mesh/App/Core/MeshKernel.cpp @@ -54,6 +54,11 @@ MeshKernel::MeshKernel(const MeshKernel& rclMesh) *this = rclMesh; } +MeshKernel::MeshKernel(MeshKernel&& rclMesh) +{ + *this = rclMesh; +} + MeshKernel& MeshKernel::operator=(const MeshKernel& rclMesh) { if (this != &rclMesh) { // must be a different instance @@ -65,6 +70,17 @@ MeshKernel& MeshKernel::operator=(const MeshKernel& rclMesh) return *this; } +MeshKernel& MeshKernel::operator=(MeshKernel&& rclMesh) +{ + if (this != &rclMesh) { // must be a different instance + this->_aclPointArray = std::move(rclMesh._aclPointArray); + this->_aclFacetArray = std::move(rclMesh._aclFacetArray); + this->_clBoundBox = rclMesh._clBoundBox; + this->_bValid = rclMesh._bValid; + } + return *this; +} + MeshKernel& MeshKernel::operator=(const std::vector& rclFAry) { MeshBuilder builder(*this); @@ -441,7 +457,7 @@ void MeshKernel::Clear() bool MeshKernel::DeleteFacet(const MeshFacetIterator& rclIter) { - FacetIndex ulNFacet, ulInd; + FacetIndex ulNFacet {}, ulInd {}; if (rclIter._clIter >= _aclFacetArray.end()) { return false; @@ -539,7 +555,7 @@ bool MeshKernel::DeletePoint(const MeshPointIterator& rclIter) { MeshFacetIterator pFIter(*this), pFEnd(*this); std::vector clToDel; - PointIndex ulInd; + PointIndex ulInd {}; // index of the point to delete ulInd = rclIter._clIter - _aclPointArray.begin(); @@ -657,7 +673,7 @@ void MeshKernel::RemoveInvalids() { std::vector aulDecrements; std::vector::iterator pDIter; - unsigned long ulDec; + unsigned long ulDec {}; MeshPointArray::_TIterator pPIter, pPEnd; MeshFacetArray::_TIterator pFIter, pFEnd; @@ -784,7 +800,7 @@ std::vector MeshKernel::GetFacetPoints(const std::vector { std::vector points; for (FacetIndex it : facets) { - PointIndex p0, p1, p2; + PointIndex p0 {}, p1 {}, p2 {}; GetFacetPoints(it, p0, p1, p2); points.push_back(p0); points.push_back(p1); @@ -913,7 +929,7 @@ void MeshKernel::Read(std::istream& rclIn) Base::InputStream str(rclIn); // Read the header with a "magic number" and a version - uint32_t magic, version, swap_magic, swap_version; + uint32_t magic {}, version {}, swap_magic {}, swap_version {}; str >> magic >> version; swap_magic = magic; Base::SwapEndian(swap_magic); @@ -950,7 +966,7 @@ void MeshKernel::Read(std::istream& rclIn) MeshFacetArray facetArray; facetArray.resize(uCtFts); - uint32_t v1, v2, v3; + uint32_t v1 {}, v2 {}, v3 {}; for (auto& it : facetArray) { str >> v1 >> v2 >> v3; @@ -1048,11 +1064,11 @@ void MeshKernel::Read(std::istream& rclIn) for (auto& it : pointArray) { str >> it.x >> it.y >> it.z; } - uint32_t dummy; + uint32_t dummy {}; for (unsigned long i = 0; i < uCtEdges; i++) { str >> dummy; } - uint32_t v1, v2, v3; + uint32_t v1 {}, v2 {}, v3 {}; facetArray.resize(uCtFts); for (auto& it : facetArray) { str >> v1 >> v2 >> v3; @@ -1124,7 +1140,7 @@ std::vector MeshKernel::CalcVertexNormals() const normals.resize(CountPoints()); - PointIndex p1, p2, p3; + PointIndex p1 {}, p2 {}, p3 {}; unsigned int ct = CountFacets(); for (unsigned int pFIter = 0; pFIter < ct; pFIter++) { GetFacetPoints(pFIter, p1, p2, p3); diff --git a/src/Mod/Mesh/App/Core/MeshKernel.h b/src/Mod/Mesh/App/Core/MeshKernel.h index 390a1cf01d..003ee2a0e4 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.h +++ b/src/Mod/Mesh/App/Core/MeshKernel.h @@ -68,6 +68,7 @@ public: MeshKernel(); /// Construction MeshKernel(const MeshKernel& rclMesh); + MeshKernel(MeshKernel&& rclMesh); /// Destruction ~MeshKernel() { @@ -411,6 +412,7 @@ public: MeshKernel& operator=(const std::vector& rclFAry); /** Assignment operator. */ MeshKernel& operator=(const MeshKernel& rclMesh); + MeshKernel& operator=(MeshKernel&& rclMesh); /** This allows to assign the mesh structure directly. The caller must make sure that the point * indices are correctly set but the neighbourhood gets checked and corrected if \a * checkNeighbourHood is true. @@ -479,6 +481,7 @@ protected: /** Calculates the gravity point to the given facet. */ inline Base::Vector3f GetGravityPoint(const MeshFacet& rclFacet) const; +private: MeshPointArray _aclPointArray; /**< Holds the array of geometric points. */ MeshFacetArray _aclFacetArray; /**< Holds the array of facets. */ mutable Base::BoundBox3f _clBoundBox; /**< The current calculated bounding box. */ diff --git a/src/Mod/Mesh/App/Core/Segmentation.cpp b/src/Mod/Mesh/App/Core/Segmentation.cpp index dd4bde4e3b..9e30640d9f 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.cpp +++ b/src/Mod/Mesh/App/Core/Segmentation.cpp @@ -203,10 +203,10 @@ std::vector PlaneSurfaceFit::Parameters() const // -------------------------------------------------------- CylinderSurfaceFit::CylinderSurfaceFit() - : fitter(new CylinderFit) + : radius(FLOAT_MAX) + , fitter(new CylinderFit) { axis.Set(0, 0, 0); - radius = FLOAT_MAX; } /*! @@ -311,10 +311,10 @@ std::vector CylinderSurfaceFit::Parameters() const // -------------------------------------------------------- SphereSurfaceFit::SphereSurfaceFit() - : fitter(new SphereFit) + : radius(FLOAT_MAX) + , fitter(new SphereFit) { center.Set(0, 0, 0); - radius = FLOAT_MAX; } SphereSurfaceFit::SphereSurfaceFit(const Base::Vector3f& c, float r) @@ -462,7 +462,7 @@ std::vector MeshDistanceGenericSurfaceFitSegment::Parameters() const bool MeshCurvaturePlanarSegment::TestFacet(const MeshFacet& rclFacet) const { for (PointIndex ptIndex : rclFacet._aulPoints) { - const CurvatureInfo& ci = info[ptIndex]; + const CurvatureInfo& ci = GetInfo(ptIndex); if (fabs(ci.fMinCurvature) > tolerance) { return false; } @@ -477,7 +477,7 @@ bool MeshCurvaturePlanarSegment::TestFacet(const MeshFacet& rclFacet) const bool MeshCurvatureCylindricalSegment::TestFacet(const MeshFacet& rclFacet) const { for (PointIndex ptIndex : rclFacet._aulPoints) { - const CurvatureInfo& ci = info[ptIndex]; + const CurvatureInfo& ci = GetInfo(ptIndex); float fMax = std::max(fabs(ci.fMaxCurvature), fabs(ci.fMinCurvature)); float fMin = std::min(fabs(ci.fMaxCurvature), fabs(ci.fMinCurvature)); if (fMin > toleranceMin) { @@ -494,11 +494,11 @@ bool MeshCurvatureCylindricalSegment::TestFacet(const MeshFacet& rclFacet) const bool MeshCurvatureSphericalSegment::TestFacet(const MeshFacet& rclFacet) const { for (PointIndex ptIndex : rclFacet._aulPoints) { - const CurvatureInfo& ci = info[ptIndex]; + const CurvatureInfo& ci = GetInfo(ptIndex); if (ci.fMaxCurvature * ci.fMinCurvature < 0) { return false; } - float diff; + float diff {}; diff = fabs(ci.fMinCurvature) - curvature; if (fabs(diff) > tolerance) { return false; @@ -515,7 +515,7 @@ bool MeshCurvatureSphericalSegment::TestFacet(const MeshFacet& rclFacet) const bool MeshCurvatureFreeformSegment::TestFacet(const MeshFacet& rclFacet) const { for (PointIndex ptIndex : rclFacet._aulPoints) { - const CurvatureInfo& ci = info[ptIndex]; + const CurvatureInfo& ci = GetInfo(ptIndex); if (fabs(ci.fMinCurvature - c2) > toleranceMin) { return false; } @@ -558,7 +558,7 @@ bool MeshSurfaceVisitor::Visit(const MeshFacet& face, void MeshSegmentAlgorithm::FindSegments(std::vector& segm) { // reset VISIT flags - FacetIndex startFacet; + FacetIndex startFacet {}; MeshCore::MeshAlgorithm cAlgo(myKernel); cAlgo.ResetFacetFlag(MeshCore::MeshFacet::VISIT); diff --git a/src/Mod/Mesh/App/Core/Segmentation.h b/src/Mod/Mesh/App/Core/Segmentation.h index ad7fe653e2..f02dc0eae5 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.h +++ b/src/Mod/Mesh/App/Core/Segmentation.h @@ -47,6 +47,12 @@ public: : minFacets(minFacets) {} virtual ~MeshSurfaceSegment() = default; + + MeshSurfaceSegment(const MeshSurfaceSegment&) = delete; + MeshSurfaceSegment(MeshSurfaceSegment&&) = delete; + MeshSurfaceSegment& operator=(const MeshSurfaceSegment&) = delete; + MeshSurfaceSegment& operator=(MeshSurfaceSegment&&) = delete; + virtual bool TestFacet(const MeshFacet& rclFacet) const = 0; virtual const char* GetType() const = 0; virtual void Initialize(FacetIndex); @@ -59,7 +65,7 @@ public: } MeshSegment FindSegment(FacetIndex) const; -protected: +private: std::vector segments; unsigned long minFacets; }; @@ -77,8 +83,10 @@ public: {} protected: + // NOLINTBEGIN const MeshKernel& kernel; float tolerance; + // NOLINTEND }; class MeshExport MeshDistancePlanarSegment: public MeshDistanceSurfaceSegment @@ -86,6 +94,12 @@ class MeshExport MeshDistancePlanarSegment: public MeshDistanceSurfaceSegment public: MeshDistancePlanarSegment(const MeshKernel& mesh, unsigned long minFacets, float tol); ~MeshDistancePlanarSegment() override; + + MeshDistancePlanarSegment(const MeshDistancePlanarSegment&) = delete; + MeshDistancePlanarSegment(MeshDistancePlanarSegment&&) = delete; + MeshDistancePlanarSegment& operator=(const MeshDistancePlanarSegment&) = delete; + MeshDistancePlanarSegment& operator=(MeshDistancePlanarSegment&&) = delete; + bool TestFacet(const MeshFacet& rclFacet) const override; const char* GetType() const override { @@ -94,7 +108,7 @@ public: void Initialize(FacetIndex) override; void AddFacet(const MeshFacet& rclFacet) override; -protected: +private: Base::Vector3f basepoint; Base::Vector3f normal; PlaneFit* fitter; @@ -105,6 +119,12 @@ class MeshExport AbstractSurfaceFit public: AbstractSurfaceFit() = default; virtual ~AbstractSurfaceFit() = default; + + AbstractSurfaceFit(const AbstractSurfaceFit&) = delete; + AbstractSurfaceFit(AbstractSurfaceFit&&) = delete; + AbstractSurfaceFit& operator=(const AbstractSurfaceFit&) = delete; + AbstractSurfaceFit& operator=(AbstractSurfaceFit&&) = delete; + virtual const char* GetType() const = 0; virtual void Initialize(const MeshGeomFacet&) = 0; virtual bool TestTriangle(const MeshGeomFacet&) const = 0; @@ -121,6 +141,12 @@ public: PlaneSurfaceFit(); PlaneSurfaceFit(const Base::Vector3f& b, const Base::Vector3f& n); ~PlaneSurfaceFit() override; + + PlaneSurfaceFit(const PlaneSurfaceFit&) = delete; + PlaneSurfaceFit(PlaneSurfaceFit&&) = delete; + PlaneSurfaceFit& operator=(const PlaneSurfaceFit&) = delete; + PlaneSurfaceFit& operator=(PlaneSurfaceFit&&) = delete; + const char* GetType() const override { return "Plane"; @@ -145,6 +171,12 @@ public: CylinderSurfaceFit(); CylinderSurfaceFit(const Base::Vector3f& b, const Base::Vector3f& a, float r); ~CylinderSurfaceFit() override; + + CylinderSurfaceFit(const CylinderSurfaceFit&) = delete; + CylinderSurfaceFit(CylinderSurfaceFit&&) = delete; + CylinderSurfaceFit& operator=(const CylinderSurfaceFit&) = delete; + CylinderSurfaceFit& operator=(CylinderSurfaceFit&&) = delete; + const char* GetType() const override { return "Cylinder"; @@ -170,6 +202,12 @@ public: SphereSurfaceFit(); SphereSurfaceFit(const Base::Vector3f& c, float r); ~SphereSurfaceFit() override; + + SphereSurfaceFit(const SphereSurfaceFit&) = delete; + SphereSurfaceFit(SphereSurfaceFit&&) = delete; + SphereSurfaceFit& operator=(const SphereSurfaceFit&) = delete; + SphereSurfaceFit& operator=(SphereSurfaceFit&&) = delete; + const char* GetType() const override { return "Sphere"; @@ -196,6 +234,14 @@ public: unsigned long minFacets, float tol); ~MeshDistanceGenericSurfaceFitSegment() override; + + MeshDistanceGenericSurfaceFitSegment(const MeshDistanceGenericSurfaceFitSegment&) = delete; + MeshDistanceGenericSurfaceFitSegment(MeshDistanceGenericSurfaceFitSegment&&) = delete; + MeshDistanceGenericSurfaceFitSegment& + operator=(const MeshDistanceGenericSurfaceFitSegment&) = delete; + MeshDistanceGenericSurfaceFitSegment& + operator=(MeshDistanceGenericSurfaceFitSegment&&) = delete; + bool TestFacet(const MeshFacet& rclFacet) const override; const char* GetType() const override { @@ -206,7 +252,7 @@ public: void AddFacet(const MeshFacet& rclFacet) override; std::vector Parameters() const; -protected: +private: AbstractSurfaceFit* fitter; }; @@ -220,7 +266,12 @@ public: , info(ci) {} -protected: + const CurvatureInfo& GetInfo(std::size_t pos) const + { + return info.at(pos); + } + +private: const std::vector& info; }; @@ -252,11 +303,10 @@ public: float tolMax, float curv) : MeshCurvatureSurfaceSegment(ci, minFacets) + , curvature(curv) , toleranceMin(tolMin) , toleranceMax(tolMax) - { - curvature = curv; - } + {} bool TestFacet(const MeshFacet& rclFacet) const override; const char* GetType() const override { @@ -277,10 +327,9 @@ public: float tol, float curv) : MeshCurvatureSurfaceSegment(ci, minFacets) + , curvature(curv) , tolerance(tol) - { - curvature = curv; - } + {} bool TestFacet(const MeshFacet& rclFacet) const override; const char* GetType() const override { @@ -330,7 +379,7 @@ public: unsigned short neighbourIndex) override; bool Visit(const MeshFacet& face, const MeshFacet&, FacetIndex ulFInd, unsigned long) override; -protected: +private: std::vector& indices; MeshSurfaceSegment& segm; }; diff --git a/src/Mod/Mesh/App/Core/SetOperations.cpp b/src/Mod/Mesh/App/Core/SetOperations.cpp index 2819b18b81..064b4409e4 100644 --- a/src/Mod/Mesh/App/Core/SetOperations.cpp +++ b/src/Mod/Mesh/App/Core/SetOperations.cpp @@ -96,14 +96,13 @@ void SetOperations::Do() return; } - unsigned long i; - for (i = 0; i < _cutMesh0.CountFacets(); i++) { + for (auto i = 0UL; i < _cutMesh0.CountFacets(); i++) { if (facetsCuttingEdge0.find(i) == facetsCuttingEdge0.end()) { _newMeshFacets[0].push_back(_cutMesh0.GetFacet(i)); } } - for (i = 0; i < _cutMesh1.CountFacets(); i++) { + for (auto i = 0UL; i < _cutMesh1.CountFacets(); i++) { if (facetsCuttingEdge1.find(i) == facetsCuttingEdge1.end()) { _newMeshFacets[1].push_back(_cutMesh1.GetFacet(i)); } @@ -115,7 +114,7 @@ void SetOperations::Do() // Base::Sequencer().next(); TriangulateMesh(_cutMesh1, 1); - float mult0, mult1; + float mult0 {}, mult1 {}; switch (_operationType) { case Union: mult0 = -1.0f; @@ -178,15 +177,12 @@ void SetOperations::Cut(std::set& facetsCuttingEdge0, MeshFacetGrid grid1(_cutMesh0, 20); MeshFacetGrid grid2(_cutMesh1, 20); - unsigned long ctGx1, ctGy1, ctGz1; + unsigned long ctGx1 {}, ctGy1 {}, ctGz1 {}; grid1.GetCtGrids(ctGx1, ctGy1, ctGz1); - unsigned long gx1; - for (gx1 = 0; gx1 < ctGx1; gx1++) { - unsigned long gy1; - for (gy1 = 0; gy1 < ctGy1; gy1++) { - unsigned long gz1; - for (gz1 = 0; gz1 < ctGz1; gz1++) { + for (auto gx1 = 0UL; gx1 < ctGx1; gx1++) { + for (auto gy1 = 0UL; gy1 < ctGy1; gy1++) { + for (auto gz1 = 0UL; gz1 < ctGz1; gz1++) { if (grid1.GetCtElements(gx1, gy1, gz1) > 0) { std::vector vecFacets2; grid2.Inside(grid1.GetBoundBox(gx1, gy1, gz1), vecFacets2); @@ -213,8 +209,8 @@ void SetOperations::Cut(std::set& facetsCuttingEdge0, float minDist1 = _minDistanceToPoint, minDist2 = _minDistanceToPoint; MeshPoint np0 = p0, np1 = p1; - int i; - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) // NOLINT + { float d1 = (f1._aclPoints[i] - p0).Length(); float d2 = (f1._aclPoints[i] - p1).Length(); if (d1 < minDist1) { @@ -228,7 +224,8 @@ void SetOperations::Cut(std::set& facetsCuttingEdge0, } // for (int i = 0; i < 3; i++) // optimize cut line if distance to nearest point is too small - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) // NOLINT + { float d1 = (f2._aclPoints[i] - p0).Length(); float d2 = (f2._aclPoints[i] - p1).Length(); if (d1 < minDist1) { @@ -310,8 +307,8 @@ void SetOperations::TriangulateMesh(const MeshKernel& cutMesh, int side) // facet corner points // const MeshFacet& mf = cutMesh._aclFacetArray[fidx]; - int i; - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) // NOLINT + { pointsSet.insert(f._aclPoints[i]); points.push_back(f._aclPoints[i]); } @@ -396,8 +393,7 @@ void SetOperations::TriangulateMesh(const MeshKernel& cutMesh, int side) } - int j; - for (j = 0; j < 3; j++) { + for (int j = 0; j < 3; j++) { std::map::iterator eit = _edges.find(Edge(facet._aclPoints[j], facet._aclPoints[(j + 1) % 3])); @@ -766,7 +762,7 @@ void MeshIntersection::connectLines(bool onlyclosed, // search for the next line on the begin/end of the polyline and add it std::list::iterator pFront, pEnd; - bool bFoundLine; + bool bFoundLine {}; do { float fFrontMin = fMinEps, fEndMin = fMinEps; bool bFrontFirst = false, bEndFirst = false; diff --git a/src/Mod/Mesh/App/Core/SetOperations.h b/src/Mod/Mesh/App/Core/SetOperations.h index bd7054fe4f..4c31f8cba5 100644 --- a/src/Mod/Mesh/App/Core/SetOperations.h +++ b/src/Mod/Mesh/App/Core/SetOperations.h @@ -76,7 +76,7 @@ public: */ void Do(); -protected: +private: const MeshKernel& _cutMesh0; /** Mesh for set operations source 1 */ const MeshKernel& _cutMesh1; /** Mesh for set operations source 2 */ MeshKernel& _resultMesh; /** Result mesh */ @@ -118,17 +118,9 @@ private: class EdgeInfo { public: - int fcounter[2]; // counter of facets attacted to the edge + int fcounter[2] {}; // counter of facets attacted to the edge MeshGeomFacet facets[2][2]; // Geom-Facets attached to the edge - FacetIndex facet[2]; // underlying Facet-Index - - EdgeInfo() - { - fcounter[0] = 0; - fcounter[1] = 0; - facet[0] = 0; - facet[1] = 0; - } + FacetIndex facet[2] {}; // underlying Facet-Index }; // class CollectFacetVisitor : public MeshFacetVisitor diff --git a/src/Mod/Mesh/App/Core/Smoothing.cpp b/src/Mod/Mesh/App/Core/Smoothing.cpp index ffeb67d757..9c6672e1ed 100644 --- a/src/Mod/Mesh/App/Core/Smoothing.cpp +++ b/src/Mod/Mesh/App/Core/Smoothing.cpp @@ -185,7 +185,7 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, } size_t n_count = cv.size(); - double w; + double w {}; w = 1.0 / double(n_count); double delx = 0.0, dely = 0.0, delz = 0.0; @@ -222,7 +222,7 @@ void LaplaceSmoothing::Umbrella(const MeshRefPointToPoints& vv_it, } size_t n_count = cv.size(); - double w; + double w {}; w = 1.0 / double(n_count); double delx = 0.0, dely = 0.0, delz = 0.0; @@ -273,8 +273,8 @@ void TaubinSmoothing::Smooth(unsigned int iterations) // Theoretically Taubin does not shrink the surface iterations = (iterations + 1) / 2; // two steps per iteration for (unsigned int i = 0; i < iterations; i++) { - Umbrella(vv_it, vf_it, lambda); - Umbrella(vv_it, vf_it, -(lambda + micro)); + Umbrella(vv_it, vf_it, GetLambda()); + Umbrella(vv_it, vf_it, -(GetLambda() + micro)); } } @@ -287,8 +287,8 @@ void TaubinSmoothing::SmoothPoints(unsigned int iterations, // Theoretically Taubin does not shrink the surface iterations = (iterations + 1) / 2; // two steps per iteration for (unsigned int i = 0; i < iterations; i++) { - Umbrella(vv_it, vf_it, lambda, point_indices); - Umbrella(vv_it, vf_it, -(lambda + micro), point_indices); + Umbrella(vv_it, vf_it, GetLambda(), point_indices); + Umbrella(vv_it, vf_it, -(GetLambda() + micro), point_indices); } } diff --git a/src/Mod/Mesh/App/Core/Smoothing.h b/src/Mod/Mesh/App/Core/Smoothing.h index 05e60cc807..6f15ffad2a 100644 --- a/src/Mod/Mesh/App/Core/Smoothing.h +++ b/src/Mod/Mesh/App/Core/Smoothing.h @@ -56,6 +56,11 @@ public: explicit AbstractSmoothing(MeshKernel&); virtual ~AbstractSmoothing(); + AbstractSmoothing(const AbstractSmoothing&) = delete; + AbstractSmoothing(AbstractSmoothing&&) = delete; + AbstractSmoothing& operator=(const AbstractSmoothing&) = delete; + AbstractSmoothing& operator=(AbstractSmoothing&&) = delete; + void initialize(Component comp, Continuity cont); /** Smooth the triangle mesh. */ @@ -63,10 +68,12 @@ public: virtual void SmoothPoints(unsigned int, const std::vector&) = 0; protected: + // NOLINTBEGIN MeshKernel& kernel; Component component {Normal}; Continuity continuity {C0}; + // NOLINTEND }; class MeshExport PlaneFitSmoothing: public AbstractSmoothing @@ -94,6 +101,10 @@ public: { lambda = l; } + double GetLambda() const + { + return lambda; + } protected: void Umbrella(const MeshRefPointToPoints&, const MeshRefPointToFacets&, double); @@ -102,7 +113,7 @@ protected: double, const std::vector&); -protected: +private: double lambda {0.6307}; }; @@ -117,7 +128,7 @@ public: micro = m; } -protected: +private: double micro {0.0424}; }; diff --git a/src/Mod/Mesh/App/Core/SphereFit.cpp b/src/Mod/Mesh/App/Core/SphereFit.cpp index 310f1cca0c..c455192958 100644 --- a/src/Mod/Mesh/App/Core/SphereFit.cpp +++ b/src/Mod/Mesh/App/Core/SphereFit.cpp @@ -204,7 +204,7 @@ float SphereFit::Fit() Eigen::VectorXd atpl(4); // Iteration loop... - double sigma0; + double sigma0 {}; bool cont = true; while (cont && (_numIter < _maxIter)) { ++_numIter; @@ -228,7 +228,7 @@ float SphereFit::Fit() // Before updating the unknowns, compute the residuals and sigma0 and check the residual // convergence - bool vConverged; + bool vConverged {}; if (!computeResiduals(x, residuals, sigma0, _vConvLimit, vConverged)) { return FLOAT_MAX; } @@ -267,8 +267,8 @@ void SphereFit::setupNormalEquationMatrices(const std::vector& r // For each point, setup the observation equation coefficients and add their // contribution into the normal equation matrices - double a[4], b[3]; - double f0, qw; + double a[4] {}, b[3] {}; + double f0 {}, qw {}; std::vector::const_iterator vIt = residuals.begin(); std::list::const_iterator cIt; for (cIt = _vPoints.begin(); cIt != _vPoints.end(); ++cIt, ++vIt) { @@ -377,8 +377,8 @@ bool SphereFit::computeResiduals(const Eigen::VectorXd& x, vConverged = true; int nPtsUsed = 0; sigma0 = 0.0; - double a[4], b[3]; - double f0, qw; + double a[4] {}, b[3] {}; + double f0 {}, qw {}; // double maxdVx = 0.0; // double maxdVy = 0.0; // double maxdVz = 0.0; diff --git a/src/Mod/Mesh/App/Core/SphereFit.h b/src/Mod/Mesh/App/Core/SphereFit.h index f392c66226..5b44156789 100644 --- a/src/Mod/Mesh/App/Core/SphereFit.h +++ b/src/Mod/Mesh/App/Core/SphereFit.h @@ -128,7 +128,7 @@ protected: double vConvLimit, bool& vConverged) const; -protected: +private: Base::Vector3d _vCenter; /**< Center of sphere. */ double _dRadius {0}; /**< Radius of the sphere. */ int _numIter {0}; /**< Number of iterations for solution to converge. */ diff --git a/src/Mod/Mesh/App/Core/Tools.h b/src/Mod/Mesh/App/Core/Tools.h index 84eb95bbcc..17f6d790c2 100644 --- a/src/Mod/Mesh/App/Core/Tools.h +++ b/src/Mod/Mesh/App/Core/Tools.h @@ -89,7 +89,7 @@ protected: Base::Vector3f _clCenter; }; -protected: +private: const MeshKernel& _rclMesh; const MeshFacetArray& _rclFAry; const MeshPointArray& _rclPAry; @@ -102,11 +102,12 @@ protected: std::vector> _aclSampledFacets; // sample points from each facet float _fSampleDistance; // distance between two sampled points Wm4::Sphere3 _akSphere; - bool _bTooFewPoints {false}; public: MeshSearchNeighbours(const MeshSearchNeighbours&) = delete; + MeshSearchNeighbours(MeshSearchNeighbours&&) = delete; void operator=(const MeshSearchNeighbours&) = delete; + void operator=(MeshSearchNeighbours&&) = delete; }; inline bool MeshSearchNeighbours::CheckDistToFacet(const MeshFacet& rclF) @@ -177,7 +178,7 @@ public: Base::Vector3f operator()(PointIndex index) { it.Set(index); - return *it; + return Base::Vector3f(it->x, it->y, it->z); } private: @@ -206,8 +207,10 @@ public: } } + // NOLINTBEGIN Index nearest_index; float nearest_dist {FLOAT_MAX}; + // NOLINTEND private: T it; diff --git a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp index f09ad7c596..8985138aa2 100644 --- a/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp +++ b/src/Mod/Mesh/App/Core/TopoAlgorithm.cpp @@ -381,7 +381,7 @@ void MeshTopoAlgorithm::DelaunayFlip(float fMaxAngle) const MeshFacet& face_1 = _rclMesh._aclFacetArray[edge.first]; const MeshFacet& face_2 = _rclMesh._aclFacetArray[edge.second]; unsigned short side = face_2.Side(edge.first); - Base::Vector3f vertex = _rclMesh.GetPoint(face_2._aulPoints[(side + 1) % 3]); + MeshPoint vertex = _rclMesh.GetPoint(face_2._aulPoints[(side + 1) % 3]); if (Base::DistanceP2(center, vertex) < radius) { SwapEdge(edge.first, edge.second); for (int i = 0; i < 3; i++) { @@ -504,14 +504,14 @@ void MeshTopoAlgorithm::AdjustEdgesToCurvatureDirection() continue; } - PointIndex uPt3, uPt4; + PointIndex uPt3 {}, uPt4 {}; unsigned short side = rFace1.Side(uPt1, uPt2); uPt3 = rFace1._aulPoints[(side + 2) % 3]; side = rFace2.Side(uPt1, uPt2); uPt4 = rFace2._aulPoints[(side + 2) % 3]; Wm4::Vector3 dir; - float fActCurvature; + float fActCurvature {}; if (fabs(aMinCurv[uPt1]) > fabs(aMaxCurv[uPt1])) { fActCurvature = aMinCurv[uPt1]; dir = aMaxCurvDir[uPt1]; @@ -1838,7 +1838,7 @@ void MeshComponents::SearchForComponents(TMode tMode, const std::vector& aSegment, std::vector>& aclT) const { - FacetIndex ulStartFacet; + FacetIndex ulStartFacet {}; if (_rclMesh.CountFacets() == 0) { return; diff --git a/src/Mod/Mesh/App/Core/TopoAlgorithm.h b/src/Mod/Mesh/App/Core/TopoAlgorithm.h index 02d140ac23..108ff01917 100644 --- a/src/Mod/Mesh/App/Core/TopoAlgorithm.h +++ b/src/Mod/Mesh/App/Core/TopoAlgorithm.h @@ -50,6 +50,11 @@ public: explicit MeshTopoAlgorithm(MeshKernel& rclM); ~MeshTopoAlgorithm(); + MeshTopoAlgorithm(const MeshTopoAlgorithm&) = delete; + MeshTopoAlgorithm(MeshTopoAlgorithm&&) = delete; + MeshTopoAlgorithm& operator=(const MeshTopoAlgorithm&) = delete; + MeshTopoAlgorithm& operator=(MeshTopoAlgorithm&&) = delete; + public: /** @name Topological Operations */ //@{ @@ -360,7 +365,7 @@ protected: } }; -protected: +private: const MeshKernel& _rclMesh; }; diff --git a/src/Mod/Mesh/App/Core/Triangulation.cpp b/src/Mod/Mesh/App/Core/Triangulation.cpp index 20049971b3..11c6c144ca 100644 --- a/src/Mod/Mesh/App/Core/Triangulation.cpp +++ b/src/Mod/Mesh/App/Core/Triangulation.cpp @@ -74,10 +74,9 @@ bool TriangulationVerifierV2::MustFlip(const Base::Vector3f& n1, const Base::Vec // ---------------------------------------------------------------------------- AbstractPolygonTriangulator::AbstractPolygonTriangulator() -{ - _discard = false; - _verifier = new TriangulationVerifier(); -} + : _discard {false} + , _verifier {new TriangulationVerifier()} +{} AbstractPolygonTriangulator::~AbstractPolygonTriangulator() { @@ -358,8 +357,8 @@ bool EarClippingTriangulator::Triangulate::InsideTriangle(float Ax, float Px, float Py) { - float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; - float cCROSSap, bCROSScp, aCROSSbp; + float ax {}, ay {}, bx {}, by {}, cx {}, cy {}, apx {}, apy {}, bpx {}, bpy {}, cpx {}, cpy {}; + float cCROSSap {}, bCROSScp {}, aCROSSbp {}; ax = Cx - Bx; ay = Cy - By; @@ -388,8 +387,8 @@ bool EarClippingTriangulator::Triangulate::Snip(const std::vector& raclPoints); void SetIndices(const std::vector& d) @@ -139,6 +149,7 @@ protected: void Done(); protected: + // NOLINTBEGIN bool _discard; Base::Matrix4D _inverse; std::vector _indices; @@ -148,6 +159,7 @@ protected: std::vector _facets; std::vector _info; TriangulationVerifier* _verifier; + // NOLINTEND }; /** diff --git a/src/Mod/Mesh/App/Core/Trim.cpp b/src/Mod/Mesh/App/Core/Trim.cpp index 00c1b58a4f..f48aa64bf0 100644 --- a/src/Mod/Mesh/App/Core/Trim.cpp +++ b/src/Mod/Mesh/App/Core/Trim.cpp @@ -165,7 +165,7 @@ bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, FacetIndex ulIndex) bool MeshTrimming::IsPolygonPointInFacet(FacetIndex ulIndex, Base::Vector3f& clPoint) { Base::Vector2d A, B, C, P; - float u, v, w, fDetPAC, fDetPBC, fDetPAB, fDetABC; + float u {}, v {}, w {}, fDetPAC {}, fDetPBC {}, fDetPAB {}, fDetABC {}; Base::Polygon2d clFacPoly; const MeshGeomFacet& rclFacet = myMesh.GetFacet(ulIndex); @@ -346,7 +346,7 @@ bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet( void MeshTrimming::AdjustFacet(MeshFacet& facet, int iInd) { - unsigned long tmp; + unsigned long tmp {}; if (iInd == 1) { tmp = facet._aulPoints[0]; @@ -774,7 +774,7 @@ void MeshTrimming::TrimFacets(const std::vector& raulFacets, { Base::Vector3f clP; std::vector clIntsct; - int iSide; + int iSide {}; Base::SequencerLauncher seq("trimming facets...", raulFacets.size()); for (FacetIndex index : raulFacets) { diff --git a/src/Mod/Mesh/App/Core/Visitor.cpp b/src/Mod/Mesh/App/Core/Visitor.cpp index 77927794fd..2c9992d3d1 100644 --- a/src/Mod/Mesh/App/Core/Visitor.cpp +++ b/src/Mod/Mesh/App/Core/Visitor.cpp @@ -34,7 +34,7 @@ using namespace MeshCore; unsigned long MeshKernel::VisitNeighbourFacets(MeshFacetVisitor& rclFVisitor, FacetIndex ulStartFacet) const { - unsigned long ulVisited = 0, j, ulLevel = 0; + unsigned long ulVisited = 0, ulLevel = 0; unsigned long ulCount = _aclFacetArray.size(); std::vector clCurrentLevel, clNextLevel; std::vector::iterator clCurrIter; @@ -52,7 +52,7 @@ unsigned long MeshKernel::VisitNeighbourFacets(MeshFacetVisitor& rclFVisitor, // visit all neighbours of the current level if not yet done for (unsigned short i = 0; i < 3; i++) { - j = clCurrFacet->_aulNeighbours[i]; // index to neighbour facet + auto j = clCurrFacet->_aulNeighbours[i]; // index to neighbour facet if (j == FACET_INDEX_MAX) { continue; // no neighbour facet } diff --git a/src/Mod/Mesh/App/Core/tritritest.h b/src/Mod/Mesh/App/Core/tritritest.h index ce65c67553..f92379a600 100644 --- a/src/Mod/Mesh/App/Core/tritritest.h +++ b/src/Mod/Mesh/App/Core/tritritest.h @@ -41,7 +41,7 @@ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHE OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - +//NOLINTBEGIN #include #define FABS(x) ((float)fabs(x)) /* implement as is fastest on your machine */ @@ -722,5 +722,5 @@ int tri_tri_intersect_with_isectline(float V0[3],float V1[3],float V2[3], } return 1; } - +//NOLINTEND // clang-format on diff --git a/src/Mod/Mesh/App/Edge.cpp b/src/Mod/Mesh/App/Edge.cpp index 1fa3ff4d75..35deaaf83d 100644 --- a/src/Mod/Mesh/App/Edge.cpp +++ b/src/Mod/Mesh/App/Edge.cpp @@ -40,7 +40,18 @@ Edge::Edge() // NOLINT } } -Edge::Edge(const Edge& e) +Edge::Edge(const Edge& e) // NOLINT + : MeshCore::MeshGeomEdge(e) + , Index(e.Index) + , Mesh(e.Mesh) +{ + for (int i = 0; i < 2; i++) { + PIndex[i] = e.PIndex[i]; + NIndex[i] = e.NIndex[i]; + } +} + +Edge::Edge(Edge&& e) // NOLINT : MeshCore::MeshGeomEdge(e) , Index(e.Index) , Mesh(e.Mesh) @@ -53,7 +64,7 @@ Edge::Edge(const Edge& e) Edge::~Edge() = default; -void Edge::operator=(const Edge& e) +Edge& Edge::operator=(const Edge& e) { MeshCore::MeshGeomEdge::operator=(e); Mesh = e.Mesh; @@ -62,6 +73,21 @@ void Edge::operator=(const Edge& e) PIndex[i] = e.PIndex[i]; NIndex[i] = e.NIndex[i]; } + + return *this; +} + +Edge& Edge::operator=(Edge&& e) +{ + MeshCore::MeshGeomEdge::operator=(e); + Mesh = e.Mesh; + Index = e.Index; + for (int i = 0; i < 2; i++) { + PIndex[i] = e.PIndex[i]; + NIndex[i] = e.NIndex[i]; + } + + return *this; } void Edge::unbound() diff --git a/src/Mod/Mesh/App/Edge.h b/src/Mod/Mesh/App/Edge.h index 27e7167160..dfc2cf8c33 100644 --- a/src/Mod/Mesh/App/Edge.h +++ b/src/Mod/Mesh/App/Edge.h @@ -43,6 +43,7 @@ class MeshExport Edge: public MeshCore::MeshGeomEdge public: Edge(); Edge(const Edge& f); + Edge(Edge&& f); ~Edge(); bool isBound() const @@ -50,7 +51,8 @@ public: return Index != -1; } void unbound(); - void operator=(const Edge& f); + Edge& operator=(const Edge& f); + Edge& operator=(Edge&& f); int Index {-1}; MeshCore::PointIndex PIndex[2]; diff --git a/src/Mod/Mesh/App/EdgePyImp.cpp b/src/Mod/Mesh/App/EdgePyImp.cpp index bfed97e7b6..a2bfd60669 100644 --- a/src/Mod/Mesh/App/EdgePyImp.cpp +++ b/src/Mod/Mesh/App/EdgePyImp.cpp @@ -26,11 +26,9 @@ #include #include -// clang-format off #include "Edge.h" #include "EdgePy.h" #include "EdgePy.cpp" -// clang-format on using namespace Mesh; @@ -125,7 +123,7 @@ PyObject* EdgePy::intersectWithEdge(PyObject* args) PyObject* EdgePy::isParallel(PyObject* args) { - PyObject* object; + PyObject* object {}; if (!PyArg_ParseTuple(args, "O!", &EdgePy::Type, &object)) { return nullptr; } @@ -138,7 +136,7 @@ PyObject* EdgePy::isParallel(PyObject* args) PyObject* EdgePy::isCollinear(PyObject* args) { - PyObject* object; + PyObject* object {}; if (!PyArg_ParseTuple(args, "O!", &EdgePy::Type, &object)) { return nullptr; } diff --git a/src/Mod/Mesh/App/Exporter.cpp b/src/Mod/Mesh/App/Exporter.cpp index 00f9a8f57a..f59c6395c8 100644 --- a/src/Mod/Mesh/App/Exporter.cpp +++ b/src/Mod/Mesh/App/Exporter.cpp @@ -28,8 +28,6 @@ #include #endif -#include "Core/IO/Writer3MF.h" -#include "Core/Iterator.h" #include #include #include @@ -40,6 +38,8 @@ #include #include #include +#include "Core/Iterator.h" +#include "Core/IO/Writer3MF.h" #include #include "Exporter.h" @@ -159,7 +159,7 @@ void Exporter::throwIfNoPermission(const std::string& filename) // ---------------------------------------------------------------------------- MergeExporter::MergeExporter(std::string fileName, MeshIO::Format) - : fName(fileName) + : fName(std::move(fileName)) {} MergeExporter::~MergeExporter() @@ -281,9 +281,9 @@ std::vector Extension3MFFactory::producer; class Exporter3MF::Private { public: - explicit Private(const std::string& filename, const std::vector& ext) + explicit Private(const std::string& filename, std::vector ext) : writer3mf(filename) - , ext(ext) + , ext(std::move(ext)) {} MeshCore::Writer3MF writer3mf; std::vector ext; @@ -428,7 +428,7 @@ bool ExporterAMF::addMesh(const char* name, const MeshObject& mesh) *outputStreamPtr << "\t\t\n" << "\t\t\t\n"; - const MeshCore::MeshGeomFacet* facet; + const MeshCore::MeshGeomFacet* facet {}; // Iterate through all facets of the mesh, and construct a: // * Cache (map) of used vertices, outputting each new unique vertex to diff --git a/src/Mod/Mesh/App/Exporter.h b/src/Mod/Mesh/App/Exporter.h index ad49921d2c..005fc5ed5b 100644 --- a/src/Mod/Mesh/App/Exporter.h +++ b/src/Mod/Mesh/App/Exporter.h @@ -27,9 +27,9 @@ #include #include -#include "Core/IO/Writer3MF.h" -#include "Core/MeshIO.h" #include "MeshFeature.h" +#include "Core/MeshIO.h" +#include "Core/IO/Writer3MF.h" namespace Mesh @@ -61,6 +61,11 @@ public: virtual bool addMesh(const char* name, const MeshObject& mesh) = 0; + Exporter(const Exporter&) = delete; + Exporter(Exporter&&) = delete; + Exporter& operator=(const Exporter&) = delete; + Exporter& operator=(Exporter&&) = delete; + protected: /// Does some simple escaping of characters for XML-type exports static std::string xmlEscape(const std::string& input); @@ -77,6 +82,11 @@ public: MergeExporter(std::string fileName, MeshCore::MeshIO::Format fmt); ~MergeExporter() override; + MergeExporter(const MergeExporter&) = delete; + MergeExporter(MergeExporter&&) = delete; + MergeExporter& operator=(const MergeExporter&) = delete; + MergeExporter& operator=(MergeExporter&&) = delete; + bool addMesh(const char* name, const MeshObject& mesh) override; private: @@ -84,8 +94,10 @@ private: void write(); protected: + // NOLINTBEGIN MeshObject mergingMesh; std::string fName; + // NOLINTEND }; // ------------------------------------------------------------------------------------------------ @@ -101,6 +113,11 @@ protected: public: virtual ~AbstractFormatExtension() = default; + + AbstractFormatExtension(const AbstractFormatExtension&) = delete; + AbstractFormatExtension(AbstractFormatExtension&&) = delete; + AbstractFormatExtension& operator=(const AbstractFormatExtension&) = delete; + AbstractFormatExtension& operator=(AbstractFormatExtension&&) = delete; }; using AbstractFormatExtensionPtr = std::shared_ptr; @@ -129,6 +146,11 @@ public: AbstractExtensionProducer() = default; virtual ~AbstractExtensionProducer() = default; virtual AbstractFormatExtensionPtr create() const = 0; + + AbstractExtensionProducer(const AbstractExtensionProducer&) = delete; + AbstractExtensionProducer(AbstractExtensionProducer&&) = delete; + AbstractExtensionProducer& operator=(const AbstractExtensionProducer&) = delete; + AbstractExtensionProducer& operator=(AbstractExtensionProducer&&) = delete; }; using AbstractExtensionProducerPtr = std::shared_ptr; @@ -186,6 +208,11 @@ public: Exporter3MF(std::string fileName, const std::vector& = {}); ~Exporter3MF() override; + Exporter3MF(const Exporter3MF&) = delete; + Exporter3MF(Exporter3MF&&) = delete; + Exporter3MF& operator=(const Exporter3MF&) = delete; + Exporter3MF& operator=(Exporter3MF&&) = delete; + bool addMesh(const char* name, const MeshObject& mesh) override; /*! * \brief SetForceModel @@ -222,6 +249,11 @@ public: /// Writes AMF footer ~ExporterAMF() override; + ExporterAMF(const ExporterAMF&) = delete; + ExporterAMF(ExporterAMF&&) = delete; + ExporterAMF& operator=(const ExporterAMF&) = delete; + ExporterAMF& operator=(ExporterAMF&&) = delete; + bool addMesh(const char* name, const MeshObject& mesh) override; private: diff --git a/src/Mod/Mesh/App/Facet.cpp b/src/Mod/Mesh/App/Facet.cpp index c4535f1edc..bcbf6f8c49 100644 --- a/src/Mod/Mesh/App/Facet.cpp +++ b/src/Mod/Mesh/App/Facet.cpp @@ -31,7 +31,9 @@ using namespace Mesh; -Facet::Facet(const MeshCore::MeshFacet& face, const MeshObject* obj, MeshCore::FacetIndex index) +Facet::Facet(const MeshCore::MeshFacet& face, // NOLINT + const MeshObject* obj, + MeshCore::FacetIndex index) : Index(index) , Mesh(obj) { @@ -47,7 +49,18 @@ Facet::Facet(const MeshCore::MeshFacet& face, const MeshObject* obj, MeshCore::F } } -Facet::Facet(const Facet& f) +Facet::Facet(const Facet& f) // NOLINT + : MeshCore::MeshGeomFacet(f) + , Index(f.Index) + , Mesh(f.Mesh) +{ + for (int i = 0; i < 3; i++) { + PIndex[i] = f.PIndex[i]; + NIndex[i] = f.NIndex[i]; + } +} + +Facet::Facet(Facet&& f) // NOLINT : MeshCore::MeshGeomFacet(f) , Index(f.Index) , Mesh(f.Mesh) @@ -60,7 +73,7 @@ Facet::Facet(const Facet& f) Facet::~Facet() = default; -void Facet::operator=(const Facet& f) +Facet& Facet::operator=(const Facet& f) { MeshCore::MeshGeomFacet::operator=(f); Mesh = f.Mesh; @@ -69,6 +82,21 @@ void Facet::operator=(const Facet& f) PIndex[i] = f.PIndex[i]; NIndex[i] = f.NIndex[i]; } + + return *this; +} + +Facet& Facet::operator=(Facet&& f) +{ + MeshCore::MeshGeomFacet::operator=(f); + Mesh = f.Mesh; + Index = f.Index; + for (int i = 0; i < 3; i++) { + PIndex[i] = f.PIndex[i]; + NIndex[i] = f.NIndex[i]; + } + + return *this; } Edge Facet::getEdge(int index) const diff --git a/src/Mod/Mesh/App/Facet.h b/src/Mod/Mesh/App/Facet.h index 2ca4ca038a..fd850fe0f8 100644 --- a/src/Mod/Mesh/App/Facet.h +++ b/src/Mod/Mesh/App/Facet.h @@ -43,13 +43,15 @@ public: const MeshObject* obj = nullptr, MeshCore::FacetIndex index = MeshCore::FACET_INDEX_MAX); Facet(const Facet& f); + Facet(Facet&& f); ~Facet(); bool isBound() const { return Index != MeshCore::FACET_INDEX_MAX; } - void operator=(const Facet& f); + Facet& operator=(const Facet& f); + Facet& operator=(Facet&& f); Edge getEdge(int) const; MeshCore::FacetIndex Index; diff --git a/src/Mod/Mesh/App/FacetPyImp.cpp b/src/Mod/Mesh/App/FacetPyImp.cpp index eb8ca46032..61d85a6e65 100644 --- a/src/Mod/Mesh/App/FacetPyImp.cpp +++ b/src/Mod/Mesh/App/FacetPyImp.cpp @@ -25,13 +25,11 @@ #include #include -// clang-format off #include "Facet.h" #include "FacetPy.h" #include "FacetPy.cpp" #include "EdgePy.h" #include "Mesh.h" -// clang-format on using namespace Mesh; diff --git a/src/Mod/Mesh/App/FeatureMeshSetOperations.cpp b/src/Mod/Mesh/App/FeatureMeshSetOperations.cpp index 7ba08f5c84..a764763d0c 100644 --- a/src/Mod/Mesh/App/FeatureMeshSetOperations.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSetOperations.cpp @@ -69,7 +69,7 @@ App::DocumentObjectExecReturn* SetOperations::execute() std::unique_ptr pcKernel(new MeshObject()); // Result Meshkernel - MeshCore::SetOperations::OperationType type; + MeshCore::SetOperations::OperationType type {}; string ot(OperationType.getValue()); if (ot == "union") { type = MeshCore::SetOperations::Union; diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 65e65dd4aa..6c3df65f05 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -63,13 +63,13 @@ TYPESYSTEM_SOURCE(Mesh::MeshSegment, Data::Segment) MeshObject::MeshObject() = default; -MeshObject::MeshObject(const MeshCore::MeshKernel& Kernel) +MeshObject::MeshObject(const MeshCore::MeshKernel& Kernel) // NOLINT : _kernel(Kernel) { // copy the mesh structure } -MeshObject::MeshObject(const MeshCore::MeshKernel& Kernel, const Base::Matrix4D& Mtrx) +MeshObject::MeshObject(const MeshCore::MeshKernel& Kernel, const Base::Matrix4D& Mtrx) // NOLINT : _Mtrx(Mtrx) , _kernel(Kernel) { @@ -84,6 +84,14 @@ MeshObject::MeshObject(const MeshObject& mesh) copySegments(mesh); } +MeshObject::MeshObject(MeshObject&& mesh) + : _Mtrx(mesh._Mtrx) + , _kernel(mesh._kernel) +{ + // copy the mesh structure + copySegments(mesh); +} + MeshObject::~MeshObject() = default; std::vector MeshObject::getElementTypes() const @@ -207,7 +215,7 @@ void MeshObject::swapSegments(MeshObject& mesh) }); } -void MeshObject::operator=(const MeshObject& mesh) +MeshObject& MeshObject::operator=(const MeshObject& mesh) { if (this != &mesh) { // copy the mesh structure @@ -215,6 +223,20 @@ void MeshObject::operator=(const MeshObject& mesh) this->_kernel = mesh._kernel; copySegments(mesh); } + + return *this; +} + +MeshObject& MeshObject::operator=(MeshObject&& mesh) +{ + if (this != &mesh) { + // copy the mesh structure + setTransform(mesh._Mtrx); + this->_kernel = mesh._kernel; + copySegments(mesh); + } + + return *this; } void MeshObject::setKernel(const MeshCore::MeshKernel& m) @@ -294,7 +316,7 @@ double MeshObject::getVolume() const Base::Vector3d MeshObject::getPoint(PointIndex index) const { - Base::Vector3f vertf = _kernel.GetPoint(index); + MeshCore::MeshPoint vertf = _kernel.GetPoint(index); Base::Vector3d vertd(vertf.x, vertf.y, vertf.z); vertd = _Mtrx * vertd; return vertd; @@ -337,7 +359,7 @@ void MeshObject::getFaces(std::vector& Points, const MeshCore::MeshFacetArray& ary = _kernel.GetFacets(); Topo.reserve(ctfacets); for (unsigned long i = 0; i < ctfacets; i++) { - Facet face; + Facet face {}; face.I1 = (unsigned int)ary[i]._aulPoints[0]; face.I2 = (unsigned int)ary[i]._aulPoints[1]; face.I3 = (unsigned int)ary[i]._aulPoints[2]; @@ -1002,7 +1024,7 @@ void MeshObject::offsetSpecial(float fSize, float zmax, float zmin) // go through all the vertex normals for (std::vector::iterator It = normals.begin(); It != normals.end(); ++It, i++) { - Base::Vector3f Pnt = _kernel.GetPoint(i); + auto Pnt = _kernel.GetPoint(i); if (Pnt.z < zmax && Pnt.z > zmin) { Pnt.z = 0; _kernel.MovePoint(i, Pnt.Normalize() * fSize); @@ -1116,7 +1138,7 @@ void MeshObject::cut(const Base::Polygon2d& polygon2d, MeshCore::MeshAlgorithm meshAlg(kernel); std::vector check; - bool inner; + bool inner {}; switch (type) { case INNER: inner = true; @@ -2124,11 +2146,17 @@ MeshObject::const_point_iterator::const_point_iterator(const MeshObject* mesh, P MeshObject::const_point_iterator::const_point_iterator(const MeshObject::const_point_iterator& fi) = default; +MeshObject::const_point_iterator::const_point_iterator(MeshObject::const_point_iterator&& fi) = + default; + MeshObject::const_point_iterator::~const_point_iterator() = default; MeshObject::const_point_iterator& MeshObject::const_point_iterator::operator=(const MeshObject::const_point_iterator& pi) = default; +MeshObject::const_point_iterator& +MeshObject::const_point_iterator::operator=(MeshObject::const_point_iterator&& pi) = default; + void MeshObject::const_point_iterator::dereference() { this->_point.x = _p_it->x; @@ -2185,11 +2213,17 @@ MeshObject::const_facet_iterator::const_facet_iterator(const MeshObject* mesh, F MeshObject::const_facet_iterator::const_facet_iterator(const MeshObject::const_facet_iterator& fi) = default; +MeshObject::const_facet_iterator::const_facet_iterator(MeshObject::const_facet_iterator&& fi) = + default; + MeshObject::const_facet_iterator::~const_facet_iterator() = default; MeshObject::const_facet_iterator& MeshObject::const_facet_iterator::operator=(const MeshObject::const_facet_iterator& fi) = default; +MeshObject::const_facet_iterator& +MeshObject::const_facet_iterator::operator=(MeshObject::const_facet_iterator&& fi) = default; + void MeshObject::const_facet_iterator::dereference() { this->_facet.MeshCore::MeshGeomFacet::operator=(*_f_it); diff --git a/src/Mod/Mesh/App/Mesh.h b/src/Mod/Mesh/App/Mesh.h index 3e68073de8..66bbb678c3 100644 --- a/src/Mod/Mesh/App/Mesh.h +++ b/src/Mod/Mesh/App/Mesh.h @@ -114,9 +114,11 @@ public: explicit MeshObject(const MeshCore::MeshKernel& Kernel); explicit MeshObject(const MeshCore::MeshKernel& Kernel, const Base::Matrix4D& Mtrx); MeshObject(const MeshObject&); + MeshObject(MeshObject&&); ~MeshObject() override; - void operator=(const MeshObject&); + MeshObject& operator=(const MeshObject&); + MeshObject& operator=(MeshObject&&); /** @name Subelement management */ //@{ @@ -380,9 +382,11 @@ public: public: const_point_iterator(const MeshObject*, PointIndex index); const_point_iterator(const const_point_iterator& pi); + const_point_iterator(const_point_iterator&& pi); ~const_point_iterator(); const_point_iterator& operator=(const const_point_iterator& fi); + const_point_iterator& operator=(const_point_iterator&& fi); const MeshPoint& operator*(); const MeshPoint* operator->(); bool operator==(const const_point_iterator& fi) const; @@ -402,9 +406,11 @@ public: public: const_facet_iterator(const MeshObject*, FacetIndex index); const_facet_iterator(const const_facet_iterator& fi); + const_facet_iterator(const_facet_iterator&& fi); ~const_facet_iterator(); const_facet_iterator& operator=(const const_facet_iterator& fi); + const_facet_iterator& operator=(const_facet_iterator&& fi); Mesh::Facet& operator*(); Mesh::Facet* operator->(); bool operator==(const const_facet_iterator& fi) const; diff --git a/src/Mod/Mesh/App/MeshPointPyImp.cpp b/src/Mod/Mesh/App/MeshPointPyImp.cpp index 966483c7f3..00f0509655 100644 --- a/src/Mod/Mesh/App/MeshPointPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPointPyImp.cpp @@ -41,7 +41,7 @@ using namespace Mesh; std::string MeshPointPy::representation() const { MeshPointPy::PointerType ptr = getMeshPointPtr(); - Base::Vector3d vec = *ptr; + Base::Vector3d vec = *ptr; // NOLINT std::stringstream str; str << "MeshPoint ("; diff --git a/src/Mod/Mesh/App/MeshProperties.cpp b/src/Mod/Mesh/App/MeshProperties.cpp index 761827f579..bcfa6cbb87 100644 --- a/src/Mod/Mesh/App/MeshProperties.cpp +++ b/src/Mod/Mesh/App/MeshProperties.cpp @@ -30,11 +30,11 @@ #include #include "Core/Iterator.h" -#include "Core/MeshIO.h" #include "Core/MeshKernel.h" +#include "Core/MeshIO.h" -#include "Mesh.h" #include "MeshProperties.h" +#include "Mesh.h" #include "MeshPy.h" @@ -645,7 +645,7 @@ void PropertyMaterial::RestoreDocFile(Base::Reader& reader) str >> count; color.resize(count); for (auto& it : color) { - uint32_t value; // must be 32 bit long + uint32_t value {}; // must be 32 bit long str >> value; it.setPackedValue(value); } @@ -656,7 +656,7 @@ void PropertyMaterial::RestoreDocFile(Base::Reader& reader) str >> count; value.resize(count); for (auto& it : value) { - float valueF; + float valueF {}; str >> valueF; it = valueF; } diff --git a/src/Mod/Mesh/App/MeshProperties.h b/src/Mod/Mesh/App/MeshProperties.h index 123312e8e7..d30048f24f 100644 --- a/src/Mod/Mesh/App/MeshProperties.h +++ b/src/Mod/Mesh/App/MeshProperties.h @@ -100,8 +100,10 @@ private: /** Curvature information. */ struct MeshExport CurvatureInfo { - float fMaxCurvature, fMinCurvature; - Base::Vector3f cMaxCurvDir, cMinCurvDir; + float fMaxCurvature {0.0F}; + float fMinCurvature {0.0F}; + Base::Vector3f cMaxCurvDir; + Base::Vector3f cMinCurvDir; }; /** The Curvature property class. @@ -236,6 +238,11 @@ public: PropertyMeshKernel(); ~PropertyMeshKernel() override; + PropertyMeshKernel(const PropertyMeshKernel&) = delete; + PropertyMeshKernel(PropertyMeshKernel&&) = delete; + PropertyMeshKernel& operator=(const PropertyMeshKernel&) = delete; + PropertyMeshKernel& operator=(PropertyMeshKernel&&) = delete; + /** @name Getter/setter */ //@{ /** This method references the passed mesh object and takes possession of it, diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index 7fb3bfdae0..7082c2ef30 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -37,14 +37,12 @@ #include "Core/Smoothing.h" #include "Core/Triangulation.h" -// clang-format off #include "Mesh.h" #include "MeshPy.h" #include "MeshPointPy.h" #include "FacetPy.h" #include "MeshPy.cpp" #include "MeshProperties.h" -// clang-format on using namespace Mesh; @@ -150,7 +148,7 @@ PyObject* MeshPy::copy(PyObject* args) PyObject* MeshPy::read(PyObject* args, PyObject* kwds) { - char* Name; + char* Name {}; static const std::array keywords_path {"Filename", nullptr}; if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "et", keywords_path, "utf-8", &Name)) { getMeshObjectPtr()->load(Name); @@ -180,8 +178,8 @@ PyObject* MeshPy::read(PyObject* args, PyObject* kwds) ext["APLY"] = MeshCore::MeshIO::APLY; ext["PY"] = MeshCore::MeshIO::PY; - PyObject* input; - char* Ext; + PyObject* input {}; + char* Ext {}; static const std::array keywords_stream {"Stream", "Format", nullptr}; if (Base::Wrapped_ParseTupleAndKeywords(args, kwds, "Os", keywords_stream, &input, &Ext)) { std::string fmt(Ext); @@ -205,7 +203,7 @@ PyObject* MeshPy::read(PyObject* args, PyObject* kwds) PyObject* MeshPy::write(PyObject* args, PyObject* kwds) { - char* Name; + char* Name = nullptr; char* Ext = nullptr; char* ObjName = nullptr; PyObject* List = nullptr; @@ -360,7 +358,7 @@ PyObject* MeshPy::writeInventor(PyObject* args) PyObject* MeshPy::offset(PyObject* args) { - float Float; + float Float {}; if (!PyArg_ParseTuple(args, "f", &Float)) { return nullptr; } @@ -376,7 +374,7 @@ PyObject* MeshPy::offset(PyObject* args) PyObject* MeshPy::offsetSpecial(PyObject* args) { - float Float, zmin, zmax; + float Float {}, zmin {}, zmax {}; if (!PyArg_ParseTuple(args, "fff", &Float, &zmin, &zmax)) { return nullptr; } @@ -392,7 +390,7 @@ PyObject* MeshPy::offsetSpecial(PyObject* args) PyObject* MeshPy::crossSections(PyObject* args) { - PyObject* obj; + PyObject* obj {}; PyObject* poly = Py_False; float min_eps = 1.0e-2f; if (!PyArg_ParseTuple(args, "O|fO!", &obj, &min_eps, &PyBool_Type, &poly)) { @@ -454,8 +452,8 @@ PyObject* MeshPy::crossSections(PyObject* args) PyObject* MeshPy::unite(PyObject* args) { - MeshPy* pcObject; - PyObject* pcObj; + MeshPy* pcObject {}; + PyObject* pcObj {}; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) { return nullptr; } @@ -474,8 +472,8 @@ PyObject* MeshPy::unite(PyObject* args) PyObject* MeshPy::intersect(PyObject* args) { - MeshPy* pcObject; - PyObject* pcObj; + MeshPy* pcObject {}; + PyObject* pcObj {}; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) { return nullptr; } @@ -494,8 +492,8 @@ PyObject* MeshPy::intersect(PyObject* args) PyObject* MeshPy::difference(PyObject* args) { - MeshPy* pcObject; - PyObject* pcObj; + MeshPy* pcObject {}; + PyObject* pcObj {}; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) { return nullptr; } @@ -514,8 +512,8 @@ PyObject* MeshPy::difference(PyObject* args) PyObject* MeshPy::inner(PyObject* args) { - MeshPy* pcObject; - PyObject* pcObj; + MeshPy* pcObject {}; + PyObject* pcObj {}; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) { return nullptr; } @@ -534,8 +532,8 @@ PyObject* MeshPy::inner(PyObject* args) PyObject* MeshPy::outer(PyObject* args) { - MeshPy* pcObject; - PyObject* pcObj; + MeshPy* pcObject {}; + PyObject* pcObj {}; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &pcObj)) { return nullptr; } @@ -554,7 +552,7 @@ PyObject* MeshPy::outer(PyObject* args) PyObject* MeshPy::section(PyObject* args, PyObject* kwds) { - PyObject* pcObj; + PyObject* pcObj {}; PyObject* connectLines = Py_True; float fMinDist = 0.0001f; @@ -603,7 +601,7 @@ PyObject* MeshPy::coarsen(PyObject* args) PyObject* MeshPy::translate(PyObject* args) { - float x, y, z; + float x {}, y {}, z {}; if (!PyArg_ParseTuple(args, "fff", &x, &y, &z)) { return nullptr; } @@ -621,7 +619,7 @@ PyObject* MeshPy::translate(PyObject* args) PyObject* MeshPy::rotate(PyObject* args) { - double x, y, z; + double x {}, y {}, z {}; if (!PyArg_ParseTuple(args, "ddd", &x, &y, &z)) { return nullptr; } @@ -641,7 +639,7 @@ PyObject* MeshPy::rotate(PyObject* args) PyObject* MeshPy::transform(PyObject* args) { - PyObject* mat; + PyObject* mat {}; if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type), &mat)) { return nullptr; } @@ -679,7 +677,7 @@ PyObject* MeshPy::getEigenSystem(PyObject* args) PyObject* MeshPy::addFacet(PyObject* args) { - double x1, y1, z1, x2, y2, z2, x3, y3, z3; + double x1 {}, y1 {}, z1 {}, x2 {}, y2 {}, z2 {}, x3 {}, y3 {}, z3 {}; if (PyArg_ParseTuple(args, "ddddddddd", &x1, &y1, &z1, &x2, &y2, &z2, &x3, &y3, &z3)) { getMeshObjectPtr()->addFacet( MeshCore::MeshGeomFacet(Base::Vector3f((float)x1, (float)y1, (float)z1), @@ -689,7 +687,7 @@ PyObject* MeshPy::addFacet(PyObject* args) } PyErr_Clear(); - PyObject *v1, *v2, *v3; + PyObject *v1 {}, *v2 {}, *v3 {}; if (PyArg_ParseTuple(args, "O!O!O!", &(Base::VectorPy::Type), @@ -709,7 +707,7 @@ PyObject* MeshPy::addFacet(PyObject* args) } PyErr_Clear(); - PyObject* f; + PyObject* f {}; if (PyArg_ParseTuple(args, "O!", &(Mesh::FacetPy::Type), &f)) { Mesh::FacetPy* face = static_cast(f); getMeshObjectPtr()->addFacet(*face->getFacetPtr()); @@ -722,7 +720,7 @@ PyObject* MeshPy::addFacet(PyObject* args) PyObject* MeshPy::addFacets(PyObject* args) { - PyObject* list; + PyObject* list {}; if (PyArg_ParseTuple(args, "O!", &PyList_Type, &list)) { Py::List list_f(list); Py::Type vVType(Base::getTypeAsObject(&Base::VectorPy::Type)); @@ -824,7 +822,7 @@ PyObject* MeshPy::addFacets(PyObject* args) PyObject* MeshPy::removeFacets(PyObject* args) { - PyObject* list; + PyObject* list {}; if (!PyArg_ParseTuple(args, "O", &list)) { return nullptr; } @@ -873,7 +871,7 @@ PyObject* MeshPy::rebuildNeighbourHood(PyObject* args) PyObject* MeshPy::addMesh(PyObject* args) { - PyObject* mesh; + PyObject* mesh {}; if (!PyArg_ParseTuple(args, "O!", &(MeshPy::Type), &mesh)) { return nullptr; } @@ -889,8 +887,8 @@ PyObject* MeshPy::addMesh(PyObject* args) PyObject* MeshPy::setPoint(PyObject* args) { - unsigned long index; - PyObject* pnt; + unsigned long index {}; + PyObject* pnt {}; if (!PyArg_ParseTuple(args, "kO!", &index, &(Base::VectorPy::Type), &pnt)) { return nullptr; } @@ -906,7 +904,7 @@ PyObject* MeshPy::setPoint(PyObject* args) PyObject* MeshPy::movePoint(PyObject* args) { - unsigned long index; + unsigned long index {}; Base::Vector3d vec; do { @@ -917,7 +915,7 @@ PyObject* MeshPy::movePoint(PyObject* args) } PyErr_Clear(); // set by PyArg_ParseTuple() - PyObject* object; + PyObject* object {}; if (PyArg_ParseTuple(args, "kO!", &index, &(Base::VectorPy::Type), &object)) { vec = *(static_cast(object)->getVectorPtr()); break; @@ -952,7 +950,7 @@ PyObject* MeshPy::getPointNormals(PyObject* args) PyObject* MeshPy::addSegment(PyObject* args) { - PyObject* pylist; + PyObject* pylist {}; if (!PyArg_ParseTuple(args, "O", &pylist)) { return nullptr; } @@ -985,7 +983,7 @@ PyObject* MeshPy::countSegments(PyObject* args) PyObject* MeshPy::getSegment(PyObject* args) { - unsigned long index; + unsigned long index {}; if (!PyArg_ParseTuple(args, "k", &index)) { return nullptr; } @@ -1055,7 +1053,7 @@ PyObject* MeshPy::getPointSelection(PyObject* args) PyObject* MeshPy::meshFromSegment(PyObject* args) { - PyObject* list; + PyObject* list {}; if (!PyArg_ParseTuple(args, "O", &list)) { return nullptr; } @@ -1353,7 +1351,7 @@ PyObject* MeshPy::countComponents(PyObject* args) PyObject* MeshPy::removeComponents(PyObject* args) { - unsigned long count; + unsigned long count {}; if (!PyArg_ParseTuple(args, "k", &count)) { return nullptr; } @@ -1371,7 +1369,7 @@ PyObject* MeshPy::removeComponents(PyObject* args) PyObject* MeshPy::fillupHoles(PyObject* args) { - unsigned long len; + unsigned long len {}; int level = 0; float max_area = 0.0f; if (!PyArg_ParseTuple(args, "k|if", &len, &level, &max_area)) { @@ -1434,7 +1432,7 @@ PyObject* MeshPy::fixCaps(PyObject* args) PyObject* MeshPy::fixDeformations(PyObject* args) { - float fMaxAngle; + float fMaxAngle {}; float fEpsilon = MeshCore::MeshDefinitions::_fMinPointDistanceP2; if (!PyArg_ParseTuple(args, "f|f", &fMaxAngle, &fEpsilon)) { return nullptr; @@ -1512,7 +1510,7 @@ PyObject* MeshPy::refine(PyObject* args) PyObject* MeshPy::removeNeedles(PyObject* args) { - float length; + float length {}; if (!PyArg_ParseTuple(args, "f", &length)) { return nullptr; } @@ -1609,8 +1607,8 @@ PyObject* MeshPy::splitEdges(PyObject* args) PyObject* MeshPy::splitEdge(PyObject* args) { - unsigned long facet, neighbour; - PyObject* vertex; + unsigned long facet {}, neighbour {}; + PyObject* vertex {}; if (!PyArg_ParseTuple(args, "kkO!", &facet, &neighbour, &Base::VectorPy::Type, &vertex)) { return nullptr; } @@ -1647,9 +1645,9 @@ PyObject* MeshPy::splitEdge(PyObject* args) PyObject* MeshPy::splitFacet(PyObject* args) { - unsigned long facet; - PyObject* vertex1; - PyObject* vertex2; + unsigned long facet {}; + PyObject* vertex1 {}; + PyObject* vertex2 {}; if (!PyArg_ParseTuple(args, "kO!O!", &facet, @@ -1685,7 +1683,7 @@ PyObject* MeshPy::splitFacet(PyObject* args) PyObject* MeshPy::swapEdge(PyObject* args) { - unsigned long facet, neighbour; + unsigned long facet {}, neighbour {}; if (!PyArg_ParseTuple(args, "kk", &facet, &neighbour)) { return nullptr; } @@ -1718,7 +1716,7 @@ PyObject* MeshPy::swapEdge(PyObject* args) PyObject* MeshPy::collapseEdge(PyObject* args) { - unsigned long facet, neighbour; + unsigned long facet {}, neighbour {}; if (!PyArg_ParseTuple(args, "kk", &facet, &neighbour)) { return nullptr; } @@ -1751,7 +1749,7 @@ PyObject* MeshPy::collapseEdge(PyObject* args) PyObject* MeshPy::collapseFacet(PyObject* args) { - unsigned long facet; + unsigned long facet {}; if (!PyArg_ParseTuple(args, "k", &facet)) { return nullptr; } @@ -1772,8 +1770,8 @@ PyObject* MeshPy::collapseFacet(PyObject* args) PyObject* MeshPy::insertVertex(PyObject* args) { - unsigned long facet; - PyObject* vertex; + unsigned long facet {}; + PyObject* vertex {}; if (!PyArg_ParseTuple(args, "kO!", &facet, &Base::VectorPy::Type, &vertex)) { return nullptr; } @@ -1798,8 +1796,8 @@ PyObject* MeshPy::insertVertex(PyObject* args) PyObject* MeshPy::snapVertex(PyObject* args) { - unsigned long facet; - PyObject* vertex; + unsigned long facet {}; + PyObject* vertex {}; if (!PyArg_ParseTuple(args, "kO!", &facet, &Base::VectorPy::Type, &vertex)) { return nullptr; } @@ -1858,8 +1856,8 @@ PyObject* MeshPy::collapseFacets(PyObject* args) PyObject* MeshPy::foraminate(PyObject* args) { - PyObject* pnt_p; - PyObject* dir_p; + PyObject* pnt_p {}; + PyObject* dir_p {}; double maxAngle = MeshCore::Mathd::PI; if (!PyArg_ParseTuple(args, "OO|d", &pnt_p, &dir_p, &maxAngle)) { return nullptr; @@ -1890,8 +1888,8 @@ PyObject* MeshPy::foraminate(PyObject* args) PyObject* MeshPy::cut(PyObject* args) { - PyObject* poly; - int mode; + PyObject* poly {}; + int mode {}; if (!PyArg_ParseTuple(args, "Oi", &poly, &mode)) { return nullptr; } @@ -1926,8 +1924,8 @@ PyObject* MeshPy::cut(PyObject* args) PyObject* MeshPy::trim(PyObject* args) { - PyObject* poly; - int mode; + PyObject* poly {}; + int mode {}; if (!PyArg_ParseTuple(args, "Oi", &poly, &mode)) { return nullptr; } @@ -1962,7 +1960,7 @@ PyObject* MeshPy::trim(PyObject* args) PyObject* MeshPy::trimByPlane(PyObject* args) { - PyObject *base, *norm; + PyObject *base {}, *norm {}; if (!PyArg_ParseTuple(args, "O!O!", &Base::VectorPy::Type, @@ -2046,7 +2044,7 @@ PyObject* MeshPy::smooth(PyObject* args, PyObject* kwds) PyObject* MeshPy::decimate(PyObject* args) { - float fTol, fRed; + float fTol {}, fRed {}; if (PyArg_ParseTuple(args, "ff", &fTol, &fRed)) { PY_TRY { @@ -2058,7 +2056,7 @@ PyObject* MeshPy::decimate(PyObject* args) } PyErr_Clear(); - int targetSize; + int targetSize {}; if (PyArg_ParseTuple(args, "i", &targetSize)) { PY_TRY { @@ -2076,8 +2074,8 @@ PyObject* MeshPy::decimate(PyObject* args) PyObject* MeshPy::nearestFacetOnRay(PyObject* args) { - PyObject* pnt_p; - PyObject* dir_p; + PyObject* pnt_p {}; + PyObject* dir_p {}; double maxAngle = MeshCore::Mathd::PI; if (!PyArg_ParseTuple(args, "OO|d", &pnt_p, &dir_p, &maxAngle)) { return nullptr; @@ -2107,7 +2105,7 @@ PyObject* MeshPy::nearestFacetOnRay(PyObject* args) PyObject* MeshPy::getPlanarSegments(PyObject* args) { - float dev; + float dev {}; unsigned long minFacets = 0; if (!PyArg_ParseTuple(args, "f|k", &dev, &minFacets)) { return nullptr; @@ -2132,14 +2130,14 @@ PyObject* MeshPy::getPlanarSegments(PyObject* args) PyObject* MeshPy::getSegmentsOfType(PyObject* args) { - char* type; - float dev; + char* type {}; + float dev {}; unsigned long minFacets = 0; if (!PyArg_ParseTuple(args, "sf|k", &type, &dev, &minFacets)) { return nullptr; } - Mesh::MeshObject::GeometryType geoType; + Mesh::MeshObject::GeometryType geoType {}; if (strcmp(type, "Plane") == 0) { geoType = Mesh::MeshObject::PLANE; } @@ -2172,7 +2170,7 @@ PyObject* MeshPy::getSegmentsOfType(PyObject* args) PyObject* MeshPy::getSegmentsByCurvature(PyObject* args) { - PyObject* l; + PyObject* l {}; if (!PyArg_ParseTuple(args, "O", &l)) { return nullptr; } diff --git a/src/Mod/Mesh/App/MeshTexture.cpp b/src/Mod/Mesh/App/MeshTexture.cpp index 3e657388c9..607131613f 100644 --- a/src/Mod/Mesh/App/MeshTexture.cpp +++ b/src/Mod/Mesh/App/MeshTexture.cpp @@ -29,8 +29,8 @@ using namespace Mesh; MeshTexture::MeshTexture(const Mesh::MeshObject& mesh, const MeshCore::Material& material) : materialRefMesh(material) + , countPointsRefMesh {mesh.countPoints()} { - countPointsRefMesh = mesh.countPoints(); unsigned long countFacets = mesh.countFacets(); if (material.binding == MeshCore::MeshIO::PER_VERTEX diff --git a/src/Mod/Mesh/App/MeshTexture.h b/src/Mod/Mesh/App/MeshTexture.h index bcc5dfc35b..88ebd0374f 100644 --- a/src/Mod/Mesh/App/MeshTexture.h +++ b/src/Mod/Mesh/App/MeshTexture.h @@ -90,7 +90,7 @@ private: } else { Base::Vector3f n; - float dist; + float dist {}; return kdTree->FindNearest(p, max_dist, n, dist); } } diff --git a/src/Mod/Mesh/Gui/AppMeshGui.cpp b/src/Mod/Mesh/Gui/AppMeshGui.cpp index c871bde735..1f338f8ae0 100644 --- a/src/Mod/Mesh/Gui/AppMeshGui.cpp +++ b/src/Mod/Mesh/Gui/AppMeshGui.cpp @@ -83,8 +83,8 @@ public: private: Py::Object convertToSTL(const Py::Tuple& args) { - char* inname; - char* outname; + char* inname {}; + char* outname {}; if (!PyArg_ParseTuple(args.ptr(), "etet", "utf-8", &inname, "utf-8", &outname)) { throw Py::Exception(); } @@ -108,7 +108,7 @@ private: } } - return Py::Boolean(ok); + return Py::Boolean(ok); // NOLINT } }; @@ -147,6 +147,7 @@ PyMOD_INIT_FUNC(MeshGui) (void)new MeshGui::CleanupHandler; } + // NOLINTBEGIN // try to instantiate flat-mesh commands try { Base::Interpreter().runString("import MeshFlatteningCommand"); @@ -162,6 +163,7 @@ PyMOD_INIT_FUNC(MeshGui) QT_TRANSLATE_NOOP("QObject", "Import-Export")); Mesh::Extension3MFFactory::addProducer(new MeshGui::ThumbnailExtensionProducer); + // NOLINTEND // clang-format off MeshGui::SoFCMeshObjectElement ::initClass(); diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index cb188c68cc..87a8d4f19b 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -465,7 +465,7 @@ CmdMeshFromGeometry::CmdMeshFromGeometry() void CmdMeshFromGeometry::activated(int) { - bool ok; + bool ok {}; double tol = QInputDialog::getDouble(Gui::getMainWindow(), QObject::tr("Meshing Tolerance"), QObject::tr("Enter tolerance for meshing geometry:"), @@ -1532,7 +1532,7 @@ void CmdMeshFillupHoles::activated(int) { std::vector meshes = getSelection().getObjectsOfType(Mesh::Feature::getClassTypeId()); - bool ok; + bool ok {}; int FillupHolesOfLength = QInputDialog::getInt(Gui::getMainWindow(), QObject::tr("Fill holes"), @@ -1797,7 +1797,7 @@ void CmdMeshScale::activated(int) return; } - bool ok; + bool ok {}; double factor = QInputDialog::getDouble(Gui::getMainWindow(), QObject::tr("Scaling"), QObject::tr("Enter scaling factor:"), diff --git a/src/Mod/Mesh/Gui/DlgDecimating.cpp b/src/Mod/Mesh/Gui/DlgDecimating.cpp index f5a5020df7..1cbf2d8f96 100644 --- a/src/Mod/Mesh/Gui/DlgDecimating.cpp +++ b/src/Mod/Mesh/Gui/DlgDecimating.cpp @@ -37,7 +37,6 @@ using namespace MeshGui; DlgDecimating::DlgDecimating(QWidget* parent, Qt::WindowFlags fl) : QWidget(parent, fl) - , numberOfTriangles(0) , ui(new Ui_DlgDecimating) { ui->setupUi(this); @@ -135,7 +134,7 @@ double DlgDecimating::reduction() const TaskDecimating::TaskDecimating() { - widget = new DlgDecimating(); + widget = new DlgDecimating(); // NOLINT Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr); taskbox->groupLayout()->addWidget(widget); diff --git a/src/Mod/Mesh/Gui/DlgDecimating.h b/src/Mod/Mesh/Gui/DlgDecimating.h index 94616ae5e6..58efb56f42 100644 --- a/src/Mod/Mesh/Gui/DlgDecimating.h +++ b/src/Mod/Mesh/Gui/DlgDecimating.h @@ -24,9 +24,9 @@ #ifndef MESHGUI_DLGDECIMATING_H #define MESHGUI_DLGDECIMATING_H +#include #include #include -#include #include namespace MeshGui @@ -49,7 +49,7 @@ private: void onCheckAbsoluteNumberToggled(bool); private: - int numberOfTriangles; + int numberOfTriangles {0}; std::unique_ptr ui; }; diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp index 5439943b03..24ef560230 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp @@ -30,20 +30,20 @@ #include #include -#include #include +#include #include +#include #include #include -#include -#include -#include #include +#include +#include #include "DlgEvaluateMeshImp.h" +#include "ui_DlgEvaluateMesh.h" #include "DlgEvaluateSettings.h" #include "ViewProviderDefects.h" -#include "ui_DlgEvaluateMesh.h" using namespace MeshCore; @@ -551,7 +551,7 @@ void DlgEvaluateMeshImp::onRepairOrientationButtonClicked() doc->openCommand(QT_TRANSLATE_NOOP("Command", "Harmonize normals")); try { Gui::Command::doCommand(Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()", + R"(App.getDocument("%s").getObject("%s").harmonizeNormals())", docName, objName); } @@ -661,16 +661,15 @@ void DlgEvaluateMeshImp::onRepairNonmanifoldsButtonClicked() Gui::Document* doc = Gui::Application::Instance->getDocument(docName); doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove non-manifolds")); try { - Gui::Command::doCommand( - Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()", - docName, - objName); + Gui::Command::doCommand(Gui::Command::App, + R"(App.getDocument("%s").getObject("%s").removeNonManifolds())", + docName, + objName); if (d->checkNonManfoldPoints) { Gui::Command::doCommand( Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifoldPoints()", + R"(App.getDocument("%s").getObject("%s").removeNonManifoldPoints())", docName, objName); } @@ -768,7 +767,7 @@ void DlgEvaluateMeshImp::onRepairIndicesButtonClicked() doc->openCommand(QT_TRANSLATE_NOOP("Command", "Fix indices")); try { Gui::Command::doCommand(Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").fixIndices()", + R"(App.getDocument("%s").getObject("%s").fixIndices())", docName, objName); } @@ -837,12 +836,11 @@ void DlgEvaluateMeshImp::onRepairDegeneratedButtonClicked() Gui::Document* doc = Gui::Application::Instance->getDocument(docName); doc->openCommand(QT_TRANSLATE_NOOP("Command", "Remove degenerated faces")); try { - Gui::Command::doCommand( - Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)", - docName, - objName, - d->epsilonDegenerated); + Gui::Command::doCommand(Gui::Command::App, + R"(App.getDocument("%s").getObject("%s").fixDegenerations(%f))", + docName, + objName, + d->epsilonDegenerated); } catch (const Base::Exception& e) { QMessageBox::warning(this, tr("Degenerations"), QString::fromLatin1(e.what())); @@ -912,7 +910,7 @@ void DlgEvaluateMeshImp::onRepairDuplicatedFacesButtonClicked() try { Gui::Command::doCommand( Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()", + R"(App.getDocument("%s").getObject("%s").removeDuplicatedFacets())", docName, objName); } @@ -982,7 +980,7 @@ void DlgEvaluateMeshImp::onRepairDuplicatedPointsButtonClicked() try { Gui::Command::doCommand( Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()", + R"(App.getDocument("%s").getObject("%s").removeDuplicatedPoints())", docName, objName); } @@ -1147,7 +1145,7 @@ void DlgEvaluateMeshImp::onRepairFoldsButtonClicked() try { Gui::Command::doCommand( Gui::Command::App, - "App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()", + R"(App.getDocument("%s").getObject("%s").removeFoldsOnSurface())", docName, objName); } @@ -1191,7 +1189,7 @@ void DlgEvaluateMeshImp::onRepairAllTogetherClicked() bool run = false; bool self = true; - int max_iter=10; + int max_iter = 10; const MeshKernel& rMesh = d->meshFeature->Mesh.getValue().getKernel(); try { do { @@ -1373,7 +1371,7 @@ bool DockEvaluateMeshImp::hasInstance() DockEvaluateMeshImp::DockEvaluateMeshImp(QWidget* parent, Qt::WindowFlags fl) : DlgEvaluateMeshImp(parent, fl) { - scrollArea = new QScrollArea(); + scrollArea = new QScrollArea(); // NOLINT scrollArea->setObjectName(QLatin1String("scrollArea")); scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setFrameShadow(QFrame::Plain); diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h index 02b99d07fc..fb43bdf3f1 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h @@ -146,7 +146,7 @@ private: * The DockEvaluateMeshImp class creates a single instance and embeds it into a dock window. * \author Werner Mayer */ -class DockEvaluateMeshImp: public DlgEvaluateMeshImp +class DockEvaluateMeshImp: public DlgEvaluateMeshImp // NOLINT { Q_OBJECT diff --git a/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp b/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp index 3ffcabc003..a250b46b4f 100644 --- a/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp +++ b/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp @@ -46,8 +46,8 @@ using namespace MeshGui; // clang-format off DlgRegularSolidImp::DlgRegularSolidImp(QWidget* parent, Qt::WindowFlags fl) - : QDialog( parent, fl ) - , ui(new Ui_DlgRegularSolid) + : QDialog(parent, fl) + , ui(new Ui_DlgRegularSolid) { ui->setupUi(this); connect(ui->createSolidButton, &QPushButton::clicked, diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index ae3f4f8252..70422e8ba2 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -29,12 +29,12 @@ #include #include #include -#include #include +#include #include "DlgSmoothing.h" -#include "Selection.h" #include "ui_DlgSmoothing.h" +#include "Selection.h" using namespace MeshGui; @@ -47,7 +47,7 @@ DlgSmoothing::DlgSmoothing(QWidget* parent) { // clang-format off ui->setupUi(this); - bg = new QButtonGroup(this); + bg = new QButtonGroup(this); //NOLINT bg->addButton(ui->radioButtonTaubin, 0); bg->addButton(ui->radioButtonLaplace, 1); @@ -151,13 +151,13 @@ SmoothingDialog::~SmoothingDialog() = default; TaskSmoothing::TaskSmoothing() { - widget = new DlgSmoothing(); + widget = new DlgSmoothing(); // NOLINT Gui::TaskView::TaskBox* taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); - selection = new Selection(); + selection = new Selection(); // NOLINT selection->setObjects( Gui::Selection().getSelectionEx(nullptr, Mesh::Feature::getClassTypeId())); Gui::Selection().clearSelection(); diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.h b/src/Mod/Mesh/Gui/DlgSmoothing.h index a1051e997f..371173f60e 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.h +++ b/src/Mod/Mesh/Gui/DlgSmoothing.h @@ -24,9 +24,9 @@ #ifndef MESHGUI_DLGSMOOTHING_H #define MESHGUI_DLGSMOOTHING_H +#include #include #include -#include #ifndef MESH_GLOBAL_H #include #endif diff --git a/src/Mod/Mesh/Gui/MeshEditor.cpp b/src/Mod/Mesh/Gui/MeshEditor.cpp index d91771439b..4393961d42 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.cpp +++ b/src/Mod/Mesh/Gui/MeshEditor.cpp @@ -23,10 +23,10 @@ #include "PreCompiled.h" #ifndef _PreComp_ -#include -#include #include #include +#include +#include #include #include @@ -51,8 +51,8 @@ #include #include #include -#include #include +#include #include "MeshEditor.h" #include "SoFCMeshObject.h" @@ -65,9 +65,8 @@ namespace sp = std::placeholders; PROPERTY_SOURCE(MeshGui::ViewProviderFace, Gui::ViewProviderDocumentObject) ViewProviderFace::ViewProviderFace() - : mesh(nullptr) - , current_index(-1) { + // NOLINTBEGIN pcCoords = new SoCoordinate3(); pcCoords->ref(); pcCoords->point.setNum(0); @@ -75,6 +74,7 @@ ViewProviderFace::ViewProviderFace() pcFaces->ref(); pcMeshPick = new SoFCMeshPickNode(); pcMeshPick->ref(); + // NOLINTEND } ViewProviderFace::~ViewProviderFace() @@ -448,12 +448,9 @@ struct NofFacetsCompare MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent) : QObject(parent) - , myMesh(nullptr) - , myNumPoints(0) - , myVertex1(0) - , myVertex2(0) , myHoleFiller(hf) { + // NOLINTBEGIN myBoundariesRoot = new SoSeparator; myBoundariesRoot->ref(); myBoundaryRoot = new SoSeparator; @@ -475,6 +472,7 @@ MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent) myVertex = new SoCoordinate3(); myBridgeRoot->addChild(myVertex); myBridgeRoot->addChild(new SoPointSet); + // NOLINTEND } MeshFillHole::~MeshFillHole() @@ -699,7 +697,7 @@ void MeshFillHole::fileHoleCallback(void* ud, SoEventCallback* n) std::map::iterator it = self->myPolygons.find(node); if (it != self->myPolygons.end()) { // now check which vertex of the polygon is closest to the ray - Mesh::PointIndex vertex_index; + Mesh::PointIndex vertex_index {}; SbVec3f closestPoint; float minDist = self->findClosestPoint(rp.getLine(), it->second, vertex_index, closestPoint); @@ -736,7 +734,7 @@ void MeshFillHole::fileHoleCallback(void* ud, SoEventCallback* n) std::map::iterator it = self->myPolygons.find(node); if (it != self->myPolygons.end()) { // now check which vertex of the polygon is closest to the ray - Mesh::PointIndex vertex_index; + Mesh::PointIndex vertex_index {}; SbVec3f closestPoint; float minDist = self->findClosestPoint(rp.getLine(), it->second, diff --git a/src/Mod/Mesh/Gui/MeshEditor.h b/src/Mod/Mesh/Gui/MeshEditor.h index a7a6ee4c62..aa06a010e2 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.h +++ b/src/Mod/Mesh/Gui/MeshEditor.h @@ -74,9 +74,9 @@ public: SoPickedPoint* getPickedPoint(const SbVec2s& pos, const Gui::View3DInventorViewer* viewer) const; - ViewProviderMesh* mesh; + ViewProviderMesh* mesh {nullptr}; std::vector index; - int current_index; + int current_index {-1}; SoCoordinate3* pcCoords; SoFaceSet* pcFaces; @@ -172,10 +172,10 @@ private: SoSeparator* myBridgeRoot; SoCoordinate3* myVertex; std::map myPolygons; - Mesh::Feature* myMesh; - int myNumPoints; - Mesh::PointIndex myVertex1; - Mesh::PointIndex myVertex2; + Mesh::Feature* myMesh {nullptr}; + int myNumPoints {0}; + Mesh::PointIndex myVertex1 {0}; + Mesh::PointIndex myVertex2 {0}; TBoundary myPolygon; MeshHoleFiller& myHoleFiller; Connection myConnection; diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index 7368e3fd77..ee54fc9eb6 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -22,9 +22,9 @@ #include "PreCompiled.h" #ifndef _PreComp_ -#include #include #include +#include #include #include @@ -44,10 +44,10 @@ #include #include #include -#include -#include -#include #include +#include +#include +#include #include "MeshSelection.h" #include "ViewProvider.h" @@ -491,7 +491,7 @@ void MeshSelection::selectGLCallback(void* ud, SoEventCallback* n) if (self->onlyVisibleTriangles) { const SbVec2s& sz = view->getSoRenderManager()->getViewportRegion().getWindowSize(); - short width, height; + short width {}, height {}; sz.getValue(width, height); std::vector pixelPoly = view->getPolygon(); SbBox2s rect; diff --git a/src/Mod/Mesh/Gui/MeshSelection.h b/src/Mod/Mesh/Gui/MeshSelection.h index a8703a4406..8ef2ad677a 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.h +++ b/src/Mod/Mesh/Gui/MeshSelection.h @@ -23,8 +23,8 @@ #ifndef MESHGUI_MESHSELECTION_H #define MESHGUI_MESHSELECTION_H -#include #include +#include #include #include @@ -49,6 +49,11 @@ public: MeshSelection(); ~MeshSelection(); + MeshSelection(const MeshSelection&) = delete; + MeshSelection(MeshSelection&&) = delete; + MeshSelection& operator=(const MeshSelection&) = delete; + MeshSelection& operator=(MeshSelection&&) = delete; + void setEnabledViewerSelection(bool); void startSelection(); diff --git a/src/Mod/Mesh/Gui/PropertyEditorMesh.cpp b/src/Mod/Mesh/Gui/PropertyEditorMesh.cpp index 11dffcf3f1..9d0e4198c4 100644 --- a/src/Mod/Mesh/Gui/PropertyEditorMesh.cpp +++ b/src/Mod/Mesh/Gui/PropertyEditorMesh.cpp @@ -35,6 +35,7 @@ PROPERTYITEM_SOURCE(MeshGui::PropertyMeshKernelItem) PropertyMeshKernelItem::PropertyMeshKernelItem() { + // NOLINTBEGIN m_p = static_cast( Gui::PropertyEditor::PropertyIntegerItem::create()); m_p->setParent(this); @@ -50,6 +51,7 @@ PropertyMeshKernelItem::PropertyMeshKernelItem() m_f->setParent(this); m_f->setPropertyName(QLatin1String("Faces")); this->appendChild(m_f); + // NOLINTEND } void PropertyMeshKernelItem::initialize() diff --git a/src/Mod/Mesh/Gui/RemeshGmsh.cpp b/src/Mod/Mesh/Gui/RemeshGmsh.cpp index 7632035553..21144686e2 100644 --- a/src/Mod/Mesh/Gui/RemeshGmsh.cpp +++ b/src/Mod/Mesh/Gui/RemeshGmsh.cpp @@ -65,7 +65,7 @@ public: } public: - Ui_RemeshGmsh ui; + Ui_RemeshGmsh ui {}; QPointer label; QPointer syntax; QProcess gmsh; @@ -176,19 +176,25 @@ void GmshWidget::accept() return; } + // clang-format off QString inpFile; QString outFile; if (writeProject(inpFile, outFile)) { // ./gmsh - -bin -2 /tmp/mesh.geo -o /tmp/best.stl QString proc = d->ui.fileChooser->fileName(); QStringList args; - args << QLatin1String("-") << QLatin1String("-bin") << QLatin1String("-2") << inpFile - << QLatin1String("-o") << outFile; + args << QLatin1String("-") + << QLatin1String("-bin") + << QLatin1String("-2") + << inpFile + << QLatin1String("-o") + << outFile; d->gmsh.start(proc, args); d->time.start(); d->ui.labelTime->setText(tr("Time:")); } + // clang-format on } void GmshWidget::readyReadStandardError() diff --git a/src/Mod/Mesh/Gui/RemeshGmsh.h b/src/Mod/Mesh/Gui/RemeshGmsh.h index c00c7fc833..be1f9d8e17 100644 --- a/src/Mod/Mesh/Gui/RemeshGmsh.h +++ b/src/Mod/Mesh/Gui/RemeshGmsh.h @@ -23,9 +23,9 @@ #ifndef MESHGUI_REMESHGMSH_H #define MESHGUI_REMESHGMSH_H +#include #include #include -#include #include #include diff --git a/src/Mod/Mesh/Gui/RemoveComponents.cpp b/src/Mod/Mesh/Gui/RemoveComponents.cpp index 3857897640..685715e2f3 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.cpp +++ b/src/Mod/Mesh/Gui/RemoveComponents.cpp @@ -37,8 +37,8 @@ using namespace MeshGui; RemoveComponents::RemoveComponents(QWidget* parent, Qt::WindowFlags fl) : QWidget(parent, fl) + , ui(new Ui_RemoveComponents) { - ui = new Ui_RemoveComponents; ui->setupUi(this); setupConnections(); ui->spSelectComp->setRange(1, INT_MAX); @@ -198,7 +198,7 @@ void RemoveComponents::reject() RemoveComponentsDialog::RemoveComponentsDialog(QWidget* parent, Qt::WindowFlags fl) : QDialog(parent, fl) { - widget = new RemoveComponents(this); + widget = new RemoveComponents(this); // NOLINT this->setWindowTitle(widget->windowTitle()); QVBoxLayout* hboxLayout = new QVBoxLayout(this); @@ -243,7 +243,7 @@ void RemoveComponentsDialog::clicked(QAbstractButton* btn) TaskRemoveComponents::TaskRemoveComponents() { - widget = new RemoveComponents(); + widget = new RemoveComponents(); // NOLINT taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/Mesh/Gui/RemoveComponents.h b/src/Mod/Mesh/Gui/RemoveComponents.h index f71c52ef31..58635b5bc4 100644 --- a/src/Mod/Mesh/Gui/RemoveComponents.h +++ b/src/Mod/Mesh/Gui/RemoveComponents.h @@ -24,11 +24,11 @@ #ifndef MESHGUI_REMOVECOMPONENTS_H #define MESHGUI_REMOVECOMPONENTS_H -#include "MeshSelection.h" +#include #include #include #include -#include +#include "MeshSelection.h" namespace MeshGui { diff --git a/src/Mod/Mesh/Gui/Segmentation.cpp b/src/Mod/Mesh/Gui/Segmentation.cpp index 434a294f53..081e09932a 100644 --- a/src/Mod/Mesh/Gui/Segmentation.cpp +++ b/src/Mod/Mesh/Gui/Segmentation.cpp @@ -41,9 +41,9 @@ using namespace MeshGui; Segmentation::Segmentation(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags fl) : QWidget(parent, fl) + , ui(new Ui_Segmentation) , myMesh(mesh) { - ui = new Ui_Segmentation; ui->setupUi(this); ui->numPln->setRange(1, INT_MAX); ui->numPln->setValue(100); @@ -158,7 +158,7 @@ void Segmentation::changeEvent(QEvent* e) TaskSegmentation::TaskSegmentation(Mesh::Feature* mesh) { - widget = new Segmentation(mesh); + widget = new Segmentation(mesh); // NOLINT taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp index c7c8acc9a1..bb1537ba07 100644 --- a/src/Mod/Mesh/Gui/SegmentationBestFit.cpp +++ b/src/Mod/Mesh/Gui/SegmentationBestFit.cpp @@ -52,7 +52,6 @@ class PlaneFitParameter: public FitParameter { public: PlaneFitParameter() = default; - ~PlaneFitParameter() override = default; std::vector getParameter(FitParameter::Points pts) const override { std::vector values; @@ -76,7 +75,6 @@ class CylinderFitParameter: public FitParameter { public: CylinderFitParameter() = default; - ~CylinderFitParameter() override = default; std::vector getParameter(FitParameter::Points pts) const override { std::vector values; @@ -142,7 +140,6 @@ class SphereFitParameter: public FitParameter { public: SphereFitParameter() = default; - ~SphereFitParameter() override = default; std::vector getParameter(FitParameter::Points pts) const override { std::vector values; @@ -169,60 +166,61 @@ ParametersDialog::ParametersDialog(std::vector& val, : QDialog(parent) , values(val) , fitParameter(fitPar) - , parameter(par) + , parameter(std::move(par)) , myMesh(mesh) { this->setWindowTitle(tr("Surface fit")); - QGridLayout* gridLayout; + QGridLayout* gridLayout {}; gridLayout = new QGridLayout(this); - QGroupBox* groupBox; + QGroupBox* groupBox {}; groupBox = new QGroupBox(this); groupBox->setTitle(tr("Parameters")); gridLayout->addWidget(groupBox, 0, 0, 1, 1); - QGroupBox* selectBox; + QGroupBox* selectBox {}; selectBox = new QGroupBox(this); selectBox->setTitle(tr("Selection")); gridLayout->addWidget(selectBox, 1, 0, 1, 1); - QVBoxLayout* selectLayout; + QVBoxLayout* selectLayout {}; selectLayout = new QVBoxLayout(selectBox); - QPushButton* regionButton; + QPushButton* regionButton {}; regionButton = new QPushButton(this); regionButton->setText(tr("Region")); regionButton->setObjectName(QString::fromLatin1("region")); selectLayout->addWidget(regionButton); - QPushButton* singleButton; + QPushButton* singleButton {}; singleButton = new QPushButton(this); singleButton->setText(tr("Triangle")); singleButton->setObjectName(QString::fromLatin1("single")); selectLayout->addWidget(singleButton); - QPushButton* clearButton; + QPushButton* clearButton {}; clearButton = new QPushButton(this); clearButton->setText(tr("Clear")); clearButton->setObjectName(QString::fromLatin1("clear")); selectLayout->addWidget(clearButton); - QPushButton* computeButton; + QPushButton* computeButton {}; computeButton = new QPushButton(this); computeButton->setText(tr("Compute")); computeButton->setObjectName(QString::fromLatin1("compute")); gridLayout->addWidget(computeButton, 2, 0, 1, 1); - QDialogButtonBox* buttonBox; + QDialogButtonBox* buttonBox {}; buttonBox = new QDialogButtonBox(this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); gridLayout->addWidget(buttonBox, 3, 0, 1, 1); int index = 0; - QGridLayout* layout; + QGridLayout* layout {}; layout = new QGridLayout(groupBox); + groupBox->setLayout(layout); for (const auto& it : parameter) { QLabel* label = new QLabel(groupBox); label->setText(it.first); @@ -331,9 +329,9 @@ void ParametersDialog::reject() SegmentationBestFit::SegmentationBestFit(Mesh::Feature* mesh, QWidget* parent, Qt::WindowFlags fl) : QWidget(parent, fl) + , ui(new Ui_SegmentationBestFit) , myMesh(mesh) { - ui = new Ui_SegmentationBestFit; ui->setupUi(this); setupConnections(); @@ -453,7 +451,7 @@ void SegmentationBestFit::accept() std::vector segm; if (ui->groupBoxCyl->isChecked()) { - MeshCore::AbstractSurfaceFit* fitter; + MeshCore::AbstractSurfaceFit* fitter {}; if (cylinderParameter.size() == 7) { std::vector& p = cylinderParameter; fitter = new MeshCore::CylinderSurfaceFit(Base::Vector3f(p[0], p[1], p[2]), @@ -470,7 +468,7 @@ void SegmentationBestFit::accept() ui->tolCyl->value())); } if (ui->groupBoxSph->isChecked()) { - MeshCore::AbstractSurfaceFit* fitter; + MeshCore::AbstractSurfaceFit* fitter {}; if (sphereParameter.size() == 4) { std::vector& p = sphereParameter; fitter = new MeshCore::SphereSurfaceFit(Base::Vector3f(p[0], p[1], p[2]), p[3]); @@ -485,7 +483,7 @@ void SegmentationBestFit::accept() ui->tolSph->value())); } if (ui->groupBoxPln->isChecked()) { - MeshCore::AbstractSurfaceFit* fitter; + MeshCore::AbstractSurfaceFit* fitter {}; if (planeParameter.size() == 6) { std::vector& p = planeParameter; fitter = new MeshCore::PlaneSurfaceFit(Base::Vector3f(p[0], p[1], p[2]), @@ -545,7 +543,7 @@ void SegmentationBestFit::changeEvent(QEvent* e) TaskSegmentationBestFit::TaskSegmentationBestFit(Mesh::Feature* mesh) { - widget = new SegmentationBestFit(mesh); + widget = new SegmentationBestFit(mesh); // NOLINT taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(), false, nullptr); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/Mesh/Gui/SegmentationBestFit.h b/src/Mod/Mesh/Gui/SegmentationBestFit.h index 3339129725..2a552c70ca 100644 --- a/src/Mod/Mesh/Gui/SegmentationBestFit.h +++ b/src/Mod/Mesh/Gui/SegmentationBestFit.h @@ -23,14 +23,14 @@ #ifndef MESHGUI_SEGMENTATIONBESTFIT_H #define MESHGUI_SEGMENTATIONBESTFIT_H -#include #include +#include #include #include -#include "MeshSelection.h" #include +#include "MeshSelection.h" class QDoubleSpinBox; @@ -53,7 +53,12 @@ public: std::vector points; std::vector normals; }; + FitParameter() = default; virtual ~FitParameter() = default; + FitParameter(const FitParameter&) = delete; + FitParameter(FitParameter&&) = delete; + FitParameter& operator=(const FitParameter&) = delete; + FitParameter& operator=(FitParameter&&) = delete; virtual std::vector getParameter(Points) const = 0; }; diff --git a/src/Mod/Mesh/Gui/Selection.h b/src/Mod/Mesh/Gui/Selection.h index 9df6f396a5..0e14d3f1db 100644 --- a/src/Mod/Mesh/Gui/Selection.h +++ b/src/Mod/Mesh/Gui/Selection.h @@ -23,8 +23,8 @@ #ifndef MESHGUI_SELECTION_H #define MESHGUI_SELECTION_H -#include #include +#include #include diff --git a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp index f29e59f20f..5b8fd7ce23 100644 --- a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp +++ b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp @@ -564,14 +564,14 @@ void SoFCIndexedFaceSet::drawFaces(SoGLRenderAction* action) SoMaterialBindingElement::Binding matbind = SoMaterialBindingElement::get(state); int32_t binding = (int32_t)(matbind); - const SoCoordinateElement* coords; - const SbVec3f* normals; - const int32_t* cindices; - int numindices; - const int32_t* nindices; - const int32_t* tindices; - const int32_t* mindices; - SbBool normalCacheUsed; + const SoCoordinateElement* coords = nullptr; + const SbVec3f* normals = nullptr; + const int32_t* cindices = nullptr; + int numindices = 0; + const int32_t* nindices = nullptr; + const int32_t* tindices = nullptr; + const int32_t* mindices = nullptr; + SbBool normalCacheUsed {}; SoMaterialBundle mb(action); @@ -648,7 +648,7 @@ void SoFCIndexedFaceSet::drawCoords(const SoGLCoordinateElement* const vertexlis int ct = 0; const int32_t* viptr = vertexindices; - int32_t v1, v2, v3; + int32_t v1 {}, v2 {}, v3 {}; SbVec3f dummynormal(0, 0, 1); const SbVec3f* currnormal = &dummynormal; if (normals) { @@ -720,16 +720,16 @@ void SoFCIndexedFaceSet::invalidate() void SoFCIndexedFaceSet::generateGLArrays(SoGLRenderAction* action) { - const SoCoordinateElement* coords; - const SbVec3f* normals; - const int32_t* cindices; + const SoCoordinateElement* coords = nullptr; + const SbVec3f* normals = nullptr; + const int32_t* cindices = nullptr; const SbColor* pcolors = nullptr; const float* transp = nullptr; - int numindices, numcolors = 0, numtransp = 0; - const int32_t* nindices; - const int32_t* tindices; - const int32_t* mindices; - SbBool normalCacheUsed; + int numindices = 0, numcolors = 0, numtransp = 0; + const int32_t* nindices = nullptr; + const int32_t* tindices = nullptr; + const int32_t* mindices = nullptr; + SbBool normalCacheUsed {}; SbBool sendNormals = true; @@ -1062,7 +1062,7 @@ void SoFCIndexedFaceSet::renderSelectionGeometry(const SbVec3f* coords3d) const int32_t* cindices = this->coordIndex.getValues(0); int fcnt = 0; - int32_t v1, v2, v3; + int32_t v1 {}, v2 {}, v3 {}; for (int index = 0; index < numfaces; index++, cindices++) { glLoadName(fcnt); glBegin(GL_TRIANGLES); @@ -1116,10 +1116,10 @@ void SoFCIndexedFaceSet::renderVisibleFaces(const SbVec3f* coords3d) uint32_t numfaces = this->coordIndex.getNum() / 4; const int32_t* cindices = this->coordIndex.getValues(0); - int32_t v1, v2, v3; + int32_t v1 {}, v2 {}, v3 {}; for (uint32_t index = 0; index < numfaces; index++, cindices++) { glBegin(GL_TRIANGLES); - float t; + float t {}; SbColor c; c.setPackedValue(index << 8, t); glColor3f(c[0], c[1], c[2]); diff --git a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.h b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.h index 37e762e690..a6a765bc1b 100644 --- a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.h +++ b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.h @@ -27,6 +27,7 @@ #include #include #include +#include #ifndef MESH_GLOBAL_H #include #endif @@ -42,6 +43,7 @@ using GLfloat = float; namespace MeshGui { +// NOLINTBEGIN class MeshRenderer { public: @@ -142,6 +144,7 @@ private: MeshRenderer render; GLuint* selectBuf {nullptr}; }; +// NOLINTEND } // namespace MeshGui diff --git a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp index f56cf1dd1e..426d89292e 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp @@ -38,9 +38,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -120,7 +120,7 @@ protected: return *gptr(); } - int numPutback; + int numPutback {}; numPutback = gptr() - eback(); if (numPutback > pbSize) { numPutback = pbSize; @@ -130,7 +130,7 @@ protected: int num = 0; for (int i = 0; i < bufSize; i++) { - char c; + char c {}; SbBool ok = inp->get(c); if (ok) { num++; @@ -152,7 +152,7 @@ protected: private: static const int pbSize = 4; static const int bufSize = 1024; - char buffer[bufSize + pbSize]; + char buffer[bufSize + pbSize] {}; SoInput* inp; }; @@ -166,6 +166,10 @@ public: this->rdbuf(&buf); } ~SoInputStream() override = default; + SoInputStream(const SoInputStream&) = delete; + SoInputStream(SoInputStream&&) = delete; + SoInputStream& operator=(const SoInputStream&) = delete; + SoInputStream& operator=(SoInputStream&&) = delete; private: SoInputStreambuf buf; @@ -203,7 +207,7 @@ SbBool SoSFMeshObject::readValue(SoInput* in) return true; } - int32_t countPt; + int32_t countPt {}; in->read(countPt); std::vector verts(countPt); in->readBinaryArray(&(verts[0]), countPt); @@ -221,7 +225,7 @@ SbBool SoSFMeshObject::readValue(SoInput* in) rPoints.push_back(p); } - int32_t countFt; + int32_t countFt {}; in->read(countFt); std::vector faces(countFt); in->readBinaryArray(&(faces[0]), countFt); @@ -396,7 +400,7 @@ void SoFCMeshPickNode::pick(SoPickAction* action) const SbVec3f& dir = line.getDirection(); Base::Vector3f pt(pos[0], pos[1], pos[2]); Base::Vector3f dr(dir[0], dir[1], dir[2]); - Mesh::FacetIndex index; + Mesh::FacetIndex index {}; if (alg.NearestFacetOnRay(pt, dr, *meshGrid, pt, index)) { SoPickedPoint* pp = raypick->addIntersection(SbVec3f(pt.x, pt.y, pt.z)); if (pp) { @@ -439,11 +443,11 @@ void SoFCMeshGridNode::GLRender(SoGLRenderAction* /*action*/) const SbVec3f& min = minGrid.getValue(); const SbVec3f& max = maxGrid.getValue(); const SbVec3s& len = lenGrid.getValue(); - short u, v, w; + short u {}, v {}, w {}; len.getValue(u, v, w); - float minX, minY, minZ; + float minX {}, minY {}, minZ {}; min.getValue(minX, minY, minZ); - float maxX, maxY, maxZ; + float maxX {}, maxY {}, maxZ {}; max.getValue(maxX, maxY, maxZ); float dx = (maxX - minX) / (float)u; float dy = (maxY - minY) / (float)v; @@ -1688,7 +1692,7 @@ void SoFCMeshObjectBoundary::drawLines(const Mesh::MeshObject* mesh) const const MeshCore::MeshFacetArray& rFacets = mesh->getKernel().GetFacets(); // When rendering open edges use the given line width * 3 - GLfloat lineWidth; + GLfloat lineWidth {}; glGetFloatv(GL_LINE_WIDTH, &lineWidth); glLineWidth(3.0f * lineWidth); diff --git a/src/Mod/Mesh/Gui/SoFCMeshObject.h b/src/Mod/Mesh/Gui/SoFCMeshObject.h index 8dd008c233..5ca888c3cd 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshObject.h +++ b/src/Mod/Mesh/Gui/SoFCMeshObject.h @@ -44,6 +44,7 @@ class MeshFacetGrid; namespace MeshGui { +// NOLINTBEGIN(cppcoreguidelines-special-member-functions,cppcoreguidelines-virtual-class-destructor) class MeshGuiExport SoSFMeshObject: public SoSField { using inherited = SoSField; @@ -77,7 +78,9 @@ public: protected: ~SoFCMeshObjectElement() override; - const Mesh::MeshObject* mesh; + +private: + const Mesh::MeshObject* mesh {}; }; // ------------------------------------------------------- @@ -93,7 +96,7 @@ public: SoFCMeshPickNode(); void notify(SoNotList*) override; - SoSFMeshObject mesh; + SoSFMeshObject mesh; // NOLINT void rayPick(SoRayPickAction* action) override; void pick(SoPickAction* action) override; @@ -181,7 +184,7 @@ public: static void initClass(); SoFCMeshObjectShape(); - unsigned int renderTriangleLimit; + unsigned int renderTriangleLimit; // NOLINT protected: void doAction(SoAction* action) override; @@ -299,6 +302,7 @@ protected: private: void drawLines(const Mesh::MeshObject*) const; }; +// NOLINTEND(cppcoreguidelines-special-member-functions,cppcoreguidelines-virtual-class-destructor) } // namespace MeshGui diff --git a/src/Mod/Mesh/Gui/SoPolygon.h b/src/Mod/Mesh/Gui/SoPolygon.h index 0801d99ae2..95e9352c3a 100644 --- a/src/Mod/Mesh/Gui/SoPolygon.h +++ b/src/Mod/Mesh/Gui/SoPolygon.h @@ -35,6 +35,7 @@ namespace MeshGui { +// NOLINTBEGIN class MeshGuiExport SoPolygon: public SoShape { using inherited = SoShape; @@ -60,6 +61,7 @@ protected: private: void drawPolygon(const SbVec3f*, int32_t) const; }; +// NOLINTEND } // namespace MeshGui diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index a2dbc6c431..e1759373f3 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -22,32 +22,32 @@ #include "PreCompiled.h" #ifndef _PreComp_ +#include #include #include -#include #include #include #include #include -#include #include #include #include #include #include #include +#include #include #include -#include #include #include #include #include #include -#include #include +#include #include +#include #endif #include @@ -234,6 +234,7 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMesh, Gui::ViewProviderGeometryObject) ViewProviderMesh::ViewProviderMesh() : highlightMode {HighlighMode::None} { + // NOLINTBEGIN static const char* osgroup = "Object Style"; ADD_PROPERTY_TYPE(LineTransparency, (0), osgroup, App::Prop_None, "Set line transparency."); @@ -334,6 +335,7 @@ ViewProviderMesh::ViewProviderMesh() } Coloring.setStatus(App::Property::Hidden, true); + // NOLINTEND } ViewProviderMesh::~ViewProviderMesh() @@ -850,7 +852,7 @@ bool ViewProviderMesh::createToolMesh(const std::vector& rclPoly, const Base::Vector3f& rcNormal, std::vector& aFaces) { - float fX, fY, fZ; + float fX {}, fY {}, fZ {}; SbVec3f pt1, pt2, pt3, pt4; MeshGeomFacet face; std::vector top, bottom, polygon; @@ -944,10 +946,10 @@ class MeshSplit { public: MeshSplit(ViewProviderMesh* mesh, - const std::vector& poly, + std::vector poly, const Gui::ViewVolumeProjection& proj) : mesh(mesh) - , poly(poly) + , poly(std::move(poly)) , proj(proj) {} void cutMesh() @@ -1001,7 +1003,7 @@ void ViewProviderMesh::clipMeshCallback(void* ud, SoEventCallback* n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), clipMeshCallback, ud); n->setHandled(); - Gui::SelectionRole role; + Gui::SelectionRole role {}; std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) { return; @@ -1071,7 +1073,7 @@ void ViewProviderMesh::trimMeshCallback(void* ud, SoEventCallback* n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), trimMeshCallback, ud); n->setHandled(); - Gui::SelectionRole role; + Gui::SelectionRole role {}; std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) { return; @@ -1141,7 +1143,7 @@ void ViewProviderMesh::partMeshCallback(void* ud, SoEventCallback* cb) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), partMeshCallback, ud); cb->setHandled(); - Gui::SelectionRole role; + Gui::SelectionRole role {}; std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) { return; @@ -1214,7 +1216,7 @@ void ViewProviderMesh::segmMeshCallback(void* ud, SoEventCallback* cb) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), segmMeshCallback, ud); cb->setHandled(); - Gui::SelectionRole role; + Gui::SelectionRole role {}; std::vector clPoly = view->getGLPolygon(&role); if (clPoly.size() < 3) { return; @@ -1291,7 +1293,7 @@ void ViewProviderMesh::selectGLCallback(void* ud, SoEventCallback* n) const SoEvent* ev = n->getEvent(); SbVec2f pos = clPoly[0]; - float pX, pY; + float pX {}, pY {}; pos.getValue(pX, pY); const SbVec2s& sz = view->getSoRenderManager()->getViewportRegion().getViewportSizePixels(); float fRatio = view->getSoRenderManager()->getViewportRegion().getViewportAspectRatio(); @@ -1423,7 +1425,7 @@ void ViewProviderMesh::boxZoom(const SbBox2s& box, const SbViewportRegion& vp, S { SbViewVolume vv = cam->getViewVolume(vp.getViewportAspectRatio()); - short sizeX, sizeY; + short sizeX {}, sizeY {}; box.getSize(sizeX, sizeY); SbVec2s size = vp.getViewportSizePixels(); @@ -1434,7 +1436,7 @@ void ViewProviderMesh::boxZoom(const SbBox2s& box, const SbViewportRegion& vp, S } // Get the new center in normalized pixel coordinates - short xmin, xmax, ymin, ymax; + short xmin {}, xmax {}, ymin {}, ymax {}; box.getBounds(xmin, ymin, xmax, ymax); const SbVec2f center((float)((xmin + xmax) / 2) / (float)std::max((int)(size[0] - 1), 1), (float)(size[1] - (ymin + ymax) / 2) @@ -1525,7 +1527,7 @@ std::vector ViewProviderMesh::getVisibleFacets(const SbViewpor mat->diffuseColor.setNum(count); SbColor* diffcol = mat->diffuseColor.startEditing(); for (uint32_t i = 0; i < count; i++) { - float t; + float t {}; diffcol[i].setPackedValue(i << 8, t); } @@ -2464,8 +2466,10 @@ PROPERTY_SOURCE(MeshGui::ViewProviderIndexedFaceSet, MeshGui::ViewProviderMesh) ViewProviderIndexedFaceSet::ViewProviderIndexedFaceSet() { + // NOLINTBEGIN pcMeshCoord = nullptr; pcMeshFaces = nullptr; + // NOLINTEND } ViewProviderIndexedFaceSet::~ViewProviderIndexedFaceSet() = default; @@ -2558,8 +2562,10 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshObject, MeshGui::ViewProviderMesh) ViewProviderMeshObject::ViewProviderMeshObject() { + // NOLINTBEGIN pcMeshNode = nullptr; pcMeshShape = nullptr; + // NOLINTEND } ViewProviderMeshObject::~ViewProviderMeshObject() = default; diff --git a/src/Mod/Mesh/Gui/ViewProvider.h b/src/Mod/Mesh/Gui/ViewProvider.h index 1da1023638..30bda1c157 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.h +++ b/src/Mod/Mesh/Gui/ViewProvider.h @@ -126,7 +126,8 @@ public: ViewProviderMesh(); ~ViewProviderMesh() override; - // Display properties + // NOLINTBEGIN + // Display properties App::PropertyPercent LineTransparency; App::PropertyFloatConstraint LineWidth; App::PropertyFloatConstraint PointSize; @@ -135,6 +136,7 @@ public: App::PropertyBool Coloring; App::PropertyEnumeration Lighting; App::PropertyColor LineColor; + // NOLINTEND void attach(App::DocumentObject*) override; void updateData(const App::Property*) override; diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp index 985cd7ae87..6e1f35104d 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp @@ -22,16 +22,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ -#include -#include #include #include #include #include +#include +#include #include -#include #include +#include #include #include #include @@ -73,6 +73,7 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshCurvature, Gui::ViewProviderDocumentObj ViewProviderMeshCurvature::ViewProviderMeshCurvature() { + // NOLINTBEGIN pcColorRoot = new SoSeparator(); pcColorRoot->ref(); pcColorMat = new SoMaterial; @@ -86,9 +87,10 @@ ViewProviderMeshCurvature::ViewProviderMeshCurvature() pcColorBar->setRange(-0.5f, 0.5f, 3); pcLinkRoot = new SoGroup; pcLinkRoot->ref(); + // NOLINTEND App::Material mat; - const SbColor* cols; + const SbColor* cols {}; if (pcColorMat->ambientColor.getNum() == 1) { cols = pcColorMat->ambientColor.getValues(0); mat.ambientColor.setPackedValue(cols[0].getPackedValue()); diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.h b/src/Mod/Mesh/Gui/ViewProviderCurvature.h index b1199d8949..483e8cf5dc 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.h +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.h @@ -72,7 +72,9 @@ public: ViewProviderMeshCurvature(); ~ViewProviderMeshCurvature() override; + // NOLINTBEGIN App::PropertyMaterial TextureMaterial; + // NOLINTEND /// Extracts the mesh data from the feature \a pcFeature and creates an Inventor node \a SoNode /// with these data. @@ -115,7 +117,7 @@ private: void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) override; -protected: +private: SoMaterial* pcColorMat; SoGroup* pcLinkRoot; Gui::SoFCColorBar* pcColorBar; diff --git a/src/Mod/Mesh/Gui/ViewProviderDefects.cpp b/src/Mod/Mesh/Gui/ViewProviderDefects.cpp index 992ce876bd..41f89a5381 100644 --- a/src/Mod/Mesh/Gui/ViewProviderDefects.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderDefects.cpp @@ -35,9 +35,9 @@ #include #include #include +#include #include #include -#include #include "ViewProviderDefects.h" @@ -95,8 +95,10 @@ void ViewProviderMeshDefects::onChanged(const App::Property* prop) ViewProviderMeshOrientation::ViewProviderMeshOrientation() { + // NOLINTBEGIN pcFaces = new SoFaceSet; pcFaces->ref(); + // NOLINTEND } ViewProviderMeshOrientation::~ViewProviderMeshOrientation() @@ -171,8 +173,10 @@ void ViewProviderMeshOrientation::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshNonManifolds::~ViewProviderMeshNonManifolds() @@ -242,8 +246,10 @@ void ViewProviderMeshNonManifolds::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshNonManifoldPoints::~ViewProviderMeshNonManifoldPoints() @@ -303,8 +309,10 @@ void ViewProviderMeshNonManifoldPoints::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshDuplicatedFaces::~ViewProviderMeshDuplicatedFaces() @@ -378,8 +386,10 @@ void ViewProviderMeshDuplicatedFaces::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshDuplicatedPoints::~ViewProviderMeshDuplicatedPoints() @@ -439,8 +449,10 @@ void ViewProviderMeshDuplicatedPoints::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshDegenerations::~ViewProviderMeshDegenerations() @@ -548,8 +560,10 @@ void ViewProviderMeshDegenerations::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshIndices::~ViewProviderMeshIndices() @@ -625,8 +639,10 @@ void ViewProviderMeshIndices::showDefects(const std::vector& ViewProviderMeshSelfIntersections::ViewProviderMeshSelfIntersections() { + // NOLINTBEGIN pcLines = new SoLineSet; pcLines->ref(); + // NOLINTEND } ViewProviderMeshSelfIntersections::~ViewProviderMeshSelfIntersections() @@ -705,8 +721,10 @@ void ViewProviderMeshSelfIntersections::showDefects(const std::vectorref(); + // NOLINTEND } ViewProviderMeshFolds::~ViewProviderMeshFolds() diff --git a/src/Mod/Mesh/Gui/ViewProviderDefects.h b/src/Mod/Mesh/Gui/ViewProviderDefects.h index c94daf67f5..8a06a0a5e5 100644 --- a/src/Mod/Mesh/Gui/ViewProviderDefects.h +++ b/src/Mod/Mesh/Gui/ViewProviderDefects.h @@ -46,8 +46,10 @@ public: ViewProviderMeshDefects(); ~ViewProviderMeshDefects() override; + // NOLINTBEGIN // Display properties App::PropertyFloat LineWidth; + // NOLINTEND // Build up the initial Inventor node void attach(App::DocumentObject* pcFeature) override = 0; @@ -58,8 +60,11 @@ protected: /// get called by the container whenever a property has been changed void onChanged(const App::Property* prop) override; +protected: + // NOLINTBEGIN SoCoordinate3* pcCoords; SoDrawStyle* pcDrawStyle; + // NOLINTEND }; /** The ViewProviderMeshOrientation class displays wrong oriented facets (i.e. flipped normals) in @@ -77,7 +82,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoFaceSet* pcFaces; }; @@ -95,7 +100,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoLineSet* pcLines; }; @@ -113,7 +118,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoPointSet* pcPoints; }; @@ -131,7 +136,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoFaceSet* pcFaces; }; @@ -150,7 +155,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoLineSet* pcLines; }; @@ -165,7 +170,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoPointSet* pcPoints; }; @@ -180,7 +185,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoFaceSet* pcFaces; }; @@ -198,7 +203,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoLineSet* pcLines; }; @@ -213,7 +218,7 @@ public: void attach(App::DocumentObject* pcFeature) override; void showDefects(const std::vector&) override; -protected: +private: SoFaceSet* pcFaces; }; diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp index 53e62186e5..7ddb233844 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp @@ -35,13 +35,13 @@ #include #include #include +#include #include #include -#include +#include "ViewProviderMeshFaceSet.h" #include "SoFCIndexedFaceSet.h" #include "SoFCMeshObject.h" -#include "ViewProviderMeshFaceSet.h" using namespace MeshGui; @@ -50,6 +50,7 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshFaceSet, MeshGui::ViewProviderMesh) ViewProviderMeshFaceSet::ViewProviderMeshFaceSet() { + // NOLINTBEGIN directRendering = false; triangleCount = 2500000; @@ -67,6 +68,7 @@ ViewProviderMeshFaceSet::ViewProviderMeshFaceSet() SoFCMaterialEngine* engine = new SoFCMaterialEngine(); engine->diffuseColor.connectFrom(&pcShapeMaterial->diffuseColor); pcMeshFaces->updateGLArray.connectFrom(&engine->trigger); + // NOLINTEND } ViewProviderMeshFaceSet::~ViewProviderMeshFaceSet() diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp index 3e5d4c9344..44f5efc025 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshPyImp.cpp @@ -25,12 +25,10 @@ #include #endif -// clang-format off #include "ViewProvider.h" // inclusion of the generated files (generated out of ViewProviderMeshPy.xml) #include "ViewProviderMeshPy.h" #include "ViewProviderMeshPy.cpp" -// clang-format on using namespace MeshGui; @@ -46,7 +44,7 @@ std::string ViewProviderMeshPy::representation() const PyObject* ViewProviderMeshPy::setSelection(PyObject* args) { - PyObject* obj; + PyObject* obj {}; if (!PyArg_ParseTuple(args, "O", &obj)) { return nullptr; } @@ -67,7 +65,7 @@ PyObject* ViewProviderMeshPy::setSelection(PyObject* args) PyObject* ViewProviderMeshPy::addSelection(PyObject* args) { - PyObject* obj; + PyObject* obj {}; if (!PyArg_ParseTuple(args, "O", &obj)) { return nullptr; } @@ -88,7 +86,7 @@ PyObject* ViewProviderMeshPy::addSelection(PyObject* args) PyObject* ViewProviderMeshPy::removeSelection(PyObject* args) { - PyObject* obj; + PyObject* obj {}; if (!PyArg_ParseTuple(args, "O", &obj)) { return nullptr; } @@ -131,7 +129,7 @@ PyObject* ViewProviderMeshPy::clearSelection(PyObject* args) PyObject* ViewProviderMeshPy::highlightSegments(PyObject* args) { - PyObject* list; + PyObject* list {}; if (!PyArg_ParseTuple(args, "O", &list)) { return nullptr; } diff --git a/src/Mod/Mesh/Gui/ViewProviderTransform.cpp b/src/Mod/Mesh/Gui/ViewProviderTransform.cpp index 7c8e21b035..a451c2a26d 100644 --- a/src/Mod/Mesh/Gui/ViewProviderTransform.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderTransform.cpp @@ -42,8 +42,10 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshTransform, MeshGui::ViewProviderMesh) ViewProviderMeshTransform::ViewProviderMeshTransform() { + // NOLINTBEGIN pcTransformerDragger = new SoTransformerManip(); pcTransformerDragger->ref(); + // NOLINTEND } ViewProviderMeshTransform::~ViewProviderMeshTransform() diff --git a/src/Mod/Mesh/Gui/ViewProviderTransform.h b/src/Mod/Mesh/Gui/ViewProviderTransform.h index 29032671bc..746fdcc716 100644 --- a/src/Mod/Mesh/Gui/ViewProviderTransform.h +++ b/src/Mod/Mesh/Gui/ViewProviderTransform.h @@ -70,7 +70,7 @@ public: /// Update the Mesh representation void updateData(const App::Property*) override; -protected: +private: SoTransformerManip* pcTransformerDragger; }; diff --git a/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp b/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp index dd37366bff..99025b5df0 100644 --- a/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.cpp @@ -54,10 +54,12 @@ PROPERTY_SOURCE(MeshGui::ViewProviderMeshTransformDemolding, MeshGui::ViewProvid ViewProviderMeshTransformDemolding::ViewProviderMeshTransformDemolding() { + // NOLINTBEGIN pcTrackballDragger = new SoTrackballDragger; pcTrackballDragger->ref(); pcTransformDrag = nullptr; pcColorMat = nullptr; + // NOLINTEND } ViewProviderMeshTransformDemolding::~ViewProviderMeshTransformDemolding() diff --git a/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.h b/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.h index b2f47ee312..f8c7dac8c0 100644 --- a/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.h +++ b/src/Mod/Mesh/Gui/ViewProviderTransformDemolding.h @@ -82,6 +82,7 @@ protected: static void sDragEndCallback(void*, SoDragger*); void DragEndCallback(); +private: SoTrackballDragger* pcTrackballDragger; SoTransform* pcTransformDrag; SoMaterial* pcColorMat; diff --git a/src/Mod/Mesh/Gui/Workbench.cpp b/src/Mod/Mesh/Gui/Workbench.cpp index 06fd6cf689..b98251efba 100644 --- a/src/Mod/Mesh/Gui/Workbench.cpp +++ b/src/Mod/Mesh/Gui/Workbench.cpp @@ -63,6 +63,7 @@ public: MeshInfoWatcher() : TaskWatcher(nullptr) { + // NOLINTBEGIN labelPoints = new QLabel(); labelPoints->setText(tr("Number of points:")); @@ -80,6 +81,7 @@ public: numMin = new QLabel(); numMax = new QLabel(); + // NOLINTEND QGroupBox* box = new QGroupBox(); box->setTitle(tr("Mesh info box")); diff --git a/src/Mod/TechDraw/App/CenterLine.cpp b/src/Mod/TechDraw/App/CenterLine.cpp index 66f59d5725..bb68b56319 100644 --- a/src/Mod/TechDraw/App/CenterLine.cpp +++ b/src/Mod/TechDraw/App/CenterLine.cpp @@ -31,16 +31,16 @@ #include #endif +#include #include -#include #include "CenterLine.h" #include "DrawUtil.h" #include "DrawViewPart.h" #include "Geometry.h" -#include "GeometryObject.h" #include "CenterLinePy.h" +#include "ShapeUtils.h" using namespace TechDraw; using DU = DrawUtil; @@ -274,6 +274,84 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(const TechDraw::DrawViewPart* p return newGeom; } +TechDraw::BaseGeomPtr CenterLine::scaledAndRotatedGeometry(TechDraw::DrawViewPart* partFeat) +{ +// Base::Console().Message("CL::scaledGeometry() - m_type: %d\n", m_type); + double scale = partFeat->getScale(); + double viewAngleDeg = partFeat->Rotation.getValue(); + std::pair ends; + try { + if (m_faces.empty() && + m_edges.empty() && + m_verts.empty() ) { +// Base::Console().Message("CL::scaledGeometry - no geometry to scale!\n"); + //CenterLine was created by points without a geometry reference, + ends = calcEndPointsNoRef(m_start, m_end, scale, m_extendBy, + m_hShift, m_vShift, m_rotate, viewAngleDeg); + } else if (m_type == CLTYPE::FACE) { + ends = calcEndPoints(partFeat, + m_faces, + m_mode, m_extendBy, + m_hShift, m_vShift, m_rotate); + } else if (m_type == CLTYPE::EDGE) { + ends = calcEndPoints2Lines(partFeat, + m_edges, + m_mode, + m_extendBy, + m_hShift, m_vShift, m_rotate, m_flip2Line); + } else if (m_type == CLTYPE::VERTEX) { + ends = calcEndPoints2Points(partFeat, + m_verts, + m_mode, + m_extendBy, + m_hShift, m_vShift, m_rotate, m_flip2Line); + } + } + + catch (...) { + Base::Console().Error("CL::scaledGeometry - failed to calculate endpoints!\n"); + return nullptr; + } + + // inversion here breaks face cl. + Base::Vector3d p1 = ends.first; + Base::Vector3d p2 = ends.second; + if (p1.IsEqual(p2, 0.00001)) { + Base::Console().Warning("Centerline endpoints are equal. Could not draw.\n"); + //what to do here? //return current geom? + return m_geometry; + } + + TopoDS_Edge newEdge; + if (getType() == CLTYPE::FACE ) { + gp_Pnt gp1(DU::togp_Pnt(p1)); + gp_Pnt gp2(DU::togp_Pnt(p2)); + TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); + // Mirror shape in Y and scale + TopoDS_Shape s = ShapeUtils::mirrorShape(e, gp_Pnt(0.0, 0.0, 0.0), scale); + // rotate using OXYZ as the coordinate system + s = ShapeUtils::rotateShape(s, gp_Ax2(), - partFeat->Rotation.getValue()); + newEdge = TopoDS::Edge(s); + } else if (getType() == CLTYPE::EDGE || + getType() == CLTYPE::VERTEX) { + gp_Pnt gp1(DU::togp_Pnt(DU::invertY(p1 * scale))); + gp_Pnt gp2(DU::togp_Pnt(DU::invertY(p2 * scale))); + newEdge = BRepBuilderAPI_MakeEdge(gp1, gp2); + } + + TechDraw::BaseGeomPtr newGeom = TechDraw::BaseGeom::baseFactory(newEdge); + if (!newGeom) { + throw Base::RuntimeError("Failed to create center line"); + } + newGeom->setClassOfEdge(ecHARD); + newGeom->setHlrVisible( true); + newGeom->setCosmetic(true); + newGeom->source(CENTERLINE); + newGeom->setCosmeticTag(getTagAsString()); + + return newGeom; +} + std::string CenterLine::toString() const { std::stringstream ss; @@ -417,12 +495,20 @@ std::pair CenterLine::calcEndPoints(const DrawVi } } TopoDS_Shape faceEdgeCompound = DU::vectorToCompound(faceEdgesAll); - if (partFeat->Rotation.getValue() != 0.0) { - // align a copy of the input shape with the cardinal axes so we can use bbox to - // get size measurements - faceEdgeCompound = ShapeUtils::rotateShape(faceEdgeCompound, partFeat->getProjectionCS(), partFeat->Rotation.getValue() * -1.0); - } + if (partFeat->Rotation.getValue() != 0.0) { + // unrotate the input shape to align with the cardinal axes so we can use bbox to + // get size measurements + faceEdgeCompound = ShapeUtils::rotateShape(faceEdgeCompound, + partFeat->getProjectionCS(), + partFeat->Rotation.getValue() * -1.0); + } + // get the center of the unrotated, scaled face + Base::Vector3d faceCenter = ShapeUtils::findCentroidVec(faceEdgeCompound, partFeat->getProjectionCS()); + // we need to move the edges to the origin here to get the right limits from the bounding box + faceEdgeCompound = ShapeUtils::moveShape(faceEdgeCompound, faceCenter * -1.0); + + // get the bounding box of the centered and unrotated face BRepBndLib::AddOptimal(faceEdgeCompound, faceBox); if (faceBox.IsVoid()) { @@ -435,11 +521,14 @@ std::pair CenterLine::calcEndPoints(const DrawVi double Xspan = fabs(Xmax - Xmin); Xspan = (Xspan / 2.0); - double Xmid = Xmin + Xspan; - + double Xmid = 0.0; + Xmax = Xmid + Xspan; + Xmin = Xmid - Xspan; double Yspan = fabs(Ymax - Ymin); Yspan = (Yspan / 2.0); - double Ymid = Ymin + Yspan; + double Ymid = 0.0; + Ymax = Ymid + Yspan; + Ymin = Ymid - Yspan; Base::Vector3d p1, p2; if (mode == CenterLine::VERTICAL) { //vertical @@ -454,6 +543,12 @@ std::pair CenterLine::calcEndPoints(const DrawVi p2 = Base::Vector3d(Xmid, Ymin, 0.0); } + // now move the extents back to the face center. this should give us the scaled, + // unrotated ends of the cl (but in 3d coordinates, which will be handled at the time + // the cl is added to the view) + p1 += faceCenter; + p2 += faceCenter; + Base::Vector3d mid = (p1 + p2) / 2.0; //extend @@ -480,14 +575,9 @@ std::pair CenterLine::calcEndPoints(const DrawVi p2.y = p2.y + vss; } - // rotate the endpoints so that when the View's Rotation is applied, the - // centerline is aligned correctly std::pair result; result.first = p1 / scale; result.second = p2 / scale; - Base::Vector3d midpoint = (result.first + result.second) / 2.0; - result = rotatePointsAroundMid(result.first, result.second, midpoint, partFeat->Rotation.getValue() * -1.0); - return result; } @@ -511,7 +601,6 @@ std::pair CenterLine::calcEndPoints2Lines(const } double scale = partFeat->getScale(); - const std::vector dbEdges = partFeat->getEdgeGeometry(); std::vector edges; for (auto& en: edgeNames) { @@ -528,14 +617,15 @@ std::pair CenterLine::calcEndPoints2Lines(const } if (edges.size() != 2) { Base::Console().Message("CL::calcEndPoints2Lines - wrong number of edges: %d!\n", edges.size()); -// return result; throw Base::IndexError("CenterLine wrong number of edges."); } - Base::Vector3d l1p1 = edges.front()->getStartPoint(); - Base::Vector3d l1p2 = edges.front()->getEndPoint(); - Base::Vector3d l2p1 = edges.back()->getStartPoint(); - Base::Vector3d l2p2 = edges.back()->getEndPoint(); + // these points are centered, rotated, scaled and inverted. + // invert the points so the math works correctly + Base::Vector3d l1p1 = DU::invertY(edges.front()->getStartPoint()); + Base::Vector3d l1p2 = DU::invertY(edges.front()->getEndPoint()); + Base::Vector3d l2p1 = DU::invertY(edges.back()->getStartPoint()); + Base::Vector3d l2p2 = DU::invertY(edges.back()->getEndPoint()); // The centerline is drawn using the midpoints of the two lines that connect l1p1-l2p1 and l1p2-l2p2. // However, we don't know which point should be l1p1 to get a geometrically correct result, see @@ -568,14 +658,17 @@ std::pair CenterLine::calcEndPoints2Lines(const } //orientation - if (mode == CenterLine::VERTICAL && !inhibitVertical) { //Vertical - p1.x = mid.x; - p2.x = mid.x; - } else if (mode == CenterLine::HORIZONTAL && !inhibitHorizontal) { //Horizontal - p1.y = mid.y; - p2.y = mid.y; - } else if (mode == CenterLine::ALIGNED) { //Aligned - // no op + if (partFeat->Rotation.getValue() == 0.0) { + // if the view is rotated, then horizontal and vertical lose their meaning + if (mode == 0 && !inhibitVertical) { //Vertical + p1.x = mid.x; + p2.x = mid.x; + } else if (mode == 1 && !inhibitHorizontal) { //Horizontal + p1.y = mid.y; + p2.y = mid.y; + } else if (mode == 2) { //Aligned + // no op + } } //extend @@ -587,9 +680,7 @@ std::pair CenterLine::calcEndPoints2Lines(const //rotate if (!DrawUtil::fpCompare(rotate, 0.0)) { //rotate p1, p2 about mid - std::pair ends = rotatePointsAroundMid(p1, p2, mid, rotate); - p1 = ends.first; - p2 = ends.second; + std::tie(p1, p2) = rotatePointsAroundMid(p1, p2, mid, rotate); } //shift @@ -604,13 +695,9 @@ std::pair CenterLine::calcEndPoints2Lines(const p2.y = p2.y + vss; } - // rotate the endpoints so that when the View's Rotation is applied, the - // centerline is aligned correctly + // the cl will be scaled when drawn, so unscale now. result.first = p1 / scale; result.second = p2 / scale; - Base::Vector3d midpoint = (result.first + result.second) / 2.0; - result = rotatePointsAroundMid(result.first, result.second, midpoint, partFeat->Rotation.getValue() * -1.0); - return result; } @@ -647,8 +734,8 @@ std::pair CenterLine::calcEndPoints2Points(const throw Base::IndexError("CenterLine wrong number of points."); } - Base::Vector3d v1 = points.front()->point(); - Base::Vector3d v2 = points.back()->point(); + Base::Vector3d v1 = DU::invertY(points.front()->point()); + Base::Vector3d v2 = DU::invertY(points.back()->point()); Base::Vector3d mid = (v1 + v2) / 2.0; Base::Vector3d dir = v2 - v1; @@ -667,16 +754,20 @@ std::pair CenterLine::calcEndPoints2Points(const inhibitVertical = true; } - if (mode == CenterLine::VERTICAL && !inhibitVertical) { + //orientation + if (partFeat->Rotation.getValue() == 0.0) { + // if the view is rotated, then horizontal and vertical lose their meaning + if (mode == CenterLine::VERTICAL && !inhibitVertical) { //Vertical v1.x = mid.x; v2.x = mid.x; - } else if (mode == CenterLine::HORIZONTAL && !inhibitHorizontal) { + } else if (mode == CenterLine::HORIZONTAL && !inhibitHorizontal) { //Horizontal v1.y = mid.y; v2.y = mid.y; - } else if (mode == CenterLine::ALIGNED) { //Aligned - // no op + } else if (mode == CenterLine::ALIGNED) { //Aligned + // no op + } } double length = dir.Length(); @@ -714,8 +805,6 @@ std::pair CenterLine::calcEndPoints2Points(const p2.y = p2.y + vss; } - // in the case of points, we do not need to apply a rotation, since the points will - // rotated already std::pair result; result.first = p1 / scale; result.second = p2 / scale; diff --git a/src/Mod/TechDraw/App/CenterLine.h b/src/Mod/TechDraw/App/CenterLine.h index 5086cb324d..98c0b4a3e0 100644 --- a/src/Mod/TechDraw/App/CenterLine.h +++ b/src/Mod/TechDraw/App/CenterLine.h @@ -88,6 +88,7 @@ public: const int mode = 0, const bool flip = false); TechDraw::BaseGeomPtr scaledGeometry(const TechDraw::DrawViewPart* partFeat); + TechDraw::BaseGeomPtr scaledAndRotatedGeometry(TechDraw::DrawViewPart* partFeat); static std::pair rotatePointsAroundMid( const Base::Vector3d& p1, @@ -139,6 +140,8 @@ public: double getExtend() const; void setFlip(const bool f); bool getFlip() const; + void setType(const int type) { m_type = type; }; + int getType() const { return m_type; } Base::Vector3d m_start; Base::Vector3d m_end; diff --git a/src/Mod/TechDraw/App/CosmeticExtension.cpp b/src/Mod/TechDraw/App/CosmeticExtension.cpp index 7245d3f09e..f2174423a4 100644 --- a/src/Mod/TechDraw/App/CosmeticExtension.cpp +++ b/src/Mod/TechDraw/App/CosmeticExtension.cpp @@ -341,7 +341,7 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(const std::string& ta } // None found - Base::Console().Message("CEx::getCosmeticEdge - CE for tag: %s not found.\n", tagString.c_str()); +// Base::Console().Message("CEx::getCosmeticEdge - CE for tag: %s not found.\n", tagString.c_str()); return nullptr; } @@ -416,10 +416,11 @@ int CosmeticExtension::add1CLToGE(const std::string& tag) // Base::Console().Message("CEx::add1CLToGE(%s) 2\n", tag.c_str()); TechDraw::CenterLine* cl = getCenterLine(tag); if (!cl) { - Base::Console().Message("CEx::add1CLToGE 2 - cl %s not found\n", tag.c_str()); +// Base::Console().Message("CEx::add1CLToGE 2 - cl %s not found\n", tag.c_str()); return -1; } - TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(getOwner()); + TechDraw::BaseGeomPtr scaledGeom = cl->scaledAndRotatedGeometry(getOwner()); +// TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(getOwner()); int iGE = getOwner()->getGeometryObject()->addCenterLine(scaledGeom, tag); return iGE; @@ -446,7 +447,8 @@ void CosmeticExtension::addCenterLinesToGeom() // Base::Console().Message("CE::addCenterLinesToGeom()\n"); const std::vector lines = CenterLines.getValues(); for (auto& cl : lines) { - TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(getOwner()); +// TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(getOwner()); + TechDraw::BaseGeomPtr scaledGeom = cl->scaledAndRotatedGeometry(getOwner()); if (!scaledGeom) { Base::Console().Error("CE::addCenterLinesToGeom - scaledGeometry is null\n"); continue; @@ -491,7 +493,6 @@ std::string CosmeticExtension::addCenterLine(TechDraw::BaseGeomPtr bg) return cl->getTagAsString(); } - //get CL by unique id TechDraw::CenterLine* CosmeticExtension::getCenterLine(const std::string& tagString) const { diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index cc6a4c225a..a93fef46a5 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -1642,8 +1642,19 @@ bool DrawUtil::isCosmeticEdge(App::DocumentObject* owner, std::string element) { auto ownerView = static_cast(owner); auto edge = ownerView->getEdge(element); - if (edge) { - return edge->getCosmetic(); + if (edge && edge->source() == 1 && edge->getCosmetic()) { + return true; + } + return false; +} + +// true if owner->element is a center line +bool DrawUtil::isCenterLine(App::DocumentObject* owner, std::string element) +{ + auto ownerView = static_cast(owner); + auto edge = ownerView->getEdge(element); + if (edge && edge->source() == 2 && edge->getCosmetic()) { + return true; } return false; } diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index bbb7a64120..6bbfae570c 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -257,6 +257,7 @@ public: static bool isCosmeticVertex(App::DocumentObject* owner, std::string element); static bool isCosmeticEdge(App::DocumentObject* owner, std::string element); + static bool isCenterLine(App::DocumentObject* owner, std::string element); //debugging routines static void dumpVertexes(const char* text, const TopoDS_Shape& s); diff --git a/src/Mod/TechDraw/App/ShapeUtils.cpp b/src/Mod/TechDraw/App/ShapeUtils.cpp index a9e0d9d71f..c0497a1ad2 100644 --- a/src/Mod/TechDraw/App/ShapeUtils.cpp +++ b/src/Mod/TechDraw/App/ShapeUtils.cpp @@ -353,3 +353,17 @@ TopoDS_Shape ShapeUtils::centerShapeXY(const TopoDS_Shape& inShape, const gp_Ax2 Base::Vector3d centroid = DrawUtil::toVector3d(inputCenter); return ShapeUtils::moveShape(inShape, centroid * -1.0); } + +std::pair ShapeUtils::getEdgeEnds(TopoDS_Edge edge) +{ + std::pair result; + TopoDS_Vertex tvFirst, tvLast; + TopExp::Vertices(edge, tvFirst, tvLast); + gp_Pnt gpFirst = BRep_Tool::Pnt(tvFirst); + gp_Pnt gpLast = BRep_Tool::Pnt(tvLast); + + result.first = DU::toVector3d(gpFirst); + result.second = DU::toVector3d(gpLast); + return result; +} + diff --git a/src/Mod/TechDraw/App/ShapeUtils.h b/src/Mod/TechDraw/App/ShapeUtils.h index e831a8c8b7..2a8272e892 100644 --- a/src/Mod/TechDraw/App/ShapeUtils.h +++ b/src/Mod/TechDraw/App/ShapeUtils.h @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -104,6 +105,9 @@ public: static TopoDS_Shape projectSimpleShape(const TopoDS_Shape& shape, const gp_Ax2& CS); static TopoDS_Shape simpleProjection(const TopoDS_Shape& shape, const gp_Ax2& projCS); static TopoDS_Shape projectFace(const TopoDS_Shape& face, const gp_Ax2& CS); + + static std::pair getEdgeEnds(TopoDS_Edge edge); + }; } diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 1340e668b4..847d07edb9 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include "PreferencesGui.h" #include "QGIView.h" @@ -360,7 +361,8 @@ std::vector ViewProviderViewPart::getSelectedCosmetics(std::vector< result.emplace_back(sub); } } else if (DU::getGeomTypeFromName(sub) == "Edge") { - if (DU::isCosmeticEdge(getViewObject(), sub)) { + if (DU::isCosmeticEdge(getViewObject(), sub) || + DU::isCenterLine(getViewObject(), sub)) { result.emplace_back(sub); } } @@ -380,9 +382,16 @@ void ViewProviderViewPart::deleteCosmeticElements(std::vector remov } if (DU::getGeomTypeFromName(name) == "Edge") { CosmeticEdge* edge = getViewObject()->getCosmeticEdgeBySelection(name); - // if not edge, something has gone very wrong! - getViewObject()->removeCosmeticEdge(edge->getTagAsString()); - continue; + if (edge) { + // if not edge, something has gone very wrong! + getViewObject()->removeCosmeticEdge(edge->getTagAsString()); + continue; + } + CenterLine* line = getViewObject()->getCenterLineBySelection(name); + if (line) { + getViewObject()->removeCenterLine(line->getTagAsString()); + continue; + } } } } diff --git a/src/Tools/generateBase/generateMetaModel_Module.xsd b/src/Tools/generateBase/generateMetaModel_Module.xsd index 725b1a151f..799056ef07 100644 --- a/src/Tools/generateBase/generateMetaModel_Module.xsd +++ b/src/Tools/generateBase/generateMetaModel_Module.xsd @@ -18,6 +18,7 @@ + diff --git a/src/Tools/generateBase/generateModel_Module.py b/src/Tools/generateBase/generateModel_Module.py index be37255883..9e126b68df 100644 --- a/src/Tools/generateBase/generateModel_Module.py +++ b/src/Tools/generateBase/generateModel_Module.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -# Generated Fri Mar 31 16:59:53 2023 by generateDS.py. +# Generated Wed Sep 27 11:00:46 2023 by generateDS.py. # Update it with: python generateDS.py -o generateModel_Module.py generateMetaModel_Module.xsd # # WARNING! All changes made in this file will be lost! @@ -789,6 +789,7 @@ class Methode: Name="", Const=0, Keyword=0, + NoArgs=0, Class=0, Static=0, Documentation=None, @@ -797,6 +798,7 @@ class Methode: self.Name = Name self.Const = Const self.Keyword = Keyword + self.NoArgs = NoArgs self.Class = Class self.Static = Static self.Documentation = Documentation @@ -849,6 +851,12 @@ class Methode: def setKeyword(self, Keyword): self.Keyword = Keyword + def getNoargs(self): + return self.NoArgs + + def setNoargs(self, NoArgs): + self.NoArgs = NoArgs + def getClass(self): return self.Class @@ -876,6 +884,8 @@ class Methode: outfile.write(' Const="%s"' % (self.getConst(),)) if self.getKeyword() is not None: outfile.write(' Keyword="%s"' % (self.getKeyword(),)) + if self.getNoargs() is not None: + outfile.write(' NoArgs="%s"' % (self.getNoargs(),)) if self.getClass() is not None: outfile.write(' Class="%s"' % (self.getClass(),)) if self.getStatic() is not None: @@ -900,6 +910,8 @@ class Methode: showIndent(outfile, level) outfile.write('Keyword = "%s",\n' % (self.getKeyword(),)) showIndent(outfile, level) + outfile.write('NoArgs = "%s",\n' % (self.getNoargs(),)) + showIndent(outfile, level) outfile.write('Class = "%s",\n' % (self.getClass(),)) showIndent(outfile, level) outfile.write('Static = "%s",\n' % (self.getStatic(),)) @@ -948,6 +960,13 @@ class Methode: self.Keyword = 0 else: raise ValueError("Bad boolean attribute (Keyword)") + if attrs.get("NoArgs"): + if attrs.get("NoArgs").value in ("true", "1"): + self.NoArgs = 1 + elif attrs.get("NoArgs").value in ("false", "0"): + self.NoArgs = 0 + else: + raise ValueError("Bad boolean attribute (NoArgs)") if attrs.get("Class"): if attrs.get("Class").value in ("true", "1"): self.Class = 1 @@ -1549,12 +1568,7 @@ class Content: subclass = None def __init__( - self, - Property=None, - Feature=None, - DocObject=None, - GuiCommand=None, - PreferencesPage=None, + self, Property=None, Feature=None, DocObject=None, GuiCommand=None, PreferencesPage=None ): if Property is None: self.Property = [] @@ -2694,6 +2708,16 @@ class SaxGeneratemodelHandler(handler.ContentHandler): self.reportError( '"Keyword" attribute must be boolean ("true", "1", "false", "0")' ) + val = attrs.get("NoArgs", None) + if val is not None: + if val in ("true", "1"): + obj.setNoargs(1) + elif val in ("false", "0"): + obj.setNoargs(0) + else: + self.reportError( + '"NoArgs" attribute must be boolean ("true", "1", "false", "0")' + ) val = attrs.get("Class", None) if val is not None: if val in ("true", "1"): @@ -3062,11 +3086,7 @@ class SaxGeneratemodelHandler(handler.ContentHandler): locator = self.locator sys.stderr.write( "Doc: %s Line: %d Column: %d\n" - % ( - locator.getSystemId(), - locator.getLineNumber(), - locator.getColumnNumber() + 1, - ) + % (locator.getSystemId(), locator.getLineNumber(), locator.getColumnNumber() + 1) ) sys.stderr.write(mesg) sys.stderr.write("\n") diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index 72f5ed1341..a9c4df8bfd 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -121,6 +121,19 @@ public: /// implementer for the @i.Name@() method PyObject* @i.Name@(PyObject *args, PyObject *kwd); - += elif i.NoArgs: + /// callback for the @i.Name@() method + static PyObject * staticCallback_@i.Name@ (PyObject *self, PyObject *args); ++ if i.Static: + /// implementer for the @i.Name@() method + static PyObject* @i.Name@(); += elif i.Class: + /// implementer for the @i.Name@() method + static PyObject* @i.Name@(PyObject *self); += else: + /// implementer for the @i.Name@() method + PyObject* @i.Name@(); +- = else: /// callback for the @i.Name@() method static PyObject * staticCallback_@i.Name@ (PyObject *self, PyObject *args); @@ -389,6 +402,17 @@ PyMethodDef @self.export.Name@::Methods[] = { reinterpret_cast(reinterpret_cast( staticCallback_@i.Name@ )), METH_VARARGS|METH_KEYWORDS, - += elif i.NoArgs: ++ if i.Class: + reinterpret_cast(reinterpret_cast( staticCallback_@i.Name@ )), + METH_NOARGS|METH_CLASS, += elif i.Static: + reinterpret_cast(reinterpret_cast( staticCallback_@i.Name@ )), + METH_NOARGS|METH_STATIC, += else: + reinterpret_cast( staticCallback_@i.Name@ ), + METH_NOARGS, +- = elif i.Class: reinterpret_cast(reinterpret_cast( staticCallback_@i.Name@ )), METH_VARARGS|METH_CLASS, @@ -532,6 +556,8 @@ PyGetSetDef @self.export.Name@::GetterSetter[] = { // has to be implemented in @self.export.Name@Imp.cpp + if i.Keyword: PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject *args, PyObject * kwd) += elif i.NoArgs: +PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject * Py_UNUSED(args)) = else: PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject *args) - @@ -568,6 +594,15 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject = else: PyObject* ret = static_cast<@self.export.Name@*>(self)->@i.Name@(args, kwd); - += elif i.NoArgs: ++ if i.Static: + (void)self; + PyObject* ret = @self.export.Name@::@i.Name@(); += elif i.Class: + PyObject* ret = @self.export.Name@::@i.Name@(self); += else: + PyObject* ret = static_cast<@self.export.Name@*>(self)->@i.Name@(); +- = else: + if i.Static: (void)self; @@ -881,6 +916,12 @@ PyObject* @self.export.Name@::@i.Name@(PyObject *self, PyObject *args, PyObject = else: PyObject* @self.export.Name@::@i.Name@(PyObject *args, PyObject *kwds) - += elif i.NoArgs: ++ if i.Class: +PyObject* @self.export.Name@::@i.Name@(PyObject *self) += else: +PyObject* @self.export.Name@::@i.Name@() +- = else: + if i.Class: PyObject* @self.export.Name@::@i.Name@(PyObject *self, PyObject *args) @@ -1222,6 +1263,12 @@ PyObject* @self.export.Name@::@i.Name@(PyObject * /*self*/, PyObject * /*args*/, = else: PyObject* @self.export.Name@::@i.Name@(PyObject * /*args*/, PyObject * /*kwds*/) - += elif i.NoArgs: ++ if i.Class: +PyObject* @self.export.Name@::@i.Name@(PyObject * /*self*/) += else: +PyObject* @self.export.Name@::@i.Name@() +- = else: + if i.Class: PyObject* @self.export.Name@::@i.Name@(PyObject * /*self*/, PyObject * /*args*/)