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 memory for new solver's parameter
63 double* createParameter();
64 /// \brief Release memory occupied by parameters
65 void removeParameters(const GCS::SET_pD& theParams);
67 /// \brief Remove all features became invalid
68 virtual void removeInvalidEntities();
71 /// \brief Verifies the constraint should not be added into the solver
73 /// This is a workaround method to avoid some kinds of conflicting constraints:
74 /// * symmetric of two points placed on the mirror line (do not add perpendicular constraint)
75 bool isRedundant(GCSConstraintPtr theCheckedConstraint,
76 ConstraintWrapperPtr theParentConstraint,
77 std::list<std::set<double*> >& theCoincidentPoints) const;
79 /// \brief Convert feature using specified builder.
80 EntityWrapperPtr createFeature(const FeaturePtr& theFeature,
81 PlaneGCSSolver_EntityBuilder* theBuilder);
83 /// \brief Convert attribute using specified builder.
84 EntityWrapperPtr createAttribute(const AttributePtr& theAttribute,
85 PlaneGCSSolver_EntityBuilder* theBuilder);
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;