1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_ConstraintCoincidence.h
4 // Created: 29 Mar 2015
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_ConstraintCoincidence_H_
8 #define SketchSolver_ConstraintCoincidence_H_
10 #include "SketchSolver.h"
11 #include <SketchSolver_Constraint.h>
12 #include <SketchSolver_Storage.h>
14 /** \class SketchSolver_ConstraintCoincidence
16 * \brief Convert coincidence constraint to SolveSpace structure
18 class SketchSolver_ConstraintCoincidence : public SketchSolver_Constraint
21 SketchSolver_ConstraintCoincidence(ConstraintPtr theConstraint) :
22 SketchSolver_Constraint(theConstraint),
23 myType(SLVS_C_UNKNOWN)
26 virtual int getType() const
29 /// \brief Tries to remove constraint
30 /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
31 virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
33 /// \brief Checks the constraint is used by current object
34 virtual bool hasConstraint(ConstraintPtr theConstraint) const;
36 /// \brief Return list of SketchPlugin constraints attached to this object
37 virtual std::list<ConstraintPtr> constraints() const;
39 /// \brief Verifies the two Coincidence constraints are intersects (have shared point)
40 bool isCoincide(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint) const;
42 /// \brief Append all data of coincidence constaint to the current
43 void attach(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint);
46 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
47 virtual void process();
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);
55 /// \brief Creates new coincidence constraint
56 Slvs_hConstraint addConstraint(Slvs_hEntity thePoint1, Slvs_hEntity thePoint2);
58 /// \brief Create full SolveSpace structure according to given constraint
59 void addConstraint(ConstraintPtr theConstraint);
62 int myType; ///< type of constraint (applicable SLVS_C_POINTS_COINCIDENT or SLVS_C_PT_ON_LINE or SLVS_C_PT_ON_CIRCLE)
63 std::map<Slvs_hConstraint, ConstraintPtr> myExtraCoincidence; ///< multiple coincidence of points
64 std::set<AttributePtr> myCoincidentPoints; ///< list of points under the Coincidence constraint