SHAPER 9.16.0
SketchSolver_Storage.h
1// Copyright (C) 2014-2026 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
35class SketchSolver_ConstraintFixedArcRadius;
36typedef std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > CoincidentPointsMap;
37
38
44{
45private:
48
49public:
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;
106
107 virtual bool changeActiveStatus(ConstraintPtr theConstraint, bool theNewState) = 0;
108
109 virtual bool UpdateDeactivateList() = 0;
110
112 void removeFeature(FeaturePtr theFeature);
114 void removeAttribute(AttributePtr theAttribute);
115
117 virtual void removeInvalidEntities() = 0;
118
120 bool areFeaturesValid() const;
121
123 virtual bool isEmpty() const
124 { return myConstraintMap.empty(); }
125
127 virtual bool isNeedToResolve()
128 { return myNeedToResolve; }
130 void setNeedToResolve(bool theFlag)
131 { myNeedToResolve = theFlag; }
132
134 std::set<ObjectPtr> getConflictingConstraints(SolverPtr theSolver) const;
135
137 virtual void getUnderconstrainedGeometry(std::set<ObjectPtr>& theFeatures) const = 0;
138
143
145 virtual void refresh() const = 0;
146
148 void blockEvents(bool isBlocked);
149
153 void subscribeUpdates(SketchSolver_Constraint* theSubscriber, const std::string& theGroup) const;
156 void unsubscribeUpdates(SketchSolver_Constraint* theSubscriber) const;
157
159 void notify(const FeaturePtr& theFeature) const;
160
164 virtual void adjustParametrizationOfArcs() = 0;
165
166protected:
168 static void resultToFeatureOrAttribute(const ObjectPtr& theResult,
169 FeaturePtr& theFeature,
170 AttributePtr& theAttribute);
171
172protected:
173 SolverPtr mySketchSolver;
176
178 std::map<ConstraintPtr, ConstraintWrapperPtr> myConstraintMap;
180 std::map<FeaturePtr, EntityWrapperPtr> myFeatureMap;
182 std::map<AttributePtr, EntityWrapperPtr> myAttributeMap;
183
184 UpdaterPtr myUpdaters;
185 std::map<ConstraintPtr, ConstraintWrapperPtr> myDeactivatedConstraintMap;
186};
187
188typedef std::shared_ptr<SketchSolver_Storage> StoragePtr;
189
190#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:127
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:175
SolverPtr mySketchSolver
Sketch solver, prepared in corresponding group.
Definition: SketchSolver_Storage.h:173
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:123
bool myNeedToResolve
parameters are changed and group needs to be resolved
Definition: SketchSolver_Storage.h:174
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:182
std::map< FeaturePtr, EntityWrapperPtr > myFeatureMap
map SketchPlugin feature to solver's entity
Definition: SketchSolver_Storage.h:180
std::map< ConstraintPtr, ConstraintWrapperPtr > myConstraintMap
map SketchPlugin constraint to a list of solver's constraints
Definition: SketchSolver_Storage.h:178
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:130
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.