]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.5 Show where the remaining degrees of freedom are (issue #2997)
authorazv <azv@opencascade.com>
Tue, 8 Oct 2019 12:23:50 +0000 (15:23 +0300)
committerazv <azv@opencascade.com>
Tue, 8 Oct 2019 12:24:24 +0000 (15:24 +0300)
Implement the possibility to collect underconstrained features in SketchSolver plugin.

src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Storage.h

index 416b338b05d4dadbedc3a8da7686886c34ece178..9716ae68c4954f897e73428188767137f5e22d50 100644 (file)
@@ -243,6 +243,11 @@ void PlaneGCSSolver_Solver::diagnose(const GCS::Algorithm& theAlgo)
   myDiagnoseBeforeSolve = false;
 }
 
+void PlaneGCSSolver_Solver::getFreeParameters(GCS::VEC_pD& theFreeParams) const
+{
+  myEquationSystem->getDependentParams(theFreeParams);
+}
+
 void PlaneGCSSolver_Solver::addFictiveConstraintIfNecessary()
 {
   bool hasOnlyMovement = true;
index 4fb2abce9eafd65f615cecdbf8d6941eb84a0430..e6c1b4ba5940c695c2653e270c1c704770ad3070 100644 (file)
@@ -79,6 +79,9 @@ public:
   /// \brief Check conflicting/redundant constraints and DoF
   void diagnose(const GCS::Algorithm& theAlgo = GCS::DogLeg);
 
+  /// \brief Return the list of modifiable parameters
+  void getFreeParameters(GCS::VEC_pD& theFreeParams) const;
+
   /// \brief Degrees of freedom
   int dof();
 
index 4f546aacce57e886154834202d6e9f626bccaec8..6404c4636515e8f72ca99d5532dc012a810d690f 100644 (file)
@@ -654,3 +654,27 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Storage::checkDegeneratedGeome
   }
   return PlaneGCSSolver_Solver::STATUS_OK;
 }
+
+
+void PlaneGCSSolver_Storage::getUnderconstrainedGeometry(std::set<FeaturePtr>& theFeatures) const
+{
+  std::vector<double*> aFreeParams;
+  mySketchSolver->getFreeParameters(aFreeParams);
+  if (aFreeParams.empty())
+    return;
+
+  std::map<double*, FeaturePtr> aParamOfFeatures;
+  for (std::map<FeaturePtr, EntityWrapperPtr>::const_iterator aFIt = myFeatureMap.begin();
+       aFIt != myFeatureMap.end(); ++aFIt) {
+    GCS::SET_pD aParams = PlaneGCSSolver_Tools::parameters(aFIt->second);
+    for (GCS::SET_pD::iterator aPIt = aParams.begin(); aPIt != aParams.end(); ++aPIt)
+      aParamOfFeatures[*aPIt] = aFIt->first;
+  }
+
+  for (std::vector<double*>::iterator anIt = aFreeParams.begin();
+       anIt != aFreeParams.end(); ++anIt) {
+    std::map<double*, FeaturePtr>::iterator aFound = aParamOfFeatures.find(*anIt);
+    if (aFound != aParamOfFeatures.end())
+      theFeatures.insert(aFound->second);
+  }
+}
index eafa686c47620bee46177f3dd8d7568fbf534955..3c350e90dd0eb3a8fdca1c0e3685cdb5e46efee8 100644 (file)
@@ -95,6 +95,9 @@ public:
   ///        Reversed arcs should have the last parameter lesser than the first parameter.
   virtual void adjustParametrizationOfArcs();
 
+  /// \brief Return list of features which are not fully constrained
+  virtual void getUnderconstrainedGeometry(std::set<FeaturePtr>& theFeatures) const;
+
 private:
   /// \brief Convert feature using specified builder.
   EntityWrapperPtr createFeature(const FeaturePtr&             theFeature,
index ab9b38fc2df6789e841b275e22e425f2805d9e19..2662f564de0453be83fbed8d288390117bf776cd 100644 (file)
@@ -496,3 +496,8 @@ bool SketchSolver_Group::areConstraintsValid() const
       return false;
   return true;
 }
+
+void SketchSolver_Group::underconstrainedFeatures(std::set<FeaturePtr>& theFeatures) const
+{
+  myStorage->getUnderconstrainedGeometry(theFeatures);
+}
index ed938f5d0c45f9c9749cf88d06a04650f49457f3..e76edf2d23e24eb1c02e3305b40da63da3fcd0a6 100644 (file)
@@ -115,6 +115,9 @@ class SketchSolver_Group
    */
   bool resolveConstraints();
 
+  /// \brief Find the list of features, which are not fully constrained.
+  void underconstrainedFeatures(std::set<FeaturePtr>& theFeatures) const;
+
   /// \brief Block or unblock events sent by features in this group
   void blockEvents(bool isBlocked);
 
index 00be4b13ef380f8f4151421c488062db0d608331..04fc5914875e1c64474d55d658a489ad137b1e75 100644 (file)
@@ -223,6 +223,19 @@ void SketchSolver_Manager::processEvent(
     }
     myIsComputed = false;
   }
+////  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURES_OF_FREEDOM)) {
+////    FeaturePtr aComposite = theMessage->sketch();
+////    std::shared_ptr<SketchPlugin_Feature> aSketch =
+////        std::dynamic_pointer_cast<SketchPlugin_Feature>(aComposite);
+////    if (aSketch) {
+////      SketchGroupPtr aGroup = findGroup(aSketch);
+////
+////      std::set<FeaturePtr> aFreeFeatures;
+////      aGroup->underconstrainedFeatures(aFreeFeatures);
+////
+////      // TODO: send features to GUI
+////    }
+////  }
 
   // resolve constraints if needed
   bool needToUpdate = needToResolve && resolveConstraints();
index 0757abfb7f2abf3f060ff3559a7fec4f09f70831..0f518b2fae67dc6a002c2477ce333d037b0db0dc 100644 (file)
@@ -128,6 +128,9 @@ public:
   /// \brief Return list of conflicting constraints
   std::set<ObjectPtr> getConflictingConstraints(SolverPtr theSolver) const;
 
+  /// \brief Return list of features which are not fully constrained
+  virtual void getUnderconstrainedGeometry(std::set<FeaturePtr>& theFeatures) const = 0;
+
   /// \brief Verify, the sketch contains degenerated geometry
   ///        after resolving the set of constraints
   /// \return STATUS_OK if the geometry is valid, STATUS_DEGENERATED otherwise.