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>
14 #include <SketchSolver_ISolver.h>
16 class PlaneGCSSolver_EntityBuilder;
18 /** \class PlaneGCSSolver_Storage
20 * \brief Contains all necessary data in PlaneGCS format to solve a single group of constraints
22 class PlaneGCSSolver_Storage : public SketchSolver_Storage
25 PlaneGCSSolver_Storage(const SolverPtr& theSolver);
27 // ============= Inherited from SketchSolver_Storage =============
29 /// \brief Change mapping between constraint from SketchPlugin and
30 /// a constraint applicable for corresponding solver.
31 /// \param theConstraint [in] original SketchPlugin constraint
32 /// \param theSolverConstraint [in] solver's constraint
33 virtual void addConstraint(ConstraintPtr theConstraint,
34 ConstraintWrapperPtr theSolverConstraint);
36 /// \brief Add list of temporary constraints which will be destroyed
37 /// after the next solving of the set of constraints.
38 /// \param theSolverConstraint [in] solver's constraint
39 virtual void addTemporaryConstraint(const ConstraintWrapperPtr& theSolverConstraint);
42 /// \brief Convert feature to the form applicable for specific solver and map it
43 /// \param theFeature [in] feature to convert
44 /// \param theForce [in] forced feature creation
45 /// \return \c true if the feature has been created or updated
46 virtual bool update(FeaturePtr theFeature, bool theForce = false);
48 /// \brief Convert attribute to the form applicable for specific solver and map it
49 /// \param theAttribute [in] attribute to convert
50 /// \param theForce [in] forced feature creation
51 /// \return \c true if the attribute has been created or updated
52 virtual bool update(AttributePtr theAttribute, bool theForce = false);
55 /// \brief Removes constraint from the storage
56 /// \return \c true if the constraint and all its parameters are removed successfully
57 virtual bool removeConstraint(ConstraintPtr theConstraint);
59 /// \brief Update SketchPlugin features after resolving constraints
60 virtual void refresh() const;
62 /// \brief Initialize solver by constraints, entities and parameters
63 virtual void initializeSolver();
65 /// \brief Initialize memory for new solver's parameter
66 double* createParameter();
67 /// \brief Release memory occupied by parameters
68 void removeParameters(const GCS::SET_pD& theParams);
70 /// \brief Remove all features became invalid
71 virtual void removeInvalidEntities();
74 /// \brief Verifies the constraint should not be added into the solver
76 /// This is a workaround method to avoid some kinds of conflicting constraints:
77 /// * symmetric of two points placed on the mirror line (do not add perpendicular constraint)
78 bool isRedundant(GCSConstraintPtr theCheckedConstraint,
79 ConstraintWrapperPtr theParentConstraint,
80 std::list<std::set<double*> >& theCoincidentPoints) const;
82 /// \brief Convert feature using specified builder.
83 EntityWrapperPtr createFeature(const FeaturePtr& theFeature,
84 PlaneGCSSolver_EntityBuilder* theBuilder);
86 /// \brief Convert attribute using specified builder.
87 EntityWrapperPtr createAttribute(const AttributePtr& theAttribute,
88 PlaneGCSSolver_EntityBuilder* theBuilder);
91 GCS::VEC_pD myParameters; ///< list of parameters
92 ConstraintID myConstraintLastID; ///< identifier of last added constraint
94 /// additional constraints for correct processing of the arcs
95 std::map<EntityWrapperPtr, ConstraintWrapperPtr> myArcConstraintMap;
97 /// list of removed constraints to notify solver
98 std::list<GCSConstraintPtr> myRemovedConstraints;