1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_ConstraintMirror.h
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_ConstraintMirror_H_
8 #define SketchSolver_ConstraintMirror_H_
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
13 /** \class SketchSolver_ConstraintMirror
15 * \brief Convert fillet constraint to SolveSpace structure
17 class SketchSolver_ConstraintMirror : public SketchSolver_Constraint
20 /// Constructor based on SketchPlugin constraint
21 SketchSolver_ConstraintMirror(ConstraintPtr theConstraint) :
22 SketchSolver_Constraint(theConstraint),
24 myMirrorLineLength(0.0)
27 virtual int getType() const
28 { return SLVS_C_SYMMETRIC_LINE; }
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());
38 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
39 virtual void process();
41 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
42 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
43 /// \param[out] theAttributes list of attributes to be filled
44 virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes)
45 { /* do nothing here */ }
47 /// \brief Verify the attributes of constraint are changed (and constraint need to rebuild)
48 /// \param[in] theConstraint constraint, which attributes should be checked (if NULL, the myBaseConstraint is used)
49 /// \return \c true if some attributes are changed
50 virtual bool checkAttributesChanged(ConstraintPtr theConstraint);
52 /// \brief Generate list of entities of mirror constraint
53 /// \param[out] theMirrorLine entity corresponding to mirror line
54 /// \param[out] theBaseEntities list of entities to mirror
55 /// \param[out] theMirrorEntities list of mirrored entities
56 void getAttributes(Slvs_Entity& theMirrorLine,
57 std::vector<Slvs_Entity>& theBaseEntities,
58 std::vector<Slvs_Entity>& theMirrorEntities);
60 /// \brief This method is used in derived objects to check consistence of constraint.
61 /// E.g. the distance between line and point may be signed.
62 virtual void adjustConstraint();
65 /// \brief Change parameters of entities to be symmetric relative a line,
66 /// given by array of parameters (coordinates of first and last points)
67 void makeMirrorEntity(const Slvs_Entity& theBase,
68 const Slvs_Entity& theMirror,
69 const double theMirrorLine[]) const;
71 /// \brief Precisely update last point to be on arc
72 void adjustArcPoints(const Slvs_Entity& theArc) const;
75 size_t myNumberOfObjects; ///< number of previously mirrored objects
76 double myMirrorLineLength; ///< length of mirror line (should be always greater than 0)