]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1389: process results on coincidences object finding
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 4 Apr 2016 13:00:22 +0000 (16:00 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 4 Apr 2016 13:00:36 +0000 (16:00 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index e353cb8a48ed53d0535472e9ed05e906b6d0662c..a18ac9a530d015a35773ee251ea16ff33e83bf2a 100644 (file)
@@ -153,10 +153,11 @@ bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*
         FeaturePtr aCoincident = PartSet_Tools::findFirstCoincidence(aFeature, aSelPnt);
         // If we have coincidence then add Detach menu
         if (aCoincident.get() != NULL) {
+          QList<FeaturePtr> aCoins;
           mySelectedFeature = aCoincident;
-          PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines,
+          PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines, aCoins,
                                           SketchPlugin_ConstraintCoincidence::ENTITY_A());
-          PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines,
+          PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines, aCoins,
                                           SketchPlugin_ConstraintCoincidence::ENTITY_B());
           if (myCoinsideLines.size() > 0) {
             aIsDetach = true;
index 27921bf5e60b2a5dcac162d4259caacdf234a315..7edba2413699d20eab7c83742c2fd3503b5a6ec1 100755 (executable)
@@ -776,8 +776,7 @@ FeaturePtr findFirstCoincidenceByData(const DataPtr& theData, std::shared_ptr<Ge
 }
 
 FeaturePtr PartSet_Tools::findFirstCoincidence(const FeaturePtr& theFeature,
-                                               std::shared_ptr<GeomAPI_Pnt2d> thePoint,
-                                               const bool theSearchInResults)
+                                               std::shared_ptr<GeomAPI_Pnt2d> thePoint)
 {
   FeaturePtr aCoincident;
   if (theFeature.get() == NULL)
@@ -804,42 +803,79 @@ FeaturePtr PartSet_Tools::findFirstCoincidence(const FeaturePtr& theFeature,
       }
     }
   }
-  if (theSearchInResults) {
-    if (!aCoincident.get()) {
-      std::list<ResultPtr> aResults = theFeature->results();
-      std::list<ResultPtr>::const_iterator aIt;
-      for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-        ResultPtr aResult = *aIt;
-        aCoincident = findFirstCoincidenceByData(aResult->data(), thePoint);
-        if (aCoincident.get())
-          break;
-      }
+  /// Find by result
+  if (!aCoincident.get()) {
+    std::list<ResultPtr> aResults = theFeature->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+      ResultPtr aResult = *aIt;
+      aCoincident = findFirstCoincidenceByData(aResult->data(), thePoint);
+      if (aCoincident.get())
+        break;
     }
   }
   return aCoincident;
 }
 
 void PartSet_Tools::findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList,
+                                     QList<FeaturePtr>& theCoincidencies,
                                      std::string theAttr)
 {
+  std::shared_ptr<GeomAPI_Pnt2d> aOrig = getCoincedencePoint(theStartCoin);
+  if (aOrig.get() == NULL)
+    return;
+
   AttributeRefAttrPtr aPnt = theStartCoin->refattr(theAttr);
-  if (!aPnt) return;
-  FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object());
-  if (!theList.contains(aObj)) {
-    std::shared_ptr<GeomAPI_Pnt2d> aOrig = getCoincedencePoint(theStartCoin);
-    if (aOrig.get() == NULL)
-      return;
-    theList.append(aObj);
-    const std::set<AttributePtr>& aRefsList = aObj->data()->refsToMe();
-    std::set<AttributePtr>::const_iterator aIt;
-    for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
-      std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
-      FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
-      if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
-        std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
-        if (aPnt.get() && aOrig->isEqual(aPnt)) {
-          findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_A());
-          findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_B());
+  if (!aPnt) 
+    return;
+  ObjectPtr aObj = aPnt->object();
+  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+  if (aFeature.get()) {
+    if (!theList.contains(aFeature)) {
+      theList.append(aFeature);
+      theCoincidencies.append(theStartCoin);
+      const std::set<AttributePtr>& aRefsList = aFeature->data()->refsToMe();
+      std::set<AttributePtr>::const_iterator aIt;
+      for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+        std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
+        FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
+        if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
+          if (!theCoincidencies.contains(aConstrFeature)) {
+            std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
+            if (aPnt.get() && aOrig->isEqual(aPnt)) {
+              findCoincidences(aConstrFeature, theList, theCoincidencies, 
+                SketchPlugin_ConstraintCoincidence::ENTITY_A());
+              findCoincidences(aConstrFeature, theList, theCoincidencies, 
+                SketchPlugin_ConstraintCoincidence::ENTITY_B());
+            }
+          }
+        }
+      }
+    }
+  } else {
+    // Find by Results
+    ResultConstructionPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+    if (aResult.get()) {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(aPnt->object());
+      if (!theList.contains(aFeature)) 
+        theList.append(aFeature);
+      theCoincidencies.append(theStartCoin);
+
+      const std::set<AttributePtr>& aRefsList = aResult->data()->refsToMe();
+      std::set<AttributePtr>::const_iterator aIt;
+      for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+        std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
+        FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
+        if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
+          if (!theCoincidencies.contains(aConstrFeature)) {
+            std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
+            if (aPnt.get() && aOrig->isEqual(aPnt)) {
+              findCoincidences(aConstrFeature, theList, theCoincidencies, 
+                SketchPlugin_ConstraintCoincidence::ENTITY_A());
+              findCoincidences(aConstrFeature, theList, theCoincidencies, 
+                SketchPlugin_ConstraintCoincidence::ENTITY_B());
+            }
+          }
         }
       }
     }
index e4b034f3cc5b52ad0f8741837317d4cd78e29209..8db945e80eb58f24647e82aceb9e2b0a11a776df 100755 (executable)
@@ -235,8 +235,7 @@ public:
   * \return the coincidence feature or null
   */
   static FeaturePtr findFirstCoincidence(const FeaturePtr& theFeature,
-                                         std::shared_ptr<GeomAPI_Pnt2d> thePoint,
-                                         const bool theSearchInResults = false);
+                                         std::shared_ptr<GeomAPI_Pnt2d> thePoint);
 
   /**
   * Returns list of features connected in a councedence feature point
@@ -245,6 +244,7 @@ public:
   * \param theAttr the attribute name
   */
   static void findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList,
+                               QList<FeaturePtr>& theCoincidencies,
                                std::string theAttr);
 
   /**
index 163063bd0b514ba46ac4bb844ae5dc0701230762..7cb22655f9b8fb4d571622a4238aeeb946a32f2d 100755 (executable)
@@ -638,6 +638,7 @@ bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute,
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
   QList<FeaturePtr> aCoinsideLines;
+  QList<FeaturePtr> aCoins;
 
   bool isObject = aRefAttr->isObject();
   ObjectPtr anObject = aRefAttr->object();
@@ -663,9 +664,9 @@ bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute,
         AttributePtr aAR = aRAttr->attr();
         if (aAR->id() != SketchPlugin_Arc::CENTER_ID()) // ignore constraint to center of arc
           aCoinList.insert(aConstrFeature);
-          PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines,
+          PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
                                           SketchPlugin_ConstraintCoincidence::ENTITY_A());
-          PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines,
+          PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
                                           SketchPlugin_ConstraintCoincidence::ENTITY_B());
       }
     }
index 82f7683c2919e7787f2f0d88a5787be182c1673f..8543f3143a8f1497c1e8cce4358270865d37853a 100644 (file)
@@ -470,7 +470,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
             if (aShape.ShapeType() == TopAbs_VERTEX) {
               FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject);
               if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) {
-                anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY, true);
+                anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY);
               }
             }
           }
@@ -650,7 +650,7 @@ bool PartSet_WidgetPoint2D::useSelectedShapes() const
 
 bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
                                           const CompositeFeaturePtr& theSketch,
-                                          double theX, double theY, const bool theSearchInResults)
+                                          double theX, double theY)
 {
   bool anOrphanPoint = false;
   if (theFeature.get()) {
@@ -681,14 +681,15 @@ bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
       std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
       // we need to find coincidence features in results also, because external object(point)
       // uses refs to me in another feature.
-      FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint, theSearchInResults);
+      FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint);
       anOrphanPoint = true;
       // if there is at least one concident line to the point, the point is not an orphant
       if (aCoincidence.get()) {
         QList<FeaturePtr> aCoinsideLines;
-        PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
+        QList<FeaturePtr> aCoins;
+        PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines, aCoins,
                                         SketchPlugin_ConstraintCoincidence::ENTITY_A());
-        PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
+        PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines, aCoins,
                                         SketchPlugin_ConstraintCoincidence::ENTITY_B());
         QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(),
                                           aLast = aCoinsideLines.end();
index e179720d3bde7b0dedc1db1a4aebdc36c2b593cb..711e37c1cecadc4d6f8f182a8ea1958bb8a0de9f 100755 (executable)
@@ -175,7 +175,7 @@ protected:
    /// \param theY an Y coordinate of the point
    /// \return boolean result
    static bool isOrphanPoint(const FeaturePtr& theFeature, const CompositeFeaturePtr& theSketch,
-                             double theX, double theY, const bool theSearchInResults = false);
+                             double theX, double theY);
 
 protected:
   ModuleBase_IWorkshop* myWorkshop; ///< workshop