1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef PlaneGCSSolver_Storage_H_
22 #define PlaneGCSSolver_Storage_H_
24 #include <PlaneGCSSolver_Defs.h>
25 #include <SketchSolver_Storage.h>
27 class PlaneGCSSolver_EntityBuilder;
29 /** \class PlaneGCSSolver_Storage
31 * \brief Contains all necessary data in PlaneGCS format to solve a single group of constraints
33 class PlaneGCSSolver_Storage : public SketchSolver_Storage
36 PlaneGCSSolver_Storage(const SolverPtr& theSolver);
38 // ============= Inherited from SketchSolver_Storage =============
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);
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);
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);
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);
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);
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);
74 /// \brief Update SketchPlugin features after resolving constraints
75 virtual void refresh() const;
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);
82 /// \brief Remove all features became invalid
83 virtual void removeInvalidEntities();
85 /// \brief Check the storage has constraints
86 virtual bool isEmpty() const
87 { return SketchSolver_Storage::isEmpty() && myArcConstraintMap.empty(); }
90 /// \brief Convert feature using specified builder.
91 EntityWrapperPtr createFeature(const FeaturePtr& theFeature,
92 PlaneGCSSolver_EntityBuilder* theBuilder);
94 /// \brief Convert attribute using specified builder.
95 EntityWrapperPtr createAttribute(const AttributePtr& theAttribute,
96 PlaneGCSSolver_EntityBuilder* theBuilder);
98 void createArcConstraints(const EntityWrapperPtr& theArc);
99 void removeArcConstraints(const EntityWrapperPtr& theArc);
102 ConstraintID myConstraintLastID; ///< identifier of last added constraint
104 /// additional constraints for correct processing of the arcs
105 std::map<EntityWrapperPtr, ConstraintWrapperPtr> myArcConstraintMap;
107 /// list of removed constraints to notify solver
108 std::list<GCSConstraintPtr> myRemovedConstraints;