1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_ConstraintMultiTranslation.h
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_ConstraintMultiTranslation_H_
8 #define SketchSolver_ConstraintMultiTranslation_H_
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
13 /** \class SketchSolver_ConstraintMultiTranslation
15 * \brief Convert translated features to the list of SolveSpace constraints
17 class SketchSolver_ConstraintMultiTranslation : public SketchSolver_Constraint
20 SketchSolver_ConstraintMultiTranslation(ConstraintPtr theConstraint) :
21 SketchSolver_Constraint(theConstraint),
24 myTranslationLine(SLVS_E_UNKNOWN)
27 virtual int getType() const
28 { return SLVS_C_MULTI_TRANSLATION; }
30 /// \brief Update constraint
31 virtual void update(ConstraintPtr theConstraint = ConstraintPtr());
33 /// \brief Tries to remove constraint
34 /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
35 virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
37 /// \brief Adds a feature to constraint and create its analogue in SolveSpace
38 virtual void addFeature(FeaturePtr theFeature);
41 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
42 virtual void process();
44 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
45 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
46 /// \param[out] theAttributes list of attributes to be filled
47 virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
48 { /* do nothing here */ }
50 /// \brief Generate list of translated entities
51 /// \param[out] theStartPoint ID of start point of translation
52 /// \param[out] theEndPoint ID of final point of translation
53 /// \param[out] thePoints list of IDs of initial points and their translated copies
54 /// \param[out] theEntities list of IDs of entities and their translated copies
55 void getAttributes(Slvs_hEntity& theStartPoint, Slvs_hEntity& theEndPoint,
56 std::vector< std::vector<Slvs_hEntity> >& thePoints,
57 std::vector< std::vector<Slvs_hEntity> >& theEntities);
59 /// \brief This method is used in derived objects to check consistence of constraint.
60 virtual void adjustConstraint();
63 size_t myNumberOfObjects; ///< number of previous initial objects
64 size_t myNumberOfCopies; ///< number of previous copies of initial objects
65 Slvs_hEntity myTranslationLine; ///< ID of translation line
66 std::vector< std::vector<Slvs_hEntity> > myPointsAndCopies; ///< list of initial points and their translated copies
67 std::vector< std::vector<Slvs_hEntity> > myCircsAndCopies; ///< list of circles and their copies (to change their radii together)
69 std::set<Slvs_hEntity> myPointsJustUpdated; ///< list of points touched by user