]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update conditions to add arc into solver (issue #1165)
authorazv <azv@opencascade.com>
Wed, 23 Dec 2015 11:24:35 +0000 (14:24 +0300)
committerazv <azv@opencascade.com>
Wed, 23 Dec 2015 11:24:35 +0000 (14:24 +0300)
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.h
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp

index 4fa74d07e6624121d38cb6718fbfc9e88a47fbef..0d12d6d478fb57f27b8f56d0d21eadc67cf72b75 100644 (file)
@@ -968,6 +968,11 @@ void PlaneGCSSolver_Storage::initializeSolver(SolverPtr theSolver)
 {
   std::shared_ptr<PlaneGCSSolver_Solver> aSolver =
       std::dynamic_pointer_cast<PlaneGCSSolver_Solver>(theSolver);
+  if (!aSolver)
+    return;
+
+  if (myExistArc)
+    processArcs();
 
   // initialize constraints
   std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
index 798935ecf3852f2160080a4591da52b8804ece22..fed8d3e82d2cb6c5860a2567c4ae73649f434b23 100644 (file)
@@ -184,8 +184,10 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG
         if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && 
             aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && 
             aFeature->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) {
-////          myFeatureMap[aFeature] = EntityWrapperPtr();
           return SketchSolver_Storage::update(aFeature);
+        } else {
+          myFeatureMap[aFeature] = EntityWrapperPtr();
+          myExistArc = true;
         }
       }
     }
@@ -574,6 +576,22 @@ void SketchSolver_Storage::setSketch(const EntityWrapperPtr& theSketch)
   addEntity(FeaturePtr(), theSketch);
 }
 
+void SketchSolver_Storage::processArcs()
+{
+  myExistArc = false;
+  std::map<FeaturePtr, EntityWrapperPtr>::iterator aFIt = myFeatureMap.begin();
+  for (; aFIt != myFeatureMap.end(); ++aFIt)
+    if (!aFIt->second && aFIt->first->getKind() == SketchPlugin_Arc::ID()) {
+      // Additional checking the attributes are initialized
+      if (aFIt->first->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && 
+          aFIt->first->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && 
+          aFIt->first->attribute(SketchPlugin_Arc::END_ID())->isInitialized())
+        update(aFIt->first);
+      else
+        myExistArc = true;
+    }
+}
+
 void SketchSolver_Storage::blockEvents(bool isBlocked)
 {
   if (isBlocked == myEventsBlocked)
index a35a7366b5e53b6d8785e7461d9a5ca52f9c2feb..138c8994f71175389c0d97fa18c579a6ac310d7e 100644 (file)
@@ -37,7 +37,8 @@ public:
   SketchSolver_Storage(const GroupID& theGroup)
     : myGroupID(theGroup),
       myNeedToResolve(false),
-      myEventsBlocked(false)
+      myEventsBlocked(false),
+      myExistArc(false)
   {}
 
   /// \brief Change mapping between constraint from SketchPlugin and
@@ -200,6 +201,9 @@ protected:
   /// \brief Verify the attribute is used by constraint
   SKETCHSOLVER_EXPORT bool isUsed(AttributePtr theAttirubute) const;
 
+  /// \brief Find arcs without corresponding entity applicable for the solver and build them
+  SKETCHSOLVER_EXPORT void processArcs();
+
 private:
   /// \brief Find the normal of the sketch
   EntityWrapperPtr getNormal() const;
@@ -208,6 +212,7 @@ protected:
   GroupID myGroupID;       ///< identifier of the group, this storage belongs to
   bool    myNeedToResolve; ///< parameters are changed and group needs to be resolved
   bool    myEventsBlocked; ///< indicates that features do not send events
+  bool    myExistArc;      ///< the storage has any point of arc but not full arc, need to add it
 
   /// map SketchPlugin constraint to a list of solver's constraints
   std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> > myConstraintMap;
index 61ceb93042dfe3cd2149adcf91d25d2ddc225ff3..8cdc2204076207d264946fd9340c8b2a581243d8 100644 (file)
@@ -1134,6 +1134,9 @@ void SolveSpaceSolver_Storage::initializeSolver(SolverPtr theSolver)
   if (!aSolver)
     return;
 
+  if (myExistArc)
+    processArcs();
+
   if (myConstraints.empty()) {
     // Adjust all arc to place their points correctly
     std::vector<Slvs_Entity>::const_iterator anEntIt = myEntities.begin();