From 2549b555bc6ab6bf2f5eb6721764561e67fa2f6a Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 26 Apr 2012 15:10:48 +0200 Subject: [PATCH] doing merge --- src/Gui/Document.cpp | 9 +++-- src/Gui/Widgets.cpp | 13 +++++++ src/Gui/Widgets.h | 1 + src/Mod/Mesh/App/Core/Degeneration.cpp | 42 ++++++++++++++++++++++ src/Mod/Mesh/App/Core/Degeneration.h | 48 ++++++++++++++++++++++++++ src/Mod/Mesh/App/Mesh.cpp | 6 ++++ src/Mod/Mesh/App/Mesh.h | 1 + 7 files changed, 118 insertions(+), 2 deletions(-) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index ed58b9f62..4a0880ffa 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -642,8 +642,13 @@ void Document::RestoreDocFile(Base::Reader &reader) std::string sMsg = "SetCamera "; sMsg += ppReturn; if (strcmp(ppReturn, "") != 0) { // non-empty attribute - if (d->_pcAppWnd->sendHasMsgToActiveView("SetCamera")) - d->_pcAppWnd->sendMsgToActiveView(sMsg.c_str()); + try { + if (d->_pcAppWnd->sendHasMsgToActiveView("SetCamera")) + d->_pcAppWnd->sendMsgToActiveView(sMsg.c_str()); + } + catch (const Base::Exception& e) { + Base::Console().Error("%s\n", e.what()); + } } } diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index e807eebe2..1db07b7cd 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -27,11 +27,13 @@ # include # include # include +# include # include # include # include # include # include +# include # include #endif @@ -641,6 +643,17 @@ void StatusWidget::setStatusText(const QString& s) label->setText(s); } +void StatusWidget::showText(int ms) +{ + show(); + QTimer timer; + QEventLoop loop; + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(ms); + loop.exec(QEventLoop::ExcludeUserInputEvents); + hide(); +} + QSize StatusWidget::sizeHint () const { return QSize(250,100); diff --git a/src/Gui/Widgets.h b/src/Gui/Widgets.h index c1d58954b..16baf74b7 100644 --- a/src/Gui/Widgets.h +++ b/src/Gui/Widgets.h @@ -275,6 +275,7 @@ public: ~StatusWidget(); void setStatusText(const QString&); QSize sizeHint () const; + void showText(int ms); protected: void showEvent(QShowEvent*); diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index fd48104e6..81bc9e6e3 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -38,6 +38,7 @@ #include "Grid.h" #include "TopoAlgorithm.h" +#include #include using namespace MeshCore; @@ -228,6 +229,47 @@ bool MeshFixDuplicatePoints::Fixup() // ---------------------------------------------------------------------- +bool MeshEvalNaNPoints::Evaluate() +{ + const MeshPointArray& rPoints = _rclMesh.GetPoints(); + for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) { + if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z)) + return false; + } + + return true; +} + +std::vector MeshEvalNaNPoints::GetIndices() const +{ + std::vector aInds; + const MeshPointArray& rPoints = _rclMesh.GetPoints(); + for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) { + if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z)) + aInds.push_back(it - rPoints.begin()); + } + + return aInds; +} + +bool MeshFixNaNPoints::Fixup() +{ + std::vector aInds; + const MeshPointArray& rPoints = _rclMesh.GetPoints(); + for (MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) { + if (boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z)) + aInds.push_back(it - rPoints.begin()); + } + + // remove invalid indices + _rclMesh.DeletePoints(aInds); + _rclMesh.RebuildNeighbours(); + + return true; +} + +// ---------------------------------------------------------------------- + namespace MeshCore { typedef MeshFacetArray::_TConstIterator FaceIterator; diff --git a/src/Mod/Mesh/App/Core/Degeneration.h b/src/Mod/Mesh/App/Core/Degeneration.h index f2b28ffd7..db6c3d010 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.h +++ b/src/Mod/Mesh/App/Core/Degeneration.h @@ -138,6 +138,54 @@ public: bool Fixup (); }; +/** + * The MeshEvalNaNPoints class searches for points with a coordinate that is NaN. + * @see MeshFixNaNPoints + * @author Werner Mayer + */ +class MeshExport MeshEvalNaNPoints : public MeshEvaluation +{ +public: + /** + * Construction. + */ + MeshEvalNaNPoints (const MeshKernel &rclM) : MeshEvaluation( rclM ) { } + /** + * Destruction. + */ + ~MeshEvalNaNPoints () { } + /** + * Returns false if a point with NaN coordinate is found. + */ + bool Evaluate (); + /** + * Returns the indices of all NaN points. + */ + std::vector GetIndices() const; +}; + +/** + * The MeshFixNaNPoints class removes all points with a coordinate that is NaN. + * @see MeshEvalNaNPoints + * @author Werner Mayer + */ +class MeshExport MeshFixNaNPoints : public MeshValidation +{ +public: + /** + * Construction. + */ + MeshFixNaNPoints (MeshKernel &rclM) : MeshValidation( rclM ) { } + /** + * Destruction. + */ + ~MeshFixNaNPoints () { } + /** + * Merges duplicated points. + */ + bool Fixup (); +}; + /** * The MeshEvalDuplicateFacets class searches for duplicated facets. * A facet is regarded as duplicated if all its point indices refer to the same location in the point array of the mesh kernel. diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index f7b133a11..bd7be06d0 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -1123,6 +1123,12 @@ void MeshObject::removeFullBoundaryFacets() } } +void MeshObject::removeInvalidPoints() +{ + MeshCore::MeshEvalNaNPoints nan(_kernel); + deletePoints(nan.GetIndices()); +} + void MeshObject::validateIndices() { unsigned long count = _kernel.CountFacets(); diff --git a/src/Mod/Mesh/App/Mesh.h b/src/Mod/Mesh/App/Mesh.h index de42bd381..dcd1ca19d 100644 --- a/src/Mod/Mesh/App/Mesh.h +++ b/src/Mod/Mesh/App/Mesh.h @@ -256,6 +256,7 @@ public: void removeSelfIntersections(const std::vector&); void removeFoldsOnSurface(); void removeFullBoundaryFacets(); + void removeInvalidPoints(); //@} /** @name Mesh segments */