1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_ConstraintMultiRotation.h
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_ConstraintMultiRotation_H_
8 #define SketchSolver_ConstraintMultiRotation_H_
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
15 /** \class SketchSolver_ConstraintMultiRotation
17 * \brief Convert rotated features to the list of SolveSpace constraints
19 class SketchSolver_ConstraintMultiRotation : public SketchSolver_Constraint
22 SketchSolver_ConstraintMultiRotation(ConstraintPtr theConstraint) :
23 SketchSolver_Constraint(theConstraint),
28 virtual int getType() const
29 { return SLVS_C_MULTI_ROTATION; }
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();
45 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
46 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
47 /// \param[out] theAttributes list of attributes to be filled
48 virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
49 { /* do nothing here */ }
51 /// \brief Generate list of rotated entities
52 /// \param[out] theCenter ID of central point of rotation
53 /// \param[out] theAngle rotation angle
54 /// \param[out] thePoints list of IDs of initial points and their rotated copies
55 /// \param[out] theEntities list of IDs of entities and their rotated copies
56 void getAttributes(Slvs_hEntity& theCenter, double& theAngle,
57 std::vector< std::vector<Slvs_hEntity> >& thePoints,
58 std::vector< std::vector<Slvs_hEntity> >& theEntities);
60 /// \brief This method is used in derived objects to check consistence of constraint.
61 virtual void adjustConstraint();
64 size_t myNumberOfObjects; ///< number of previous initial objects
65 size_t myNumberOfCopies; ///< number of previous copies of initial objects
66 Slvs_hEntity myRotationCenter; ///< ID of center of rotation
67 double myAngle; ///< angle of rotation
68 std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their rotated copies
69 std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies; ///< list of circles and their copies (to change their radii together)
71 std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user
72 std::set<Slvs_hEntity> myInitialPoints; ///< list of points containig initial objects