]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h
Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Storage.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef PlaneGCSSolver_Storage_H_
22 #define PlaneGCSSolver_Storage_H_
23
24 #include <PlaneGCSSolver_Defs.h>
25 #include <SketchSolver_Storage.h>
26
27 class PlaneGCSSolver_EntityBuilder;
28
29 /** \class   PlaneGCSSolver_Storage
30  *  \ingroup Plugins
31  *  \brief   Contains all necessary data in PlaneGCS format to solve a single group of constraints
32  */
33 class PlaneGCSSolver_Storage : public SketchSolver_Storage
34 {
35 public:
36   PlaneGCSSolver_Storage(const SolverPtr& theSolver);
37
38 // =============   Inherited from SketchSolver_Storage   =============
39
40   /// \brief Change mapping between constraint from SketchPlugin and
41   ///        a constraint applicable for corresponding solver.
42   /// \param theConstraint       [in]   original SketchPlugin constraint
43   /// \param theSolverConstraint [in]   solver's constraint
44   virtual void addConstraint(ConstraintPtr        theConstraint,
45                              ConstraintWrapperPtr theSolverConstraint);
46
47   /// \brief Add a movement constraint which will be destroyed
48   ///        after the next solving of the set of constraints.
49   /// \param theSolverConstraint [in]  solver's constraint
50   virtual void addMovementConstraint(const ConstraintWrapperPtr& theSolverConstraint);
51
52
53   /// \brief Convert feature to the form applicable for specific solver and map it
54   /// \param theFeature [in]  feature to convert
55   /// \param theForce   [in]  forced feature creation
56   /// \return \c true if the feature has been created or updated
57   virtual bool update(FeaturePtr theFeature, bool theForce = false);
58
59   /// \brief Convert attribute to the form applicable for specific solver and map it
60   /// \param theAttribute [in]  attribute to convert
61   /// \param theForce     [in]  forced feature creation
62   /// \return \c true if the attribute has been created or updated
63   virtual bool update(AttributePtr theAttribute, bool theForce = false);
64
65   /// \brief Make entity external
66   virtual void makeExternal(const EntityWrapperPtr& theEntity);
67   /// \brief Make entity non-external
68   virtual void makeNonExternal(const EntityWrapperPtr& theEntity);
69
70   /// \brief Removes constraint from the storage
71   /// \return \c true if the constraint and all its parameters are removed successfully
72   virtual bool removeConstraint(ConstraintPtr theConstraint);
73
74   /// \brief Update SketchPlugin features after resolving constraints
75   virtual void refresh() const;
76
77   /// \brief Initialize memory for new solver's parameter
78   double* createParameter();
79   /// \brief Release memory occupied by parameters
80   void removeParameters(const GCS::SET_pD& theParams);
81
82   /// \brief Remove all features became invalid
83   virtual void removeInvalidEntities();
84
85   /// \brief Check the storage has constraints
86   virtual bool isEmpty() const
87   { return SketchSolver_Storage::isEmpty() && myArcConstraintMap.empty(); }
88
89 private:
90   /// \brief Convert feature using specified builder.
91   EntityWrapperPtr createFeature(const FeaturePtr&             theFeature,
92                                  PlaneGCSSolver_EntityBuilder* theBuilder);
93
94   /// \brief Convert attribute using specified builder.
95   EntityWrapperPtr createAttribute(const AttributePtr&           theAttribute,
96                                    PlaneGCSSolver_EntityBuilder* theBuilder);
97
98   void createArcConstraints(const EntityWrapperPtr& theArc);
99   void removeArcConstraints(const EntityWrapperPtr& theArc);
100
101 private:
102   ConstraintID myConstraintLastID;   ///< identifier of last added constraint
103
104   /// additional constraints for correct processing of the arcs
105   std::map<EntityWrapperPtr, ConstraintWrapperPtr> myArcConstraintMap;
106
107   /// list of removed constraints to notify solver
108   std::list<GCSConstraintPtr> myRemovedConstraints;
109 };
110
111 #endif