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_Storage
18 * \brief Contains all necessary data in PlaneGCS format to solve a single group of constraints
20 class PlaneGCSSolver_Storage : public SketchSolver_Storage
23 PlaneGCSSolver_Storage(const GroupID& theGroup);
25 // ============= Inherited from SketchSolver_Storage =============
27 /// \brief Change mapping between constraint from SketchPlugin and
28 /// the list of constraints applicable for corresponding solver.
29 /// Derived here to update point-point coincidence.
30 /// \param theConstraint [in] original SketchPlugin constraint
31 /// \param theSolverConstraints [in] list of solver's constraints
32 virtual void addConstraint(ConstraintPtr theConstraint,
33 std::list<ConstraintWrapperPtr> theSolverConstraints);
35 /// \brief Update constraint's data
36 /// \return \c true if any value is updated
37 virtual bool update(ConstraintWrapperPtr theConstraint);
38 /// \brief Update entity's data
39 /// \return \c true if any value is updated
40 virtual bool update(EntityWrapperPtr theEntity);
41 /// \brief Update parameter's data
42 /// \return \c true if the value of parameter is updated
43 virtual bool update(ParameterWrapperPtr theParameter);
45 /// \brief Update SketchPlugin features after resolving constraints
46 /// \param theFixedOnly [in] if \c true the fixed points will be updated only
47 virtual void refresh(bool theFixedOnly = false) const;
49 /// \brief Check if some parameters or entities are returned
50 /// to the current group after removing temporary constraints
51 virtual void verifyFixed();
53 /// \brief Mark two points as coincident
54 virtual void addCoincidentPoints(EntityWrapperPtr theMaster, EntityWrapperPtr theSlave);
56 /// \brief Shows the storage has the same constraint twice
57 virtual bool hasDuplicatedConstraint() const
60 /// \brief Calculate point on theBase entity. Value theCoeff is in [0.0 .. 1.0] and
61 /// shows the distance from the start point.
62 virtual EntityWrapperPtr calculateMiddlePoint(EntityWrapperPtr theBase, double theCoeff);
64 /// \brief Initialize solver by constraints, entities and parameters
65 virtual void initializeSolver(SolverPtr theSolver);
68 /// \brief Remove constraint
69 /// \return \c true if the constraint and all its parameters are removed successfully
70 virtual bool remove(ConstraintWrapperPtr theConstraint);
71 /// \brief Remove entity
72 /// \return \c true if the entity and all its parameters are removed successfully
73 virtual bool remove(EntityWrapperPtr theEntity);
74 /// \brief Remove parameter
75 /// \return \c true if the parameter has been removed
76 virtual bool remove(ParameterWrapperPtr theParameter);
78 /// \brief Update the group for the given entity, its sub-entities and parameters
79 virtual void changeGroup(EntityWrapperPtr theEntity, const GroupID& theGroup);
80 /// \brief Update the group for the given parameter
81 virtual void changeGroup(ParameterWrapperPtr theParam, const GroupID& theGroup);
84 // ============= Own methods =============
86 /// \brief Move parameters of the entity to the constants
87 void makeConstant(const EntityWrapperPtr& theEntity);
88 /// \brief Move parameters of the entity to the variables
89 void makeVariable(const EntityWrapperPtr& theEntity);
92 /// \brief Move parameters of the entity from the list of variables to the list of constants
94 /// \param theEntity [in] entity to be changed
95 /// \param theFrom [out] source list
96 /// \param theTo [out] destination list
97 void toggleEntity(const EntityWrapperPtr& theEntity, GCS::VEC_pD& theFrom, GCS::VEC_pD& theTo);
99 /// \brief Create additional constraints for correct processing of arcs
100 /// \param theArc [in] updated arc
101 void processArc(const EntityWrapperPtr& theArc);
104 GCS::VEC_pD myParameters; ///< list of parameters
105 GCS::VEC_pD myConst; ///< list of constants
106 EntityID myEntityLastID; ///< identifier of last added entity
108 std::map<EntityWrapperPtr, std::vector<GCSConstraintPtr> >
109 myArcConstraintMap; ///< additional constraints for correct processing of the arcs
111 std::list<GCSConstraintPtr> myRemovedConstraints; ///< list of removed constraints to notify solver