]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Creation of producedByFeature initial implementation neede for the issue #1306
authormpv <mpv@opencascade.com>
Wed, 6 Apr 2016 14:01:57 +0000 (17:01 +0300)
committermpv <mpv@opencascade.com>
Wed, 6 Apr 2016 14:01:57 +0000 (17:01 +0300)
src/GeomAPI/GeomAPI_Shape.cpp
src/Model/Model_Application.cpp
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/ModelAPI/ModelAPI_Document.h
src/SketcherPrs/SketcherPrs_PositionMgr.cpp

index 3ae40cab1238b28e440b0050f1e29bd7645e98d5..279e3738a712ad482aec9eb2e6893e08e47e0349 100644 (file)
@@ -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;
   }
index 704a6afdc81d9b0f1a3c91eb5c1b0d44611f673d..324cefee0cf882997a9d530f08786ae8284faf1c 100644 (file)
@@ -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;
 }
index 7dd2b7366b197e1f327125bf8f360ad8ad4d1b82..bb2881544210d5fb1fc17184be438e05fc29a173 100755 (executable)
@@ -15,6 +15,7 @@
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultBody.h>
 
 #include <Events_Loop.h>
 #include <Events_Error.h>
@@ -38,6 +39,9 @@
 #include <TDF_AttributeDeltaList.hxx>
 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TNaming_SameShapeIterator.hxx>
+
 
 #include <climits>
 #ifndef WIN32
@@ -1266,3 +1270,32 @@ FeaturePtr Model_Document::lastFeature()
     return myObjs->lastFeature();
   return FeaturePtr();
 }
+
+std::shared_ptr<ModelAPI_Feature> Model_Document::producedByFeature(
+    std::shared_ptr<ModelAPI_Result> theResult,
+    const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(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<TopoDS_Shape>();
+  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;
+}
index 6f0b2bee68a1f38058e8c8cf21669e560966614c..312472a8d4cf3919a2330695fb8b741de34f6044 100644 (file)
@@ -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<ModelAPI_Feature> producedByFeature(
+    std::shared_ptr<ModelAPI_Result> theResult,
+    const std::shared_ptr<GeomAPI_Shape>& theShape);
+
  protected:
   //! Returns (creates if needed) the general label
   TDF_Label generalLabel() const;
index 8c1297359b113bdbe76c4156f6aa546717d14d64..6fe1c9121fbdbeda6def3657e870fb062f3cd1e8 100644 (file)
@@ -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<ModelAPI_Feature> producedByFeature(
+    std::shared_ptr<ModelAPI_Result> theResult,
+    const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
 
 protected:
   //! Only for SWIG wrapping it is here
index 1eb15216c24f051af4d2e9eed72d8857f84f9f5d..22d9837129720d09cd36def4c13187900df73568 100644 (file)
@@ -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;
     }