1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_ConstraintMulti.h
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_ConstraintMulti_H_
8 #define SketchSolver_ConstraintMulti_H_
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
15 /** \class SketchSolver_ConstraintMulti
17 * \brief Common base class for the Multi constraints
19 class SketchSolver_ConstraintMulti : public SketchSolver_Constraint
22 SketchSolver_ConstraintMulti(ConstraintPtr theConstraint) :
23 SketchSolver_Constraint(theConstraint),
28 virtual int getType() const
29 { return SLVS_C_UNKNOWN; }
31 /// \brief Update constraint
32 virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
34 /// \brief Tries to remove constraint
35 /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
36 virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
38 /// \brief Adds a feature to constraint and create its analogue in SolveSpace
39 virtual void addFeature(FeaturePtr theFeature);
42 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
43 virtual void process()
44 { /* do nothing here */ }
46 /// \brief Collect entities and their copies, like circles and arcs
47 void processEntities(const std::vector< std::vector<Slvs_hEntity> >& theEntAndCopies);
49 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
50 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
51 /// \param[out] theAttributes list of attributes to be filled
52 virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
53 { /* do nothing here */ }
55 /// \brief This method is used in derived objects to check consistence of constraint.
56 virtual void adjustConstraint();
58 /// \brief Update parameters of derived classes
59 virtual void updateLocal() = 0;
61 /// \brief Returns name of NUMBER_OF_COPIES parameter for corresponding feature
62 virtual const std::string& nameNbCopies() = 0;
65 /// \brief Convert absolute coordinates to relative coordinates
66 virtual void getRelative(double theAbsX, double theAbsY, double& theRelX, double& theRelY) = 0;
67 /// \brief Convert relative coordinates to absolute coordinates
68 virtual void getAbsolute(double theRelX, double theRelY, double& theAbsX, double& theAbsY) = 0;
69 /// \brief Apply transformation for relative coordinates
70 virtual void transformRelative(double& theX, double& theY) = 0;
73 size_t myNumberOfObjects; ///< number of previous initial objects
74 size_t myNumberOfCopies; ///< number of previous copies of initial objects
76 std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their copies
77 std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies; ///< list of circles and their copies (to change their radii together)
79 std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
80 std::set<Slvs_hEntity> myInitialPoints; ///< list of points containing initial objects