From 7cb6ac084270943d926ec7ef35bf9e63d6a3eaf5 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 5 Oct 2015 16:23:37 +0300 Subject: [PATCH] Optimize the flushing: this improvement speed ups the unit test for 3-4 times --- src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp | 10 ++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h | 4 ++++ src/Model/Model_Document.cpp | 12 +++--------- src/Model/Model_Document.h | 3 +-- src/ModelAPI/ModelAPI_Document.h | 3 +-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp index 096dc4a96..dffcecce4 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp @@ -25,6 +25,16 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::point( return aRes; } +std::shared_ptr GeomAlgoAPI_PointBuilder::point( + const double theX, const double theY, const double theZ) +{ + const gp_Pnt aPnt(theX, theY, theZ); + BRepBuilderAPI_MakeVertex aMaker(aPnt); + TopoDS_Vertex aVertex = aMaker.Vertex(); + std::shared_ptr aRes(new GeomAPI_Vertex); + aRes->setImpl(new TopoDS_Shape(aVertex)); + return aRes; +} std::shared_ptr GeomAlgoAPI_PointBuilder::point(std::shared_ptr theVertex) { diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h index 893c70c97..cff50ee05 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h @@ -24,6 +24,10 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder /// Creates a shape by point static std::shared_ptr point(std::shared_ptr thePoint); + /// Creates a shape by point coordinates + static std::shared_ptr point( + const double theX, const double theY, const double theZ); + /// Return point by shape vertex static std::shared_ptr point(std::shared_ptr theVertex); }; diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 6c7ea7a3c..e0ae73e76 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -749,8 +749,8 @@ std::shared_ptr Model_Document::currentFeature(const bool theV return std::shared_ptr(); // null feature means the higher than first } -void Model_Document::setCurrentFeature(std::shared_ptr theCurrent, - const bool theVisible, const bool theFlushUpdates) +void Model_Document::setCurrentFeature( + std::shared_ptr theCurrent, const bool theVisible) { // blocks the flush signals to avoid each objects visualization in the viewer // they should not be shown once after all modifications are performed @@ -844,12 +844,6 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr } // unblock the flush signals and up them after this aLoop->activateFlushes(isActive); - - if (theFlushUpdates) { - aLoop->flush(aCreateEvent); - aLoop->flush(aRedispEvent); - aLoop->flush(aDeleteEvent); - } } void Model_Document::setCurrentFeatureUp() @@ -860,7 +854,7 @@ void Model_Document::setCurrentFeatureUp() if (aCurrent.get()) { // if not, do nothing because null is the upper FeaturePtr aPrev = myObjs->nextFeature(aCurrent, true); // do not flush: it is called only on remove, it will be flushed in the end of transaction - setCurrentFeature(aPrev, false, false); + setCurrentFeature(aPrev, false); } } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index a728c2158..1c7645b0c 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -134,9 +134,8 @@ class Model_Document : public ModelAPI_Document //! will be appended after this one. //! \param theCurrent the selected feature as current: blow it everythin become disabled //! \param theVisible use visible features only: flag is true for Object Browser functionality - //! \param theFlushUpdates if it is true method calls flushes for creation/redisplay/delete messages MODEL_EXPORT virtual void setCurrentFeature(std::shared_ptr theCurrent, - const bool theVisible, const bool theFlushUpdates = true); + const bool theVisible); //! Makes the current feature one feature upper MODEL_EXPORT virtual void setCurrentFeatureUp(); diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index b6419ec82..4edc005c9 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -103,9 +103,8 @@ public: //! will be appended after this one. //! \param theCurrent the selected feature as current: blow it everythin become disabled //! \param theVisible use visible features only: flag is true for Object Browser functionality - //! \param theFlushUpdates if it is true (default) it flashes creation/redisplay/delete messages virtual void setCurrentFeature(std::shared_ptr theCurrent, - const bool theVisible, const bool theFlushUpdates = true) = 0; + const bool theVisible) = 0; //! Makes the current feature one feature upper virtual void setCurrentFeatureUp() = 0; -- 2.39.2