SHAPER 9.16.0
SolveSpaceSolver_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 SolveSpaceSolver_Storage_H_
21#define SolveSpaceSolver_Storage_H_
22
23#include <SketchSolver_Storage.h>
24#include <SolveSpaceSolver_Solver.h>
25
26#include <list>
27#include <memory>
28#include <set>
29#include <vector>
30
31typedef std::list< std::set<ConstraintWrapperPtr> > SameConstraintMap;
32
39{
40public:
41 SolveSpaceSolver_Storage(const GroupID& theGroup);
42
43// ============= Inherited from SketchSolver_Storage =============
44
47 virtual bool update(ConstraintWrapperPtr theConstraint);
50 virtual bool update(EntityWrapperPtr theEntity);
53 virtual bool update(ParameterWrapperPtr theParameter);
54
57 virtual void refresh(bool theFixedOnly = false) const;
58
61 virtual void verifyFixed();
62
64 virtual void addCoincidentPoints(EntityWrapperPtr theMaster, EntityWrapperPtr theSlave);
65
68 virtual EntityWrapperPtr calculateMiddlePoint(EntityWrapperPtr theBase, double theCoeff);
69
70protected:
73 virtual bool remove(ConstraintWrapperPtr theConstraint);
76 virtual bool remove(EntityWrapperPtr theEntity);
79 virtual bool remove(ParameterWrapperPtr theParameter);
80
82 virtual void changeGroup(EntityWrapperPtr theEntity, const GroupID& theGroup);
84 virtual void changeGroup(ParameterWrapperPtr theParam, const GroupID& theGroup);
85
86
87// ============= Own methods =============
88public:
90 void storeWorkplane(EntityWrapperPtr theSketch);
91
96 Slvs_hParam addParameter(const Slvs_Param& theParam);
101 Slvs_hParam updateParameter(const Slvs_Param& theParam);
106 bool removeParameter(const Slvs_hParam& theParamID);
108 const Slvs_Param& getParameter(const Slvs_hParam& theParamID) const;
109
114 Slvs_hEntity addEntity(const Slvs_Entity& theEntity);
119 Slvs_hEntity updateEntity(const Slvs_Entity& theEntity);
125 bool removeEntity(const Slvs_hEntity& theEntityID);
127 const Slvs_Entity& getEntity(const Slvs_hEntity& theEntityID) const;
129 const Slvs_hEntity& entityMaxID() const
130 { return myEntityMaxID; }
131
136 Slvs_hConstraint addConstraint(const Slvs_Constraint& theConstraint);
142 Slvs_hConstraint updateConstraint(const Slvs_Constraint& theConstraint);
148 bool removeConstraint(const Slvs_hConstraint& theConstraintID);
150 const Slvs_Constraint& getConstraint(const Slvs_hConstraint& theConstraintID) const;
152 size_t nbConstraints() const
153 { return myConstraints.size(); }
154
156 virtual bool hasDuplicatedConstraint() const
157 { return myDuplicatedConstraint; }
158
160 virtual void initializeSolver(SolverPtr theSolver);
161
162private:
164 void adjustArc(const Slvs_Entity& theArc);
165
167 void replaceInFeatures(EntityWrapperPtr theSource, EntityWrapperPtr theDest);
169 void replaceInConstraints(EntityWrapperPtr theSource, EntityWrapperPtr theDest);
170
175 void addSameConstraints(ConstraintWrapperPtr theConstraint1,
176 ConstraintWrapperPtr theConstraint2);
177
179 bool findSameConstraint(ConstraintWrapperPtr theConstraint);
180
181private:
182 Slvs_hEntity myWorkplaneID;
183
185 Slvs_hParam myParamMaxID;
186
188 std::vector<Slvs_Param> myParameters;
189 Slvs_hEntity myEntityMaxID;
190
192 std::vector<Slvs_Entity> myEntities;
193
195 Slvs_hConstraint myConstrMaxID;
196
198 std::vector<Slvs_Constraint> myConstraints;
199
200 bool myDuplicatedConstraint;
201
202 SameConstraintMap myEqualConstraints;
203};
204
205#endif
Interface to map SketchPlugin features to the entities of corresponding solver.
Definition: SketchSolver_Storage.h:44
virtual void refresh() const =0
Update SketchPlugin features after resolving constraints.
Contains all necessary data in SolveSpace format to solve a single group of constraints.
Definition: SolveSpaceSolver_Storage.h:39
virtual bool remove(ConstraintWrapperPtr theConstraint)
Remove constraint.
Definition: SolveSpaceSolver_Storage.cpp:915
const Slvs_Param & getParameter(const Slvs_hParam &theParamID) const
Returns the parameter by its ID.
Definition: SolveSpaceSolver_Storage.cpp:671
virtual bool update(ConstraintWrapperPtr theConstraint)
Update constraint's data.
Definition: SolveSpaceSolver_Storage.cpp:66
const Slvs_Constraint & getConstraint(const Slvs_hConstraint &theConstraintID) const
Returns the constraint by its ID.
Definition: SolveSpaceSolver_Storage.cpp:878
virtual void verifyFixed()
Check if some parameters or entities are returned to the current group after removing temporary const...
Definition: SolveSpaceSolver_Storage.cpp:1082
size_t nbConstraints() const
Returns quantity of constraints in this storage.
Definition: SolveSpaceSolver_Storage.h:152
virtual void initializeSolver(SolverPtr theSolver)
Initialize constraint solver by the entities collected by current storage.
Definition: SolveSpaceSolver_Storage.cpp:891
Slvs_hEntity addEntity(const Slvs_Entity &theEntity)
Add new entity to the current group.
Definition: SolveSpaceSolver_Storage.cpp:684
virtual bool hasDuplicatedConstraint() const
Shows the storage has the same constraint twice.
Definition: SolveSpaceSolver_Storage.h:156
bool removeEntity(const Slvs_hEntity &theEntityID)
Removes the entity by its ID.
Definition: SolveSpaceSolver_Storage.cpp:719
Slvs_hParam updateParameter(const Slvs_Param &theParam)
Updates parameter in the current group.
Definition: SolveSpaceSolver_Storage.cpp:633
Slvs_hConstraint updateConstraint(const Slvs_Constraint &theConstraint)
Updates constraint in the current group.
Definition: SolveSpaceSolver_Storage.cpp:808
const Slvs_Entity & getEntity(const Slvs_hEntity &theEntityID) const
Returns the entity by its ID.
Definition: SolveSpaceSolver_Storage.cpp:764
Slvs_hEntity updateEntity(const Slvs_Entity &theEntity)
Updates entity in the current group.
Definition: SolveSpaceSolver_Storage.cpp:701
virtual void changeGroup(EntityWrapperPtr theEntity, const GroupID &theGroup)
Update the group for the given entity, its sub-entities and parameters.
Definition: SolveSpaceSolver_Storage.cpp:255
virtual void addCoincidentPoints(EntityWrapperPtr theMaster, EntityWrapperPtr theSlave)
Mark two points as coincident.
Definition: SolveSpaceSolver_Storage.cpp:292
Slvs_hConstraint addConstraint(const Slvs_Constraint &theConstraint)
Add new constraint to the current group.
Definition: SolveSpaceSolver_Storage.cpp:777
bool removeConstraint(const Slvs_hConstraint &theConstraintID)
Removes the constraint by its ID.
Definition: SolveSpaceSolver_Storage.cpp:850
const Slvs_hEntity & entityMaxID() const
Returns maximal ID of entities in this storage.
Definition: SolveSpaceSolver_Storage.h:129
Slvs_hParam addParameter(const Slvs_Param &theParam)
Add new parameter to the current group.
Definition: SolveSpaceSolver_Storage.cpp:616
bool removeParameter(const Slvs_hParam &theParamID)
Removes the parameter by its ID.
Definition: SolveSpaceSolver_Storage.cpp:652
virtual EntityWrapperPtr calculateMiddlePoint(EntityWrapperPtr theBase, double theCoeff)
Calculate point on theBase entity.
Definition: SolveSpaceSolver_Storage.cpp:530
void storeWorkplane(EntityWrapperPtr theSketch)
Obtain and store identifier of sketch.
Definition: SolveSpaceSolver_Storage.cpp:235