1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PlaneGCSSolver_Storage.h
4 // Created: 14 Dec 2015
5 // Author: Artem ZHIDKOV
7 #ifndef PlaneGCSSolver_Storage_H_
8 #define PlaneGCSSolver_Storage_H_
10 #include <PlaneGCSSolver_Defs.h>
12 #include <SketchSolver.h>
13 #include <SketchSolver_Storage.h>
15 class PlaneGCSSolver_EntityBuilder;
17 /** \class PlaneGCSSolver_Storage
19 * \brief Contains all necessary data in PlaneGCS format to solve a single group of constraints
21 class PlaneGCSSolver_Storage : public SketchSolver_Storage
24 PlaneGCSSolver_Storage(const SolverPtr& theSolver);
26 // ============= Inherited from SketchSolver_Storage =============
28 /// \brief Change mapping between constraint from SketchPlugin and
29 /// a constraint applicable for corresponding solver.
30 /// \param theConstraint [in] original SketchPlugin constraint
31 /// \param theSolverConstraint [in] solver's constraint
32 virtual void addConstraint(ConstraintPtr theConstraint,
33 ConstraintWrapperPtr theSolverConstraint);
35 /// \brief Add list of temporary constraints which will be destroyed
36 /// after the next solving of the set of constraints.
37 /// \param theSolverConstraint [in] solver's constraint
38 virtual void addTemporaryConstraint(const ConstraintWrapperPtr& theSolverConstraint);
41 /// \brief Convert feature to the form applicable for specific solver and map it
42 /// \param theFeature [in] feature to convert
43 /// \param theForce [in] forced feature creation
44 /// \return \c true if the feature has been created or updated
45 virtual bool update(FeaturePtr theFeature, bool theForce = false);
47 /// \brief Convert attribute to the form applicable for specific solver and map it
48 /// \param theAttribute [in] attribute to convert
49 /// \param theForce [in] forced feature creation
50 /// \return \c true if the attribute has been created or updated
51 virtual bool update(AttributePtr theAttribute, bool theForce = false);
54 /// \brief Removes constraint from the storage
55 /// \return \c true if the constraint and all its parameters are removed successfully
56 virtual bool removeConstraint(ConstraintPtr theConstraint);
58 /// \brief Update SketchPlugin features after resolving constraints
59 virtual void refresh() const;
61 /// \brief Initialize memory for new solver's parameter
62 double* createParameter();
63 /// \brief Release memory occupied by parameters
64 void removeParameters(const GCS::SET_pD& theParams);
66 /// \brief Remove all features became invalid
67 virtual void removeInvalidEntities();
70 /// \brief Convert feature using specified builder.
71 EntityWrapperPtr createFeature(const FeaturePtr& theFeature,
72 PlaneGCSSolver_EntityBuilder* theBuilder);
74 /// \brief Convert attribute using specified builder.
75 EntityWrapperPtr createAttribute(const AttributePtr& theAttribute,
76 PlaneGCSSolver_EntityBuilder* theBuilder);
79 ConstraintID myConstraintLastID; ///< identifier of last added constraint
81 /// additional constraints for correct processing of the arcs
82 std::map<EntityWrapperPtr, ConstraintWrapperPtr> myArcConstraintMap;
84 /// list of removed constraints to notify solver
85 std::list<GCSConstraintPtr> myRemovedConstraints;