Salome HOME
Fix incorrect processing of the copied entities after the "Multi" constraint has...
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Storage.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    PlaneGCSSolver_Storage.h
4 // Created: 14 Dec 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef PlaneGCSSolver_Storage_H_
8 #define PlaneGCSSolver_Storage_H_
9
10 #include <PlaneGCSSolver_Defs.h>
11 #include <SketchSolver_Storage.h>
12
13 class PlaneGCSSolver_EntityBuilder;
14
15 /** \class   PlaneGCSSolver_Storage
16  *  \ingroup Plugins
17  *  \brief   Contains all necessary data in PlaneGCS format to solve a single group of constraints
18  */
19 class PlaneGCSSolver_Storage : public SketchSolver_Storage
20 {
21 public:
22   PlaneGCSSolver_Storage(const SolverPtr& theSolver);
23
24 // =============   Inherited from SketchSolver_Storage   =============
25
26   /// \brief Change mapping between constraint from SketchPlugin and
27   ///        a constraint applicable for corresponding solver.
28   /// \param theConstraint       [in]   original SketchPlugin constraint
29   /// \param theSolverConstraint [in]   solver's constraint
30   virtual void addConstraint(ConstraintPtr        theConstraint,
31                              ConstraintWrapperPtr theSolverConstraint);
32
33   /// \brief Add list of temporary constraints which will be destroyed
34   ///        after the next solving of the set of constraints.
35   /// \param theSolverConstraint [in]  solver's constraint
36   virtual void addTemporaryConstraint(const ConstraintWrapperPtr& theSolverConstraint);
37
38
39   /// \brief Convert feature to the form applicable for specific solver and map it
40   /// \param theFeature [in]  feature to convert
41   /// \param theForce   [in]  forced feature creation
42   /// \return \c true if the feature has been created or updated
43   virtual bool update(FeaturePtr theFeature, bool theForce = false);
44
45   /// \brief Convert attribute to the form applicable for specific solver and map it
46   /// \param theAttribute [in]  attribute to convert
47   /// \param theForce     [in]  forced feature creation
48   /// \return \c true if the attribute has been created or updated
49   virtual bool update(AttributePtr theAttribute, bool theForce = false);
50
51   /// \brief Make entity external
52   virtual void makeExternal(const EntityWrapperPtr& theEntity);
53   /// \brief Make entity non-external
54   virtual void makeNonExternal(const EntityWrapperPtr& theEntity);
55
56   /// \brief Removes constraint from the storage
57   /// \return \c true if the constraint and all its parameters are removed successfully
58   virtual bool removeConstraint(ConstraintPtr theConstraint);
59
60   /// \brief Update SketchPlugin features after resolving constraints
61   virtual void refresh() const;
62
63   /// \brief Initialize memory for new solver's parameter
64   double* createParameter();
65   /// \brief Release memory occupied by parameters
66   void removeParameters(const GCS::SET_pD& theParams);
67
68   /// \brief Remove all features became invalid
69   virtual void removeInvalidEntities();
70
71   /// \brief Check the storage has constraints
72   virtual bool isEmpty() const
73   { return SketchSolver_Storage::isEmpty() && myArcConstraintMap.empty(); }
74
75 private:
76   /// \brief Convert feature using specified builder.
77   EntityWrapperPtr createFeature(const FeaturePtr&             theFeature,
78                                  PlaneGCSSolver_EntityBuilder* theBuilder);
79
80   /// \brief Convert attribute using specified builder.
81   EntityWrapperPtr createAttribute(const AttributePtr&           theAttribute,
82                                    PlaneGCSSolver_EntityBuilder* theBuilder);
83
84   void createArcConstraints(const EntityWrapperPtr& theArc);
85   void removeArcConstraints(const EntityWrapperPtr& theArc);
86
87 private:
88   ConstraintID myConstraintLastID;   ///< identifier of last added constraint
89
90   /// additional constraints for correct processing of the arcs
91   std::map<EntityWrapperPtr, ConstraintWrapperPtr> myArcConstraintMap;
92
93   /// list of removed constraints to notify solver
94   std::list<GCSConstraintPtr> myRemovedConstraints;
95 };
96
97 #endif