From: mpv Date: Wed, 6 Apr 2016 14:01:57 +0000 (+0300) Subject: Creation of producedByFeature initial implementation neede for the issue #1306 X-Git-Tag: V_2.3.0~290 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=49c180426b47ea37eee3a779362fef3b78ab7cb9;p=modules%2Fshaper.git Creation of producedByFeature initial implementation neede for the issue #1306 --- diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 3ae40cab1..279e3738a 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -116,7 +116,7 @@ bool GeomAPI_Shape::isPlanar() const Handle(Geom_RectangularTrimmedSurface) aTrimSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); aType = aTrimSurface->BasisSurface()->DynamicType(); } - return (aType == STANDARD_TYPE(Geom_Plane)); + return (aType == STANDARD_TYPE(Geom_Plane)) == Standard_True; } else { return false; } diff --git a/src/Model/Model_Application.cpp b/src/Model/Model_Application.cpp index 704a6afdc..324cefee0 100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@ -153,7 +153,7 @@ void Model_Application::removeUselessDocuments( int Model_Application::generateDocumentId() { - int aResult = myDocs.size(); + int aResult = int(myDocs.size()); for(; myDocs.find(aResult) != myDocs.end(); aResult++); // count until the result id is unique return aResult; } diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 7dd2b7366..bb2881544 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,9 @@ #include #include #include +#include +#include + #include #ifndef WIN32 @@ -1266,3 +1270,32 @@ FeaturePtr Model_Document::lastFeature() return myObjs->lastFeature(); return FeaturePtr(); } + +std::shared_ptr Model_Document::producedByFeature( + std::shared_ptr theResult, + const std::shared_ptr& theShape) +{ + ResultBodyPtr aBody = std::dynamic_pointer_cast(theResult); + if (!aBody.get()) { + return feature(theResult); // for not-body just returns the feature that produced this result + } + // otherwise get the shape and search the very initial label for it + TopoDS_Shape aShape = theShape->impl(); + if (aShape.IsNull()) + return FeaturePtr(); + + + FeaturePtr aResult; + for(TNaming_SameShapeIterator anIter(aShape, myDoc->Main()); anIter.More(); anIter.Next()) { + TDF_Label aNSLab = anIter.Label(); + while(aNSLab.Depth() > 4) + aNSLab = aNSLab.Father(); + FeaturePtr aFeature = myObjs->feature(aNSLab); + if (aFeature.get()) { + if (!aResult.get() || myObjs->isLater(aResult, aFeature)) { + aResult = aFeature; + } + } + } + return aResult; +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 6f0b2bee6..312472a8d 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -209,6 +209,11 @@ class Model_Document : public ModelAPI_Document /// \returns null if there is no features FeaturePtr lastFeature(); + /// Returns the feature that produced the given face of the given result. + MODEL_EXPORT virtual std::shared_ptr producedByFeature( + std::shared_ptr theResult, + const std::shared_ptr& theShape); + protected: //! Returns (creates if needed) the general label TDF_Label generalLabel() const; diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 8c1297359..6fe1c9121 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -25,6 +25,7 @@ class ModelAPI_ResultPart; class ModelAPI_ResultGroup; class ModelAPI_ResultParameter; class ModelAPI_Data; +class GeomAPI_Shape; /**\class ModelAPI_Document * \ingroup DataModel @@ -157,6 +158,11 @@ public: /// Returns true if document is opened and valid virtual bool isOpened() = 0; + /// Returns the feature that produced the given face of the given result. + virtual std::shared_ptr producedByFeature( + std::shared_ptr theResult, + const std::shared_ptr& theShape) = 0; + protected: //! Only for SWIG wrapping it is here diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index 1eb15216c..22d983712 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -38,7 +38,7 @@ int SketcherPrs_PositionMgr::getPositionIndex(ObjectPtr theLine, return aPosMap[thePrs]; } else { // Add a new [Presentation - Index] pair - int aInd = aPosMap.size(); + int aInd = int(aPosMap.size()); aPosMap[thePrs] = aInd; return aInd; }