SHAPER  9.12.0
SketchSolver_Storage.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef SketchSolver_Storage_H_
21 #define SketchSolver_Storage_H_
22 
23 #include <PlaneGCSSolver_ConstraintWrapper.h>
24 #include <PlaneGCSSolver_EntityWrapper.h>
25 
26 #include <PlaneGCSSolver_Solver.h>
27 #include <PlaneGCSSolver_UpdateFeature.h>
28 
29 #include <ModelAPI_Attribute.h>
30 #include <ModelAPI_AttributeDouble.h>
31 #include <ModelAPI_Feature.h>
32 #include <SketchPlugin_Constraint.h>
33 
35 class SketchSolver_ConstraintFixedArcRadius;
36 typedef std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > CoincidentPointsMap;
37 
38 
44 {
45 private:
47  SketchSolver_Storage& operator=(const SketchSolver_Storage&);
48 
49 public:
50  SketchSolver_Storage(SolverPtr theSolver);
51 
56  virtual void addConstraint(ConstraintPtr theConstraint,
57  ConstraintWrapperPtr theSolverConstraint);
58 
62  virtual void addMovementConstraint(const ConstraintWrapperPtr& theSolverConstraint) = 0;
63 
68  void addEntity(FeaturePtr theFeature,
69  EntityWrapperPtr theSolverEntity);
70 
75  void addEntity(AttributePtr theAttribute,
76  EntityWrapperPtr theSolverEntity);
77 
82  virtual bool update(FeaturePtr theFeature, bool theForce = false) = 0;
83 
88  virtual bool update(AttributePtr theAttribute, bool theForce = false) = 0;
89 
91  const ConstraintWrapperPtr& constraint(const ConstraintPtr& theConstraint) const;
92 
94  const EntityWrapperPtr& entity(const FeaturePtr& theFeature) const;
96  const EntityWrapperPtr& entity(const AttributePtr& theAttribute) const;
97 
99  virtual void makeExternal(const EntityWrapperPtr& theEntity) = 0;
101  virtual void makeNonExternal(const EntityWrapperPtr& theEntity) = 0;
102 
105  virtual bool removeConstraint(ConstraintPtr theConstraint) = 0;
107  void removeFeature(FeaturePtr theFeature);
109  void removeAttribute(AttributePtr theAttribute);
110 
112  virtual void removeInvalidEntities() = 0;
113 
115  bool areFeaturesValid() const;
116 
118  virtual bool isEmpty() const
119  { return myConstraintMap.empty(); }
120 
122  virtual bool isNeedToResolve()
123  { return myNeedToResolve; }
125  void setNeedToResolve(bool theFlag)
126  { myNeedToResolve = theFlag; }
127 
129  std::set<ObjectPtr> getConflictingConstraints(SolverPtr theSolver) const;
130 
132  virtual void getUnderconstrainedGeometry(std::set<ObjectPtr>& theFeatures) const = 0;
133 
138 
140  virtual void refresh() const = 0;
141 
143  void blockEvents(bool isBlocked);
144 
148  void subscribeUpdates(SketchSolver_Constraint* theSubscriber, const std::string& theGroup) const;
151  void unsubscribeUpdates(SketchSolver_Constraint* theSubscriber) const;
152 
154  void notify(const FeaturePtr& theFeature) const;
155 
159  virtual void adjustParametrizationOfArcs() = 0;
160 
161 protected:
163  static void resultToFeatureOrAttribute(const ObjectPtr& theResult,
164  FeaturePtr& theFeature,
165  AttributePtr& theAttribute);
166 
167 protected:
168  SolverPtr mySketchSolver;
171 
173  std::map<ConstraintPtr, ConstraintWrapperPtr> myConstraintMap;
175  std::map<FeaturePtr, EntityWrapperPtr> myFeatureMap;
177  std::map<AttributePtr, EntityWrapperPtr> myAttributeMap;
178 
179  UpdaterPtr myUpdaters;
180 };
181 
182 typedef std::shared_ptr<SketchSolver_Storage> StoragePtr;
183 
184 #endif
SolveStatus
The result of constraints solution.
Definition: PlaneGCSSolver_Solver.h:33
Convert distance constraint to SolveSpace structure.
Definition: SketchSolver_ConstraintDistance.h:30
Converts SketchPlugin constraint to the constraint applicable for solver.
Definition: SketchSolver_Constraint.h:39
Interface to map SketchPlugin features to the entities of corresponding solver.
Definition: SketchSolver_Storage.h:44
void subscribeUpdates(SketchSolver_Constraint *theSubscriber, const std::string &theGroup) const
Subscribe for updates of features.
Definition: SketchSolver_Storage.cpp:227
virtual bool isNeedToResolve()
Shows the sketch should be resolved.
Definition: SketchSolver_Storage.h:122
bool areFeaturesValid() const
Check the features have not been removed.
Definition: SketchSolver_Storage.cpp:189
bool myEventsBlocked
indicates that features do not send events
Definition: SketchSolver_Storage.h:170
SolverPtr mySketchSolver
Sketch solver, prepared in corresponding group.
Definition: SketchSolver_Storage.h:168
virtual void makeExternal(const EntityWrapperPtr &theEntity)=0
Make entity external.
void notify(const FeaturePtr &theFeature) const
Notify all subscribers about update of the feature.
Definition: SketchSolver_Storage.cpp:238
void addEntity(FeaturePtr theFeature, EntityWrapperPtr theSolverEntity)
Change mapping feature from SketchPlugin and the entity applicable for corresponding solver.
Definition: SketchSolver_Storage.cpp:96
virtual bool isEmpty() const
Check the storage has constraints.
Definition: SketchSolver_Storage.h:118
bool myNeedToResolve
parameters are changed and group needs to be resolved
Definition: SketchSolver_Storage.h:169
virtual void getUnderconstrainedGeometry(std::set< ObjectPtr > &theFeatures) const =0
Return list of features which are not fully constrained.
void blockEvents(bool isBlocked)
Block or unblock events when refreshing features.
Definition: SketchSolver_Storage.cpp:199
const ConstraintWrapperPtr & constraint(const ConstraintPtr &theConstraint) const
Returns constraint related to corresponding constraint.
Definition: SketchSolver_Storage.cpp:125
virtual void removeInvalidEntities()=0
Remove all features became invalid.
virtual void refresh() const =0
Update SketchPlugin features after resolving constraints.
void removeAttribute(AttributePtr theAttribute)
Removes attribute from the storage.
Definition: SketchSolver_Storage.cpp:182
virtual PlaneGCSSolver_Solver::SolveStatus checkDegeneratedGeometry() const =0
Verify, the sketch contains degenerated geometry after resolving the set of constraints.
void unsubscribeUpdates(SketchSolver_Constraint *theSubscriber) const
Unsubscribe for updates of features.
Definition: SketchSolver_Storage.cpp:233
virtual void addMovementConstraint(const ConstraintWrapperPtr &theSolverConstraint)=0
Add a movement constraint which will be destroyed after the next solving of the set of constraints.
std::set< ObjectPtr > getConflictingConstraints(SolverPtr theSolver) const
Return list of conflicting constraints.
Definition: SketchSolver_Storage.cpp:215
virtual void adjustParametrizationOfArcs()=0
Make parametrization of arcs consistent.
std::map< AttributePtr, EntityWrapperPtr > myAttributeMap
map attribute to solver's entity
Definition: SketchSolver_Storage.h:177
std::map< FeaturePtr, EntityWrapperPtr > myFeatureMap
map SketchPlugin feature to solver's entity
Definition: SketchSolver_Storage.h:175
std::map< ConstraintPtr, ConstraintWrapperPtr > myConstraintMap
map SketchPlugin constraint to a list of solver's constraints
Definition: SketchSolver_Storage.h:173
virtual bool update(FeaturePtr theFeature, bool theForce=false)=0
Convert feature to the form applicable for specific solver and map it.
void setNeedToResolve(bool theFlag)
Changes the flag of group to be resolved.
Definition: SketchSolver_Storage.h:125
virtual void makeNonExternal(const EntityWrapperPtr &theEntity)=0
Make entity non-external.
void removeFeature(FeaturePtr theFeature)
Removes feature from the storage.
Definition: SketchSolver_Storage.cpp:176
static void resultToFeatureOrAttribute(const ObjectPtr &theResult, FeaturePtr &theFeature, AttributePtr &theAttribute)
Convert result to feature or attribute if theResult is linked to center of circle/arc.
Definition: SketchSolver_Storage.cpp:243
const EntityWrapperPtr & entity(const FeaturePtr &theFeature) const
Returns entity related to corresponding feature.
Definition: SketchSolver_Storage.cpp:137
virtual bool update(AttributePtr theAttribute, bool theForce=false)=0
Convert attribute to the form applicable for specific solver and map it.
virtual void addConstraint(ConstraintPtr theConstraint, ConstraintWrapperPtr theSolverConstraint)
Change mapping between constraint from SketchPlugin and a constraint applicable for corresponding sol...
Definition: SketchSolver_Storage.cpp:46
virtual bool removeConstraint(ConstraintPtr theConstraint)=0
Removes constraint from the storage.