1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Builder.h
4 // Created: 25 Mar 2015
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_Builder_H_
8 #define SketchSolver_Builder_H_
10 #include <SketchSolver_Constraint.h>
11 #include <SketchPlugin_Constraint.h>
13 #include <GeomAPI_Lin2d.h>
14 #include <GeomAPI_Pnt2d.h>
16 /** \class SketchSolver_Builder
18 * \brief Abstract class for builders of solver's entities
20 class SketchSolver_Builder
23 /// \brief Creates a storage specific for used solver
24 virtual StoragePtr createStorage(const GroupID& theGroup) const = 0;
25 /// \brief Creates specific solver
26 virtual SolverPtr createSolver() const = 0;
28 /// \brief Creates a solver's constraint using given SketchPlugin constraint
29 /// or returns empty pointer if not all attributes are correct
30 SolverConstraintPtr createConstraint(ConstraintPtr theConstraint) const;
32 /// \brief Creates temporary constraint to fix the placement of the feature
33 SolverConstraintPtr createFixedConstraint(FeaturePtr theFixedFeature) const;
35 /// \brief Creates temporary constraint to fix the feature after movement
36 SolverConstraintPtr createMovementConstraint(FeaturePtr theFixedFeature) const;
38 //// /// \brief Creates constraint for parametrically given attribute
39 //// SolverConstraintPtr createParametricConstraint(AttributePtr theAttribute) const;
41 /// \brief Creates new constraint(s) using given parameters
42 /// \param theConstraint [in] original constraint
43 /// \param theGroupID [in] group the constraint belongs to
44 /// \param theSketchID [in] sketch the constraint belongs to
45 /// \param theType [in] type of constraint
46 /// \param theValue [in] numeric characteristic of constraint (e.g. distance or radius) if applicable
47 /// \param theEntity1 [in] first attribute of constraint
48 /// \param theEntity2 [in] second attribute of constraint
49 /// \param theEntity3 [in] third attribute of constraint
50 /// \param theEntity4 [in] fourth attribute of constraint
51 /// \return Created list of wrappers of constraints applicable for specific solver.
52 /// Most of constraint types lead to single constraint, but there are some kind of
53 /// constraints (e.g. mirror), which may produce couple of constraints.
54 virtual std::list<ConstraintWrapperPtr>
55 createConstraint(ConstraintPtr theConstraint,
56 const GroupID& theGroup,
57 const EntityID& theSketchID,
58 const SketchSolver_ConstraintType& theType,
59 const double& theValue,
60 const EntityWrapperPtr& theEntity1,
61 const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(),
62 const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(),
63 const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()) const = 0;
65 /// \brief Creates new multi-translation or multi-rotation constraint
66 /// \param theConstraint [in] original constraint
67 /// \param theGroupID [in] group the constraint belongs to
68 /// \param theSketchID [in] sketch the constraint belongs to
69 /// \param theType [in] type of constraint
70 /// \param theValue [in] numeric characteristic of constraint (angle for multi-rotation) if applicable
71 /// \param thePoint1 [in] center for multi-rotation or start point for multi-translation
72 /// \param thePoint2 [in] end point for multi-translation (empty for multi-rotation)
73 /// \param theTrsfEnt [in] list of transformed entities
74 virtual std::list<ConstraintWrapperPtr>
75 createConstraint(ConstraintPtr theConstraint,
76 const GroupID& theGroup,
77 const EntityID& theSketchID,
78 const SketchSolver_ConstraintType& theType,
79 const double& theValue,
80 const EntityWrapperPtr& thePoint1,
81 const EntityWrapperPtr& thePoint2,
82 const std::list<EntityWrapperPtr>& theTrsfEnt) const = 0;
84 /// \brief Update flags for several kinds of constraints
85 virtual void adjustConstraint(ConstraintWrapperPtr theConstraint) const = 0;
87 /// \brief Creates a feature using list of already created attributes
88 /// \param theFeature [in] feature to create
89 /// \param theAttributes [in] attributes of the feature
90 /// \param theGroupID [in] group the feature belongs to
91 /// \param theSketchID [in] sketch the feature belongs to
92 /// \return Created wrapper of the feature applicable for specific solver
93 virtual EntityWrapperPtr createFeature(FeaturePtr theFeature,
94 const std::list<EntityWrapperPtr>& theAttributes,
95 const GroupID& theGroupID,
96 const EntityID& theSketchID = EID_UNKNOWN) const = 0;
98 /// \brief Creates an attribute
99 /// \param theAttribute [in] attribute to create
100 /// \param theGroup [in] group the attribute belongs to
101 /// \param theSketchID [in] sketch the attribute belongs to
102 /// \return Created wrapper of the attribute applicable for specific solver
103 virtual EntityWrapperPtr createAttribute(AttributePtr theAttribute,
104 const GroupID& theGroup,
105 const EntityID& theSketchID = EID_UNKNOWN) const = 0;
108 /// \brief Convert entity to point
109 /// \return empty pointer if the entity is not a point
110 SKETCHSOLVER_EXPORT std::shared_ptr<GeomAPI_Pnt2d> point(EntityWrapperPtr theEntity) const;
111 /// \brief Convert entity to line
112 /// \return empty pointer if the entity is not a line
113 SKETCHSOLVER_EXPORT std::shared_ptr<GeomAPI_Lin2d> line(EntityWrapperPtr theEntity) const;
116 typedef std::shared_ptr<SketchSolver_Builder> BuilderPtr;