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 /// Constructor based on SketchPlugin constraint
22 SketchSolver_ConstraintCoincidence(ConstraintPtr theConstraint) :
23 SketchSolver_Constraint(theConstraint),
24 myType(SLVS_C_UNKNOWN)
27 virtual int getType() const
30 /// \brief Tries to remove constraint
31 /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
32 virtual bool remove(ConstraintPtr theConstraint = ConstraintPtr());
34 /// \brief Checks the constraint is used by current object
35 virtual bool hasConstraint(ConstraintPtr theConstraint) const;
37 /// \brief Return list of SketchPlugin constraints attached to this object
38 virtual std::list<ConstraintPtr> constraints() const;
40 /// \brief Verifies the two Coincidence constraints are intersects (have shared point)
41 bool isCoincide(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint) const;
43 /// \brief Append all data of coincidence constaint to the current
44 void attach(std::shared_ptr<SketchSolver_ConstraintCoincidence> theConstraint);
47 /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
48 virtual void process();
50 /// \brief Generate list of attributes of constraint in order useful for SolveSpace constraints
51 /// \param[out] theValue numerical characteristic of constraint (e.g. distance)
52 /// \param[out] theAttributes list of attributes to be filled
53 virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes);
56 /// \brief Creates new coincidence constraint
57 Slvs_hConstraint addConstraint(Slvs_hEntity thePoint1, Slvs_hEntity thePoint2);
59 /// \brief Create full SolveSpace structure according to given constraint
60 void addConstraint(ConstraintPtr theConstraint);
62 /// \brief Create constraint of point concident to the line or circle
63 Slvs_hConstraint addPointOnEntity(Slvs_hEntity thePoint, Slvs_hEntity theEntity);
66 int myType; ///< type of constraint (applicable SLVS_C_POINTS_COINCIDENT or SLVS_C_PT_ON_LINE or SLVS_C_PT_ON_CIRCLE)
67 std::map<ConstraintPtr, Slvs_hConstraint> myExtraCoincidence; ///< multiple coincidence of points
68 std::set<AttributePtr> myCoincidentPoints; ///< list of points under the Coincidence constraint