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>
11 #include <SketchSolver_Storage.h>
13 class PlaneGCSSolver_EntityBuilder;
15 /** \class PlaneGCSSolver_Storage
17 * \brief Contains all necessary data in PlaneGCS format to solve a single group of constraints
19 class PlaneGCSSolver_Storage : public SketchSolver_Storage
22 PlaneGCSSolver_Storage(const SolverPtr& theSolver);
24 // ============= Inherited from SketchSolver_Storage =============
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);
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);
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);
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);
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);
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);
60 /// \brief Update SketchPlugin features after resolving constraints
61 virtual void refresh() const;
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);
68 /// \brief Remove all features became invalid
69 virtual void removeInvalidEntities();
71 /// \brief Check the storage has constraints
72 virtual bool isEmpty() const
73 { return SketchSolver_Storage::isEmpty() && myArcConstraintMap.empty(); }
76 /// \brief Convert feature using specified builder.
77 EntityWrapperPtr createFeature(const FeaturePtr& theFeature,
78 PlaneGCSSolver_EntityBuilder* theBuilder);
80 /// \brief Convert attribute using specified builder.
81 EntityWrapperPtr createAttribute(const AttributePtr& theAttribute,
82 PlaneGCSSolver_EntityBuilder* theBuilder);
84 void createArcConstraints(const EntityWrapperPtr& theArc);
85 void removeArcConstraints(const EntityWrapperPtr& theArc);
88 ConstraintID myConstraintLastID; ///< identifier of last added constraint
90 /// additional constraints for correct processing of the arcs
91 std::map<EntityWrapperPtr, ConstraintWrapperPtr> myArcConstraintMap;
93 /// list of removed constraints to notify solver
94 std::list<GCSConstraintPtr> myRemovedConstraints;